Hi,
How does one handle a node, when the user hits ctrl-z? Is there a function with something like "oneditundo"? My current problem is that my node gets in a bad state, if it is configured, and then undo-ed afterwards with ctrl-z.
Hi,
How does one handle a node, when the user hits ctrl-z? Is there a function with something like "oneditundo"? My current problem is that my node gets in a bad state, if it is configured, and then undo-ed afterwards with ctrl-z.
Hi,
no, there is no undo event like that. Can you expand a bit on how that causes your node to get into a bad state? The undo of an edit event returns a node to its exact configuration prior to the edit.
My node gets information from a GET command via the "oneditprepare" function.
Hereafter one can configure the node. When the "save" button is pushed, the node sends a POST command with the new settings. Now if I hit ctrl-z the HTTP req/res does not get updated (it does not know that there was an undo action).
Hi Simon (@Simo219h),
Interesting question, but I think you have to redesign it somehow.
This is how Node-RED works:
So the oneditsave is not really saving like you save a document in another application. Your are still dealing with temporary data, until the 'Deploy' is triggered. I 'think' it is not good practice to use the the oneditsave to do things on your server, which need to be reverted in case you do CTRLZ. Normally you should do such things as soon as your new value 'Y' arrives on the server. When you executed CTRL-Z afterwards and deploy the original value 'X' again to the server, that is the point where your server side code should revert the things you have done earlier ...
BTW don't think a new feature like oneditundo would make sense, because at that point you don't have your config screen open anymore. And all those functions (oneditprepare, oneditsave, ...) are part of the config screen...
I'd like to vote for some kind of UNDO event for the following reason that I have encountered:
Unless you can do all this automatically, which would be very nice - you'd need to watch for any property changes in other nodes when one is edited/saved and restore them as part of the same "transaction" + make sure that resizing happens on all updated nodes.