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.
Problem/Motivation
As pointed in #2836010: Paragraphs Diff behavior plugin support when diffing the label provided by the plugin might show the machine name of the field, bad UX. Thus, we could use settings summary to provide information for the diff changes.
Proposed resolution
Use settings summary with plugins so they can provide a better label for each field.
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#20 | add_settings_summary_to-2841309-20.patch | 4.31 KB | Ginovski |
#20 | interdiff-2841309-14-20.txt | 602 bytes | Ginovski |
#14 | add_settings_summary_to-2841309-14.patch | 4.31 KB | Ginovski |
#14 | interdiff-2841309-11-14.txt | 798 bytes | Ginovski |
#11 | add_settings_summary_to-2841309-11.patch | 3.53 KB | Ginovski |
Comments
Comment #2
Ginovski CreditAttribution: Ginovski at MD Systems GmbH commentedDiscussed with @Berdir, it is better to implement a settingsSummary() in the interface, config schema won't be enough.
Adding patch with settingsSummary implemented and tested with the test plugins.
Comment #3
Ginovski CreditAttribution: Ginovski at MD Systems GmbH commentedComment #4
Ginovski CreditAttribution: Ginovski at MD Systems GmbH commentedComment #5
Berdirkey doesn't matter, that is not displayed. But the summary should be properly translated string, e.g. $bold_setting ? $this->t('Bold: Yes') : $this->t('Bold: No').
And here it would be $this->t('Text color: @color', ['@color' => $text_color])
Comment #6
Berdirkey doesn't matter, that is not displayed. But the summary should be properly translated string, e.g. $bold_setting ? $this->t('Bold: Yes') : $this->t('Bold: No').
And here it would be $this->t('Text color: @color', ['@color' => $text_color])
Comment #7
Ginovski CreditAttribution: Ginovski at MD Systems GmbH commentedDid the changes from #6 comment.
Comment #8
johnchqueYour branch is behind one commit.
Comment #9
Ginovski CreditAttribution: Ginovski at MD Systems GmbH commentedUpdated with last commit
Comment #10
Berdirstring[]
We don't return settings, we return a summary that describes the settings.
I'd just write this as return [$bold_setting ? $this->t('Bold: Yes') : $this->t('Bold: No')];
no need for a variable or array keys.
Comment #11
Ginovski CreditAttribution: Ginovski at MD Systems GmbH commented1. Changed array -> string[]
2. Changed return array in the plugins.
3. Fixed test
Comment #12
BerdirLooks good to me now.
Comment #13
BerdirWorth noting that committing this will break paragraphs_collection as there is no default implementation.
Since not all behaviors will have settings, we shouldn't make this required, lets add an empty default implementation that returns an empty array.
Comment #14
Ginovski CreditAttribution: Ginovski at MD Systems GmbH commentedAdded default settingsSummary.
Comment #15
miro_dietikerComment #16
BerdirOk. We're not actually using this yet but the diff issue will be using it.
Comment #17
miro_dietikerI'm missing a formal definition about what a summary should be. For instance:
The summary could skip indicating default values, because they are assumed, thus not worth getting space in the summary.
The summary could define being verbose, the rule would be to always output every relevant / configurable setting with its label and value.
For diff reasons, the second might make more sense.
For display reasons, the first could make more sense.
What happens for more complex settings such as a nested structure? What would be the expected presentation in the string?
Output as in summary completely depends the use cases about how to display.
Some cases also would demand for a more structural approach with a label + value each.
With these questions, i just want to avoid that we commit ourself to an API that we later would want to change.
Comment #18
Berdirfield formatters also don't have much more than that: "* Returns a short summary for the current formatter settings.".
That said, of a paragraph" is of course bogus, I'd use above, simply replace formatter with behavior.
IMHO, the structure is OK, I wouldn't go for a more formal structure, this would also allow to put multiple yes/no options on one line and stuff like that, how detailed we want it to be is something we can still change and is something we need to decide per-plugin anyway.
Comment #19
miro_dietikerOK great, let's get this in and use it for the diff change indication, so we can gain experience with our plugins.
Comment #20
Ginovski CreditAttribution: Ginovski at MD Systems GmbH commentedChanged method docs.
Comment #21
miro_dietikerCommitted. :-)