Uploaded image for project: 'Magnolia UI'
  1. Magnolia UI
  2. MGNLUI-6787

Select all option for checkBoxGroupField

    XMLWordPrintable

Details

    • Improvement
    • Resolution: Workaround exists
    • Neutral
    • None
    • 6.2.10
    • None
    • None

    Description

      It would be useful to have a select all by default option for checkBoxGroupField

      The following custom factory class is an example that will create the field with all checked by default.

       public class CustomCheckBoxGroupFieldFactory<T> extends CheckBoxGroupFieldFactory<T>{	
      	public CustomCheckBoxGroupFieldFactory(CheckBoxGroupFieldDefinition<T> definition, ComponentProvider componentProvider, SelectFieldSupport<Set<T>> selectFieldSupport) {
      		super(definition, componentProvider, selectFieldSupport);
      	}	
      	@Override
          public CheckBoxGroup<T> createField() {
      		CheckBoxGroup<T> group = (CheckBoxGroup<T>) super.createField();
      		Stream<T> stream = group.getDataProvider().fetch(new Query());
      		Set<T> set = stream.collect(Collectors.toSet());
      		group.updateSelection(set, group.getEmptyValue());
      		return group;
      	}
      }
      

      To implement it, this logic should be added to info.magnolia.ui.field.factory.CheckBoxGroupFieldFactory as well as a new property in the definition class that let users enable/disable this behaviour (a boolean allCheckedByDefault)

      Checklists

        Acceptance criteria

        Attachments

          Activity

            People

              dmaslanka Dominik Maslanka
              jayala Jonathan Ayala
              Nucleus
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Checklists

                  Task DoD