Skip to content

feat(field): add grouping support for data page sourced options in autocomplete - #578

Merged
tumms2021389 merged 5 commits into
masterfrom
mod/decouplers/ENHANCEMENT-14802
Sep 22, 2026
Merged

tumms2021389 merged 5 commits into
masterfrom
mod/decouplers/ENHANCEMENT-14802

Conversation

@samhere06

@samhere06 samhere06 commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

ENHANCEMENT-14802: Autocomplete supports grouping

Adds optional grouping to AutoCompleteComponent for datapage-sourced options, driven by pConn$.getRawMetadata().config.groupsFields metadata. Groups are sorted case-sensitively and rendered via Angular Material's native mat-optgroup, reusing its built-in non-selectable headers and keyboard-navigation skipping. Behavior, props, and DOM output remain byte-for-byte unchanged when no group-by field is configured or for associated/local-list sourced options.

// Present only when at least one secondary column resolves to a non-empty value (research.md §4a/§4b)
secondaryComponents?: any[];
secondarySearchText?: string;
// Present only when a group-by field is configured for this (datapage-sourced) field (data-model.md)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete speckit reference (data-model.md)

group?: string;
}

// Internal, render-time-only view-model — never part of the PConnect contract (data-model.md)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete speckit reference (data-model.md)

columns: any[] = [];
parameters: {};
filteredOptions: Observable<AutoCompleteOption[]>;
// Grouped view of filteredOptions, only rendered when hasGroupBy is true (research.md §4)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete speckit reference (research.md §4)

this.fieldControl.setValue(this.value$);
}

// Matches only primary text and secondary search text — group value is never used for search (FR-007)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete speckit reference (FR-007)

return this.options$?.filter(option => option.value?.toLowerCase().includes(filterVal) || option.secondarySearchText?.includes(filterVal));
}

// Buckets the already-sorted option list into contiguous groups by exact group value (research.md §7)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete speckit reference (research.md §7)

}

// Secondary text is out of scope for associated/local list options (FR-012)
// Secondary text and grouping are both out of scope for associated/local list options (FR-012/FR-013)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete speckit reference (FR-012/FR-013)

// Read from raw metadata, not resolved config, because config.value must stay an unresolved
// property reference (e.g. "@P .propName") for use as a column value (research.md §1).
// Reads unresolved groupsFields metadata to derive group-by column descriptor(s); not a
// display/search column, so grouping stays independent of primary/secondary text (FR-001/FR-007)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete speckit reference (FR-001/FR-007)

this.setOptions(optionsData);
}

// Null/undefined/whitespace-only source values normalize to '' — the shared blank group (FR-011)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete speckit reference (FR-011)

return stringValue.trim() ? stringValue : '';
}

// Ascending, case-sensitive, stable sort so same-group options keep their original relative order (FR-005/FR-012)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete speckit reference (FR-005/FR-012)

@tumms2021389
tumms2021389 merged commit a9ba8e7 into master Sep 22, 2026
6 checks passed
@tumms2021389
tumms2021389 deleted the mod/decouplers/ENHANCEMENT-14802 branch September 22, 2026 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants