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

33 lines
803 B
JavaScript
Raw Normal View History

import ngModule from '../module';
2020-03-17 13:43:46 +00:00
import Section from 'salix/components/section';
2020-03-17 13:43:46 +00:00
class Controller extends Section {
constructor($element, $) {
super($element, $);
this.botanical = {
2020-03-17 13:43:46 +00:00
itemFk: this.$params.id
};
2018-02-20 13:30:02 +00:00
}
2018-02-21 12:10:23 +00:00
_getBotanical() {
2018-02-20 13:30:02 +00:00
let filter = {
2020-03-17 13:43:46 +00:00
where: {itemFk: this.$params.id},
2018-02-20 13:30:02 +00:00
include: [{relation: 'genus'}, {relation: 'specie'}]
};
this.$http.get(`ItemBotanicals?filter=${JSON.stringify(filter)}`)
2018-02-20 13:30:02 +00:00
.then(res => {
if (res.data.length)
2018-02-21 07:44:00 +00:00
this.botanical = res.data[0];
2018-02-20 13:30:02 +00:00
});
}
2018-02-21 12:10:23 +00:00
$onInit() {
this._getBotanical();
}
2018-02-20 13:30:02 +00:00
}
ngModule.vnComponent('vnItemBotanical', {
template: require('./index.html'),
controller: Controller
});