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

35 lines
824 B
JavaScript
Raw Normal View History

import ngModule from '../module';
class Controller {
2018-02-20 13:30:02 +00:00
constructor($http, $state) {
this.$http = $http;
this.$state = $state;
this.botanical = {
itemFk: this.$state.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 = {
2018-02-21 07:44:00 +00:00
where: {itemFk: this.$state.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
}
Controller.$inject = ['$http', '$state'];
2018-02-20 13:30:02 +00:00
ngModule.component('vnItemBotanical', {
template: require('./index.html'),
controller: Controller
});