From 94f19c2cb5205dcc6866dd802fbaf88ab8371d90 Mon Sep 17 00:00:00 2001 From: Gerard Date: Tue, 29 Jan 2019 14:38:31 +0100 Subject: [PATCH] =?UTF-8?q?#1073=20item.tags=20no=20busca=20tags=20cuando?= =?UTF-8?q?=20se=20a=C3=B1ade=20una=20linea=20nueva?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/model-proxy/model-proxy.js | 20 ++++++++++++------- modules/item/front/tags/index.html | 2 +- modules/item/front/tags/index.js | 2 +- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/front/core/components/model-proxy/model-proxy.js b/front/core/components/model-proxy/model-proxy.js index 3ea2fed55..de809dc2a 100644 --- a/front/core/components/model-proxy/model-proxy.js +++ b/front/core/components/model-proxy/model-proxy.js @@ -145,8 +145,9 @@ export default class ModelProxy extends DataModel { }); return new Proxy(obj, { set: (obj, prop, value) => { - let changed = prop.charAt(0) !== '$' && value !== obj[prop] && !obj.$isNew; - if (changed) { + let changed = prop.charAt(0) !== '$' && value !== obj[prop]; + + if (changed && !obj.$isNew) { if (!obj.$oldData) obj.$oldData = {}; if (!obj.$oldData[prop]) @@ -159,7 +160,8 @@ export default class ModelProxy extends DataModel { if (changed) { this.emit('rowChange', {obj, prop, value}); this.emit('dataUpdate'); - if (this.autoSave) + + if (!obj.$isNew && this.autoSave) this.save(); } @@ -173,9 +175,10 @@ export default class ModelProxy extends DataModel { this.isChanged = false; let data = this.proxiedData; - if (data) + if (data) { for (let row of data) row.$oldData = null; + } } /** @@ -186,18 +189,21 @@ export default class ModelProxy extends DataModel { let orgData = this.orgData; if (!data) return; - for (let row of data) + for (let row of data) { if (row.$isNew) { let orgRow = {}; - for (let prop in row) + for (let prop in row) { if (prop.charAt(0) !== '$') orgRow[prop] = row[prop]; + } row.$orgIndex = orgData.push(orgRow) - 1; row.$orgRow = orgRow; row.$isNew = false; - } else if (row.$oldData) + } else if (row.$oldData) { for (let prop in row.$oldData) row.$orgRow[prop] = row[prop]; + } + } let removed = this.removed; diff --git a/modules/item/front/tags/index.html b/modules/item/front/tags/index.html index e8a6d6214..8ce050546 100644 --- a/modules/item/front/tags/index.html +++ b/modules/item/front/tags/index.html @@ -5,7 +5,6 @@ link="{itemFk: $ctrl.$stateParams.id}" include="$ctrl.include" order="priority ASC" - on-row-change="$ctrl.getSourceTable(obj)" data="$ctrl.itemTags" auto-load="true"> @@ -31,6 +30,7 @@ initial-data="itemTag.tag" field="itemTag.tagFk" data="tags" + on-change="$ctrl.getSourceTable(tag)" show-field="name" vn-acl="buyer" vn-focus> diff --git a/modules/item/front/tags/index.js b/modules/item/front/tags/index.js index d221263c1..2fc30e1ac 100644 --- a/modules/item/front/tags/index.js +++ b/modules/item/front/tags/index.js @@ -30,7 +30,7 @@ class Controller { getSourceTable(obj) { let sourceTable; this.sourceTables[obj.id] = {}; - let tag = obj.tag; + let tag = obj.tag || obj.selection; if (!tag || !tag.sourceTable && (tag.isFree === true || tag.isFree === undefined)) sourceTable = null;