imerss-bioinfo 1.17.0 → 1.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "imerss-bioinfo",
3
3
  "description": "Working data of the IMERSS biodiversity informatics working group, together with algorithms",
4
- "version": "1.17.0",
4
+ "version": "1.18.0",
5
5
  "author": "Antranig Basman",
6
6
  "scripts": {
7
7
  "lint": "fluid-lint-all",
@@ -115,7 +115,18 @@ hortis.libreMap.polygonFilter.makeDraw = function (that, map, mapboxDrawOptions,
115
115
  const modeChange = e => that.drawMode = e.mode;
116
116
  const listeners = {"draw.create": updateArea, "draw.delete": updateArea, "draw.update": updateArea, "draw.modechange": modeChange};
117
117
  Object.entries(listeners).forEach(([event, listener]) => map.on(event, listener));
118
- togo = {map, draw, listeners};
118
+ // MapboxDraw's trash deletes only the polygons selected, and polygons restored from the URL are drawn unselected
119
+ // - so with none selected, the trash deletes them all. Heard before MapboxDraw's own handler, while the
120
+ // selection is still as the user left it
121
+ const trashButton = map.getContainer().querySelector(".mapbox-gl-draw_trash");
122
+ const trashAll = () => {
123
+ if (draw.getSelectedIds().length === 0 && draw.getAll().features.length > 0) {
124
+ draw.deleteAll();
125
+ updateArea();
126
+ }
127
+ };
128
+ trashButton?.addEventListener("click", trashAll, true);
129
+ togo = {map, draw, listeners, trashButton, trashAll};
119
130
  } else {
120
131
  togo = fluid.unavailable({message: "The MapboxDraw library is not loaded", variety: "config"});
121
132
  }
@@ -124,6 +135,7 @@ hortis.libreMap.polygonFilter.makeDraw = function (that, map, mapboxDrawOptions,
124
135
 
125
136
  hortis.libreMap.polygonFilter.removeDraw = function (record) {
126
137
  Object.entries(record.listeners).forEach(([event, listener]) => record.map.off(event, listener));
138
+ record.trashButton?.removeEventListener("click", record.trashAll, true);
127
139
  record.map.removeControl(record.draw);
128
140
  };
129
141