From 37af88ee190295bf5d66141c95819cf38eb2c75f Mon Sep 17 00:00:00 2001 From: Daniel Herrero Date: Tue, 9 Jan 2018 09:50:08 +0100 Subject: [PATCH 1/5] watcher bug fixed --- client/core/src/lib/fullEmpty.js | 2 +- client/core/src/watcher/watcher.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client/core/src/lib/fullEmpty.js b/client/core/src/lib/fullEmpty.js index 136a99e03..86c8e6bce 100644 --- a/client/core/src/lib/fullEmpty.js +++ b/client/core/src/lib/fullEmpty.js @@ -1,7 +1,7 @@ import {module} from '../module'; const isFullEmpty = item => { - return (!item && item !== 0 && item !== false) || (typeof item === 'object' && !Object.keys(item).length); + return (item === null || item === undefined) || (typeof item === 'object' && !Object.keys(item).length); }; export default isFullEmpty; diff --git a/client/core/src/watcher/watcher.js b/client/core/src/watcher/watcher.js index 83012eca4..bbe298bb4 100644 --- a/client/core/src/watcher/watcher.js +++ b/client/core/src/watcher/watcher.js @@ -96,7 +96,7 @@ export default class Watcher extends Component { let changedData = getModifiedData(this.data, this.orgData); if (this.save) { - this.save.model = this.copyInNewObject(changedData); + this.save.model = changedData; // this.copyInNewObject(changedData); return new Promise((resolve, reject) => { this.save.accept().then( json => this.writeData({data: json}, resolve), From d245f7c4f2a328cdcba640b4d9eb2188dbe040e7 Mon Sep 17 00:00:00 2001 From: Daniel Herrero Date: Tue, 9 Jan 2018 11:25:35 +0100 Subject: [PATCH 2/5] model taxGroup changed --- services/item/common/models/intrastat.json | 2 +- .../item/common/models/{tax-group.json => tax-class.json} | 4 ++-- services/item/server/model-config.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) rename services/item/common/models/{tax-group.json => tax-class.json} (86%) diff --git a/services/item/common/models/intrastat.json b/services/item/common/models/intrastat.json index 615c16a1e..53f8ce2f9 100644 --- a/services/item/common/models/intrastat.json +++ b/services/item/common/models/intrastat.json @@ -21,7 +21,7 @@ "taxGroup": { "type": "belongsTo", "model": "TaxGroup", - "foreignKey": "taxGroupFk" + "foreignKey": "taxClassFk" }, "taxCode": { "type": "belongsTo", diff --git a/services/item/common/models/tax-group.json b/services/item/common/models/tax-class.json similarity index 86% rename from services/item/common/models/tax-group.json rename to services/item/common/models/tax-class.json index e2fdd5a3b..c107f3391 100644 --- a/services/item/common/models/tax-group.json +++ b/services/item/common/models/tax-class.json @@ -1,9 +1,9 @@ { - "name": "TaxGroup", + "name": "TaxClass", "base": "VnModel", "options": { "mysql": { - "table": "taxGroup", + "table": "taxClass", "database": "vn" } }, diff --git a/services/item/server/model-config.json b/services/item/server/model-config.json index 9258f7f1c..43c9a80fe 100644 --- a/services/item/server/model-config.json +++ b/services/item/server/model-config.json @@ -42,7 +42,7 @@ "Intrastat": { "dataSource": "vn" }, - "TaxGroup": { + "TaxClass": { "dataSource": "vn" }, "TaxCode": { From b1afc20b95fd1cc6b3db4d7377aafd6d9b15ffa5 Mon Sep 17 00:00:00 2001 From: Daniel Herrero Date: Tue, 9 Jan 2018 13:49:15 +0100 Subject: [PATCH 3/5] refactor watcher --- client/core/src/watcher/watcher.js | 7 ++++--- client/core/src/watcher/watcher.spec.js | 6 +++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/client/core/src/watcher/watcher.js b/client/core/src/watcher/watcher.js index bbe298bb4..5108174cd 100644 --- a/client/core/src/watcher/watcher.js +++ b/client/core/src/watcher/watcher.js @@ -12,12 +12,13 @@ import isFullEmpty from '../lib/fullEmpty'; * properties are provided. */ export default class Watcher extends Component { - constructor($element, $scope, $state, $transitions, $http, vnApp, $translate) { + constructor($element, $scope, $state, $transitions, $http, vnApp, $translate, $attrs) { super($element); this.$scope = $scope; this.$state = $state; this.$http = $http; this.$translate = $translate; + this.$attrs = $attrs; this.vnApp = vnApp; this.state = null; @@ -93,7 +94,7 @@ export default class Watcher extends Component { (resolve, reject) => this.noChanges(reject) ); } - let changedData = getModifiedData(this.data, this.orgData); + let changedData = this.$attrs.save === 'post' ? this.copyInNewObject(this.data) : getModifiedData(this.data, this.orgData); if (this.save) { this.save.model = changedData; // this.copyInNewObject(changedData); @@ -194,7 +195,7 @@ export default class Watcher extends Component { } } -Watcher.$inject = ['$element', '$scope', '$state', '$transitions', '$http', 'vnApp', '$translate']; +Watcher.$inject = ['$element', '$scope', '$state', '$transitions', '$http', 'vnApp', '$translate', '$attrs']; module.component('vnWatcher', { template: require('./watcher.html'), diff --git a/client/core/src/watcher/watcher.spec.js b/client/core/src/watcher/watcher.spec.js index 5faba7934..e27efc9f0 100644 --- a/client/core/src/watcher/watcher.spec.js +++ b/client/core/src/watcher/watcher.spec.js @@ -11,6 +11,7 @@ describe('Component vnWatcher', () => { let vnApp; let $translate; let controller; + let $attrs; beforeEach(() => { angular.mock.module('client'); @@ -25,7 +26,10 @@ describe('Component vnWatcher', () => { $transitions = _$transitions_; $httpBackend = _$httpBackend_; $translate = _$translate_; - controller = $componentController('vnWatcher', {$scope, $element, $state, vnApp, $transitions, $httpBackend, $translate}); + $attrs = { + save: "patch" + }; + controller = $componentController('vnWatcher', {$scope, $element, $state, vnApp, $transitions, $httpBackend, $translate, $attrs}); })); describe('$onInit()', () => { From 234f187139bd2c186d5506f17774c2d44b205672 Mon Sep 17 00:00:00 2001 From: Daniel Herrero Date: Tue, 9 Jan 2018 13:51:17 +0100 Subject: [PATCH 4/5] watcher save method to lowercase --- client/core/src/watcher/watcher.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/core/src/watcher/watcher.js b/client/core/src/watcher/watcher.js index 5108174cd..4331b1f8f 100644 --- a/client/core/src/watcher/watcher.js +++ b/client/core/src/watcher/watcher.js @@ -94,7 +94,7 @@ export default class Watcher extends Component { (resolve, reject) => this.noChanges(reject) ); } - let changedData = this.$attrs.save === 'post' ? this.copyInNewObject(this.data) : getModifiedData(this.data, this.orgData); + let changedData = this.$attrs.save.toLowerCase() === 'post' ? this.copyInNewObject(this.data) : getModifiedData(this.data, this.orgData); if (this.save) { this.save.model = changedData; // this.copyInNewObject(changedData); From 628c77a440af602028f5ecfce820c4b192ace6b5 Mon Sep 17 00:00:00 2001 From: Daniel Herrero Date: Tue, 9 Jan 2018 13:52:20 +0100 Subject: [PATCH 5/5] bug fixed watcher --- client/core/src/watcher/watcher.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/core/src/watcher/watcher.js b/client/core/src/watcher/watcher.js index 4331b1f8f..0ac4bf1d4 100644 --- a/client/core/src/watcher/watcher.js +++ b/client/core/src/watcher/watcher.js @@ -94,7 +94,7 @@ export default class Watcher extends Component { (resolve, reject) => this.noChanges(reject) ); } - let changedData = this.$attrs.save.toLowerCase() === 'post' ? this.copyInNewObject(this.data) : getModifiedData(this.data, this.orgData); + let changedData = (this.$attrs.save && this.$attrs.save.toLowerCase() === 'post') ? this.copyInNewObject(this.data) : getModifiedData(this.data, this.orgData); if (this.save) { this.save.model = changedData; // this.copyInNewObject(changedData);