Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 28 additions & 6 deletions browser/modules/sqlQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,7 @@ module.exports = {
});
} else {
$.each(sortObject(fieldConf), (name, property) => {
let metaDataForField = metaDataKeys[keyWithOutPrefix].fields[property.key] ? metaDataKeys[keyWithOutPrefix].fields[property.key] : null;
if (property.value.querable) {
let value = feature.properties[property.key];
// Only set field template if property is set or not empty string OR if 'replaceNull' helper is used, which will replace nulls
Expand Down Expand Up @@ -834,10 +835,18 @@ module.exports = {
}
}
}
// If metaDataForField.restrictions has an array, we get the related values
else if (metaDataForField && metaDataForField.restriction && Array.isArray(metaDataForField.restriction)) {
property.restrictions = metaDataForField.restriction;
let restriction = property.restrictions.find(restriction => restriction.value === value);
if (restriction) {
value = restriction.alias;
}
}
fields.push({title: property.value.alias || property.key, value});
fieldLabel = (property.value.alias !== null && property.value.alias !== "") ? property.value.alias : property.key;
if (feature.properties[property.key] !== undefined) {
out.push([property.key, property.value.sort_id, fieldLabel, property.value.link, property.value.template, property.value.content]);
out.push([property.key, property.value.sort_id, fieldLabel, property.value.link, property.value.template, property.value.content, property.restrictions || null]);
}
}
});
Expand All @@ -859,6 +868,7 @@ module.exports = {
link: property[3],
template: property[4],
content: property[5],
restrictions: property[6]
})
});
first = false;
Expand Down Expand Up @@ -934,17 +944,29 @@ module.exports = {
*/
makeDraggable: (popup) => {
const map = cloud.get().map
const wrapper = '.leaflet-popup-content-wrapper'
const popupContent = popup._container.querySelector(wrapper);

// Only apply dragging behavior to content wrapper, not children
popupContent.style.cursor = 'move';
popupContent.children[0].style.cursor = 'auto';

const draggable = new L.Draggable(popup._container, popup._wrapper);
// change cursor class
$(".leaflet-popup-content-wrapper").css('cursor', 'move');

// Handle mousedown event to check if it should start dragging
popup._container.addEventListener('mousedown', function(e) {
// drag only on the wrapper class
if (!e.target.classList.contains(wrapper.replace('.', ''))) {
draggable.disable();
setTimeout(() => draggable.enable(), 100); // Re-enable after interaction
}
});
draggable.on('dragstart', function (e) {
//on first drag, remove the pop-up tip
$(".leaflet-popup-tip-container").hide();
});
draggable.on('dragend', function (e) {
// set the new position
popup.setLatLng(map.layerPointToLatLng(e.target._newPos));
});
});
draggable.enable();
},

Expand Down
6 changes: 6 additions & 0 deletions public/js/gc2/gc2table.js
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,12 @@ var gc2table = (function () {
layerClone[n] = `<div style="cursor: pointer" onclick="window.open().document.body.innerHTML = '<img src=\\'${layerClone[n]}\\' />';">
<img style='width:25px' src='${layerClone[n]}'/>
</div>`
} else if (k.dataIndex === n && (k?.restrictions && (layerClone[n] && layerClone[n] !== ''))) {
let restriction = k.restrictions.find(restriction => restriction.value === layerClone[n]);
if (restriction) {
// replace value with alias
layerClone[n] = restriction.alias;
}
}
});
});
Expand Down