Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
As described in #2825557: [META] Introduce edit perspectives and added the first step in #2828506: Introduce a plugin system for paragraphs types we will be able to add Plugins fields to the Paragraphs entities. It should, for instance, have two edit perspectives where each one should group the fields where "Content" has the entity fields and "Behavior" has the plugins fields.
Proposed resolution
Add two tabs when editing a content with paragraphs.
"Content" (default) and "Behavior". Use jquery tabs to have a user-side solution.
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#77 | implement_edit-2829671-77.patch | 15.96 KB | drobnjak |
#77 | interdiff-2829671-75-77.txt | 1.18 KB | drobnjak |
#75 | interdiff-2829671-73-75.txt | 1.82 KB | drobnjak |
#75 | implement_edit-2829671-75.patch | 16.6 KB | drobnjak |
#73 | interdiff-2829671-71-73.txt | 2.64 KB | drobnjak |
Comments
Comment #2
johnchqueWill start with this.
Comment #3
johnchqueWas able to add tabs, the only problem with that is that it only work for the first Paragraph as the id is pointing to just one, need to investigate about this.
The combined patch was made along with #2828506: Introduce a plugin system for paragraphs types
Comment #6
miro_dietikerI guess this is limited to Drupal admin UI, thus should be paragraphs.admin.js.
The selector is not properly limited. It needs to be limited to a paragraphs specific list.
Don't use IDs as they would need to be unique per DOM. Use classes.
Also, i thought this makes the region assignment configurable (title "allow to manage") but instead it just makes the defined regions visible. So is the other patch already defining the regions?
The title "Label" and description "Label for the paragraphs type" is much unfortunate as it doesn't really introduce a real case example. Instead we should implement an example such as a Layout selector, offering a drop down, and then adding a class to the output.
Comment #7
miro_dietikerNote that this switcher is supposed to be present only on the top (host entity field) level and affect all children.
We don't want to commit an intermediate version that is overloading the UI. Thus we need to use a nested example as reference.
Comment #8
miro_dietikerThe issue was not properly linked to the parent META. I created a new issue for feature plugin META.
Comment #9
johnchqueMade some progress, still doesn't work with nested paragraphs.
Comment #12
johnchqueAdded a layout plugin depending on the field layout module added in: #2796173: Add experimental Field Layout module to allow entity view/form modes to switch between layouts so now we can select the region of the field the only problem is that this plugin can be applied to every entity type not just paragraphs, need to investigate about it.
Comment #15
johnchqueAs the issue got in, no need of combined patch anymore, now the tabs are shown just once at the top of the paragraph field in the node, the switch also work for nested paragraphs. :)
Comment #16
johnchqueAdded on creation hide elements, now it work a bit better with the field_layout module.
Comment #17
BerdirDiscussed with miro to leave out the configuration/UI part from this issue. Lets focus on the edit UI here and open an issue for that, as we think that will end up being complicated.
this doesn't work, an id needs to be unique. You need to do this relative from your current position based on button you clicked, go up from there to the parent parent container, then select the subform of it.
this should probably be template. I also don't think that this is limited to sub-paragraphs only?
But it should probably be limited to having any plugins enabled, at least for now.
Comment #18
johnchqueInterdiff bigger. Changed to use unique id's referring to the table created by paragraphs. The logic behind it is that the tabs are only added when the parent is not a paragraph, if it is a paragraph then adds a class to the subform for avoid hiding it because it might have the subform/behavior fields of the children paragraph.
Still need to work in the template.
Comment #19
johnchqueChanged a bit the approach, tried to implement the same structure as NodeForm, where it create containers that are set as the groups of the fields, doesn't work at all, needs investigation.
Comment #21
miro_dietikerThe issue needs an update of title and description due to rescoping and (creation of the) the related / separated issue too.
Comment #22
johnchqueComment #23
miro_dietikerWe discussed the approach of the tabs. The summary and goal description should also contain HOW we want to achieve this.
Do we already have the follow-ups created?
Comment #24
johnchqueAdded follow-up will update the META issue.
Comment #25
BerdirRe-rolled and tried to make the #group work, but it is very tricky, because #group needs the full tree, including the parents, which we do not know yet. Also had to change a few other things, #group needs a container, and we need to change our logic to not overwrite it.
The attached example hardcodes the path for the paragraphs_demo field, but only works for the first item, just to show how it needs to look like.
The JS also doesn't really seem to work, and keep in mind that you need to figure out how to show the things even in nested fields, wich the current approach isn't going to be able to do at all. I also don't think that we should use jquery ui tabs.
I guess we need to move the grouping logic complety to JS and add classes to fields and behavior plugin structures that allow it to dynamically hide/show things, exclude paragraph fields and so on.
Not much point for an interdiff, as many things changed a lot with the reroll anyway.
Comment #27
johnchqueMade a small change, which makes it work with multiple paragraphs, need to think about nested ones. Will investigate more a bit later.
Comment #28
miro_dietikerHm reuploading to trigger Mr. Testbot.
Comment #30
johnchqueFinally working with nested paragraphs, also tests fixed. :)
Comment #31
realityloopPatch wasn't applying
Comment #32
mbrc CreditAttribution: mbrc at Unic commentedFixed #31, which was missing the JS.
Also renamed js/paragraphs.js to js/paragraphs.admin.js as per Miro's suggestion in #6.
Comment #33
megadesk3000 CreditAttribution: megadesk3000 at Unic commentedI tested #32 and basically it works.
But there is an issue, that the background image field for example is displayed both in the "content" and the "behavior" perspective when using nested paragraphs. After a discussion with Berdir, we decided to implement it a little differently, cause the approach with the #group property is not working for every case (e.g. fields attached to a paragraph that are not entity reference revision fields).
Comment #34
johnchqueI actually think that my approach works with nested paragraphs. Did you change the widget of the nested field to use the experimental widget?
I tested this patch and works in similar way (Also for nested). Maybe we need more tests to show why my patch was failing. :)
Comment #35
johnchqueI actually tested both patches and a problem comes with validation errors, when for example, we submit an invalid value in a plugin field, the error message is displayed, the field has red margin, but it is not focused, because the js builds the tabs after the response with the message. Not sure how to deal with that.
Comment #36
johnchqueIt needs investigation of validation errors messages and focus.
Comment #37
drobnjak CreditAttribution: drobnjak at MD Systems GmbH commentedPromoting, since now that we have behavior plugins it is highly important to get edit perspectives. I am still not sure if we need focus on validation errors. For example, if we add invalid file type in the image field of article content type, it is also not in focus after we press submit.
Comment #38
miro_dietikerThis is not limited to Paragraphs in any kind.
It seems to have a high risk of clashes if we combine Paragraphs with Field Group or something using tabs.
Comment #39
miro_dietikerI only see screens above with yellow background...
As this is a UI issue, please provide a final UX screen of the effective proposed state.
Also, the patch doesn't apply currently.
Comment #40
drobnjak CreditAttribution: drobnjak at MD Systems GmbH commentedThis patch should fix merge conflicts. Did renaming as suggested in #38. Moved ui-tabs-panel to field-multiple-table since it is limited to paragraphs only. Uploading screenshots for both perspectives.
There is a possibility to remove paragraph in both perspectives. However, after removing one paragraph, perspective is changed and locked to content only. This should be fixed. Easiest way to do it is to limit remove button to content perspective only.
Comment #41
drobnjak CreditAttribution: drobnjak at MD Systems GmbH commentedI will keep working on this.
Comment #42
BerdirThe order of Behavior/Content is still wrong, looks very weird to me that Behavior is first but not selected by default.
I don't see what using jquery ui tabs brings us, we're doing the show/hide ourself anyway? Why not just have those two buttons/divs/things and register events on them? I suspect it will just get more in the way once we'll try to implement something that looks remotely like the mockups? I think making the elements smaller and adding an icon would already help a lot, looks quite... clunky to me right now.
Comment #43
miro_dietikerAnd i see the Style plugin settings in the Content tab. So hiding doesn't work?
Comment #44
miro_dietikerI'm confused UX wise, why Content is not the first tab... This right-to-left is against our standard UX expetation IMHO.
Comment #45
drobnjak CreditAttribution: drobnjak at MD Systems GmbH commentedAdding a patch to update the progress. Resolved many merge conflicts due to Paragraphs recent commits. Removed jQuerry UI tabs, using lightweight solution now. There are still multiple things that need to be investigated and done here.
Comment #46
drobnjak CreditAttribution: drobnjak at MD Systems GmbH commentedWorking in both normal and nested case. Added CSS classes and changed layout a bit. Currently working on adding JS test.
Comment #47
drobnjak CreditAttribution: drobnjak at MD Systems GmbH commentedForgot the screenshot.
Comment #49
miro_dietikerWhile on it, i really like to have the plugin fields first and then the content field such as the add buttons too.
And i tested a deeply nested paragraphs setup with layout plugin fields on a child.
After reload, the nested plugin fields also / still show on the content tab (for my second paragraph in a child).
It is possible that the filtering is limited to the first child only?
Comment #50
miro_dietikerAlso the collapse action is broken for me with this patch. It simply reloads without any effect.
Comment #51
miro_dietikerUX follow-up: The paragraphs that are filtered (no content field) in behavior tab have no summary. Thus you don't know what a paragraph has inside. The problem here is, if we pre-generate the summary, it will be out of date. And regenerating it again with AJAX is not wanted as it makes it slow...
Comment #52
pivica CreditAttribution: pivica at MD Systems GmbH commentedFixed and re-rolled patch against latest dev so it cleanly applies again. Reviewing this.
Comment #53
miro_dietikerWith this patch applied, this setup based on paragraphs collection demo was broken:
- setting the paragraph fields to closed mode (content type, paragraph type container)
- editing the front page
- click edit on first container
- click edit - the paragraph doesn't expand
Comment #54
drobnjak CreditAttribution: drobnjak at MD Systems GmbH commentedPatch re-rolled after sass commit. Provided JS test placeholder for the future changes that will require testing.
Comment #55
miro_dietikerSo, we proposed a JS based approach to have the UI fast.
This though contains 2 problems:
- High JS complexity
- All behavior forms are always rendered even if hidden, making the server side form generation and the browser slow
I think we should restart this implementation with an ajax based approach. After 55 comments, i think it's best in a new issue.
Here's why:
- The content form is slim, fast
- Switching between content and settings is likely not happening THAT much
- The added complexity is small. Two ajax buttons and a new widget state property. A few additional lines if / else to either call content form or behavior settings form.
Created this issue about tristate behavior enabling:
#2856008: Enable behavior plugins with a tristate
Comment #56
drobnjak CreditAttribution: drobnjak at MD Systems GmbH commentedAfter discussion with @Berdir we realized that ajax approach would be much more complex. If there are changes applied to the content and/or behavior fields we would have multiple changes in field widgets leading to complexity in further ajax requests. It would require much more work than a two buttons and a new widget state property.
Comment #57
drobnjak CreditAttribution: drobnjak at MD Systems GmbH commentedUploading patch so the feature can be tested with special cases. I need to fix the tests, write small JS test and move CSS to .scss
Comment #59
miro_dietikerPromoting it to critical... The current UX is super cumbersome as soon as plugins are enabled.
Comment #60
miro_dietikerI have tested this with a paragraph and nesting. The top level paragrpah had a style and layout selection. The style switched. But layout - and similarly all layout settings of children - were not hidden ever.
Comment #61
miro_dietikerUndo prio change. :-)
Comment #62
drobnjak CreditAttribution: drobnjak at MD Systems GmbH commentedAdded small change to remove overriding the form with an empty array.
Comment #64
drobnjak CreditAttribution: drobnjak at MD Systems GmbH commentedAdding a check to make sure that we stay on the same perspective after an action (Duplicate, Remove etc.) being performed. Moving the setting of an active class from back-end to front.
Comment #66
miro_dietikerThis start to look good. Added this patch to our test environment. :-)
Let's get this in as-is because it significantly improves the UX. But first, let's create the follow-ups that deal with all the problems...
- Deduplicating the JS
- Fix NoJS fallback and improve accessibility
- Switch to collapsed paragraphs widget mode by default
- Only display the tabs if there is a behavior element
-- (Should we display element count in the tab "Behavior (15)"?)
- Hide children / tree if they have no content
- Extend JS test coverage to a case with multiple plugins and nesting. Test each field expectation.
Our top prio is on improving visual language and declutter those plugin settings now.
Comment #67
miro_dietikerAh yeah and... tests are still failing? :-)
Comment #68
miro_dietikerTested functionality of #64, but didn't work.
If i click the behavior tab, i can see the behavior fields.
Then when expanding / collapsing some other paragraph, the behavior tab is staying active, but the behavior fields disappear.
I need to reclick the tab to make them visible.
Comment #69
drobnjak CreditAttribution: drobnjak at MD Systems GmbH commentedThe patch is addressing the issue of duplicating or editing on Behavior tab, which led to switching back to Content perspective in Ajax form reload. We are assigning class to the layout container and in that way keeping it, without losing it due to form reload. Other changes are test fixes.
Comment #71
drobnjak CreditAttribution: drobnjak at MD Systems GmbH commentedRe-rolling.
Comment #73
drobnjak CreditAttribution: drobnjak at MD Systems GmbH commentedImproved and fixed JS test.
Comment #74
miro_dietikerOK, wanted to commit this as WIP, but still some issues we need to fix first.
This is not properly prefixed. We can not change ALL horizontal tabs.
Consider our character limit per line.
Also i see many child items here. Child means we first need to fix children until we can commit the parent and close it.
Instead those should be related. Also they should be more child of our parent META #2825557.
Finally, not all issues listed in comment 66 are created as issues.
This all should be fixed first before a WIP commit.
Comment #75
drobnjak CreditAttribution: drobnjak at MD Systems GmbH commentedAddressing comment #74
Comment #76
miro_dietikerAnother follow-up: The JS only works on nodes. Note that paragraphs could similarly exist on terms or other entities.
These (and other subform) changes are not related. It even makes things inconsistent here. We should leave this transformation to the other existing issues and limit us here to the purpose only.
Comment #77
drobnjak CreditAttribution: drobnjak at MD Systems GmbH commentedAddressing comment #76
Comment #79
miro_dietikerThx, committed. Back to needs-work for complete follow-up management.
Comment #80
miro_dietikerWhat is really critical from #66 is a regression we created.
Everyone switching to the new widget now sees the tabs even if there is (likely) no behavior plugin at all.
Originally worded: "Only display the tabs if there is a behavior element"
Let's try to address this soon.
Comment #81
drobnjak CreditAttribution: drobnjak at MD Systems GmbH commentedAdding all follow-ups here:
#2852041: Allow plugins to declare fields as behavior
#2852044: Expose plugins as extra fields to allow configuring the order
#2862929: Refactor JS code for Edit perspectives
#2862933: [META] Edit perspectives user experience
#2862935: Only display tabs if there is a behavior element
#2867035: Add element count display on edit perspectives
#2867049: Extend JS tests for edit perspectives
#2867068: Switch to collapsed paragraphs widget mode by default
Discussing the possible follow-up from comment #66 for hiding children/trees if they have no content/behavior plugins:
In my opinion, for the best UX, we shouldn't hide the elements even if they don't have plugins or content.
Simply because it can be confusing, user can create structure, and then in behavior tab, the structure is different which leads to losing more time when changing the settings and content.
Comment #82
drobnjak CreditAttribution: drobnjak at MD Systems GmbH commentedClosing this issue and moving discussion to #2862933: [META] Edit perspectives user experience.
Comment #84
marcvangendThis issue introduced a bug: the javascript is incompatible with Drupal Form API #states. I created a follow-up: #2946856: Perspectives tabs break Form API #states