From 03116ed595ad1b2ed7d5a84df63dc9206b73982e Mon Sep 17 00:00:00 2001 From: Carlos Jimenez <=> Date: Thu, 1 Feb 2018 10:05:20 +0100 Subject: [PATCH] item descriptor now shows itemTags ordered by priority --- client/item/src/card/item-card.js | 3 +- .../item/src/descriptor/item-descriptor.html | 9 ++--- services/db/localDB09Inserts.sql | 20 +++++------ services/item/common/models/item.json | 5 +++ services/item/common/models/itemTag.json | 36 +++++++++++++++++++ services/item/common/models/tag.json | 30 ++++++++++++++++ services/item/server/model-config.json | 6 ++++ 7 files changed, 94 insertions(+), 15 deletions(-) create mode 100644 services/item/common/models/itemTag.json create mode 100644 services/item/common/models/tag.json diff --git a/client/item/src/card/item-card.js b/client/item/src/card/item-card.js index 35e8323b4..aeb921651 100644 --- a/client/item/src/card/item-card.js +++ b/client/item/src/card/item-card.js @@ -16,7 +16,8 @@ class ItemCard { {relation: "producer"}, {relation: "intrastat"}, {relation: "expence"}, - {relation: "taxClass"} + {relation: "taxClass"}, + {relation: "itemTag", scope: {order: "priority ASC", include: {relation: "tag"}}} ] }; this.$http.get(`/item/api/Items/${this.$state.params.id}?filter=${JSON.stringify(filter)}`).then( diff --git a/client/item/src/descriptor/item-descriptor.html b/client/item/src/descriptor/item-descriptor.html index 3b2db6901..864da6928 100644 --- a/client/item/src/descriptor/item-descriptor.html +++ b/client/item/src/descriptor/item-descriptor.html @@ -9,9 +9,10 @@
Id: {{$ctrl.item.id}}
Name: {{$ctrl.item.name}}
-
Description: {{$ctrl.item.description}}
-
Size: {{$ctrl.item.size}}
-
Type: {{$ctrl.item.itemType.name}}
+
{{$ctrl.item.itemTag[0].tag.name}}: {{$ctrl.item.itemTag[0].value}}
+
{{$ctrl.item.itemTag[1].tag.name}}: {{$ctrl.item.itemTag[1].value}}
+
{{$ctrl.item.itemTag[2].tag.name}}: {{$ctrl.item.itemTag[2].value}}
+
{{$ctrl.item.itemTag[3].tag.name}}: {{$ctrl.item.itemTag[3].value}}
- \ No newline at end of file + diff --git a/services/db/localDB09Inserts.sql b/services/db/localDB09Inserts.sql index 77e140b1c..7721c6313 100644 --- a/services/db/localDB09Inserts.sql +++ b/services/db/localDB09Inserts.sql @@ -606,16 +606,16 @@ INSERT INTO `salix`.`user`(`id`,`username`,`password`,`email`) INSERT INTO `vn`.`tag`(`id`,`name`,`free`,`isQuantitatif`,`sourceTable`,`unit`) VALUES - (1, 'color', 1, 0, null, null), - (2, 'power', 1, 0, null, null), - (3, 'shape', 1, 0, null, null), - (4, 'location', 1, 0, null, null), - (5, 'owner', 1, 1, null, null); + (1, 'Color', 1, 0, null, null), + (2, 'Power', 1, 0, null, null), + (3, 'Shape', 1, 0, null, null), + (4, 'Location', 1, 0, null, null), + (5, 'Owner', 1, 1, null, null); INSERT INTO `vn`.`itemTag`(`id`,`itemFk`,`tagFk`,`value`,`priority`) VALUES - (1, 1, 1, 'Yellow', 0), - (2, 1, 2, 'Manipulates time', 0), - (3, 1, 3, 'round', 0), - (4, 1, 4, 'given to Gamora by the Warlock', 0), - (5, 1, 5, 'Gamora', 0); + (1, 1, 1, 'Yellow', 5), + (2, 1, 2, 'Manipulates time', 4), + (3, 1, 3, 'round', 3), + (4, 1, 4, 'Gamoras hideout', 2), + (5, 1, 5, 'Gamora', 1); diff --git a/services/item/common/models/item.json b/services/item/common/models/item.json index 8cfc618ba..c7a1ef363 100644 --- a/services/item/common/models/item.json +++ b/services/item/common/models/item.json @@ -80,6 +80,11 @@ "type": "belongsTo", "model": "TaxClass", "foreignKey": "taxClassFk" + }, + "itemTag": { + "type": "hasMany", + "model": "ItemTag", + "foreignKey": "itemFk" } } } \ No newline at end of file diff --git a/services/item/common/models/itemTag.json b/services/item/common/models/itemTag.json new file mode 100644 index 000000000..3de8dc1aa --- /dev/null +++ b/services/item/common/models/itemTag.json @@ -0,0 +1,36 @@ +{ + "name": "ItemTag", + "base": "VnModel", + "options": { + "mysql": { + "table": "itemTag", + "database": "vn" + } + }, + "properties": { + "id": { + "type": "Number", + "id": true, + "description": "Identifier" + }, + "value": { + "type": "String", + "required": true + }, + "priority": { + "type": "Number" + } + }, + "relations": { + "item": { + "type": "belongsTo", + "model": "Item", + "foreignKey": "itemFk" + }, + "tag": { + "type": "belongsTo", + "model": "Tag", + "foreignKey": "tagFk" + } + } + } diff --git a/services/item/common/models/tag.json b/services/item/common/models/tag.json new file mode 100644 index 000000000..3a2097f97 --- /dev/null +++ b/services/item/common/models/tag.json @@ -0,0 +1,30 @@ +{ + "name": "Tag", + "base": "VnModel", + "options": { + "mysql": { + "table": "tag", + "database": "vn" + } + }, + "properties": { + "id": { + "type": "Number", + "id": true, + "description": "Identifier" + }, + "name": { + "type": "String", + "required": true + }, + "free": { + "type": "Number" + }, + "sourceTable": { + "type": "String" + }, + "unit": { + "type": "String" + } + } + } diff --git a/services/item/server/model-config.json b/services/item/server/model-config.json index 8380de2bf..5d1ae1b8a 100644 --- a/services/item/server/model-config.json +++ b/services/item/server/model-config.json @@ -56,5 +56,11 @@ }, "Country": { "dataSource": "salix" + }, + "ItemTag": { + "dataSource": "vn" + }, + "Tag": { + "dataSource": "vn" } }