VACMS-14752: Adds check all (mixed state) field formatter for checkbox widgets.#21046
VACMS-14752: Adds check all (mixed state) field formatter for checkbox widgets.#21046dsasser wants to merge 23 commits into
Conversation
…pdates es5 js to align with current select_all_options.es6.js changes. Updates FieldSelectAllOptions to output select all option markup.
…e handling. Updates naming of things to align to 'mixed_checkbox' namespacing.
…ting messy and we need to be able to wrap the checkboxes in a container for easy targetting in css/js.
…specific to vagovclaro styles.
…-all-option-for-checkbox-widgets
|
Checking composer.lock changes... |
|
Checking composer.lock changes... |
|
Checking composer.lock changes... |
|
Getting this error when editing this node, that is not occurring on my local: Pulling in a fresh db locally to see if I can replicate.
I could not reproduce this locally with the same db as TB. I added a simple bail out conditional in va_gov_backend_field_widget_single_element_paragraphs_form_alter() if the paragraph couldn't be found. That would be an extremely odd situation, since this function is only called during paragraph widget forms are built, but a safeguard doesn't hurt. |
|
Checking composer.lock changes... |
This commit has resolved the problem. |
Description
Relates to #14752
This PR creates a new field formatter (for multi-value boolean fields (checkboxes) that adds a 'select all' option. Created as a field widget to be usable across the system. This implementation detail was chosen in order to avoid bespoke code for a single use case.
Why not an existing Drupal module? See here.
The 'select all' formatter implements a 'checkbox mixed/tri-state' variant that includes checked, unchecked, and mixed states. The mixed state is represented visually and with ARIA attributes for accessibility.
The formatter allows for custom for 'select all' text such that each field can have a contextual value. (see screenshot below for VAMC System Banner Alert with Situation Updates).
The javascript for the formatter was modified from W3.org. License is GPL compatible so we are good to use and modify providing we include the license info, which was added to the new checkbox_mix library per Drupal standards.
Generated description
This pull request includes several changes to enhance the functionality and styling of checkboxes in the
va_gov_backendmodule. The most significant changes involve adding a new "select mixed options" checkbox behavior, updating related JavaScript files, and modifying the backend to support these changes.Enhancements to checkbox functionality:
docroot/modules/custom/va_gov_backend/js/checkbox_mixed.es6.js: Added a new "select mixed options" checkbox behavior to work as Drupal behaviors. This includes event handlers and state management for mixed checkboxes.docroot/modules/custom/va_gov_backend/js/checkbox_mixed.js: Added a compiled version of the new "select mixed options" checkbox behavior for production use.Backend support for new checkbox behavior:
docroot/modules/custom/va_gov_backend/src/Plugin/Field/FieldWidget/CheckboxMixedWidget.php: Implemented a new field widget plugin for checkboxes with "select all" functionality, including default settings, settings form, and form element rendering.Styling updates:
docroot/themes/custom/vagovclaro/assets/scss/components/_checkbox_mixed.scss: Added styles for the new mixed checkbox state, including background color and SVG icon for the mixed state.docroot/themes/custom/vagovclaro/assets/scss/styles.scss: Imported the new checkbox mixed styles into the main styles file.Configuration updates:
config/sync/core.entity_form_display.node.full_width_banner_alert.default.yml: Updated dependencies and third-party settings to include the new checkbox behavior and related modules. [1] [2] [3]docroot/modules/custom/va_gov_backend/va_gov_backend.libraries.yml: Added the newcheckbox_mixedlibrary with its dependencies and license information.Testing done
Tested in a VAMC System Banner Alert with Situation Updates content type manually using both mouse and keyboard functionality (for accessibility).
Verified the GraphQL query results in no structural changes or additional data. [proof tbd]
Screenshots
QA steps
As an admin...
Validate Existing VAMC Banner with Situation Updates Form:
Validate New VAMC Banner with Situation Updates Form:
document.querySelectorAll('.field--name-field-banner-alert-vamcs .field__item').lengthDefinition of Done
Select Team for PR review
CMS TeamPublic websitesFacilitiesUser supportAccelerated Publishing