item-summary

This commit is contained in:
Daniel Herrero 2018-02-20 12:33:17 +01:00
parent ecc513272f
commit 5f07fab6cf
3 changed files with 128 additions and 0 deletions

View File

@ -0,0 +1,56 @@
<vn-card>
<vn-vertical pad-medium>
<vn-horizontal>
<vn-one margin-medium>
<img
ng-src="http://verdnatura.es/vn-image-data/catalog/200x200/{{$ctrl.item.image}}"
zoom-image="http://verdnatura.es/vn-image-data/catalog/900x900/{{$ctrl.item.image}}" on-error-src/>
</vn-one>
<vn-one margin-medium>
<vn-vertical>
<h5 translate>Basic data</h5>
<p><span translate>Name</span>: <b>{{::$ctrl.item.name}}</b></p>
<p><span translate>Type</span>: <b>{{::$ctrl.item.itemType.name}}</b></p>
<p><span translate>Intrastat</span>: <b>{{::$ctrl.item.intrastat.description}}</b></p>
<p><span translate>Relevancy</span>: <b>{{::$ctrl.item.relevancy}}</b></p>
<p><span translate>Origin</span>: <b>{{::$ctrl.item.origin.name}}</b></p>
<p><span translate>Expence</span>: <b>{{::$ctrl.item.expence.name}}</b></p>
</vn-vertical>
</vn-one>
<vn-one margin-medium>
<vn-vertical>
<h5 translate>Tags</h5>
<p ng-repeat="tag in $ctrl.tags track by tag.id">
<span translate>{{tag.tag.name}}</span>: <b>{{tag.value}}</b>
</p>
</vn-vertical>
</vn-one>
</vn-horizontal>
<vn-horizontal>
<vn-one margin-medium>
<vn-vertical>
<h5 translate>Nicho</h5>
<p><span translate>Name</span>: <b>{{::$ctrl.item.name}}</b></p>
<p><span translate>Name</span>: <b>{{::$ctrl.item.name}}</b></p>
<p><span translate>Name</span>: <b>{{::$ctrl.item.name}}</b></p>
</vn-vertical>
</vn-one>
<vn-one margin-medium>
<vn-vertical>
<h5 translate>Botanical</h5>
<p><span translate>Botanical</span>: <b>{{::$ctrl.item.botanical.botanical}}</b></p>
<p><span translate>Genus</span>: <b>{{::$ctrl.item.botanical.genus.latin_genus_name}}</b></p>
<p><span translate>Specie</span>: <b>{{::$ctrl.item.botanical.specie.latin_species_name}}</b></p>
</vn-vertical>
</vn-one>
<vn-one margin-medium>
<vn-vertical>
<h5 translate>Barcode</h5>
<p ng-repeat="barcode in $ctrl.barcodes track by $index">
<b>{{::$ctrl.barcode.code}}</b>
</p>
</vn-vertical>
</vn-one>
</vn-horizontal>
</vn-vertical>
</vn-card>

View File

@ -0,0 +1,62 @@
import ngModule from '../module';
import './style.scss';
class ItemSummary {
constructor($http) {
this.$http = $http;
}
_getTags() {
let filter = {
where: {
itemFk: this.item.id
}
};
this.tags = [];
this.$http.get(`/item/api/ItemTags?filter=${JSON.stringify(Object.assign({}, filter, {include: {relation: 'tag'}}))}`).then(res => {
this.tags = res.data;
});
}
_getBotanical() {
let filter = {
include: [{relation: 'genus'}, {relation: 'specie'}]
};
this.item.botanical = {};
this.$http.get(`/item/api/ItemBotanicals/${this.item.id}/?filter=${JSON.stringify(filter)}`)
.then(res => {
if (res.data) {
this.item.botanical = res.data;
}
});
}
_getBarcodes() {
let filter = {
where: {
itemFk: this.item.id
}
};
this.barcodes = [];
this.$http.get(`/item/api/ItemBarcodes?filter=${JSON.stringify(filter)}`).then(response => {
this.barcodes = response.data;
});
}
$onChanges() {
if (this.item && this.item.id) {
this._getTags();
if (!this.item.botanical)
this._getBotanical();
}
}
}
ItemSummary.$inject = ['$http'];
ngModule.component('vnItemSummary', {
template: require('./item-summary.html'),
controller: ItemSummary,
bindings: {
item: '<'
}
});

View File

@ -0,0 +1,10 @@
@import "../../../salix/src/styles/colors";
vn-item-summary{
h5 {
border-bottom: 2px solid $color-orange;
}
p {
margin: 0 0 5px 0;
}
}