<template>
    <cs-date-box        
        :control="control"
        :errors="null"
        v-model="myvalue"
    />
</template>

<script>
    import Control from '@CsClasses/Controls/Control';

    export default {
        props: {
            app: {required: true},
            column: {required: true},
            rowvalues: {required: true},
        },

        data: () => ({
            control: null,
            myvalue: null,
        }),

        watch: {
            rowvalues: {
                deep: true,
                handler: function() {
                    this.myvalue = this.rowvalues['col-' + this.column.id];
                },
            },
            
            myvalue: function(value) {
                let r = {...this.rowvalues};
                r['col-' + this.column.id]  = value;
                this.$emit('update-values', r);
            },
        },

        created() {
            this.control = new Control(this.app.forms.Registrelemelerow);
            this.control.hideDetails = true;

            this.myvalue = this.rowvalues['col-' + this.column.id];
        },

        components: {
            CsDateBox: require('@CsVueComp/controls/dates/CsDateBox').default,
        },
        
        name: 'RegistruRowInputDatebox',
    }
</script>