refactor watcher
This commit is contained in:
parent
862420e434
commit
424f607063
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue