<template>
    <v-sheet class="transparent d-flex justify-space-between align-center" width="100%">
        <v-sheet class="ml-2" width="30">
            <v-checkbox dense hide-details class="ma-0 pa-0" :true-value="1" :false-value="0"
                v-model="checked"
            />
        </v-sheet>

        <div v-if="allow_upload_row_files">
            <v-chip small outlined @click="OnClickFiles">
                <span class="text-caption">
                    {{  __(':x fișiere', {x: column.files_count}) }}
                </span>
            </v-chip>
        </div>

        <div class="text-right text-caption">
            {{ column.text }}
        </div>
    </v-sheet>
</template>

<script>
    export default {
        props: {
            app: {required: true},
            column: {required: true},

            createdby: {default: null},
            customer: {default: null},
            created_at: {default: null},

            allow_upload_row_files: {default: true},
            
            fakeData: {default: false},
        },

        computed: {
            controller() {
                return this.app.classes.Customerregistru;
            },

            selected() {
                return this.controller.selectedrows;
            },

            row_id() {
                return this.column.row_id;
            },

            checked: {
                get: function() {
                    let r = !! _.find(this.selected, item => 1 * item == 1 * this.row_id);
                    return r ? 1 : 0;
                },

                set: function(checked) {
                    let selected = _.filter(this.selected, item => 1 * item != 1 * this.row_id);

                    if(checked)
                    {
                        selected.push(1 * this.row_id);
                    }

                    this.controller.selectedrows = [...selected];
                }
            },
        },

        methods: {
            OnClickFiles() {
                this.controller.rowfilesmenu.visible = false;

                this.app.vue.$nextTick( () => {
                    this.controller.rowfilesmenu.visible = true;
                    this.controller.rowfilesmenu.x = 0;
                    this.controller.rowfilesmenu.y = 0;
                    this.controller.rowfilesmenu.row_id = this.row_id;
                    
                });
            }
        },

        name: 'RegistruTableBodyColumnN'
    }
</script>