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

Merge branch '514-custom-overlays' into 'devel_12.1.x'

Resolve "Custom overlays are not sorted in numeric order"

See merge request !405
parents 19d4f8f3 58a360bd
No related branches found
No related tags found
2 merge requests!412changes from 12.1.0~beta.1 into master,!405Resolve "Custom overlays are not sorted in numeric order"
Pipeline #6430 passed
......@@ -329,7 +329,7 @@ OverlayPanel.prototype.overlayToDataRow = function (overlay, checked, disabled)
result[4] = "";
}
if (overlay.getDescription() !== "") {
for (var i = 0; i < result.length; i++) {
for (var i = 1; i < result.length; i++) {
result[i] = "<div class=\"minerva-tooltip\">" + result[i] +
"<span class=\"minerva-tooltip-text\">" + overlay.getDescription() + "</span>" +
......@@ -579,6 +579,7 @@ OverlayPanel.prototype.init = function () {
var table = $(this.getControlElement(PanelControlElementType.OVERLAY_CUSTOM_OVERLAY_TABLE)).DataTable({
columns: [{
title: 'No',
type: 'num',
className: "no_padding"
}, {
title: 'Name'
......@@ -605,8 +606,18 @@ OverlayPanel.prototype.init = function () {
for (var i = 0, ien = diff.length; i < ien; i++) {
var rowData = table.row(diff[i].node).data();
var overlayId = $(rowData[2]).attr("data");
promises.push(self.updateOverlayOrder(overlayId, diff[i].newData));
var checkbox = $("[type='checkbox']", rowData[2])[0];
if (checkbox === undefined) {
checkbox = rowData[2];
}
var overlayId = parseInt($(checkbox).attr("data"));
var order;
if (Functions.isInt(diff[i].newData)) {
order = diff[i].newData;
} else {
order = parseInt($.parseHTML(diff[i].newData)[0].innerHTML);
}
promises.push(self.updateOverlayOrder(overlayId, order));
}
promises.push(self.getMap().redrawSelectedDataOverlays());
return Promise.all(promises);
......@@ -619,7 +630,7 @@ OverlayPanel.prototype.init = function () {
*
* @param {number} overlayId
* @param {number} order
* @returns {PromiseLike}
* @returns {Promise}
*/
OverlayPanel.prototype.updateOverlayOrder = function (overlayId, order) {
var self = this;
......
......@@ -241,7 +241,7 @@ public class OverlayRestImpl extends BaseRestImpl {
layoutDao.update(layout);
return getOverlayById(token, layout.getModel().getProject().getProjectId(), overlayId);
} catch (NumberFormatException e) {
throw new ObjectNotFoundException("overlay doesn't exist");
throw new QueryException("invliad overlay id", e);
}
}
......@@ -314,7 +314,8 @@ public class OverlayRestImpl extends BaseRestImpl {
}
public Map<String, Object> addOverlay(String token, String projectId, String name, String description, String content,
String fileId, String filename, String type, String googleLicenseConsent) throws SecurityException, QueryException, IOException {
String fileId, String filename, String type, String googleLicenseConsent)
throws SecurityException, QueryException, IOException {
User user = getUserService().getUserByToken(token);
if (Configuration.ANONYMOUS_LOGIN.equals(user.getLogin())) {
throw new SecurityException("You have no privileges to add overlay");
......@@ -355,9 +356,10 @@ public class OverlayRestImpl extends BaseRestImpl {
}
}
Layout layout = layoutService.createLayout(new CreateLayoutParams().async(false).colorInputStream(stream)
.description(description).layoutFileName(filename).model(model).name(name).user(user)
.colorSchemaType(colorSchemaType).directory(".").googleLicenseConsent(googleLicenseConsent.equalsIgnoreCase("true")));
Layout layout = layoutService
.createLayout(new CreateLayoutParams().async(false).colorInputStream(stream).description(description)
.layoutFileName(filename).model(model).name(name).user(user).colorSchemaType(colorSchemaType)
.directory(".").googleLicenseConsent(googleLicenseConsent.equalsIgnoreCase("true")));
int count = layoutService.getCustomLayouts(model, token, false, user).size();
layout.setOrderIndex(count);
......
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