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.
Motivation
We heavily use paragraphs and features. But now it is not possible to add a new feature with a paragraph without changing the field configuration.
Example
Types:
- Row
- Column
- Teaser
- Image
- .....
Row can only include Column.
Column can include all Types except column and row.
Solution
Add a option in ParagraphSelection for exclude types.
Comment | File | Size | Author |
---|---|---|---|
#45 | exclude_types-2856901-45.patch | 5.53 KB | Ginovski |
#45 | exclude_types-2856901-45-test-only.patch | 3.04 KB | Ginovski |
#44 | add_a_possibility_for-2856901-44.patch | 5.53 KB | Ginovski |
#44 | interdiff-2856901-42-44.txt | 4.15 KB | Ginovski |
#42 | exclude_types-2856901-42.patch | 2.42 KB | Ginovski |
Comments
Comment #2
Erik Seifert CreditAttribution: Erik Seifert commentedComment #3
Erik Seifert CreditAttribution: Erik Seifert commentedComment #4
Erik Seifert CreditAttribution: Erik Seifert commentedAdd new validation for DefaultSelection
Comment #5
Erik Seifert CreditAttribution: Erik Seifert commentedRemove notices.
Comment #6
johnchqueNot sure what you want to do exactly, but did you try with disabling all, as the help text says, "All disabled is all enabled".
Comment #7
Erik Seifert CreditAttribution: Erik Seifert commentedNo, i want to exclude some types and allow the remaining..
Comment #8
Erik Seifert CreditAttribution: Erik Seifert commentedComment #9
Ginovski CreditAttribution: Ginovski at MD Systems GmbH commentedMaybe "Choose allowed paragraph types" or "Choose paragraph types" would be more proper, since the exclude might mix with the include option and would not make sense.
array() -> []
Comment #10
Erik Seifert CreditAttribution: Erik Seifert commentedFor test i need more time. A little help would be nice ;- )
Add (1) and (2).
Comment #11
JeroenTWrote a test for this issue.
Comment #12
JeroenTAdded the negotate item to the schema + made some changes to the backend screen. I changed the select to a checkbox. What do you think?
Comment #17
miro_dietikerPlease always add screenshots for UI change proposals. It allows much easier UX review.
Comment #18
JeroenTUndid the UI changes.
Comment #20
JeroenTComment #29
miro_dietikerBefore adding more configurability to Paragraphs that is not simply catching up with core patterns, we should define the final goal of how we want to manage paragraph types.
That makes it related to the paragraph type grouping we are also introducing:
#2831762: Add grouping for Paragraph types in "Modal" add mode
People asked to define sets of paragraph types and only allow that set, so adding a new type to a set doesn't require editing every single other paragraph type adding that new type... Others are proposing better tools for batch updates.
See also #2504583: A way to select between predefined sets of paragraphs?
Comment #30
miro_dietikerComment #31
Ginovski CreditAttribution: Ginovski at MD Systems GmbH commentedAdded in the experimental and change some descriptions.
Screenshot:
Comment #32
Ginovski CreditAttribution: Ginovski at MD Systems GmbH commentedRenamed config setting negotate -> negate
Comment #33
miro_dietikerI don't think this is correct.
(BTW some more comments in the logic would help read it faster.)
If no paragraph type is selected, thus it seems getAllowedTypes() returns emptyness now, still all should be allowed.
Is this selection thing well test covered or am i wrong?
I'm very unhappy we need to put this type of setting into the widget.
Instead, a heper method should just interprete the setting and provide us the list of allowed paragraph types. Like getAllowedBundles().
Comment #34
Ginovski CreditAttribution: Ginovski at MD Systems GmbH commentedCreated an issue #2881145: Get allowed paragraph types from ParagraphSelection, this can wait for that
Comment #35
Ginovski CreditAttribution: Ginovski at MD Systems GmbH commentedThis is build on top of #2881145: Get allowed paragraph types from ParagraphSelection
Comment #36
Ginovski CreditAttribution: Ginovski at MD Systems GmbH commented#2881145: Get allowed paragraph types from ParagraphSelection is committed.
So adding a patch with the negate setting. Works properly atm.
Screenshot of the form:
Comment #37
Primsi CreditAttribution: Primsi at MD Systems GmbH for MD Systems GmbH commentedWouldn't this be integer? Because I think if its bool, radios would interprete false as not selected.
Options are not translated.
Also I am not sure about those options. Maybe like that (not really happy with those either)?
1 All selected below
0 All, except the ones selected below
I am not really familiar with return_value. What does this do?
Hm, if we change the schema to int, we might want to fallback to 0 here.
So if we make this a int, will it still evaluate to '1'?
Comment #38
Ginovski CreditAttribution: Ginovski at MD Systems GmbH commentedAddressed #37.
For the descriptions I used:
Exclude the selected below
Include the selected below
Comment #40
miro_dietikerCommitted. :-)
But i noticed that the base of ParagraphSelection is DefaultSelection that implements many methods that are not overridden. There are methods like getReferenceableEntities() countReferenceableEntities() buildEntityQuery() and even createNewEntity() that keep the old (at least not negated) behavior. Where are those methods used?
Needs work for discussion and then to be closed.
Comment #41
BerdirYes, this was too early, it's has incomplete test coverage. Validation doesn't work and entities can't be saved.
Not sure if it's worth to revert, @Ginovski is working on improving it.
Comment #42
Ginovski CreditAttribution: Ginovski at MD Systems GmbH commentedAdding buildEntityQuery() and validate.
Comment #44
Ginovski CreditAttribution: Ginovski at MD Systems GmbH commentedFixed methods and extended tests.
Comment #45
Ginovski CreditAttribution: Ginovski at MD Systems GmbH commentedAdding test-only patch.
Comment #49
miro_dietikerCommitted, thx. :-)
Comment #50
miro_dietiker