cambio en watcher sustitucion de la función copy de Angular, para que ignore en las copias los campos vacios
This commit is contained in:
parent
45849e4daa
commit
41182abb6e
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue