diff --git a/frontend-js/src/main/js/Configuration.js b/frontend-js/src/main/js/Configuration.js index fa5aa5bdefcdc731d51635f8aa951d96c495a377..c14121af1112a36a2a46614c7c0e89b893d7de30 100644 --- a/frontend-js/src/main/js/Configuration.js +++ b/frontend-js/src/main/js/Configuration.js @@ -41,7 +41,7 @@ Configuration.prototype.constructor = Configuration; * Updates configuration data from object passed from server side. * * @param modelView - * object retrieved from server side + * object retrieved from server side */ Configuration.prototype.loadFromModelView = function(modelView) { if (typeof modelView === "string") { @@ -54,11 +54,10 @@ Configuration.prototype.loadFromModelView = function(modelView) { this.MAX_ZOOM = modelView.maxZoom; this.MIN_ZOOM = modelView.minZoom; this.MAP_NAME = modelView.version; - this.CENTER_LAT = modelView.centerLatLng.lat; - this.CENTER_LNG = modelView.centerLatLng.lng; + this.setCenter(modelView.centerLatLng); - this.MAPS = modelView.layouts; - this.MAPS = this.MAPS.concat(modelView.customLayouts); + this.addLayouts(modelView.layouts); + this.addLayouts(modelView.customLayouts); this.SUBMODELS = []; if (modelView.submodels !== undefined) { @@ -83,8 +82,21 @@ Configuration.prototype.getId = function() { return this.ID_MODEL; }; +Configuration.prototype.setCenter = function(center) { + if (center !== undefined) { + this.CENTER_LAT = center.lat; + this.CENTER_LNG = center.lng; + } +}; + Configuration.prototype.addLayout = function(layout) { this.MAPS.push(layout); }; +Configuration.prototype.addLayouts = function(layouts) { + if (layouts !== undefined) { + this.MAPS = this.MAPS.concat(layouts); + } +}; + module.exports = Configuration;