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 getModifiedData from '../lib/modified';
|
||||||
import copyObject from '../lib/copy';
|
import copyObject from '../lib/copy';
|
||||||
import isEqual from '../lib/equals';
|
import isEqual from '../lib/equals';
|
||||||
|
import isFullEmpty from '../lib/fullEmpty';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component that checks for changes on a specific model property and
|
* 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);
|
let changedData = getModifiedData(this.data, this.orgData);
|
||||||
|
|
||||||
if (this.save) {
|
if (this.save) {
|
||||||
this.save.model = changedData;
|
this.save.model = this.copyInNewObject(changedData);
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.save.accept().then(
|
this.save.accept().then(
|
||||||
json => this.writeData({data: json}, resolve),
|
json => this.writeData({data: json}, resolve),
|
||||||
|
@ -154,7 +155,7 @@ export default class Watcher extends Component {
|
||||||
if (data && typeof data === 'object') {
|
if (data && typeof data === 'object') {
|
||||||
Object.keys(data).forEach(
|
Object.keys(data).forEach(
|
||||||
val => {
|
val => {
|
||||||
if (data[val] !== "" && data[val] !== undefined && data[val] !== null) {
|
if (!isFullEmpty(data[val])) {
|
||||||
if (typeof data[val] === 'object') {
|
if (typeof data[val] === 'object') {
|
||||||
newCopy[val] = this.copyInNewObject(data[val]);
|
newCopy[val] = this.copyInNewObject(data[val]);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue