Skip to content

Commit

Permalink
Added context phrase to institutions filter modal on search pages
Browse files Browse the repository at this point in the history
  • Loading branch information
bodintsov committed Feb 21, 2025
1 parent 7005478 commit e2ce23f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
3 changes: 3 additions & 0 deletions app/models/related-property-path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ interface PropertyPath {
resourceType: Array<{ '@id': string }>;
displayLabel: LanguageText[];
shortFormLabel: LanguageText[];
description?: LanguageText[];
link_text?: LanguageText[];
link?: LanguageText[];
}

export enum SuggestedFilterOperators {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ export default class FilterFacet extends Component<FilterFacetArgs> {
@tracked filterString = '';
@tracked hasMoreValueOptions = false;
@tracked nextPageCursor = '';
@tracked hasDescription = false;
@tracked description = '';
@tracked link_text = '';
@tracked link = '';

get shouldShowTopValues() {
const { args: { property: { propertyPathKey } } } = this;
Expand All @@ -56,6 +60,13 @@ export default class FilterFacet extends Component<FilterFacetArgs> {
@action
toggleFacet() {
if (this.shouldShowTopValues) {
const propertyPath = this.args.property.propertyPath || [];
this.hasDescription = propertyPath.length > 0 &&
Array.isArray(propertyPath[0]?.description) &&
propertyPath[0].description.length > 0;
this.description = propertyPath[0]?.description?.[0]?.['@value'] || '';
this.link_text = propertyPath[0]?.link_text?.[0]?.['@value'] || '';
this.link = propertyPath[0]?.link?.[0]?.['@value'] || '';
if (this.filterableValues.length === 0 && !taskFor(this.fetchFacetValues).lastComplete) {
taskFor(this.fetchFacetValues).perform();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@
</Button>
</li>
{{/if}}
{{#if (and this.hasDescription (not this.collapsed))}}
<Button
data-analytics-name='See more filterable values {{@property.displayLabel}}'
data-test-see-more-filterable-values={{@property.displayLabel}}
@layout='fake-link'
{{on 'click' this.openSeeMoreModal}}
>
{{t 'search.filter-facet.see-more'}}
</Button>
{{/if}}
</ul>
{{/if}}
<OsfDialog
Expand All @@ -76,7 +86,11 @@
{{@property.displayLabel}}
</dialog.heading>
<dialog.main local-class='see-more-dialog'>
{{t 'search.filter-facet.see-more-modal-text'}}
{{#if (and this.hasDescription)}}
{{ this.description }} <a href={{this.link}}> {{ this.link_text }} </a>
{{else }}
{{t 'search.filter-facet.see-more-modal-text'}}
{{/if}}
<PowerSelect
data-test-property-value-select
@options={{this.modalValueOptions}}
Expand Down

0 comments on commit e2ce23f

Please sign in to comment.