salix/modules/agency/front/descriptor/index.js

44 lines
990 B
JavaScript

import ngModule from '../module';
class Controller {
constructor($scope, $state, $http) {
this.$scope = $scope;
this.$state = $state;
this.$http = $http;
this.moreOptions = [
{callback: this.editZone, name: 'Settings'},
{callback: this.deleteZone, name: 'Delete'}
];
}
onMoreChange(callback) {
callback.call(this);
}
deleteZone() {
this.$scope.deleteZone.show();
}
editZone() {
this.$state.go('zone.card.edit', {zone: this.zone});
}
returnDialog(response) {
if (response === 'ACCEPT') {
this.$http.delete(`/agency/api/Zones/${this.zone.id}`).then(() => {
this.$state.go('zone.index');
});
}
}
}
Controller.$inject = ['$scope', '$state', '$http'];
ngModule.component('vnZoneDescriptor', {
template: require('./index.html'),
controller: Controller,
bindings: {
zone: '<'
}
});