From a3985e70ed5b5363ceac458e8db9ead16573b5ee Mon Sep 17 00:00:00 2001 From: Daniel Herrero Date: Tue, 20 Feb 2018 08:53:06 +0100 Subject: [PATCH 1/3] Tarea #37 ItemBotanical --- client/item/src/botanical/item-botanical.html | 46 +++++++++++++++++-- client/item/src/botanical/item-botanical.js | 27 ++++++++++- 2 files changed, 67 insertions(+), 6 deletions(-) diff --git a/client/item/src/botanical/item-botanical.html b/client/item/src/botanical/item-botanical.html index 36cd49f8f..de6b31787 100644 --- a/client/item/src/botanical/item-botanical.html +++ b/client/item/src/botanical/item-botanical.html @@ -1,5 +1,41 @@ - - - Botanical - - \ No newline at end of file + + + + +
+ + + Botanical + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/client/item/src/botanical/item-botanical.js b/client/item/src/botanical/item-botanical.js index 8bd744e53..03020648b 100644 --- a/client/item/src/botanical/item-botanical.js +++ b/client/item/src/botanical/item-botanical.js @@ -1,5 +1,30 @@ import ngModule from '../module'; +class ItemBotanical { + constructor($http, $state) { + this.$http = $http; + this.botanical = { + itemFk: $state.params.id + }; + } + $onInit() { + let filter = { + where: { + itemFk: this.botanical.itemFk + }, + include: [{relation: 'genus'}, {relation: 'specie'}] + }; + this.$http.get(`/item/api/ItemBotanicals?filter=${JSON.stringify(filter)}`) + .then(res => { + if (res.data) { + Object.assign(this.botanical, res.data); + } + }); + } +} +ItemBotanical.$inject = ['$http', '$state']; + ngModule.component('vnItemBotanical', { - template: require('./item-botanical.html') + template: require('./item-botanical.html'), + controller: ItemBotanical }); From ecc513272f0bafbdd9e1bc1b32da4473e251d081 Mon Sep 17 00:00:00 2001 From: Daniel Herrero Date: Tue, 20 Feb 2018 11:10:54 +0100 Subject: [PATCH 2/3] refactor itemBotanical and item --- client/item/routes.json | 7 +++++ client/item/src/barcode/item-barcode.html | 1 - client/item/src/botanical/item-botanical.html | 12 ++++---- client/item/src/botanical/item-botanical.js | 28 ++----------------- client/item/src/card/item-card.js | 28 +++++++++++++++---- client/item/src/item.js | 1 + 6 files changed, 40 insertions(+), 37 deletions(-) diff --git a/client/item/routes.json b/client/item/routes.json index 127c1e84f..b3941d555 100644 --- a/client/item/routes.json +++ b/client/item/routes.json @@ -97,6 +97,13 @@ "description": "Barcode", "icon": "folder" } + },{ + "url" : "/summary", + "state": "item.card.summary", + "component": "vn-item-summary", + "params": { + "item": "$ctrl.item" + } } ] } \ No newline at end of file diff --git a/client/item/src/barcode/item-barcode.html b/client/item/src/barcode/item-barcode.html index 985d3a02b..4f7da2dee 100644 --- a/client/item/src/barcode/item-barcode.html +++ b/client/item/src/barcode/item-barcode.html @@ -3,7 +3,6 @@ Item Barcodes - diff --git a/client/item/src/botanical/item-botanical.html b/client/item/src/botanical/item-botanical.html index de6b31787..4c657cd6c 100644 --- a/client/item/src/botanical/item-botanical.html +++ b/client/item/src/botanical/item-botanical.html @@ -4,7 +4,7 @@ @@ -13,20 +13,20 @@ Botanical - + { - if (res.data) { - Object.assign(this.botanical, res.data); - } - }); - } -} -ItemBotanical.$inject = ['$http', '$state']; - ngModule.component('vnItemBotanical', { template: require('./item-botanical.html'), - controller: ItemBotanical + bindings: { + item: '<' + } }); diff --git a/client/item/src/card/item-card.js b/client/item/src/card/item-card.js index 903631d42..f414bebc8 100644 --- a/client/item/src/card/item-card.js +++ b/client/item/src/card/item-card.js @@ -4,7 +4,21 @@ class ItemCard { constructor($http, $state) { this.$http = $http; this.$state = $state; - this.item = {}; + } + + _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]; + } + }); } $onInit() { @@ -19,10 +33,14 @@ class ItemCard { {relation: "itemTag", scope: {order: "priority ASC", include: {relation: "tag"}}} ] }; - this.$http.get(`/item/api/Items/${this.$state.params.id}?filter=${JSON.stringify(filter)}`).then( - res => { - this.item = res.data; - } + 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(); + } + } ); } } diff --git a/client/item/src/item.js b/client/item/src/item.js index 9ddba12ad..ef5846179 100644 --- a/client/item/src/item.js +++ b/client/item/src/item.js @@ -12,4 +12,5 @@ import './history/item-history'; import './niche/item-niche'; import './botanical/item-botanical'; import './barcode/item-barcode'; +import './summary/item-summary'; From 4c26879fdb3a2c6c2823fea364960080cf01a7c8 Mon Sep 17 00:00:00 2001 From: Bernat Exposito Date: Tue, 20 Feb 2018 11:16:02 +0100 Subject: [PATCH 3/3] update fixtures edi.genus/specie --- services/db/04-fixtures.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/db/04-fixtures.sql b/services/db/04-fixtures.sql index 5ccd1b5e3..7f15a7a13 100644 --- a/services/db/04-fixtures.sql +++ b/services/db/04-fixtures.sql @@ -436,4 +436,4 @@ INSERT INTO `vn`.`itemTag`(`id`,`itemFk`,`tagFk`,`value`,`priority`) INSERT INTO `vn`.`itemLog` (`id`, `originFk`, `userFk`, `action`, `description`) VALUES - ('1', '1', '1', 'insert', 'We made an change!'); \ No newline at end of file + ('1', '1', '1', 'insert', 'We made an change!'); \ No newline at end of file