Skip to content

Commit

Permalink
feat: make prompt configurable for removable layers (origo-map#1759)
Browse files Browse the repository at this point in the history
  • Loading branch information
Grammostola authored May 2, 2023
1 parent b3beca3 commit 6e789f6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/controls/draganddrop.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ const DragAndDrop = function DragAndDrop(options = {}) {
const groupName = options.groupName || 'egna-lager';
const groupTitle = options.groupTitle || 'Egna lager';
const draggable = options.draggable || true;
const promptlessRemoval = options.promptlessRemoval !== false;
const styleByAttribute = options.styleByAttribute || false;
const featureStyles = options.featureStyles || {
Point: [{
Expand Down Expand Up @@ -153,6 +154,7 @@ const DragAndDrop = function DragAndDrop(options = {}) {
styleByAttribute,
queryable: true,
removable: true,
promptlessRemoval,
visible: true,
source: 'none',
type: 'GEOJSON',
Expand Down
5 changes: 3 additions & 2 deletions src/controls/legend/overlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,11 @@ const OverlayLayer = function OverlayLayer(options) {
onRender() {
const labelEl = document.getElementById(this.getId());
labelEl.addEventListener('click', (e) => {
if (window.confirm('Vill du radera lagret?')) {
const doRemove = (layer.get('promptlessRemoval') === true) || window.confirm('Vill du radera lagret?');
if (doRemove) {
viewer.getMap().removeLayer(layer);
e.preventDefault();
}
e.preventDefault();
});
},
render() {
Expand Down

0 comments on commit 6e789f6

Please sign in to comment.