From 5f07fab6cf2b61b475eb264b32abce3439b723ca Mon Sep 17 00:00:00 2001 From: Daniel Herrero Date: Tue, 20 Feb 2018 12:33:17 +0100 Subject: [PATCH] item-summary --- client/item/src/summary/item-summary.html | 56 ++++++++++++++++++++ client/item/src/summary/item-summary.js | 62 +++++++++++++++++++++++ client/item/src/summary/style.scss | 10 ++++ 3 files changed, 128 insertions(+) create mode 100644 client/item/src/summary/item-summary.html create mode 100644 client/item/src/summary/item-summary.js create mode 100644 client/item/src/summary/style.scss diff --git a/client/item/src/summary/item-summary.html b/client/item/src/summary/item-summary.html new file mode 100644 index 000000000..9ed62a354 --- /dev/null +++ b/client/item/src/summary/item-summary.html @@ -0,0 +1,56 @@ + + + + + + + + +
Basic data
+

Name: {{::$ctrl.item.name}}

+

Type: {{::$ctrl.item.itemType.name}}

+

Intrastat: {{::$ctrl.item.intrastat.description}}

+

Relevancy: {{::$ctrl.item.relevancy}}

+

Origin: {{::$ctrl.item.origin.name}}

+

Expence: {{::$ctrl.item.expence.name}}

+
+
+ + +
Tags
+

+ {{tag.tag.name}}: {{tag.value}} +

+
+
+
+ + + +
Nicho
+

Name: {{::$ctrl.item.name}}

+

Name: {{::$ctrl.item.name}}

+

Name: {{::$ctrl.item.name}}

+
+
+ + +
Botanical
+

Botanical: {{::$ctrl.item.botanical.botanical}}

+

Genus: {{::$ctrl.item.botanical.genus.latin_genus_name}}

+

Specie: {{::$ctrl.item.botanical.specie.latin_species_name}}

+
+
+ + +
Barcode
+

+ {{::$ctrl.barcode.code}} +

+
+
+
+
+
\ No newline at end of file diff --git a/client/item/src/summary/item-summary.js b/client/item/src/summary/item-summary.js new file mode 100644 index 000000000..17b062af3 --- /dev/null +++ b/client/item/src/summary/item-summary.js @@ -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: '<' + } +}); diff --git a/client/item/src/summary/style.scss b/client/item/src/summary/style.scss new file mode 100644 index 000000000..f5f1b6cfc --- /dev/null +++ b/client/item/src/summary/style.scss @@ -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; + } +} \ No newline at end of file