refactor watcher added requiredField
This commit is contained in:
parent
c983859cde
commit
f1f8c74175
|
@ -101,10 +101,21 @@ export default class Watcher extends Component {
|
|||
(resolve, reject) => this.noChanges(reject)
|
||||
);
|
||||
}
|
||||
let changedData = (this.$attrs.save && this.$attrs.save.toLowerCase() === 'post')
|
||||
let isPost = (this.$attrs.save && this.$attrs.save.toLowerCase() === 'post');
|
||||
let changedData = isPost
|
||||
? this.copyInNewObject(this.data)
|
||||
: getModifiedData(this.data, this.orgData);
|
||||
|
||||
if (this.requiredField && !changedData[this.requiredField]) {
|
||||
let required = this.data[this.requiredField] || this.orgData[this.requiredField];
|
||||
if (required === undefined) {
|
||||
return new Promise(
|
||||
(resolve, reject) => this.invalidForm(reject)
|
||||
);
|
||||
}
|
||||
changedData[this.requiredField] = required;
|
||||
}
|
||||
|
||||
if (this.save && this.save.accept) {
|
||||
this.save.model = changedData; // this.copyInNewObject(changedData);
|
||||
return new Promise((resolve, reject) => {
|
||||
|
@ -213,6 +224,7 @@ ngModule.component('vnWatcher', {
|
|||
bindings: {
|
||||
url: '@?',
|
||||
idField: '@?',
|
||||
requiredField: '@?',
|
||||
data: '<',
|
||||
form: '<',
|
||||
save: '<',
|
||||
|
|
Loading…
Reference in New Issue