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.
  • minItems and maxItems: 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() reads maxItems. 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.
  • InstanceInterface throws \OutOfRangeException on 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:

Showing these constraints to the user, before a drop is refused, is #3628832: Show slot constraints in the Canvas and the Scaffold.

Remaining tasks

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

pdureau created an issue. See original summary.

pdureau’s picture

On 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.

mogtofu33’s picture

Issue summary: View changes
Status: Active » Needs work
Issue tags: +display_builder-1.0.0-beta9

The summary is a bit old, updated to current state. Plus add a line on UX for a child issue.