2018-01-18 07:38:04 +00:00
|
|
|
import ngModule from '../module';
|
|
|
|
|
2018-05-25 08:03:45 +00:00
|
|
|
class Controller {
|
2018-02-20 13:30:02 +00:00
|
|
|
constructor($http, $state) {
|
|
|
|
this.$http = $http;
|
|
|
|
this.$state = $state;
|
2018-05-31 09:52:39 +00:00
|
|
|
this.botanical = {
|
|
|
|
itemFk: this.$state.params.id
|
|
|
|
};
|
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 = {
|
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'}]
|
|
|
|
};
|
2018-02-21 07:44:00 +00:00
|
|
|
this.$http.get(`/item/api/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
|
|
|
|
|
|
|
Controller.$inject = ['$http', '$state'];
|
2018-02-20 13:30:02 +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
|
|
|
});
|