Paragraph settings are quite complex and when editing existing paragrahs, you often have to compare which values changed (!= default). Like with field settings or block filters, it would help a lot to point out the changed (non-default) values without having to look at all settings tabs.

Additionally, it might be helpful to also mark each changed field individually, which shouldn't be too hard by for example adding a class.

@thomas.frobieter what do you think about the ideas?

Proposed solution:

- [ ] Mark fields with non default values with a general css class (to be defined by @thomas.frobieter)
- [ ] Display default value below the field, as "-" is not always the default
- [ ] Output summary of changed values at high level, e.g. the fieldset description, if possible. (esp. 1.x)
- [ ] Output summary in preview through twig variables (4.x)

============================

For 4.x:

  1. Determine the modified values (!= default value)
  2. Pass those values to the paragraph.html.twig
  3. Create a drowl_paragraphs.admin_settings_preview library to deliver the required CSS & JS
  4. If possible, link the preview values to the settings form (+ open the right fieldset + tab)
  5. Older Versions (pre-Layout-Paragraphs): Maybe we should print out the modified settings in the paragraph edit form too?

We already have something similar for Container-Paragraphs in the Paragraphs preview (Layout Paragraphs):

So we should standardize this and reuse it for the rest of the values, but we should differ between values which show up directly (like the background-image preview here) and an expandable container holding other modified values.

In case of the background settings, the values are printed out right inside the paragraphs.html.twig (only for the preview view mode used in Layout Paragraphs).

Idea:

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:

Comments

Anybody created an issue. See original summary.

anybody’s picture

@thomas.frobieter: Best would be to output the summary in the collapsed settings fieldset description, not yet sure if that's possible. But definitely on a high level.

For marking the non-default field values, could you please provide a general backend class to indicate that?

I guess we should furthermore output the default value, perhaps simply in the field description?

anybody’s picture

Priority: Normal » Major
Issue summary: View changes

Updated issue summary accordingly.

anybody’s picture

Issue tags: +Needs backport

Should also be backported to 1.x

thomas.frobieter’s picture

@Anybody Yeah, good idea. I think we should collect the modified values in PHP and pass it to the twig template. The result is printed out in the paragraph--drowl-paragraphs-types.html.twig once (inside a Twig block, so type specific overrides could modify this), without blowing this file up with this logic stuff. Rest is CSS+JS.

If we need to show up the values also in the paragraph edit form.. oou.. I'd like to prevent that. If we really need to, we may should create some kind of a reusable component, using its own template file, which is then embeded into the form and the paragraph preview.

thomas.frobieter’s picture

Issue summary: View changes
anybody’s picture

Assigned: thomas.frobieter » Unassigned
Issue summary: View changes

Showing the changes in the field widget is important for 1.x - where we should leave out most of the more complex changes.

anybody’s picture

@thomas.frobieter could you propose a class for "non default value" indication in the field widget? This will be the simplest part and especially helpful in 1.x, but also in 4.x when currently editing. You can then decide how to use it.

thomas.frobieter’s picture

I think form-item--none-default or probably better form-item--value-modified would be fine.

We might should add the default value (key) as data-attribute (data-default-value) too, so we are able to set this class 'live' with JS too.

anybody’s picture

@thomas.frobieter I thought about an intelligent code structure for the "real" default value comparison, but it's always a lot of copy / pasted code due to the array structure.

Perhaps we should really try to add a "#standard_value" and compare it to "#default_value" (which is the actual value) in the loop...

Not yet sure, but don't waste much time, this can also be tricky. And we should check if Drupal complains about the extra FAPI key.

thomas.frobieter’s picture

Another .. thing to consider here, are the configured default values we set in the field settings (eg: /admin/structure/paragraphs_type/container/fields/paragraph.container.field_paragraph_settings).

We might better skip / remove those configured defaults in future relases (4.x) and add all our hardcoded default field values to the drowl_paragraph settings page, see: https://www.drupal.org/project/drowl_paragraphs/issues/3273439.

So we need to get this values also and then ask: IF isset(configured.default_value) => use this ELSE use the default value we have defined right in the code.

thomas.frobieter’s picture

anybody’s picture

Project: DROWL Paragraphs » DROWL Paragraphs for Bootstrap
Version: 4.x-dev » 1.x-dev

Moved over for future implementation.