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

61 lines
1.4 KiB
JavaScript
Raw Normal View History

2018-12-04 12:18:27 +00:00
import ngModule from '../module';
2020-03-18 13:08:04 +00:00
import Section from 'salix/components/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};
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
}
}
ngModule.vnComponent('vnZoneLocation', {
2018-09-24 12:51:27 +00:00
template: require('./index.html'),
controller: Controller,
bindings: {
zone: '<'
},
require: {
card: '^vnZoneCard'
}
});