salix/modules/item/front/botanical/index.js

33 lines
803 B
JavaScript

import ngModule from '../module';
import Section from 'salix/components/section';
class Controller extends Section {
constructor($element, $) {
super($element, $);
this.botanical = {
itemFk: this.$params.id
};
}
_getBotanical() {
let filter = {
where: {itemFk: this.$params.id},
include: [{relation: 'genus'}, {relation: 'specie'}]
};
this.$http.get(`ItemBotanicals?filter=${JSON.stringify(filter)}`)
.then(res => {
if (res.data.length)
this.botanical = res.data[0];
});
}
$onInit() {
this._getBotanical();
}
}
ngModule.vnComponent('vnItemBotanical', {
template: require('./index.html'),
controller: Controller
});