2017-12-20 13:36:12 +00:00
|
|
|
import ngModule from '../module';
|
|
|
|
|
|
|
|
class ItemCard {
|
2017-12-21 13:09:55 +00:00
|
|
|
constructor($http, $state) {
|
|
|
|
this.$http = $http;
|
|
|
|
this.$state = $state;
|
2018-02-20 10:10:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_getBotanical() {
|
|
|
|
let filter = {
|
|
|
|
where: {
|
|
|
|
itemFk: this.$state.params.id
|
|
|
|
},
|
|
|
|
include: [{relation: 'genus'}, {relation: 'specie'}]
|
|
|
|
};
|
|
|
|
this.$http.get(`/item/api/ItemBotanicals?filter=${JSON.stringify(filter)}`)
|
|
|
|
.then(res => {
|
|
|
|
if (res.data) {
|
|
|
|
this.item.botanical = res.data[0];
|
|
|
|
}
|
|
|
|
});
|
2017-12-20 13:36:12 +00:00
|
|
|
}
|
2017-12-21 13:09:55 +00:00
|
|
|
|
|
|
|
$onInit() {
|
|
|
|
let filter = {
|
|
|
|
include: [
|
|
|
|
{relation: "itemType"},
|
|
|
|
{relation: "origin"},
|
|
|
|
{relation: "ink"},
|
|
|
|
{relation: "producer"},
|
2018-01-30 07:59:43 +00:00
|
|
|
{relation: "intrastat"},
|
|
|
|
{relation: "expence"},
|
2018-02-01 09:05:20 +00:00
|
|
|
{relation: "itemTag", scope: {order: "priority ASC", include: {relation: "tag"}}}
|
2017-12-21 13:09:55 +00:00
|
|
|
]
|
|
|
|
};
|
2018-02-20 10:10:54 +00:00
|
|
|
this.$http.get(`/item/api/Items/${this.$state.params.id}?filter=${JSON.stringify(filter)}`)
|
|
|
|
.then(
|
|
|
|
res => {
|
|
|
|
if (res.data && res.data.id) {
|
|
|
|
this.item = res.data;
|
|
|
|
this._getBotanical();
|
|
|
|
}
|
|
|
|
}
|
2017-12-21 13:09:55 +00:00
|
|
|
);
|
|
|
|
}
|
2017-12-20 13:36:12 +00:00
|
|
|
}
|
2017-12-21 13:09:55 +00:00
|
|
|
ItemCard.$inject = ['$http', '$state'];
|
2017-12-20 13:36:12 +00:00
|
|
|
|
|
|
|
ngModule.component('vnItemCard', {
|
|
|
|
template: require('./item-card.html'),
|
|
|
|
controller: ItemCard
|
|
|
|
});
|