I am new to node red and am trying to learn how edit dialog works. I have already implemented a simpler edit dialog and understand how the html parts of it work. I am now trying to add in something more complicated and not all of the code goes into the html part, some of it goes into oneditprepare according to the page I've been following to learn this https://nodered.org/docs/creating-nodes/edit-dialog. This is the code I'm trying to add,
I'm not sure what I'm supposed to do to use the code that is in the oneditprepare box in the first image or even how to use the onedit functions at all. I couldn't really find much documentation on it either. Could someone please explain how this works or ideally give an example of how and where I'm supposed to be using this?
I have solved my own problem, I am not familiar with boards like these so sorry if I have added clutter to the board. Since I have already posted this though I may as well post the solution. It took me a while to find the answer and it seems to me that there wasn't much easy to find documentation on it, so I'm hoping that anyone else having the same issue that I did will run into this post and have an easier time than me.
It is often best to check out existing examples of nodes that do something you want to do.
One thing you should remember about typedInput's is that some of the types are asynchronous and so will need additional async processing in your runtime. Personally, I now use a standard function to wrap them so I don't have to think about it.
Thank you for your reply. Would you by any chance know of a set of example nodes that someone has published somewhere? When I was trying to figure this out I tried looking at some of the default nodes and also tried looking through the palette manager to try to find an example to understand what was going on. Unfortunately all the nodes I found had a bit too much going on for me to understand what I was looking at. It would be great if there were some set of nodes published somewhere with the purpose of just demonstrating the implementation of different features in node red. If that does exist I do not know where to find it though.
Obviously, the nodes I am most familiar with are my own. Though I do have my own way of working with nodes that I find far more suitable for me than the "standard" way shown in the docs.
The uib-tag node in uibuilder is an example. It has multiple typed inputs most of which allow msg.* and so have to be processed asynchronously. Which means that the input message handler for the node also needs to be async.
Note how the input message callback fn is async and so must call the done() function when it has finished. Also note how I process all of the typed inputs in parallel using promise.all. And that I use a standard function, getSource which is in one of my standard libraries:
The nearest I can offer for that are my test nodes.
I use these to test out how Node-RED processes nodes and how I can improve my understanding and write better nodes. You can clone the repo and then run your own tests if you like.
Note though that this does use my own way of working, as mentioned above. I think that, at least for the node runtime's, this makes it a lot easier to follow the different operational phases of Node-RED (initial startup, instantiation of a node instance, receipt of a message, etc.) but that might just be me.
The Editor panels are also broken out into separate files to make it easier to work on them in VS Code and with ESLINT but the structure is a bit more complex.
Then you also have an example of using a common library to support the Editor panels of all the nodes.