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

45 lines
1.0 KiB
JavaScript

import ngModule from '../module';
class Controller {
constructor($, $http, $stateParams) {
this.$ = $;
this.$http = $http;
this.$stateParams = $stateParams;
}
onSearch(params) {
this.$.model.applyFilter(null, params);
this.$.$applyAsync(() => this.$.treeview.refresh());
}
exprBuilder(param, value) {
switch (param) {
case 'search':
return {name: {like: `%${value}%`}};
}
}
onSelection(item, isIncluded) {
let node = Object.assign({}, item);
node.isIncluded = isIncluded;
node.childs = []; // Data too large
const path = '/agency/api/ZoneIncludeds/toggleIsIncluded';
const params = {zoneFk: this.zone.id, item: node};
this.$http.post(path, params);
}
}
Controller.$inject = ['$scope', '$http', '$stateParams'];
ngModule.component('vnZoneLocation', {
template: require('./index.html'),
controller: Controller,
bindings: {
zone: '<'
},
require: {
card: '^vnZoneCard'
}
});