}
} else {
this._recordId = null;
- this.record = null;
+ this._record = null;
}
}
+ get recordId(): any {
+ return this._recordId;
+ }
+
// IDL record we are editing
_record: IdlObject;
this.handleRecordChange();
}
} else {
- this.recordId = null;
+ this._recordId = null;
this._record = null;
}
}
let promise;
if (this.record && this.recordId === null) {
promise = Promise.resolve(this.record);
- } else {
+ } else if (this.recordId) {
promise =
this.pcrud.retrieve(this.idlClass, this.recordId).toPromise();
+ } else {
+ // Not enough data yet to fetch anything
+ return Promise.resolve();
}
return promise.then(rec => {
record found with id ${this.recordId}`);
}
- this.record = rec;
+ // Set this._record (not this.record) to avoid loop in initRecord()
+ this._record = rec;
this.convertDatatypesToJs();
return this.getFieldList();
});
//
// Create a new record from the stub record provided by the
// caller or a new from-scratch record
- this.record = this.record || this.idl.create(this.idlClass);
- this.recordId = null; // avoid future confusion
+ // Set this._record (not this.record) to avoid loop in initRecord()
+ this._record = this.record || this.idl.create(this.idlClass);
+ this._recordId = null; // avoid future confusion
return this.getFieldList();
}