watcher renamed properties
This commit is contained in:
parent
8df67ad95e
commit
e2312d954d
|
@ -23,7 +23,7 @@ export default class Watcher extends Component {
|
|||
this.state = null;
|
||||
this.deregisterCallback = $transitions.onStart({},
|
||||
transition => this.callback(transition));
|
||||
this.copyData();
|
||||
this.updateOriginalData();
|
||||
}
|
||||
|
||||
$onInit() {
|
||||
|
@ -36,7 +36,7 @@ export default class Watcher extends Component {
|
|||
|
||||
$onChanges(changes) {
|
||||
if (this.data) {
|
||||
this.copyData();
|
||||
this.updateOriginalData();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ export default class Watcher extends Component {
|
|||
this.$http.get(`${this.url}/${id}`).then(
|
||||
json => {
|
||||
this.data = copyObject(json.data);
|
||||
this.copyData();
|
||||
this.updateOriginalData();
|
||||
}
|
||||
// json => reject(json)
|
||||
);
|
||||
|
@ -127,15 +127,8 @@ export default class Watcher extends Component {
|
|||
}
|
||||
|
||||
writeData(json, resolve) {
|
||||
/* Object.keys(this.data).forEach(
|
||||
key => {
|
||||
this.data[key] = json.data[key];
|
||||
}
|
||||
);*/
|
||||
|
||||
this.data = Object.assign(this.data, json.data);
|
||||
|
||||
this.copyData();
|
||||
Object.assign(this.data, json.data);
|
||||
this.updateOriginalData();
|
||||
resolve(json);
|
||||
}
|
||||
|
||||
|
@ -153,26 +146,26 @@ export default class Watcher extends Component {
|
|||
resolve();
|
||||
}
|
||||
|
||||
copyData() {
|
||||
this.orgData = this.copyObject(this.data);
|
||||
updateOriginalData() {
|
||||
this.orgData = this.copyInNewObject(this.data);
|
||||
}
|
||||
|
||||
copyObject(data) {
|
||||
let copy = {};
|
||||
if (data) {
|
||||
copyInNewObject(data) {
|
||||
let newCopy = {};
|
||||
if (data && typeof data === 'object') {
|
||||
Object.keys(data).forEach(
|
||||
val => {
|
||||
if (data[val] !== "" && data[val] !== undefined && data[val] !== null) {
|
||||
if (typeof data[val] === 'object') {
|
||||
copy[val] = this.copyObject(data[val]);
|
||||
newCopy[val] = this.copyInNewObject(data[val]);
|
||||
} else {
|
||||
copy[val] = data[val];
|
||||
newCopy[val] = data[val];
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
return copy;
|
||||
return newCopy;
|
||||
}
|
||||
|
||||
callback(transition) {
|
||||
|
@ -187,7 +180,7 @@ export default class Watcher extends Component {
|
|||
}
|
||||
|
||||
dataChanged() {
|
||||
let newData = this.copyObject(this.data);
|
||||
let newData = this.copyInNewObject(this.data);
|
||||
return !myEqual(newData, this.orgData);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue