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 {module} from '../module';
|
||||||
import Component from '../lib/component';
|
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';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -116,7 +116,7 @@ export default class Watcher extends Component {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
writeData(json, resolve) {
|
writeData(json, resolve) {
|
||||||
copyObject(json.data, this.data);
|
this.data = this.copyObject(json.data);
|
||||||
this.copyData();
|
this.copyData();
|
||||||
resolve(json);
|
resolve(json);
|
||||||
}
|
}
|
||||||
|
@ -133,8 +133,22 @@ export default class Watcher extends Component {
|
||||||
resolve();
|
resolve();
|
||||||
}
|
}
|
||||||
copyData() {
|
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) {
|
callback(transition) {
|
||||||
if (!this.state && this.dataChanged()) {
|
if (!this.state && this.dataChanged()) {
|
||||||
this.state = transition.to().name;
|
this.state = transition.to().name;
|
||||||
|
@ -145,11 +159,12 @@ export default class Watcher extends Component {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
dataChanged() {
|
dataChanged() {
|
||||||
return !isEqual(this.data, this.orgData);
|
let newData = this.copyObject(this.data);
|
||||||
|
return !isEqual(newData, this.orgData);
|
||||||
}
|
}
|
||||||
onConfirmResponse(response) {
|
onConfirmResponse(response) {
|
||||||
if (response === 'ACCEPT') {
|
if (response === 'ACCEPT') {
|
||||||
copyObject(this.orgData, this.data);
|
this.data = this.copyObject(this.orgData);
|
||||||
this.$state.go(this.state);
|
this.$state.go(this.state);
|
||||||
} else {
|
} else {
|
||||||
this.state = null;
|
this.state = null;
|
||||||
|
|
Loading…
Reference in New Issue