Commit cef6c523 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

when changing owner of the overlay, the overlay is always added on the bottom of the list

parent e6d4b196
......@@ -990,8 +990,34 @@ EditProjectDialog.prototype.saveOverlay = function (overlayId) {
overlay.setDescription($("[name='description-" + overlayId + "']", self.getElement())[0].value);
overlay.setPublicOverlay($("[name='publicOverlay-" + overlayId + "']", self.getElement())[0].checked);
overlay.setDefaultOverlay($("[name='defaultOverlay-" + overlayId + "']", self.getElement())[0].checked);
overlay.setCreator($("[name='creator-" + overlayId + "']", self.getElement())[0].value);
var creator = $("[name='creator-" + overlayId + "']", self.getElement())[0].value;
if (creator === "") {
creator = undefined;
}
if (overlay.getCreator() !== creator) {
//put it on the bottom of ordered list of data overlays for given user
var order = 1;
for (var key in self._overlayById) {
if (self._overlayById.hasOwnProperty(key)) {
var existingOverlay = self._overlayById[key];
if (existingOverlay.getCreator() === creator) {
if (existingOverlay.getId() !== overlayId) {
order = Math.max(order, self._overlayById[key].getOrder() + 1);
} else {
order = Math.max(order, self._overlayById[key].getOrder());
}
}
}
}
if (creator === undefined) {
creator = "";
}
overlay.setCreator(creator);
overlay.setOrder(order);
}
console.log("output");
console.log(overlay);
return self.getServerConnector().updateOverlay(overlay);
};
......
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