bartbutenaers / node-red-contrib-ui-svg

A Node-RED widget node to show interactive SVG (vector graphics) in the dashboard
Apache License 2.0
94 stars 27 forks source link

Add or remove elements via input messages #3

Closed bartbutenaers closed 4 years ago

bartbutenaers commented 5 years ago

Currently attribute values of existing elements can be updated via an input message:

"payload": {
    "elementId": "camera_living",
    "attributeName": "fill",
    "attributeValue": "orange"
}
"topic": "update_attribute"

I'm not sure whether I should also support other topics ("create_element", "remove_element") because then my SVG editor is being replaced by JSON ...

Steve-Mcl commented 5 years ago

The ability to change properties is an excellent feature. If a user can move things, hide things, adjust fill etc - it should satisfy most interactions. Adding/removing might be nice but perhaps make that a future feature (if heavily justified)?

littleyoda commented 5 years ago

I would like to see at least a command like "set_attribute".

The reason is quite simple: Current I'm trying to hide SVG Objects: {"elementId":"rainspringler","attributeName":"visibility","attributeValue":"hidden"}

This works only, after adding visibility="visible" to every relevant svg-element in the svg-file. I'm using inkscape to create the svg and it is somewhat annoying to add this attribute to every relevant element, every time I'm changing something.

I'm not really sure, if both update_attributes and set_attributes are really necessary. is there anything against update_attribute automatically adding missing attributes?

bartbutenaers commented 5 years ago

Hi Sven (@littleyoda ),

is there anything against update_attribute automatically adding missing attributes?

I cannot think of anything that should be bad about your proposal. But to be certain that I don't forget anything: could you please ask this question on our discussion in the Node-RED forum? Perhaps anybody else has some extra input about this...

bartbutenaers commented 4 years ago

Adding and removing elements via input messages has currently be implemented in the "panzoom" branch, and will be part of the 2.0.0 version. Further discussions about it will be on the Node-RED forum