dceejay / RedMap

A web map app for Node-RED to put blobs on
Apache License 2.0
110 stars 60 forks source link

Popups / contextmenu feedback issues #268

Closed zafrirron closed 6 months ago

zafrirron commented 6 months ago

Hi, Attached sample flow demonstrating two issues

  1. ${name} replacement is not done for popups and done only for feedback "value" field
  2. feedback function tries to invoke sendDrawing function (line 787) if polygon name exists (it shouldn't - throughs exception)
  3. the sample created two buttons demonstrating different behavior (same buttons for popup and contextmenu just for the demonstration on different behavior)
  4. The simple workaround (until I have some time to fix it..), is to avoid sending the shape name in the name field and add it to the value field to be intercepted by the income node handler:

feedback(\"*\",{\"attr1\":value1, \"name\":\"{{name}}\"}, action, true);

reproduce flow: [ { "id": "46f4b9ae1c66c1ba", "type": "tab", "label": "Flow 4", "disabled": false, "info": "", "env": [] }, { "id": "c643e022.1816c", "type": "worldmap", "z": "46f4b9ae1c66c1ba", "name": "", "lat": "30", "lon": "0", "zoom": "3", "layer": "OSMG", "cluster": "", "maxage": "", "usermenu": "show", "layers": "show", "panit": "false", "panlock": "false", "zoomlock": "false", "hiderightclick": "false", "coords": "deg", "showgrid": "false", "showruler": "false", "allowFileDrop": "false", "path": "worldmap", "overlist": "DR,CO,RA,DN", "maplist": "OSMG,OSMH,EsriS", "mapname": "", "mapurl": "", "mapopt": "", "mapwms": false, "x": 1000, "y": 480, "wires": [] }, { "id": "4966f5218c3fe1df", "type": "inject", "z": "46f4b9ae1c66c1ba", "name": "", "repeat": "", "crontab": "", "once": false, "topic": "", "payload": "", "payloadType": "none", "x": 530, "y": 480, "wires": [ [ "87dff974113c8c54" ] ] }, { "id": "87dff974113c8c54", "type": "function", "z": "46f4b9ae1c66c1ba", "name": "add new rectangle", "func": "\nmsg.payload = {\"command\":{\"bounds\":[[49.83682820280039,-4.019763692204326],[51.4723362586149,1.1741268015945219]]}};\nnode.send(msg);\nmsg.payload = {\"command\":{\"zoom\":9.7}};\nnode.send(msg);\n\nvar popup = \"<button name=\\\"B1name\\\" onclick='feedback(\\\"${name}\\\",\\\"${name} sends Hellow\\\",\\\"myAction\\\",true);'>Hellow Error1</button>\";\npopup += \"<button name=\\\"B2name\\\" onclick='feedback(this.name,\\\"${name} sends Hellow\\\",\\\"myAction\\\",true);'>Hellow Erro2</button>\";\n\nvar points = [ { \"lat\": 50.66, \"lng\": -1.59 }, { \"lat\": 50.60, \"lng\": -1.47 } ] ;\nmsg.payload = {\n popup: popup,\n contextmenu: popup,\n name: \"myShape\",\n area: points,\n clickable:true,\n };;\n\n\nreturn msg;", "outputs": 1, "timeout": "", "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 770, "y": 480, "wires": [ [ "c643e022.1816c", "34ad8daae96efd3e" ] ] }, { "id": "32d7cc4d4db67f66", "type": "worldmap in", "z": "46f4b9ae1c66c1ba", "name": "", "path": "/worldmap", "events": "connect,disconnect,point,layer,bounds,files,draw,other", "x": 500, "y": 540, "wires": [ [ "32a2b83008623990" ] ] }, { "id": "32a2b83008623990", "type": "debug", "z": "46f4b9ae1c66c1ba", "name": "debug 14", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "statusVal": "", "statusType": "auto", "x": 680, "y": 540, "wires": [] }, { "id": "34ad8daae96efd3e", "type": "debug", "z": "46f4b9ae1c66c1ba", "name": "debug 15", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "statusVal": "", "statusType": "auto", "x": 980, "y": 400, "wires": [] } ]

zafrirron commented 6 months ago

Pull request #271