[MGNLUI-6787] Select all option for checkBoxGroupField Created: 12/Jul/21  Updated: 12/Sep/23  Resolved: 12/Sep/23

Status: Closed
Project: Magnolia UI
Component/s: None
Affects Version/s: 6.2.10
Fix Version/s: None

Type: Improvement Priority: Neutral
Reporter: Jonathan Ayala Assignee: Dominik Maslanka
Resolution: Workaround exists Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
relation
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Date of First Response:
Epic Link: Maintenance of vaadin8 framework
Team: Nucleus

 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)


Generated at Mon Feb 12 09:40:00 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.