Problem/Motivation
User story...
As a content editor using paragraphs_sets to add a lot of complex paragraph content, I want paragraphs to spawn collapsed, so my entity form is less overwhelming.
Currently, paragraphs_sets spawns paragraphs in an "open" state ("edit mode") i.e.: similar to the default behaviour when you click the "Add more" button on the paragraphs field.
Once a paragraph has been added to a page, it is possible to "Close" / "Collapse" it to just a summary. This is easier to read and takes up less vertical space.
The site I'm working on is using paragraphs_sets to spawn lengthly, pre-defined lists, i.e.: where each paragraph is an item in the list, and there are often 7 or more items in a list. Each of the list items has a title field, which paragraphs_sets populates, and a bunch of optional additional data that will be filled in later on, resulting in loooooong node/add pages, meaning the content editor has to do a lot of unnecessary scrolling to get to the rest of the node/add form.
Contrast this with when the content editor goes to edit the node later on: we can configure the widget to collapse / close the paragraphs on the node/edit page, and the client prefers this interface.
Ideally, paragraphs_sets could spawn the paragraphs in a collapsed state, reducing the work / information overload on the content editor, while still allowing them to customize the paragraphs they want (i.e.: by expanding / opening / clicking "edit" on them) similar to what they do on the node/edit form.
Proposed resolution
Provide a way for paragraphs_sets to spawn paragraphs in a collapsed state.
Not sure exactly how: ideally, paragraphs spawn collapsed; but if that's not possible, we might have to collapse paragraphs after they've spawned.
Remaining tasks
Write a patchUpdate the issue summary UI changes, API changes, data model changes.- Review and feedback
- RTBC and feedback
- Commit
- Release
User interface changes
- Add a "Default state for new paragraphs" select list to the ParagraphsSetForm, i.e.: at
/admin/structure/paragraphs_set/add
and/admin/structure/paragraphs_set/{paragraphs_set}
API changes
- Added a public
\Drupal\paragraphs_sets\Entity\ParagraphsSet::$new_paragraph_mode
field - Added a public
\Drupal\paragraphs_sets\ParagraphsSetInterface::getNewParagraphMode()
function - Added a
\Drupal\paragraphs_sets\ParagraphsSetInterface::PARAGRAPH_MODE_CLOSED
constant - Added a
\Drupal\paragraphs_sets\ParagraphsSetInterface::PARAGRAPH_MODE_OPEN
constant
Data model changes
- Added a
new_paragraph_mode
field to theparagraphs_sets.set.*
configuration schema; i.e.: to the set ofconfig_export
data for theparagraphs_set
configuration entity.
Comment | File | Size | Author |
---|---|---|---|
#3 | 3200477-2--spawn-paragraphs-in-closed-state.patch | 26.96 KB | mparker17 |
Issue fork paragraphs_sets-3200477
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
Comment #3
mparker17Merge request !4 contains my work thus far. Feedback welcome!
Note that reviewing/merging this is not urgent, as I can use the patch for now.
Comment #4
mparker17(fixing typo in issue summary)
Comment #5
stBorchertWouldn't it be much better to use the existing "Edit mode" to control the initial state of the paragraphs within a new set? Adding another option would make the settings form unnecessary complex (it is already IMHO, but that's another case :) ).
Apart from that it's a nice addition to the module.
Comment #7
stBorchertI got this working with simply adding one line and change another :)
@mparker17 would be great if you could have a look and test this.
Comment #8
mparker17Hey @stBorchert, sorry for the delay in answering. What is currently on
8.x-2.x
works great! Thank you very much! :)