<template>
    <v-sheet tile>

        <template v-if="action != 'delete'">
            <v-row dense>
                <cs-text-box 
                    ref="First"
                    :control="controls.name"
                    :errors="errorsManager.ByField('name')"

                    v-model="activeRecord.name"
                    
                    @focus="errorsManager.ResetField('name')"
                    @blur="errorsManager.Validate('name')"
                    
                />

            </v-row>
        </template>

        <cs-info-alert 
            v-else
            color="red"
            icon="mdi-alert"
            :message="__('Sunteți sigur că doriți ștergerea folderului :name?', {
                name: activeRecord.name
            })"
        />

        
    </v-sheet>
</template>

<script>
    export default {

        props: {
            controls: {default: () => ({})},
            activeRecord: {required: true},
            errorsManager: {required: true},
            action: {required: true},
            currentAction: {required: true},
        },

        methods: {
            Focus() {
                
                this.$refs.First.Focus();
            }
        },

        mounted() {
            if(this.action != 'delete')
            {
                setTimeout( () => {
                    this.Focus();
                }, 150);
            }    
        },

        components: {
            CsTextBox: require('@CsVueComp/controls/texts/CsTextBox').default,
            CsInfoAlert: require('@CsVueComp/sheets/CsInfoAlert').default,
        },

        name: 'FolderInput',
    }
</script>