Skip to content

Commit 0baaaba

Browse files
authored
Merge pull request #1013 from Vlad0n20/fix/ENG-11346
fix(ENG-11346): show placeholder in cedar-derived filter dropdowns
2 parents bfd5bc9 + f0167e6 commit 0baaaba

4 files changed

Lines changed: 21 additions & 2 deletions

File tree

src/app/shared/components/search-filters/search-filters.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
<osf-generic-filter
2626
[filterOperator]="filter.operator"
27-
[placeholder]="FILTER_PLACEHOLDERS[filter.key] || '' | translate"
27+
[placeholder]="getPlaceholderKey(filter) | translate: { label: filter.label }"
2828
[options]="filter.options || []"
2929
[selectedOptions]="selectedOptions()[filter.key] || []"
3030
[searchResults]="filterSearchResults()[filter.key] || []"

src/app/shared/components/search-filters/search-filters.component.spec.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,4 +283,18 @@ describe('SearchFiltersComponent', () => {
283283

284284
expect(component.selectedOptionValues()).toEqual({});
285285
});
286+
287+
it('should return specific placeholder key for known filter keys', () => {
288+
fixture.detectChanges();
289+
290+
const filter = { key: 'subject', label: 'Subject' } as DiscoverableFilter;
291+
expect(component.getPlaceholderKey(filter)).toBe('common.search.filterPlaceholders.subject');
292+
});
293+
294+
it('should return generic placeholder key for CEDAR-derived filters not in FILTER_PLACEHOLDERS', () => {
295+
fixture.detectChanges();
296+
297+
const cedarFilter = { key: 'Collected Type Choices', label: 'Collected Type Choices' } as DiscoverableFilter;
298+
expect(component.getPlaceholderKey(cedarFilter)).toBe('common.search.filterPlaceholders.generic');
299+
});
286300
});

src/app/shared/components/search-filters/search-filters.component.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ export class SearchFiltersComponent {
128128
this.filterOptionSelected.emit({ filter, filterOption: isChecked ? [option] : [] });
129129
}
130130

131+
getPlaceholderKey(filter: DiscoverableFilter): string {
132+
return FILTER_PLACEHOLDERS[filter.key] ?? 'common.search.filterPlaceholders.generic';
133+
}
134+
131135
private scrollPanelIntoView(key: string) {
132136
of(key)
133137
.pipe(delay(this.SCROLL_DELAY_MS), takeUntilDestroyed(this.destroyRef))

src/assets/i18n/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@
105105
"isPartOfCollection": "Select collection",
106106
"dateCreated": "Select date",
107107
"creator": "Creator name",
108-
"resourceType": "Select resource type"
108+
"resourceType": "Select resource type",
109+
"generic": "Select {{label}}"
109110
}
110111
},
111112
"sort": {

0 commit comments

Comments
 (0)