TLDR
Add an option in Configurator_SequenceTabledrag to allow string keys instead of numeric keys.
Background / history
The Configurator_SequenceTabledrag allows to configure a sequence of components instances of the same type.
It allows to add, delete and reorder.
E.g. it can be used to build a sequence of EntityDisplay components.
All the items will have sequential numeric keys.
Problem
In some cases it will be useful to have custom string keys for items.
E.g. to configure a list of tabs that should be controlled by url hash, the url hash can be encoded in the string keys.
Spec / Desired behavior
In the "sequence" mode, the Configurator_SequenceTabledrag needs to behave exactly as before.
In the "assoc" mode, it should behave like this:
Stored config value:
Like before, but with string keys instead of numeric keys.
Returned value:
Like before, but with string keys instead of numeric keys.
Summary:
Use the string keys in the item labels.
Form:
Show a textfield for the string key next to the "Add item" button.
The string key is defined when adding a new item.
Show string keys in the form item labels.
Do NOT show a textfield for the string key in existing items, to avoid clutter in the form.
The only way to change a string key is to remove the item and insert a new item with the same config. The copy/paste functionality can help with that.
Implementation
Add the new mode to Configurator_SequenceTabledrag.
Add a static factory Configurator_SequenceTabledrag::createAssoc().
(I previously experimented with a shared base class and a separate class Configurator_AssocTabledrag, but it was really hard to separate the two.)
Risks
The class gets more complex.
The extended API needs to be supported in the future.
Comments
Comment #2
donquixote commentedComment #3
donquixote commentedComment #4
donquixote commentedComment #6
donquixote commentedFixed in 7.x-2.0-alpha6.
Comment #7
donquixote commented