From 41182abb6ed9cf27ca56e4e769026f1013514892 Mon Sep 17 00:00:00 2001 From: Dani Herrero Date: Thu, 13 Jul 2017 14:55:07 +0200 Subject: [PATCH] =?UTF-8?q?cambio=20en=20watcher=20sustitucion=20de=20la?= =?UTF-8?q?=20funci=C3=B3n=20copy=20de=20Angular,=20para=20que=20ignore=20?= =?UTF-8?q?en=20las=20copias=20los=20campos=20vacios?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/core/src/watcher/watcher.js | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/client/core/src/watcher/watcher.js b/client/core/src/watcher/watcher.js index c50ea94c39..086dc314b0 100644 --- a/client/core/src/watcher/watcher.js +++ b/client/core/src/watcher/watcher.js @@ -1,7 +1,7 @@ import {module} from '../module'; import Component from '../lib/component'; import getModifiedData from '../lib/modified'; -import copyObject from '../lib/copy'; +// import copyObject from '../lib/copy'; import isEqual from '../lib/equals'; /** @@ -116,7 +116,7 @@ export default class Watcher extends Component { }); } writeData(json, resolve) { - copyObject(json.data, this.data); + this.data = this.copyObject(json.data); this.copyData(); resolve(json); } @@ -133,8 +133,22 @@ export default class Watcher extends Component { resolve(); } copyData() { - this.orgData = copyObject(this.data); + this.orgData = this.copyObject(this.data); } + + copyObject(data) { + let copy = {}; + if (data) { + Object.keys(data).forEach( + val => { + if (data[val] !== "" && data[val] !== undefined && data[val] !== null) + copy[val] = data[val]; + } + ); + } + return copy; + } + callback(transition) { if (!this.state && this.dataChanged()) { this.state = transition.to().name; @@ -145,11 +159,12 @@ export default class Watcher extends Component { return true; } dataChanged() { - return !isEqual(this.data, this.orgData); + let newData = this.copyObject(this.data); + return !isEqual(newData, this.orgData); } onConfirmResponse(response) { if (response === 'ACCEPT') { - copyObject(this.orgData, this.data); + this.data = this.copyObject(this.orgData); this.$state.go(this.state); } else { this.state = null;