import ngModule from '../module'; export default class Controller { constructor($, $http, $state) { this.$ = $; this.$http = $http; this.$state = $state; } /** * Opens a summary modal * @param {Object} event - Event object * @param {Object} zone - Selected item */ preview(event, zone) { this.stopEvent(event); this.selectedZone = zone; this.$.summary.show(); } /** * Clones a zone and all its properties * @param {Object} event - Event object * @param {Object} zone - Selected item */ clone(event, zone) { this.stopEvent(event); this.selectedZone = zone; 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}); }); } stopEvent(event) { event.preventDefault(); event.stopImmediatePropagation(); } } Controller.$inject = ['$scope', '$http', '$state']; ngModule.component('vnZoneIndex', { template: require('./index.html'), controller: Controller });