Problem/Motivation

Today, "Data from a field" ("[Entity] => [Field]" starting UI Patterns 2.0.5) is a single source in the Blocks library panel. So, we need to drop it and then pick the chosen field in the instance panel.

Proposed resolution

Add a new "Field" section in the Blocks library panel, alongside "List (Views)", "Menus" and "Others".

However, it will not be hardcoded like "List (Views)", "Menus" and "Others" (it was OK to hardcode them because they are Drupal blocks), but it will rely on the ui_patterns_overrides's SourcesBundlerInterface to get the list of sources.

So, instead of dragging only to the builder panel:

  source_id: entity_field
  source: {  }

We are dragging directly something like that:

  source_id: entity_field
  source:
    derivable_context: 'field:node:article:title'
    'field:node:article:title':
      value: {}

It would be nice to move this SourcesBundlerInterface logic to UI Patterns 2 by the way: #3513568: [2.0.7] Source usability : better interfaces for sources relying on child plugins

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

pdureau created an issue. See original summary.

mogtofu33’s picture

pdureau’s picture

Would it be possible to do the same for [Entity] ➜ Referenced [Entity]"?

So, with both modifications:

before after
before after
pdureau’s picture

Title: [1.0.0-alpha2] Flatten the Fields list » Flatten the Fields list
Issue tags: -display_builder-1.0.0-alpha2 +display_builder-1.0.0-alpha3
pdureau’s picture

just_like_good_vibes made their first commit to this issue’s fork.

pdureau’s picture

Status: Active » Needs work

Thanks for your ongoing work.

Can you also remove SourcesBundlerInterface and ComponentSource from ui_patterns_overrides module? You will need to update the class actually depending on this interface:

  • SlotSourceProxy : replace SourcesBundlerInterface::getOptionLabel() by something from SourceWithChoicesInterface
  • ComponentLibraryPanel: replaces SourcesBundlerInterface::getDataSkeleton() by SourceWithChoicesInterface::getChoiceSettings()
  • BlockLibraryPanel: a linter will remove automatically the remaining SourcesBundlerInterface
  • WysiwygWidget: just remove it, SourcesBundlerInterface doesn't make sense here

We also need to check the UI (not because UI is part of this issue scope, but because it will tell us if we did things the right way):

  • In BuilderPanel, LayersPanel and TreePanel: we have source label + summary (example: "[Entity] ➜ [Field]: body") instead of the choice label ("Body")
  • In Menu islands: we have only source label (example: "[Entity] ➜ [Field]") instead of the choice label ("Body')
  • What else?
just_like_good_vibes’s picture

Assigned: just_like_good_vibes » mogtofu33
Status: Needs work » Needs review

mogtofu33’s picture

Assigned: mogtofu33 » Unassigned
Status: Needs review » Fixed

mogtofu33’s picture

Status: Fixed » Needs work

When moving a component we have now an error.

Seems this broke the component library, adding a component_id when we want an instance_id. Either we create it as what getDataSkeleton was doing or we need to change the ApiController.

  • mogtofu33 committed de1f3626 on 1.0.x
    Issue #3529260 by just_like_good_vibes, pdureau, mogtofu33: Flatten the...
mogtofu33’s picture

Because it's a big regression I set back the getDataSkeleton, let me know if there can be optimization here.

just_like_good_vibes’s picture

i posted an update of the code which seems to correct the issue,
but this issue in ui_patterns is needed : https://www.drupal.org/project/ui_patterns/issues/3540835

just_like_good_vibes’s picture

just_like_good_vibes’s picture

Assigned: Unassigned » pdureau
Status: Needs work » Needs review
just_like_good_vibes’s picture

Assigned: pdureau » mogtofu33

mogtofu33’s picture

Assigned: mogtofu33 » Unassigned
Status: Needs review » Needs work

Still not good, had to fallback to:

        'source_id' => 'component',
        'source' => ['component' => $source->getChoiceSettings($component_id)],

  • mogtofu33 committed 7bbe9c89 on 1.0.x
    Issue #3529260 by just_like_good_vibes, pdureau: Flatten the Fields list
    

  • mogtofu33 committed 5cc64d50 on 1.0.x
    Issue #3529260 by just_like_good_vibes, pdureau: Flatten the Fields list
    
mogtofu33’s picture

Title: Flatten the Fields list » Flatten the Fields list (pending ui_patterns 2.0.8)

As discussed with @just_like_good_vibes seems working with ui_patterns 2.x-dev and 2.0.8 release, so need to come back and finish here when 2.0.8 is out.

just_like_good_vibes’s picture

Assigned: Unassigned » pdureau
Status: Needs work » Needs review

and finally :)

grimreaper’s picture

Thanks!

It fixes the fatal on latest dev version of ui_patterns 2.0.8.

just_like_good_vibes’s picture

this fix has been pushed and re-pushed again until we finally have it now with a clean dependency to a required ui_patterns min version.
finally... but this is not finished, we will follow-up - in that issue or not? - performances issues introduced now.

mogtofu33’s picture

Assigned: pdureau » mogtofu33

mogtofu33’s picture

Assigned: mogtofu33 » Unassigned
Status: Needs review » Fixed

Let's have a follow up issue for the performance.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.