FlowFuse / node-red-dashboard

https://dashboard.flowfuse.com
Apache License 2.0
181 stars 45 forks source link

ui-dropdown - Not parsing `options` when widget is reload based on message `widget-load` #1022

Closed arturv2000 closed 1 month ago

arturv2000 commented 2 months ago

Current Behavior

The Widget ui-dropdown no longer accepts/parse the options part of the message that receives when it is loaded widget-load

Was working at least in V1.8.1.

It seems that the function: https://github.com/FlowFuse/node-red-dashboard/blob/61e3d24cbed9ab588709dcfb873f0a2f69d5876d/ui/src/widgets/ui-dropdown/UIDropdown.vue#L92

Should not only call the select , but it seems to be more practical to call onDynamicProperties to reload the proprieties/options/payload for this widget.

Expected Behavior

Options should load on widget load based on the last message.

Steps To Reproduce

Small example:

[{"id":"ea3e5bce236e8acb","type":"inject","z":"08258208cc944d94","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":390,"y":620,"wires":[["15f02d9187400bf7"]]},{"id":"15f02d9187400bf7","type":"function","z":"08258208cc944d94","name":"function 49","func":"msg.payload = '-1';\nmsg.options = [];\n\nmsg.options.push({ value: '-1', label: `Unknown`});\nmsg.options.push({ value: '0', label: 'None' });\nmsg.options.push({ value: '1', label: '1' });\nmsg.options.push({ value: '2', label: '2' });\nmsg.options.push({ value: '3', label: '3'});\n\nreturn msg;\n","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":560,"y":620,"wires":[["3a7b3ff5da2f3d2a"]]},{"id":"3a7b3ff5da2f3d2a","type":"ui-dropdown","z":"08258208cc944d94","group":"b23855b34abcb2f9","name":"","label":"Select Option:","tooltip":"","order":0,"width":0,"height":0,"passthru":false,"multiple":false,"options":[{"label":"","value":"","type":"str"}],"payload":"","topic":"topic","topicType":"msg","className":"","x":760,"y":620,"wires":[[]]},{"id":"b23855b34abcb2f9","type":"ui-group","name":"My Group","page":"8a2139abc63ea4cd","width":"6","height":"1","order":-1,"showTitle":true,"className":"","visible":"true","disabled":"false"},{"id":"8a2139abc63ea4cd","type":"ui-page","name":"Page N","ui":"9df4836d2f5c3db3","path":"/pageN1","icon":"home","layout":"flex","theme":"6abc079232f2e7a5","order":-1,"className":"","visible":"true","disabled":"false"},{"id":"9df4836d2f5c3db3","type":"ui-base","name":"My Dashboard","path":"/dashboard","includeClientData":true,"acceptsClientConfig":["ui-notification","ui-control"],"showPathInSidebar":false,"navigationStyle":"default"},{"id":"6abc079232f2e7a5","type":"ui-theme","name":"Default Theme","colors":{"surface":"#097479","primary":"#097479","bgPage":"#111111","groupBg":"#333333","groupOutline":"#cccccc"},"sizes":{"pagePadding":"6px","groupGap":"6px","groupBorderRadius":"4px","widgetGap":"6px"}}]

After selecting the value on the dropdown, force a page refresh.

Environment

Have you provided an initial effort estimate for this issue?

I am not a FlowFuse team member

arturv2000 commented 2 months ago

Is the change from

onLoad (msg) {
            // update vuex store to reflect server-state
            this.$store.commit('data/bind', {
                widgetId: this.id,
                msg
            })
            this.select(this.messages[this.id]?.payload)
        },

to

onLoad (msg) {
            // update vuex store to reflect server-state
            this.$store.commit('data/bind', {
                widgetId: this.id,
                msg
            })
            // this.select(this.messages[this.id]?.payload)
            this.onDynamicProperties(msg)
        },

A valid option?

It it is, I can create a PR with this change to close this