- 🇬🇧United Kingdom joachim
> Summaries are a javascript only implementation, there is no server roundtrip. Whatever we do, there is no way around each condition that wants to display a summary having to provide a javascript snippet for this.
I don't think that's true. The JS that creates a summary line is completely generic: it just takes the checkbox labels and joins them together:
function checkboxesSummary(context) { const values = []; const $checkboxes = $(context).find( 'input[type="checkbox"]:checked + label', ); const il = $checkboxes.length; for (let i = 0; i < il; i++) { values.push($($checkboxes[i]).html()); } if (!values.length) { values.push(Drupal.t('Not restricted')); } return values.join(', '); }
That would cover most condition plugins in contrib.
The only thing that needs to be changed would be the JS that decides which vertical tabs to apply the above to:
$( '[data-drupal-selector="edit-visibility-node-type"], [data-drupal-selector="edit-visibility-entity-bundlenode"], [data-drupal-selector="edit-visibility-language"], [data-drupal-selector="edit-visibility-user-role"], [data-drupal-selector="edit-visibility-response-status"]', ).drupalSetSummary(checkboxesSummary);
Make it opt-out so more complex conditions that supply their own JS and declare that they're opting out in their plugin definition.
I call this a bug -- Drupal is meant to be extensible, and this isn't.
- leymannx Berlin
I agree and would also vote for bug, given that there's even a place in the condition plugin's code where you provide a dynamic summary to be picked up in this exact vertical tabs place.