I am trying to do a custom widget there I select and item, action and type a command.
I have successfully added the item via the find and select box
I want the action to behave like it is in the basic widget list-item there you can select an action instead like in my custom widget action where I only can type it in as a text.
Here is the custom widget, parameters
uid: sample_widget
tags: []
props:
parameters:
- context: item
description: Item we are executing our command through
label: Action Item
name: actionItem
required: true
type: TEXT
- description: Action to perform when the element is clicked
label: Action
name: action
required: true
type: TEXT
- description: An action you wish to perform
label: Action Command
name: actionCommand
required: true
...
Here i show the a screenshot on list-item set prop dialog
But say I wish to use the same action and actionItem on all my buttons and a different actionCommand on each button how do I set that up, I don’t want the user to specify which command?
The custom widget hierarchy
my_custom_remote (Specify actionitem and select action, with same ui as picture as above without displaying Action command)
my_custom_button (Use my my_custom_remote actionItem and action but specify only actionCommand)
my_custom_button (Use my my_custom_remote actionItem and action but specify only actionCommand)
my_custom_button (Use my my_custom_remote actionItem and action but specify only actionCommand)
my_custom_button (Use my my_custom_remote actionItem and action but specify only actionCommand)
I don’t think you can invoke the actions popup directly in the custom widget parameters, but you can build your own clone by using options and limitToOptions.
options sets a mapped list of possible values for the parameter. But this will just render as a text box with autocomplete suggestions. To get the radio buttons you have to set limitToOptions to true.
If you have six or more items in the options map then it will automatically generate the popover for the radio button list as in the image above. If you have five or fewer it will just render them directly on the page.
Alas, there are a couple of reasons why that won’t work. 1) I don’t think you can access the props or items objects within the parameters section, but I don’t know for sure, 2) even if you can access the items object, it does not contain the information about each item, it only contains a string of the item state and (if configured for the item) the display state. So you cannot get to an item’s metadata that way.
Ok so we are stuck defining constants twice
It would be nice to have one source of truth, so we don’t need to update it manually?
Do you know why it is decoupled in that way?
My Thoughts:
speed things up?
Can see one thing if we change it on the fly we will store props that don’t validate no more, but I suppose that are the case even with manual handling?
What I am thinking ‘Set props’ part would it not be nice to have the meta data as well or am I in deep water thinking like that?
I would do some testing see what I can access on items.