2018-12-04 12:18:27 +00:00
|
|
|
import ngModule from '../module';
|
2020-03-18 11:55:22 +00:00
|
|
|
import Section from 'salix/component/section';
|
2019-10-08 07:23:29 +00:00
|
|
|
import './style.scss';
|
2018-09-24 12:51:27 +00:00
|
|
|
|
2020-03-18 11:55:22 +00:00
|
|
|
class Controller extends Section {
|
2019-11-10 10:08:44 +00:00
|
|
|
$postLink() {
|
|
|
|
this.onSearch();
|
|
|
|
}
|
|
|
|
|
2019-09-19 13:51:39 +00:00
|
|
|
onSearch(params) {
|
2019-10-08 05:22:38 +00:00
|
|
|
this.$.model.applyFilter({}, params).then(() => {
|
|
|
|
const data = this.$.model.data;
|
|
|
|
this.$.treeview.data = data;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
onFetch(item) {
|
|
|
|
const params = item ? {parentId: item.id} : null;
|
2019-11-10 10:08:44 +00:00
|
|
|
return this.$.model.applyFilter({}, params)
|
|
|
|
.then(() => this.$.model.data);
|
2019-10-08 05:22:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
onSort(a, b) {
|
|
|
|
if (b.selected !== a.selected) {
|
|
|
|
if (a.selected == null)
|
|
|
|
return 1;
|
|
|
|
if (b.selected == null)
|
|
|
|
return -1;
|
|
|
|
return b.selected - a.selected;
|
|
|
|
}
|
|
|
|
|
|
|
|
return a.name.localeCompare(b.name);
|
2019-01-21 10:45:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
exprBuilder(param, value) {
|
|
|
|
switch (param) {
|
|
|
|
case 'search':
|
|
|
|
return {name: {like: `%${value}%`}};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-08 05:22:38 +00:00
|
|
|
onSelection(value, item) {
|
|
|
|
if (value == null)
|
|
|
|
value = undefined;
|
|
|
|
const params = {geoId: item.id, isIncluded: value};
|
2019-10-24 22:53:53 +00:00
|
|
|
const path = `zones/${this.zone.id}/toggleIsIncluded`;
|
2019-02-25 09:03:50 +00:00
|
|
|
this.$http.post(path, params);
|
2018-09-24 12:51:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-04 12:18:27 +00:00
|
|
|
ngModule.component('vnZoneLocation', {
|
2018-09-24 12:51:27 +00:00
|
|
|
template: require('./index.html'),
|
|
|
|
controller: Controller,
|
|
|
|
bindings: {
|
|
|
|
zone: '<'
|
|
|
|
},
|
|
|
|
require: {
|
|
|
|
card: '^vnZoneCard'
|
|
|
|
}
|
|
|
|
});
|