-
Notifications
You must be signed in to change notification settings - Fork 0
Labels
enhancementNew feature or requestNew feature or request
Description
Summary
Add support for alternate term names (alternateName) for faceted search terms in the UI filtering system.
Background
Currently, facet terms are represented by the Term interface:
export interface Term {
count: number;
name: string;
selected: boolean;
}There is a need to support alternate display names for facet terms. Example scenarios include synonyms, UI localization, or projects with more user-friendly phrasing.
Requirements
- Model: Add an
alternateName?: stringproperty to theTerminterface. - Population:
- The alternate term names map shall be loaded by the app from a file at
/fe-api/alternateTermNames.jsonin the/publicfolder, if it exists in the app (not in this repo). - This file is optional and may be absent or empty in some apps. The system must be robust to the file not existing, being empty, or not containing certain facets/terms.
- The alternate term names map should be loaded once on app load (not per facet) and cached in memory for the duration of the session.
- Loading and storage must be handled by a high-level provider, such as
AppStateProvideror a similar top-level provider, and injected/provided throughout the app.
- The alternate term names map shall be loaded by the app from a file at
- Integration:
- When creating
Termobjects (inbindFacetTermsinsrc/hooks/useFileManifest/common/utils.ts), look up thealternateName(if available) by facet and term name from the in-memory alternate term name map. - If not found or file is missing, default to normal
name.
- When creating
- Display:
- Update the facet display code so that wherever term labels are rendered for facets, use
term.alternateName ?? term.name. - Do not update data row/table mappers for results display—only the facet selection UI should use
alternateName.
- Update the facet display code so that wherever term labels are rendered for facets, use
Example implementation summary and changes
1. Term Interface
export interface Term {
count: number;
name: string;
selected: boolean;
alternateName?: string;
}2. Loading alternate term names (sample pattern)
// In AppStateProvider or similar top-level provider
const [alternateTermNames, setAlternateTermNames] = useState<Record<string, Record<string, string>> | null>(null);
useEffect(() => {
fetch('/fe-api/alternateTermNames.json')
.then(response => response.ok ? response.json() : {})
.then(data => setAlternateTermNames(data))
.catch(() => setAlternateTermNames({})); // fallback: empty map
}, []);Then inject this map/context to wherever bindFacetTerms or its caller needs to reference alternate names.
3. Completing bindFacetTerms
accum.push({
count: responseTerm.count,
name,
selected,
alternateName: getAlternateName(facetName, name) // look up from injected/loaded alternate names map
});getAlternateName should check the in-memory map for [facetName][name] and return undefined if missing.
4. Facet Display
Wherever facet terms are rendered, use:
{term.alternateName ?? term.name}Notes
- The alternate term names file is NOT managed in this repo; it is app-specific and may be unavailable.
- All network/file loading for alternate names must be done once, on app load, without retries or repeated requests.
- The system must operate without errors, warnings, or visible problems if the alternate names file is missing or incomplete.
- Do not change result row/record mappers or result/table display—facet selection UI only.
- Apps with custom result row/record displays should open their own tickets as needed.
- Provide a robust fallback to always display
term.nameifalternateNameis missing.
Acceptance criteria
- Alternate term names are loaded from the optional
public/fe-api/alternateTermNames.jsonfile by the app, once, and stored in memory. - Facet terms can display alternate names in the filter UI.
- If the alternateName file or value is not found, fallback to the original name.
- No errors, warnings, or unnecessary fetches/retries if the file is missing.
- All requirements are validated via code review, UI verification, and tests.
- Includes tests for:
- Fallback behavior if no file or key is present.
- Proper use of alternateName in the facet UI when present.
Copilot
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request