Commit 417411fe authored by Piotr Gawron's avatar Piotr Gawron
Browse files

default zoom level can be chosen from valid values

parent b8d02288
......@@ -114,7 +114,7 @@ EditProjectDialog.prototype.addTab = function (params) {
navigationObject: navLi,
navigationBar: params.tabMenuDiv
});
$(contentDiv).css("overflow","auto");
$(contentDiv).css("overflow", "auto");
if (params.content !== undefined) {
contentDiv.appendChild(params.content);
......@@ -821,7 +821,12 @@ function getValueOrEmpty(value) {
}
}
EditProjectDialog.prototype.mapToTableRow = function (map, users) {
/**
*
* @param {MapModel} map
* @returns {Array}
*/
EditProjectDialog.prototype.mapToTableRow = function (map) {
var row = [];
var id = map.getId();
var centerX = getValueOrEmpty(map.getDefaultCenterX());
......@@ -831,7 +836,17 @@ EditProjectDialog.prototype.mapToTableRow = function (map, users) {
row[1] = map.getName();
row[2] = "<input name='defaultCenterX-" + id + "' value='" + centerX + "'/>";
row[3] = "<input name='defaultCenterY-" + id + "' value='" + centerY + "'/>";
row[4] = "<input name='defaultZoomLevel-" + id + "' value='" + zoomLevel + "'/>";
var zoomLevelSelect = "<select name='defaultZoomLevel-" + id + "' value='" + zoomLevel + "'>" +
"<option value=''>---</option>";
for (var i = map.getMinZoom(); i <= map.getMaxZoom(); i++) {
var selected = "";
if (i === zoomLevel) {
selected = " selected ";
}
zoomLevelSelect += "<option value='" + i + "' " + selected + ">" + (i - map.getMinZoom()) + "</option>";
}
zoomLevelSelect += "</select>";
row[4] = zoomLevelSelect;
row[5] = "<button name='saveMap' data='" + id + "'><i class=\"fa fa-save\" style=\"font-size:17px\"></i></button>";
return row;
......@@ -921,8 +936,10 @@ EditProjectDialog.prototype.saveOverlay = function (overlayId) {
EditProjectDialog.prototype.saveMap = function (mapId) {
var self = this;
var map = self._mapsById[mapId];
map.setDefaultCenterX($("[name='defaultCenterX-" + mapId + "']", self.getElement())[0].value);
map.setDefaultCenterY($("[name='defaultCenterY-" + mapId + "']", self.getElement())[0].value);
var centerX = parseInt($("[name='defaultCenterX-" + mapId + "']", self.getElement())[0].value);
var centerY = parseInt($("[name='defaultCenterY-" + mapId + "']", self.getElement())[0].value);
map.setDefaultCenterX(centerX);
map.setDefaultCenterY(centerY);
map.setDefaultZoomLevel($("[name='defaultZoomLevel-" + mapId + "']", self.getElement())[0].value);
return ServerConnector.updateModel({projectId: self.getProject().getProjectId(), model: map});
......
......@@ -455,8 +455,16 @@ MapModel.prototype.getDefaultZoomLevel = function () {
return this._defaultZoomLevel;
};
/**
*
* @param {number} defaultZoomLevel
*/
MapModel.prototype.setDefaultZoomLevel = function (defaultZoomLevel) {
this._defaultZoomLevel = defaultZoomLevel;
if (!isNaN(defaultZoomLevel)) {
this._defaultZoomLevel = defaultZoomLevel;
} else {
this._defaultZoomLevel = null;
}
};
/**
......@@ -467,8 +475,16 @@ MapModel.prototype.getDefaultCenterX = function () {
return this._defaultCenterX;
};
/**
*
* @param {number} defaultCenterX
*/
MapModel.prototype.setDefaultCenterX = function (defaultCenterX) {
this._defaultCenterX = defaultCenterX;
if (!isNaN(defaultCenterX)) {
this._defaultCenterX = defaultCenterX;
} else {
this._defaultCenterX = null;
}
};
/**
......@@ -480,7 +496,11 @@ MapModel.prototype.getDefaultCenterY = function () {
};
MapModel.prototype.setDefaultCenterY = function (defaultCenterY) {
this._defaultCenterY = defaultCenterY;
if (!isNaN(defaultCenterY)) {
this._defaultCenterY = defaultCenterY;
} else {
this._defaultCenterY = null;
}
};
MapModel.prototype.getSubmodelType = function () {
......
......@@ -138,6 +138,8 @@ public class ModelRestImpl extends BaseRestImpl {
private Double parseDouble(Object value) throws QueryException {
if (value instanceof Double) {
return (Double) value;
} else if (value instanceof Integer) {
return ((Integer) value).doubleValue();
} else if (value instanceof String) {
if (((String) value).equalsIgnoreCase("")) {
return null;
......@@ -151,7 +153,7 @@ public class ModelRestImpl extends BaseRestImpl {
} else if (value == null) {
return null;
} else {
throw new InvalidArgumentException();
throw new QueryException("Don't know how to change " + value.getClass() + " into Double");
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment