2018-12-04 12:18:27 +00:00
|
|
|
import ngModule from '../module';
|
2018-09-19 13:05:07 +00:00
|
|
|
|
|
|
|
export default class Controller {
|
2020-03-07 12:52:02 +00:00
|
|
|
constructor($, $http, $state) {
|
|
|
|
this.$ = $;
|
2019-03-14 14:07:24 +00:00
|
|
|
this.$http = $http;
|
|
|
|
this.$state = $state;
|
2018-09-19 13:05:07 +00:00
|
|
|
}
|
2018-09-25 07:28:55 +00:00
|
|
|
|
2019-03-14 14:07:24 +00:00
|
|
|
/**
|
2020-03-07 12:52:02 +00:00
|
|
|
* Opens a summary modal
|
2019-03-14 14:07:24 +00:00
|
|
|
* @param {Object} event - Event object
|
|
|
|
* @param {Object} zone - Selected item
|
|
|
|
*/
|
2020-03-07 12:52:02 +00:00
|
|
|
preview(event, zone) {
|
2019-03-14 14:07:24 +00:00
|
|
|
this.stopEvent(event);
|
|
|
|
this.selectedZone = zone;
|
2020-03-07 12:52:02 +00:00
|
|
|
this.$.summary.show();
|
2019-03-14 14:07:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-03-07 12:52:02 +00:00
|
|
|
* Clones a zone and all its properties
|
2019-03-14 14:07:24 +00:00
|
|
|
* @param {Object} event - Event object
|
|
|
|
* @param {Object} zone - Selected item
|
|
|
|
*/
|
2020-03-07 12:52:02 +00:00
|
|
|
clone(event, zone) {
|
2019-03-14 14:07:24 +00:00
|
|
|
this.stopEvent(event);
|
|
|
|
this.selectedZone = zone;
|
2020-03-07 12:52:02 +00:00
|
|
|
this.$.clone.show();
|
|
|
|
}
|
|
|
|
|
|
|
|
onCloneAccept() {
|
|
|
|
return this.$http.post(`Zones/${this.selectedZone.id}/clone`)
|
|
|
|
.then(res => {
|
|
|
|
this.selectedZone = null;
|
|
|
|
this.$state.go('zone.card.basicData', {id: res.data.id});
|
|
|
|
});
|
2019-03-14 14:07:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
stopEvent(event) {
|
2018-09-25 07:28:55 +00:00
|
|
|
event.preventDefault();
|
|
|
|
event.stopImmediatePropagation();
|
|
|
|
}
|
2018-09-19 13:05:07 +00:00
|
|
|
}
|
|
|
|
|
2019-03-14 14:07:24 +00:00
|
|
|
Controller.$inject = ['$scope', '$http', '$state'];
|
2018-09-19 13:05:07 +00:00
|
|
|
|
|
|
|
ngModule.component('vnZoneIndex', {
|
|
|
|
template: require('./index.html'),
|
|
|
|
controller: Controller
|
|
|
|
});
|