to save the some of the limited space of the config dialog I'm looking for a multi select drop down widget for the editor. (as far as I found out themultiple attribute only works on select lists and not dropdowns)
Is there already a method / widget / tool available witch I can use?
Any other idea to select multiple items without loosing at least tree rows of dialog space
Is it ok to throw in one of the available libraries like select2 (I really like to avoid this)
If I need one of the libraries which one can you recommend (no styling no swiss army knife necessary)
Great, will try this I searched here but couldn't find the 'multiple' property. Are there perhaps other hidden treasures like a color type .... best together with with alpha value?
A little follow up if you don't mind. Nothing I could not work around but perhaps somebody has some ideas or hints before I dig deeper
Works like a charm, especially I can handle the "all series" case better
But: I get a comma separated string. Should be fine in most cases but I would prefer an array same as a list with the multiple flag set outputs (imagine commas in the value strings)
If I set this string during oneditprepare I get this:
The title is empty but the items are set as expected.
Only if i drop down the list and close it again it seams the expected "2 selected" appears
If i switch from selected series (2 selected) to all series and back i get this
Not what I expected. Now the "title" is correct but no options are selected. Closing the dropdown gives "0 selected" and the selections are lost.
Here are my properties ... (you can ignore my uiElements object, it only handles the ui elements I use and make editable lists easier and oneditsave a one line job.
I should preface this by saying the multi select option of the TypedInput isn't widely used - I think we use it one place within the editor. So I'm sure there will be edge cases that it doesn't handle as well as you may expect. But equally, it can only improve by being put through its paces as you are doing.
The TypedInput widget only deals with string properties because it wraps a regular html text input. This is why it encodes the selection as a comma separated list of options.
When you set it to all series, it clears the current value - the list of selected options. When you switch back, as the value has been cleared, nothing is selected.
There is some code in the widget to handle a similar scenario (I forget the specifics) - we'd have to look at what logic makes sense here.
Thank you our detailed answer, always appreciated!
I think I can work around the "one of a kind" use case.
Values as Stings, no problem I'm in charge of the value so I can make sure there is no comma were no comma should be.
Switching types ... Either I find a way to via the change( event, type, value ) event or go with the "multi select only" only version which worked flawless.
perhaps because it isn't documented? This could change now No worries, the forum forgets realy fast.
BTW: would be nice too if the list drops down as soon as the type is changed to avoid a second click on the other (right) side.
I love the typed input - lot of options, flexible, possible customization and using a minimal amount of UI real estate . Would be nice if there could be a "code" type (for callback functions) and a multi line string type (i.e. in the visual JSON editor reasonable editing is "difficult"). (not asking for a color type any more)
Enough for now! As always thank you for your support and have a nice sunday.
What I found out´ after digging deeper into the multiselect list feature:
The only issue I found: If the type changes the the label does not update. It should say "0 selected" when the value is set to "" and not show the last state while the internal value has changed.
This problem can be workaround:
oneditprepare : I define the type first and then set the value
for type changes I use the change event to update the value (to "" or whatever default / last value I need). The title is then updated correctly.
If a fix here is necessary the label should update "x selected" on type changes always reflect the current value.
here is my code to handle type changes while preserving the last selected. (Don't know if piggybacking the lastSelectedValue on the input element is ok)
(event, type, value) => {
let element = $(event.target);
let lastSelected = element.prop('_lastSelectedValue'); // recall last selection
switch (type) {
case 'selected': // type with multiple flag set
if (lastSelected && value!==lastSelected) { // to avoid e endless loop
element.typedInput('value', lastSelected);
}
element.prop('_lastSelectedValue',value); // remember last selection
break;
}
}
@Steve-Mcl in cronplus I observed the same issue if someone switch types for solar events. Either the title is empty but the two default events are selected or the title shows "x selected" when none are actually selected.