From 7eab262175e45985075be1874ae355bf2c8f25e6 Mon Sep 17 00:00:00 2001 From: Daniel Herrero Date: Tue, 30 Jan 2018 08:59:43 +0100 Subject: [PATCH 1/2] CRUD item basic data finish --- client/item/src/card/item-card.js | 4 +++- client/item/src/data/item-data.html | 17 +++++++++++++++++ services/item/common/models/item.json | 5 +++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/client/item/src/card/item-card.js b/client/item/src/card/item-card.js index 063910369..35e8323b4 100644 --- a/client/item/src/card/item-card.js +++ b/client/item/src/card/item-card.js @@ -14,7 +14,9 @@ class ItemCard { {relation: "origin"}, {relation: "ink"}, {relation: "producer"}, - {relation: "intrastat"} + {relation: "intrastat"}, + {relation: "expence"}, + {relation: "taxClass"} ] }; this.$http.get(`/item/api/Items/${this.$state.params.id}?filter=${JSON.stringify(filter)}`).then( diff --git a/client/item/src/data/item-data.html b/client/item/src/data/item-data.html index 35fbf0b1a..16deded6c 100644 --- a/client/item/src/data/item-data.html +++ b/client/item/src/data/item-data.html @@ -23,6 +23,7 @@ show-field="name" value-field="id" field="$ctrl.item.typeFk" + initial-data="$ctrl.item.itemType" > @@ -35,6 +36,7 @@ field="$ctrl.item.intrastatFk" order="description ASC" filter-search="{where: {description: {regexp: 'search'}} }" + initial-data="$ctrl.item.intrastat" > {{$parent.$parent.item.description}} @@ -49,13 +51,28 @@ show-field="name" value-field="id" field="$ctrl.item.originFk" + initial-data="$ctrl.item.origin" > + + {{$parent.$parent.item.description}} + + diff --git a/services/item/common/models/item.json b/services/item/common/models/item.json index 3b0db4753..8cfc618ba 100644 --- a/services/item/common/models/item.json +++ b/services/item/common/models/item.json @@ -75,6 +75,11 @@ "type": "belongsTo", "model": "Expence", "foreignKey": "expenceFk" + }, + "taxClass": { + "type": "belongsTo", + "model": "TaxClass", + "foreignKey": "taxClassFk" } } } \ No newline at end of file From 90fab7b01a48609019b4dc0fddc1a074d3a265d0 Mon Sep 17 00:00:00 2001 From: Daniel Herrero Date: Tue, 30 Jan 2018 14:47:47 +0100 Subject: [PATCH 2/2] address observations, list and view edit (TODO save) --- .../client/src/address-edit/address-edit.html | 41 ++++++++++++ .../client/src/address-edit/address-edit.js | 67 ++++++++++++++++++- client/client/src/addresses/addresses.html | 28 +++++--- client/salix/src/styles/font-style.scss | 14 +++- karma.conf.js | 6 +- .../client/common/methods/client/addresses.js | 3 +- .../common/models/address-observation.json | 34 ++++++++++ services/client/common/models/address.json | 5 ++ .../common/models/observation-type.json | 22 ++++++ services/client/server/model-config.json | 6 ++ 10 files changed, 209 insertions(+), 17 deletions(-) create mode 100644 services/client/common/models/address-observation.json create mode 100644 services/client/common/models/observation-type.json diff --git a/client/client/src/address-edit/address-edit.html b/client/client/src/address-edit/address-edit.html index 2d4caea42..f83fee845 100644 --- a/client/client/src/address-edit/address-edit.html +++ b/client/client/src/address-edit/address-edit.html @@ -46,6 +46,47 @@ + + + Notes + + + + {{$parent.$parent.item.description}} + + + + + + + + + + + + diff --git a/client/client/src/address-edit/address-edit.js b/client/client/src/address-edit/address-edit.js index caad023e2..14db7035d 100644 --- a/client/client/src/address-edit/address-edit.js +++ b/client/client/src/address-edit/address-edit.js @@ -1,13 +1,76 @@ import ngModule from '../module'; export default class Controller { - constructor($state) { + constructor($state, $http) { this.address = { id: parseInt($state.params.addressId) }; + this.$http = $http; + this.notes = []; + } + + _setIconAdd() { + if (this.notes.length) { + this.notes.forEach(element => { + element.showAddIcon = false; + }); + this.notes[this.notes.length - 1].showAddIcon = true; + } + } + _setRemoveAdd() { + if (this.notes.length) { + this.notes.forEach(element => { + element.showRemoveIcon = true; + }); + } else { + this.notes = [this._createEmptyNote()]; + } + } + _createEmptyNote() { + return {id: this._createFakeId(), observationTypeFk: null, description: null, showRemoveIcon: true, showAddIcon: true}; + } + _createFakeId() { + let now = Date.now(); + let random = Math.ceil((Math.random() * 100000) + 1); + return `fakeId${now}${random}`; + } + addNote() { + this.notes.push(this._createEmptyNote()); + this._setIconAdd(); + this._setRemoveAdd(); + } + removeNote(id) { + let found = false; + for (let i = 0; i < this.notes.length; i++) { + if (this.notes[i].id === id) { + this.notes.splice(i, 1); + found = true; + break; + } + } + + if (found) { + this._setIconAdd(); + this._setRemoveAdd(); + } + } + $onInit() { + let filter = { + where: { + addressFk: this.address.id + }, + include: [ + {relation: 'observationType'} + ] + }; + this.$http.get(`/client/api/AddressObservations?filter=${JSON.stringify(filter)}`).then(res => { + this.notes = (res.data && res.data.length) ? res.data : [this._createEmptyNote()]; + this._setIconAdd(); + this._setRemoveAdd(); + }); } } -Controller.$inject = ['$state']; +Controller.$inject = ['$state', '$http']; ngModule.component('vnAddressEdit', { template: require('./address-edit.html'), diff --git a/client/client/src/addresses/addresses.html b/client/client/src/addresses/addresses.html index 8b7050222..251520fc2 100644 --- a/client/client/src/addresses/addresses.html +++ b/client/client/src/addresses/addresses.html @@ -5,21 +5,29 @@ Addresses - + + ng-class="{'bg-dark-item': address.isDefaultAddress,'bg-opacity-item': !address.isEnabled && !address.isDefaultAddress}"> - star - star_border + star + star_border - -
{{::i.consignee}}
-
{{::i.street}}
-
{{::i.city}}, {{::i.province}}
-
{{::i.phone}}, {{::i.mobile}}
+ +
{{::address.consignee}}
+
{{::address.street}}
+
{{::address.city}}, {{::address.province}}
+
{{::address.phone}}, {{::address.mobile}}
- + + + + {{::observation.observationType.description}}: + {{::observation.description}} + + + +
diff --git a/client/salix/src/styles/font-style.scss b/client/salix/src/styles/font-style.scss index db0198cde..bb26140ee 100644 --- a/client/salix/src/styles/font-style.scss +++ b/client/salix/src/styles/font-style.scss @@ -9,4 +9,16 @@ body { } html [uppercase], .uppercase { text-transform: uppercase; -} \ No newline at end of file +} + +html [green], .green{color: $color-green} +html [orange], .orange{color: $color-orange} +html [white], .white{color: $color-white} +html [dark], .dark{color: $color-dark} +html [dark-grey], .dark-grey{color: $color-dark-grey} +html [light-grey], .light-grey{color: $color-light-grey} +html [medium-grey], .medium-grey{color: $color-medium-grey} +html [medium-green], .medium-green{color: $color-medium-green} +html [medium-orange], .medium-orange{color: $color-medium-orange} +html [light-green], .light-green{color: $color-light-green} +html [light-orange], .light-orange{color: $color-light-orange} \ No newline at end of file diff --git a/karma.conf.js b/karma.conf.js index e8b1fcbd5..bf4d0e461 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -61,10 +61,10 @@ module.exports = function(config) { // start these browsers // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher - browsers: ['ChromeNoSandboxHeadless'], + browsers: ['ChromiumNoSandboxHeadless'], customLaunchers: { - ChromeNoSandboxHeadless: { - base: 'Chrome', + ChromiumNoSandboxHeadless: { + base: 'Chromium', flags: [ '--no-sandbox', // See https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md diff --git a/services/client/common/methods/client/addresses.js b/services/client/common/methods/client/addresses.js index a4c09ac7e..5000d04d0 100644 --- a/services/client/common/methods/client/addresses.js +++ b/services/client/common/methods/client/addresses.js @@ -38,7 +38,8 @@ module.exports = function(Client) { }, skip: (params.page - 1) * params.size, limit: params.size, - order: ['isDefaultAddress DESC', 'isEnabled DESC'] + order: ['isDefaultAddress DESC', 'isEnabled DESC'], + include: {observations: 'observationType'} }; let total = null; diff --git a/services/client/common/models/address-observation.json b/services/client/common/models/address-observation.json new file mode 100644 index 000000000..53b6155ec --- /dev/null +++ b/services/client/common/models/address-observation.json @@ -0,0 +1,34 @@ +{ + "name": "AddressObservation", + "base": "VnModel", + "options": { + "mysql": { + "table": "addressObservation", + "database": "vn" + } + }, + "properties": { + "id": { + "type": "Number", + "id": true, + "description": "Identifier" + }, + "description": { + "type": "string", + "required": true + } + }, + "relations": { + "address": { + "type": "belongsTo", + "model": "Address", + "foreignKey": "addressFk" + }, + "observationType": { + "type": "belongsTo", + "model": "ObservationType", + "foreignKey": "observationTypeFk" + } + } + } + \ No newline at end of file diff --git a/services/client/common/models/address.json b/services/client/common/models/address.json index 937073d16..1dfe5a52c 100644 --- a/services/client/common/models/address.json +++ b/services/client/common/models/address.json @@ -60,6 +60,11 @@ "type": "belongsTo", "model": "AgencyMode", "foreignKey": "defaultAgencyFk" + }, + "observations": { + "type": "hasMany", + "model": "AddressObservation", + "foreignKey": "addressFk" } } } diff --git a/services/client/common/models/observation-type.json b/services/client/common/models/observation-type.json new file mode 100644 index 000000000..b1a45e883 --- /dev/null +++ b/services/client/common/models/observation-type.json @@ -0,0 +1,22 @@ +{ + "name": "ObservationType", + "base": "VnModel", + "options": { + "mysql": { + "table": "observationType", + "database": "vn" + } + }, + "properties": { + "id": { + "type": "Number", + "id": true, + "description": "Identifier" + }, + "description": { + "type": "string", + "required": true + } + } + } + \ No newline at end of file diff --git a/services/client/server/model-config.json b/services/client/server/model-config.json index 9a8946a2e..7335468a7 100644 --- a/services/client/server/model-config.json +++ b/services/client/server/model-config.json @@ -74,5 +74,11 @@ }, "Company": { "dataSource": "vn" + }, + "AddressObservation": { + "dataSource": "vn" + }, + "ObservationType": { + "dataSource": "vn" } }