From 424f607063c67adc6c4c16fe7ff95702a250fefc Mon Sep 17 00:00:00 2001 From: Daniel Herrero Date: Thu, 21 Dec 2017 14:09:16 +0100 Subject: [PATCH] refactor watcher --- client/core/src/watcher/watcher.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/client/core/src/watcher/watcher.js b/client/core/src/watcher/watcher.js index d259f6f39..83012eca4 100644 --- a/client/core/src/watcher/watcher.js +++ b/client/core/src/watcher/watcher.js @@ -3,6 +3,7 @@ import Component from '../lib/component'; import getModifiedData from '../lib/modified'; import copyObject from '../lib/copy'; import isEqual from '../lib/equals'; +import isFullEmpty from '../lib/fullEmpty'; /** * Component that checks for changes on a specific model property and @@ -95,7 +96,7 @@ export default class Watcher extends Component { let changedData = getModifiedData(this.data, this.orgData); if (this.save) { - this.save.model = changedData; + this.save.model = this.copyInNewObject(changedData); return new Promise((resolve, reject) => { this.save.accept().then( json => this.writeData({data: json}, resolve), @@ -154,7 +155,7 @@ export default class Watcher extends Component { if (data && typeof data === 'object') { Object.keys(data).forEach( val => { - if (data[val] !== "" && data[val] !== undefined && data[val] !== null) { + if (!isFullEmpty(data[val])) { if (typeof data[val] === 'object') { newCopy[val] = this.copyInNewObject(data[val]); } else {