ensure delete drawing appears under drawing events

This commit is contained in:
Dave Conway-Jones 2023-10-06 18:38:34 +01:00
parent 4f9956d474
commit b6bbdb64ef
No known key found for this signature in database
GPG Key ID: 1DDB0E91A28C2643
3 changed files with 10 additions and 4 deletions

View File

@ -617,6 +617,7 @@ If <i>Web Path</i> is left empty, then by default <code>⌘⇧m</code> - <code>c
<li><b>delete</b> - when a point or shape is deleted</li>
<li><b>point</b> - when a point is added manually using right-click</li>
<li><b>draw</b> - when a shape is added manually to the drawing layer</li>
<li><b>drawdelete</b> - when a shape is deleted from the drawing layer</li>
<li><b>layer</b> - when a base layer is changed</li>
<li><b>addlayer</b> - when an overlay is added to the map</li>
<li><b>dellayer</b> - when an overlay is removed from the map</li>
@ -662,10 +663,10 @@ If <i>Web Path</i> is left empty, then by default <code>⌘⇧m</code> - <code>c
{ value: "connect", label: "Connect"},
{ value: "disconnect", label: "Disconnect"},
{ value: "point", label: "Add, move, delete point"},
{ value: "draw", label: "Add, edit or delete drawing"},
{ value: "layer", label: "Add, remove layers"},
{ value: "bounds", label: "Boundary change"},
{ value: "files", label: "File drop"},
{ value: "draw", label: "Drawing"},
{ value: "other", label: "All other"}
]
}]});

View File

@ -139,7 +139,7 @@ module.exports = function(RED) {
delete message.from;
sendToRest(message,client.id);
}
if (message.action === "delete") {
if (message.action === "delete" || message.action === "drawdelete") {
delete allPoints[message.name];
sendToRest(message,client.id);
}
@ -313,7 +313,7 @@ module.exports = function(RED) {
message.content = Buffer.from(message.content.split('base64,')[1], 'base64');
setImmediate(function() {node.send({payload:message, topic:node.path.substr(1), _sessionid:client.id, _sessionip:sessionip})});
}
if ((node.events.indexOf("draw")!==-1) && (message.action === "draw")) {
if ((node.events.indexOf("draw")!==-1) && ((message.action === "draw")||(message.action === "drawdelete"))) {
setImmediate(function() {node.send({payload:message, topic:node.path.substr(1), _sessionid:client.id, _sessionip:sessionip})});
}
if (node.events.indexOf("other")!==-1 && "connected,point,delete,move,draw,files,bounds".indexOf(message.action) === -1) {

View File

@ -1384,9 +1384,11 @@ helpText += 'The default is that only visible layers add to the heatmap.</p>';
// Delete a marker or shape (and notify websocket)
var delMarker = function(dname,note) {
if (note) { map.closePopup(); }
var pol = false;
if (typeof polygons[dname] != "undefined") {
layers[polygons[dname].lay].removeLayer(polygons[dname]);
delete polygons[dname];
pol = true;
}
if (typeof polygons[dname+"_"] != "undefined") {
layers[polygons[dname+"_"].lay].removeLayer(polygons[dname+"_"]);
@ -1402,7 +1404,10 @@ var delMarker = function(dname,note) {
delete markers[dname];
}
delete allData[dname];
if (note) { ws.send(JSON.stringify({action:"delete", name:dname, deleted:true})); }
if (note) {
if (pol === false) { ws.send(JSON.stringify({action:"delete", name:dname, deleted:true})); }
else { ws.send(JSON.stringify({action:"drawdelete", name:dname, deleted:true}))}
}
}
var editPoly = function(pname,fun) {