import ngModule from '../module';

class Controller {
    constructor($scope, $state, $http) {
        this.$scope = $scope;
        this.$state = $state;
        this.$http = $http;
        this.moreOptions = [
            {callback: this.deleteZone, name: 'Delete'}
        ];
    }

    onMoreChange(callback) {
        callback.call(this);
    }

    deleteZone() {
        this.$scope.deleteZone.show();
    }

    returnDialog(response) {
        if (response === 'ACCEPT') {
            this.$http.delete(`/agency/api/Zones/${this.zone.id}`).then(() => {
                this.$state.go('zone.index');
            });
        }
        console.log('res', response);
    }
}

Controller.$inject = ['$scope', '$state', '$http'];

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