Problem/Motivation
#3514072: SDC slots can set expectations and cardinality added three optional keywords to each SDC slot definition:
expected: a list of SDC plugin IDs, with a colon, or of tags or groups, without one.minItemsandmaxItems: a strictly positive lower or upper limit on the number of children.
SDC and the Render API only suggest, they do not enforce. UI Patterns and Display Builder decide what to do with them.
Done: maxItems
#3544026: Cardinality constraints for slots landed the cardinality, shared with the rest of this scope:
SourceWithSlotsInterface::getSlotCardinality()readsmaxItems.DisplayBuildableInterface::getRootCardinality()gives the root its own limit.- Every dropzone carries the limit as
data-max-items, and a drag never lands in a full one. InstanceInterfacethrows\OutOfRangeExceptionon an attach or a move into a full root or slot, and the builder answers with a toast.- UI Patterns does the same in its slot form, #3551587: Slots restrictions according to suggestions and cardinality.
Out of scope
- The Config panel: slots edited there go through the UI Patterns slot form.
minItems, for now.
Proposed resolution
Apply expected the way maxItems is applied:
- It restricts components only. Blocks still go anywhere.
- On the server, in
InstanceInterface, next to the cardinality check: one rule for every way in, drag, click insert #3628802: Insert from the library without dragging, paste, duplicate and preset. - In the Canvas and the Scaffold, a drag never lands in a dropzone that does not expect the dragged component. The Navigator only moves nodes within itself, and the server check covers it.
- Put the logic in UI Patterns when it can be shared, to avoid writing it twice. #3571009: Add SourceWithSlotsInterface and LayoutSource and #3572186: Use SourceWithSlotsInterface from UI Patterns may give it a home on
SourceWithSlotsInterface.
Showing these constraints to the user, before a drop is refused, is #3628832: Show slot constraints in the Canvas and the Scaffold.
Remaining tasks
- Decide whether the constraints are strict for everyone, or configurable per profile or island, so only some roles are held to them.
- Implement
expected, server and drag. - Show the constraints in the Canvas and the Scaffold: #3628832: Show slot constraints in the Canvas and the Scaffold.
User interface changes
A component cannot be dropped or inserted in a slot that does not expect it.
API changes
InstanceInterface refuses an attach or a move that breaks expected. The exception is to decide with #3627028: InstanceInterface: one failure style for the tree methods.
Data model changes
None.
Comments
Comment #2
pdureau commentedOn UI Patterns, we are adding this mechanism for
ComponentSlotForm: #3551587: Slots restrictions according to suggestions and cardinality.And maybe a dedicated public method to SourceWithSlotsInterface later: #3571009: Add SourceWithSlotsInterface and LayoutSource & #3572186: Use SourceWithSlotsInterface from UI Patterns.
Lets' try to elegantly leverage all this.
Comment #3
mogtofu33 commentedThe summary is a bit old, updated to current state. Plus add a line on UX for a child issue.