Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

<osf-generic-filter
[filterOperator]="filter.operator"
[placeholder]="FILTER_PLACEHOLDERS[filter.key] || '' | translate"
[placeholder]="getPlaceholderKey(filter) | translate: { label: filter.label }"
[options]="filter.options || []"
[selectedOptions]="selectedOptions()[filter.key] || []"
[searchResults]="filterSearchResults()[filter.key] || []"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,4 +283,18 @@ describe('SearchFiltersComponent', () => {

expect(component.selectedOptionValues()).toEqual({});
});

it('should return specific placeholder key for known filter keys', () => {
fixture.detectChanges();

const filter = { key: 'subject', label: 'Subject' } as DiscoverableFilter;
expect(component.getPlaceholderKey(filter)).toBe('common.search.filterPlaceholders.subject');
});

it('should return generic placeholder key for CEDAR-derived filters not in FILTER_PLACEHOLDERS', () => {
fixture.detectChanges();

const cedarFilter = { key: 'Collected Type Choices', label: 'Collected Type Choices' } as DiscoverableFilter;
expect(component.getPlaceholderKey(cedarFilter)).toBe('common.search.filterPlaceholders.generic');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ export class SearchFiltersComponent {
this.filterOptionSelected.emit({ filter, filterOption: isChecked ? [option] : [] });
}

getPlaceholderKey(filter: DiscoverableFilter): string {
return FILTER_PLACEHOLDERS[filter.key] ?? 'common.search.filterPlaceholders.generic';
}

private scrollPanelIntoView(key: string) {
of(key)
.pipe(delay(this.SCROLL_DELAY_MS), takeUntilDestroyed(this.destroyRef))
Expand Down
3 changes: 2 additions & 1 deletion src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@
"isPartOfCollection": "Select collection",
"dateCreated": "Select date",
"creator": "Creator name",
"resourceType": "Select resource type"
"resourceType": "Select resource type",
"generic": "Select {{label}}"
}
},
"sort": {
Expand Down
Loading