WIP: Aureplop/kpsul js refactor #501
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