Problem/Motivation
There are several places in Views where the ability to easily add a component would be super helpful, such as an Alert as a No Results behavior.
Steps to reproduce
There really aren't great options (that I am aware of)... maybe some sort of block?
Proposed resolution
Create a Views Area plugin, which could be used for No Results, Header, or Footer.
Remaining tasks
1. Create a plugin that exposes all the UI Patterns gravy in Views areas.
User interface changes
1. Lovely new options for Views builders!
API changes
Data model changes
Issue fork ui_patterns-3582319
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:
- 3582319-create-a-views-b
changes, plain diff MR !508
- 3582319-create-a-views
changes, plain diff MR !487
Comments
Comment #2
yannickooComment #4
scottsawyerI got something that sort of works. At least I can add an area.
Not yet working:
Anyway, I would appreciate any insight into these two.
Comment #5
just_like_good_vibesHello,
thank you for reporting that.
i see we are trying to solve two problems here :
- have the ability to configure and inject components in a view area
- make sure the views tokens can work in that context.
i have another proposition to make, to be able to tackle this in another way and that may work.
- we first introduce a views area plugin (that is similar to other ui_patterns views plugins in the way it is working).
- we also introduce a new special hardcoded context string. That context string will be be injected by the views area plugin inside the context of the components rendered.
- we create a new ui_patterns source such as ViewsAreaTextCustom. its definition would require that new context keyword to be present. that new ui_patterns source would allow to embed and render a ViewsArea "text_custom". it will simplify and nicely solve the need of using views related data inside the components.
what do you think? do you want to make to implement that or you would like to keep working and i would just review?
let me know
best
Comment #6
scottsawyer@just_like_good_vibes
Thank you for your thoughts. As I am pretty new to the ui_suite ecosystem, i am totally open to doing things the recommended way, though I am probably going to need some assistance getting going.
I will have a closer look at the other source plugins to see if I can figure out how to make them work. Though, I have tried using the existing ui_patterns_views plugins and I seem to be having the same problem with the replaced components. That could mean I have done something incorrectly in my components (though, they seem to work as expected in LayouBuilder), or maybe there is a general problem (bug maybe?) with ui_patterns. I haven't seen other bugs reported about that, so probably I am just doing something wrong..
I think we have a viable work around for my current project, so this is going to be something I work on in my free time (of which there is very little).
I think next steps is going to be for me to study up on the existing source plugins and see if I can get something that you can look at.
Comment #7
scottsawyer@just_like_good_vibes, I started a new branch of the issue fork to attempt implementing the context as you described, however I feel like I am missing some fundamental understanding. I studied the other Views source plugins but it didn't help me.
Would you mind taking a look at the code and let me know where I go from here?
In particular, I think I need the most help here
https://git.drupalcode.org/issue/ui_patterns-3582319/-/blob/3582319-crea...
and here:
https://git.drupalcode.org/issue/ui_patterns-3582319/-/blob/3582319-crea...
Comment #10
scottsawyerAfter thinking about this more, I don't think I need a source plugin. This area plugin just renders a component. There are already some views source plugins, and all this really needs to do is use one of the existing sources. There are other views area plugins that we might want to convert to sources, but I think those should be different issues.
Anyway, this seems to replace the global tokens and the view replacements ootb, so I think this is pretty much ready.
Comment #11
yannickooThe code looks very clean and like doing what I would expect from this, nice one 💪