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

  1. Write a patch
  2. Update the issue summary UI changes, API changes, data model changes.
  3. Review and feedback
  4. RTBC and feedback
  5. Commit
  6. Release

User interface changes

  1. 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

  1. Added a public \Drupal\paragraphs_sets\Entity\ParagraphsSet::$new_paragraph_mode field
  2. Added a public \Drupal\paragraphs_sets\ParagraphsSetInterface::getNewParagraphMode() function
  3. Added a \Drupal\paragraphs_sets\ParagraphsSetInterface::PARAGRAPH_MODE_CLOSED constant
  4. Added a \Drupal\paragraphs_sets\ParagraphsSetInterface::PARAGRAPH_MODE_OPEN constant

Data model changes

  1. Added a new_paragraph_mode field to the paragraphs_sets.set.* configuration schema; i.e.: to the set of config_export data for the paragraphs_set configuration entity.
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:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mparker17 created an issue. See original summary.

mparker17’s picture

Issue summary: View changes
Status: Active » Needs review
FileSize
26.96 KB

Merge 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.

mparker17’s picture

Issue summary: View changes

(fixing typo in issue summary)

stBorchert’s picture

Wouldn'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.

  • 3728691 committed on 8.x-2.x
    Issue #3200477 by mparker17, stBorchert: Spawn paragraphs in collapsed...
stBorchert’s picture

I got this working with simply adding one line and change another :)
@mparker17 would be great if you could have a look and test this.

mparker17’s picture

Status: Needs review » Fixed

Hey @stBorchert, sorry for the delay in answering. What is currently on 8.x-2.x works great! Thank you very much! :)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.