WIP: Aureplop/kpsul js refactor #501

Draft
delobell wants to merge 215 commits from aureplop/kpsul_js_refactor into master
Showing only changes of commit 485ae86a42 - Show all commits

View file

@ -137,14 +137,23 @@ class ModelObject {
*/ */
from(data) { from(data) {
// TODO: add restrict // 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 properties to {@link Models.ModelObject.default_data|default_data}.
*/ */
clear() { clear() {
this.from({}); $.extend(this, this.constructor.default_data);
} }