Problem/Motivation

We planned long time ago to do improve the support of views in ui_patterns.
We already have :
- a source for views title
- a source for views rows inside a views style plugin
- a source for view field inside a views rows plugin

we already have some tickets opened for :
- pager #3450570: Add views pager plugin
- exposed form #3504992: [2.1.0] Allow to choose exposed filters as a slot
- more link #3551577: views more link source support

We need the other parts of a view to be able to fully support views rendering :
- views header
- views attachment_before
- views rows (but the styled rows, after views style has been applied, not the raw rows)
- views empty (that one was forgotten in current display_builder)
- views attachment_after
- views footer
- views feed_icons

Those sources were almost all introduced in the display_builder project.
They used to rely on a preprocess hook to operate, but they have recently evolve to a better shape, similar to what we wanted to have in the module.

To be able to specify the context of a view render/display, we would introduce a new context requirement ("views:display") to indicate we are currently rendering a view.

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

just_like_good_vibes created an issue. See original summary.

just_like_good_vibes’s picture

Issue summary: View changes
just_like_good_vibes’s picture

Issue summary: View changes
just_like_good_vibes’s picture

Assigned: just_like_good_vibes » Unassigned
Status: Active » Needs review

Ready for review

just_like_good_vibes’s picture

we will now support usages like this, see the tests in the MR :

   $build = [
      '#type' => 'component',
      '#component' => '...'
      '#ui_patterns' => [
        'props' => [
          'title' => ['source_id' => 'view_title'],
        ],
        'slots' => [
          'header' => ['sources' => [['source_id' => 'view_header']]],
          'exposed' => ['sources' => [['source_id' => 'view_exposed']]],
          'attachment_before' => ['sources' => [['source_id' => 'view_attachment_before']]],
          'rows' => ['sources' => [['source_id' => 'view_styled_rows']]],
          'empty' => ['sources' => [['source_id' => 'view_empty']]],
          'pager' => ['sources' => [['source_id' => 'view_pager']]],
          'attachment_after' => ['sources' => [['source_id' => 'view_attachment_after']]],
          'more' => ['sources' => [['source_id' => 'view_more']]],
          'footer' => ['sources' => [['source_id' => 'view_footer']]],
          'feed_icons' => ['sources' => [['source_id' => 'view_feed_icons']]],
        ],
      ],
      '#source_contexts' => [
        'ui_patterns_views:view' => new Context(new ContextDefinition('any'), $view),
      ],
    ];
just_like_good_vibes’s picture

We also introduced the component form to configure the display of a view.
The MR includes some playwright tests for that feature.

mogtofu33’s picture

Status: Needs review » Needs work

Left some reviews on the MR.

just_like_good_vibes’s picture

Status: Needs work » Needs review
just_like_good_vibes’s picture

thank so veryyy much for the review, it has allowed to strengthen the code :)
it seems better now, ready for merge?

just_like_good_vibes’s picture

Pierre suggested we merge the two sources for raw rows and styled rows,
and provide both logics in the same class.
doable but we also provide a little evolution of RequiredArrayValuesConstraintValidator to allow a list of candidate contexts to match.
i will modify the code and push.

just_like_good_vibes’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.