forked from DGNum/gestioCOF
add update method to ModelObject
This commit is contained in:
parent
6afbcb44a1
commit
485ae86a42
1 changed files with 11 additions and 2 deletions
|
@ -137,14 +137,23 @@ class ModelObject {
|
|||
*/
|
||||
from(data) {
|
||||
// TODO: add restrict
|
||||
$.extend(this, this.constructor.default_data, data);
|
||||
this.clear();
|
||||
this.update(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update properties of this instance from data ones.
|
||||
* @param {Object} data
|
||||
*/
|
||||
update(data) {
|
||||
$.extend(this, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear properties to {@link Models.ModelObject.default_data|default_data}.
|
||||
*/
|
||||
clear() {
|
||||
this.from({});
|
||||
$.extend(this, this.constructor.default_data);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue