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

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

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

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

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