Skip to content
Snippets Groups Projects
Commit c9f6174d authored by Piotr Gawron's avatar Piotr Gawron
Browse files

confiugartion will not crash when some params are missing

parent 644b4869
No related branches found
No related tags found
1 merge request!5Frontend refactor
......@@ -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;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment