<template>
    <v-sheet :outlined="1 * column.is_group == 1">

        <v-sheet class="px-0 py-0" v-show="(column.type != 'STATUS') || ( (column.type == 'STATUS') && (app.platform == 'admin'))">
        
            <template v-if="1 * column.is_group == 1">
                <v-sheet class="px-2">
                    <div class="text-body-2 font-weight-medium">
                        {{ __(column.caption) }}
                    </div>

                    <registru-row-input-column 
                        v-for="(item, index) in column.children"
                        :key="'item-' + index"
                        :app="app"
                        :column="item"
                        :rowvalues="rowvalues"
                        @update-values="OnUpdateValues"
                        class="mb-1"
                    />
                </v-sheet>
            </template>

            <template v-else>
                <v-sheet class="d-flex align-center px-0 py-0" v-if="componentname">
                    <v-sheet width="60%" class="text-caption text-right pr-2">
                        {{ __(column.caption) }}: 
                    </v-sheet>

                    <v-sheet width="40%" class="text-caption">
                        <component 
                            :is="componentname"
                            :app="app"
                            :column="column"
                            :rowvalues="rowvalues"
                            @update-values="OnUpdateValues"
                        >
                        </component>
                    </v-sheet>

                </v-sheet>
            </template>
        </v-sheet>
    </v-sheet>
</template>

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

        computed: {
            componentname() {
                if(this.column.type == 'C')
                {
                    return 'registru-row-input-textbox';
                }

                if(this.column.type == 'E')
                {
                    return 'registru-row-input-editbox';
                }

                if(this.column.type == 'N')
                {
                    return 'registru-row-input-numberbox';
                }

                if(this.column.type == 'D')
                {
                    return 'registru-row-input-datebox';
                }

                if(this.column.type == 'T')
                {
                    return 'registru-row-input-datetimebox';
                }

                if(this.column.type == 'O')
                {
                    return 'registru-row-input-optionsbox';
                }

                if(this.column.type == 'STATUS')
                {
                    return 'registru-row-input-status';
                }

                if(this.column.type == 'DEPARTAMENT')
                {
                    return 'registru-row-input-departament';
                }
            }
        },

        methods: {
            OnUpdateValues(e) {
                this.$emit('update-values', e);
            }
        },

        name: 'RegistruRowInputColumn',
    }
</script>