2019-09-25 18:06:42 +00:00
|
|
|
import ngModule from '../module';
|
2019-10-24 10:44:36 +00:00
|
|
|
import Component from 'core/lib/component';
|
2019-09-25 18:06:42 +00:00
|
|
|
|
2019-10-24 10:44:36 +00:00
|
|
|
class Controller extends Component {
|
|
|
|
constructor($element, $) {
|
|
|
|
super($element, $);
|
2019-09-25 18:06:42 +00:00
|
|
|
|
2019-10-24 22:53:53 +00:00
|
|
|
this.path = `Zones/${this.$params.id}/warehouses`;
|
2019-09-25 18:06:42 +00:00
|
|
|
this.refresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
refresh() {
|
|
|
|
let filter = {include: 'warehouse'};
|
|
|
|
this.$http.get(this.path, {params: {filter}})
|
|
|
|
.then(res => this.$.data = res.data);
|
|
|
|
}
|
|
|
|
|
|
|
|
onCreate() {
|
|
|
|
this.selected = {};
|
|
|
|
this.$.dialog.show();
|
|
|
|
}
|
|
|
|
|
|
|
|
onSave(response) {
|
|
|
|
if (response != 'ACCEPT') return;
|
|
|
|
|
|
|
|
this.$http.post(this.path, this.selected)
|
|
|
|
.then(() => {
|
|
|
|
this.selected = null;
|
|
|
|
this.isNew = null;
|
|
|
|
this.$.dialog.hide();
|
|
|
|
this.refresh();
|
|
|
|
});
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
onDelete(index) {
|
|
|
|
this.$.confirm.show();
|
|
|
|
this.deleteIndex = index;
|
|
|
|
}
|
|
|
|
|
|
|
|
delete(response) {
|
|
|
|
if (response != 'ACCEPT') return;
|
|
|
|
let id = this.$.data[this.deleteIndex].id;
|
|
|
|
if (!id) return;
|
|
|
|
this.$http.delete(`${this.path}/${id}`)
|
|
|
|
.then(() => {
|
|
|
|
this.$.data.splice(this.deleteIndex, 1);
|
|
|
|
this.deleteIndex = null;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ngModule.component('vnZoneWarehouses', {
|
|
|
|
template: require('./index.html'),
|
|
|
|
controller: Controller
|
|
|
|
});
|