Skip to content

Commit

Permalink
When editing a raster tile layer the altered properties for the featu…
Browse files Browse the repository at this point in the history
…re-info template is also send to the editor. So e.g. HTML tags for links and images are rendered in the editor form. Now an unaltered clone is send instead.
  • Loading branch information
mapcentia committed May 6, 2022
1 parent aa7acc9 commit 9d0a7c4
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [CalVer](https://calver.org/).

## [UNRELEASED] - 2022-5-5
### Fixed
- When editing a raster tile layer the altered properties for the feature-info template is also send to the editor. So e.g. HTML tags for links and images are rendered in the editor form. Now an unaltered clone is send instead.

## [2022.5.0] - 2022-5-5
### Changed
- In conflictSearch requests to the GC2 SQL API now happens concurrently. This is done by implementing a promise pool. The default size of the pool is 30, but this can be set in the build config. Note that this setting can't be changed in a run-time config.
Expand Down
6 changes: 4 additions & 2 deletions browser/modules/sqlQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ module.exports = {
dashSelected: true
});
if (!parsedMeta.info_element_selector) {
_table.object.on("openpopup" + "_" + _table.uid, function (e) {
_table.object.on("openpopup" + "_" + _table.uid, function (e, layersClone) {
let popup = e.getPopup();
if (popup?._closeButton) {
popup._closeButton.onclick = function () {
Expand All @@ -421,7 +421,9 @@ module.exports = {
}, 100);

$(".popup-edit-btn").unbind("click.popup-edit-btn").bind("click.popup-edit-btn", function () {
editor.edit(e, _key_, qstore);
// We reset the query layer and use a unaltered layer for editor
layerObj.reset();
editor.edit(layersClone, _key_, qstore);
editingStarted = true;
});

Expand Down
7 changes: 5 additions & 2 deletions extensions/editor/browser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,7 @@ module.exports = {
break;

default:
cloud.get().map.addLayer(e);
let numberOfNodes = 0;
const coors = editedFeature.feature.geometry.coordinates;
const calculateCount = (arr) => {
Expand Down Expand Up @@ -857,7 +858,7 @@ module.exports = {
switchLayer.registerLayerDataAlternation(schemaQualifiedName);

sqlQuery.reset(qstore);
me.stopEdit();
me.stopEdit(editedFeature);

// Reloading only vector layers, as uncommited changes can be displayed only for vector layers
if (isVectorLayer) {
Expand Down Expand Up @@ -910,7 +911,6 @@ module.exports = {

_self.openAttributesDialog();
};

let confirmMessage = __(`Application is offline, tiles will not be updated. Proceed?`);
if (isVectorLayer) {
editFeature();
Expand Down Expand Up @@ -1031,6 +1031,9 @@ module.exports = {
if (editor) {
cloud.get().map.removeLayer(editor);
}
if (editedFeature) {
cloud.get().map.removeLayer(editedFeature);
}

// If feature was edited, then reload the layer
if (editedFeature) {
Expand Down
12 changes: 9 additions & 3 deletions public/js/gc2/gc2table.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ var gc2table = (function () {

var customOnLoad = false, destroy, assignEventListeners, clickedFlag = false;

let clonedLayers = {};

$(el).parent("div").addClass("gc2map");

var originalLayers, filters, filterControls, uncheckedIds = [];
Expand Down Expand Up @@ -135,7 +137,7 @@ var gc2table = (function () {
try {
m.map._layers[id].setStyle({
opacity: 1,
dashArray: dashSelected ? "5 8": false,
dashArray: dashSelected ? "5 8" : false,
dashSpeed: 10,
lineCap: "butt"
});
Expand Down Expand Up @@ -180,7 +182,7 @@ var gc2table = (function () {
if (onPopupClose) onPopupClose(id);
});

object.trigger("openpopup" + "_" + uid, m.map._layers[id]);
object.trigger("openpopup" + "_" + uid, m.map._layers[id], clonedLayers[id]);
}
});

Expand Down Expand Up @@ -386,6 +388,10 @@ var gc2table = (function () {
loadDataInTable();
};

$.each(store.layer._layers, function (i, v) {
const l = L.geoJson(JSON.parse(JSON.stringify(v.toGeoJSON())))._layers;
clonedLayers[i] = l[Object.keys(l)[0]];
})
loadDataInTable = function (doNotCallCustomOnload = false, forceDataLoad = false) {
data = [];
$.each(store.layer._layers, function (i, v) {
Expand Down Expand Up @@ -491,7 +497,7 @@ var gc2table = (function () {
store: store,
moveEndOff: moveEndOff,
moveEndOn: moveEndOn,
bootStrapTable : $(el).bootstrapTable
bootStrapTable: $(el).bootstrapTable
};
};
return {
Expand Down

0 comments on commit 9d0a7c4

Please sign in to comment.