Skip to content

Commit

Permalink
feat: add other records
Browse files Browse the repository at this point in the history
  • Loading branch information
f-necas committed Oct 3, 2023
1 parent 609628b commit 9e2e317
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ <h2 class="text-xl mr-4 font-title" translate>
(toggled)="toggleSpatialFilter($event)"
></gn-ui-check-toggle>
</div>
<div class="spatial-filter-toggle sm:col-span-2" *ngIf="true">
<div class="spatial-filter-toggle sm:col-span-2" *ngIf="userId">
<gn-ui-check-toggle
[title]="'search.filters.myRecordsHelp' | translate"
[label]="'search.filters.myRecords' | translate"
Expand All @@ -72,6 +72,21 @@ <h2 class="text-xl mr-4 font-title" translate>
(toggled)="toggleMyRecordsFilter($event)"
></gn-ui-check-toggle>
</div>
<div
class="spatial-filter-toggle sm:col-span-2"
*ngIf="!userId && (myRecordsFilterEnabled() | async)"
>
<gn-ui-button
type="light"
extraClass="text-sm align-middle"
(buttonClick)="toggleMyRecordsFilter(false)"
>
<span>{{ 'search.filters.otherRecords' | translate }}</span>
<mat-icon class="material-symbols-outlined ml-3 opacity-40"
>close</mat-icon
>
</gn-ui-button>
</div>
</div>
<div
class="col-span-2 flex flex-col justify-between"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class SearchFiltersComponent implements OnInit {
filters: QueryList<FilterDropdownComponent>
searchConfig: { fieldName: string; title: string }[]
isOpen = false
private userId: string
userId: string

constructor(
public searchFacade: SearchFacade,
Expand All @@ -38,7 +38,7 @@ export class SearchFiltersComponent implements OnInit {
) {}

ngOnInit(): void {
this.authService.user$.subscribe((user) => (this.userId = user.id))
this.authService.user$.subscribe((user) => (this.userId = user?.id))
this.searchConfig = (
getOptionalSearchConfig().ADVANCED_FILTERS || [
'publisher',
Expand Down Expand Up @@ -130,7 +130,12 @@ export class SearchFiltersComponent implements OnInit {
switchMap((filters) => {
return this.fieldsService.readFieldValuesFromFilters(filters)
}),
map((fieldValues) => !!fieldValues['owner'])
map((fieldValues) => {
if (fieldValues['owner'] && Array.isArray(fieldValues['owner'])) {
return fieldValues['owner'].length > 0
}
return !!fieldValues['owner']
})
)
}

Expand Down
1 change: 1 addition & 0 deletions translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@
"search.filters.minimize": "Minimize",
"search.filters.myRecords": "Show only my records",
"search.filters.myRecordsHelp": "When this is enabled, records only created by myself are shown; records created by others will not show up.",
"search.filters.otherRecords": "Showing records from another person",
"search.filters.title": "Filter your results",
"search.filters.useSpatialFilter": "Show records in the area of interest first",
"search.filters.useSpatialFilterHelp": "When this is enabled, records situated in the catalog's area of interest are shown first; records outside of this area will not show up.",
Expand Down

0 comments on commit 9e2e317

Please sign in to comment.