<template>
    <v-chip
        :color="user.active ? 'green' : 'red'"
        small
        outlined
        :title="__(user.active ? 'Activ' : 'Inactiv')"
        @contextmenu="ShowStatusForm"
    >
        <v-icon small>
            mdi-{{ user.active ? 'check' : 'lock'}}
        </v-icon>
    </v-chip>
</template>

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

        methods: {
            ShowStatusForm(e) {
                if(this.form)
                {
                    e.preventDefault();

                    this.form.formprovider
                        .Reset()
                        .SetAction('update')
                        .SetActiveRecord({...this.user});
                    
                    this.form.visible = false
                    this.form.left = e.clientX
                    this.form.top = e.clientY
                    this.form.target = 'status';
                    
                    this.$nextTick(() => {
                        this.form.visible = true
                    })
                }
            }
        },
        
        name: 'UserActive',
    }
</script>