az-digital / az_quickstart

UArizona's web content management system built with Drupal 10.
https://quickstart.arizona.edu
GNU General Public License v2.0
30 stars 20 forks source link

Make card and accordion fields configurable in UI #2709

Open joshuasosa opened 1 year ago

joshuasosa commented 1 year ago

Motivation

Sometimes a site builder needs to adjust existing fields or add new field options to cards and accordions. It used to be possible to do that with the UI in UAQS, but it is not currently possible to do that with the UI in AZQS.

Is your feature request related to a problem? Please describe.

There are sometimes cases where I need to change or add fields to cards, but I cannot do that easily. Changes needed require rewriting code.

Proposed Resolution

Describe the solution you'd like

In UAQS, cards and panels were configured as field collections. A regular migration would take field collections and convert them into paragraph types. Cards and accordions could potentially be re-created as paragraph types.

Additional context

UAQS card decks refer to the card field collection

image

UAQS field collections

image

Card fields are fully configurable in UAQS UI

image

AZQS cards refer to a card type

image

AZQS card types cannot be configured in UI

Changes to anything in Default value don't save, such as changing the default card background color or default text format for card body. It's also not possible to add new fields. image

trackleft commented 1 year ago

Do you think this could be done with layout paragraphs? https://www.drupal.org/project/layout_paragraphs

joshuasosa commented 1 year ago

Do you think this could be done with layout paragraphs? https://www.drupal.org/project/layout_paragraphs

I think Layout Paragraphs does a more general paradigm change to the way pages are set up in general. A paragraph type can be created with layout pagaraphs behavior enabled that specifies various layouts as options. From there, the Page content type would need to be changed: form display and display changed to use Layout Paragraphs instead of Paragraphs. image

It's definitely an interesting module that could improve the service offering of AZQS to enable side-by-side paragraphs and other layouts, but I don't think it's entirely related to this issue. The Cards paragraph type could be changed to put the fields in there or removed to create a Card paragraph type with the fields. Layout Paragraphs could be used to specify layout options for placing individual cards in columns. But it's a significant change to the Page editing experience that would be good to explore in a higher-level issue/PR.

See examples: Build Highly Visual Long Form Content With Layout Paragraphs: DrupalCon Portland 2022 Layout Paragraphs - DrupalSouth

For this issue, I think this solution would work:

  1. Create new paragraph types for Card (or Card item) and Accordion item.
  2. Add all the fields needed for both types.
  3. In the existing Cards (az_cards) and Accordion (az_accordion) paragraph types, remove the existing fields with Card and Accordion field types, respectively.
  4. In each, add a new field to Reference revisions > Paragraph and select the respective 'item' paragraph type.
  5. Adjust form display as needed (e.g., closed mode 'Preview', add mode 'Buttons').