<template>
    <v-card tile flat outlined class="pa-2 mb-3" :color="is_active ?'purple lighten-4' : null">

        <div class="text-body-2 d-flex justify-space-between align-center">
            <v-sheet class="transparent text-truncate text-caption purple--text text--darken-3 font-weight-medium" whidth="calc(100% - 60px)">
                {{ item.name }}
            </v-sheet>

            <div>
                <cs-btn 
                    icon="mdi-pencil"
                    color="purple darken-3"
                    @click="OnClickShowEdit($event, item)"
                />

                <cs-btn 
                    icon="mdi-chevron-double-right"
                    color="purple darken-3"
                    @click="controller.OnClickRegistru(item)"
                />
            </div>
        </div>

        <v-card tile flat class="transparent" :disabled="! is_active" v-if="false">
            <v-checkbox
                dense
                hide-details
                v-model="item.allow_upload_row_files"
                :true-value="1"
                :false-value="0"
                color="purple darken-3"
                class="my-0 py-0"
            >
                <template #label>
                    <span class="text-caption">
                        {{__('Încarcarea de fișiere la nivel de rând')}}
                    </span>
                </template>
            </v-checkbox>

            <v-checkbox
                dense
                hide-details
                v-model="item.has_departamente_column"
                :true-value="1"
                :false-value="0"
                color="purple darken-3"
                class="my-0 py-0"
            >
                <template #label>
                    <span class="text-caption">
                        {{__('Coloana Departament')}}
                    </span>
                </template>
            </v-checkbox>

            <v-checkbox
                dense
                hide-details
                v-model="item.has_status_column"
                :true-value="1"
                :false-value="0"
                color="purple darken-3"
                class="my-0 py-0"
            >
                <template #label>
                    <span class="text-caption">
                        {{__('Coloana Status')}}
                    </span>
                </template>
            </v-checkbox>

            <v-checkbox
                dense
                hide-details
                v-model="item.allow_versions"
                :true-value="1"
                :false-value="0"
                color="purple darken-3"
                class="my-0 py-0"
            >
                <template #label>
                    <span class="text-caption">
                        {{__('Permite versionare')}}
                    </span>
                </template>
            </v-checkbox>
        
        </v-card>

    </v-card>
</template>

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

        computed: {
            is_active() {
                return this.selected_registru && (this.item.id == this.selected_registru.id);
            }
        },

        methods: {

            OnClickShowEdit(e, item) {
                this.controller.registruformmenu.visible = false;

                this.$nextTick( () => {
                    this.controller.registruformmenu.visible = true;
                    this.controller.registruformmenu.x = e.clientX;
                    this.controller.registruformmenu.y = e.clientY;

                    this.controller.registruformmenu.activeRecord = this.item;

                    this.controller.OnClickRegistru(item);
                });
            },
        },

        components: {
            CsBtn: require('@CsVueComp/buttons/CsBtn').default,
        },
        
        name: 'RegistruItem',
    }
</script>