import ngModule from '../../module';
import Descriptor from 'salix/components/descriptor';

class Controller extends Descriptor {
    get alias() {
        return this.entity;
    }

    set alias(value) {
        this.entity = value;
    }

    onDelete() {
        return this.$http.delete(`MailAliases/${this.id}`)
            .then(() => this.$state.go('account.alias'))
            .then(() => this.vnApp.showSuccess(this.$t('Alias removed')));
    }
}

ngModule.component('vnAliasDescriptor', {
    template: require('./index.html'),
    controller: Controller,
    bindings: {
        alias: '<'
    }
});