2018-01-18 07:38:04 +00:00
|
|
|
import ngModule from '../module';
|
2020-03-17 13:43:46 +00:00
|
|
|
import Section from 'salix/components/section';
|
2018-01-18 07:38:04 +00:00
|
|
|
|
2020-03-17 13:43:46 +00:00
|
|
|
class Controller extends Section {
|
|
|
|
constructor($element, $) {
|
|
|
|
super($element, $);
|
2018-05-31 09:52:39 +00:00
|
|
|
this.botanical = {
|
2020-03-17 13:43:46 +00:00
|
|
|
itemFk: this.$params.id
|
2018-05-31 09:52:39 +00:00
|
|
|
};
|
2018-02-20 13:30:02 +00:00
|
|
|
}
|
2018-05-25 15:25:35 +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'}]
|
|
|
|
};
|
2019-10-24 22:53:53 +00:00
|
|
|
this.$http.get(`ItemBotanicals?filter=${JSON.stringify(filter)}`)
|
2018-02-20 13:30:02 +00:00
|
|
|
.then(res => {
|
2018-05-31 09:52:39 +00:00
|
|
|
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-05-25 08:03:45 +00:00
|
|
|
|
2018-02-21 12:10:23 +00:00
|
|
|
$onInit() {
|
|
|
|
this._getBotanical();
|
|
|
|
}
|
2018-02-20 13:30:02 +00:00
|
|
|
}
|
2018-05-25 08:03:45 +00:00
|
|
|
|
2018-01-18 07:38:04 +00:00
|
|
|
ngModule.component('vnItemBotanical', {
|
2018-05-25 08:03:45 +00:00
|
|
|
template: require('./index.html'),
|
|
|
|
controller: Controller
|
2018-01-18 07:38:04 +00:00
|
|
|
});
|