diff --git a/src/app/shared/search/advanced-search/advanced-search.component.spec.ts b/src/app/shared/search/advanced-search/advanced-search.component.spec.ts index 6289b0e5346..ea3394c4aeb 100644 --- a/src/app/shared/search/advanced-search/advanced-search.component.spec.ts +++ b/src/app/shared/search/advanced-search/advanced-search.component.spec.ts @@ -5,6 +5,8 @@ import { import { Router } from '@angular/router'; import { TranslateModule } from '@ngx-translate/core'; +import { APP_CONFIG } from '../../../../config/app-config.interface'; +import { environment } from '../../../../environments/environment.test'; import { SearchService } from '../../../core/shared/search/search.service'; import { SearchConfigurationService } from '../../../core/shared/search/search-configuration.service'; import { SearchFilterService } from '../../../core/shared/search/search-filter.service'; @@ -39,6 +41,7 @@ describe('AdvancedSearchComponent', () => { { provide: SearchService, useValue: searchService }, { provide: SearchConfigurationService, useValue: searchConfigurationService }, { provide: SearchFilterService, useValue: searchFilterService }, + { provide: APP_CONFIG, useValue: environment }, ], }).compileComponents(); diff --git a/src/app/shared/search/advanced-search/advanced-search.component.ts b/src/app/shared/search/advanced-search/advanced-search.component.ts index 22488e40462..92e43983c0e 100644 --- a/src/app/shared/search/advanced-search/advanced-search.component.ts +++ b/src/app/shared/search/advanced-search/advanced-search.component.ts @@ -5,6 +5,7 @@ import { } from '@angular/common'; import { Component, + Inject, Input, OnDestroy, OnInit, @@ -23,6 +24,10 @@ import { } from 'rxjs'; import { take } from 'rxjs/operators'; +import { + APP_CONFIG, + AppConfig, +} from '../../../../config/app-config.interface'; import { SearchService } from '../../../core/shared/search/search.service'; import { SearchConfigurationService } from '../../../core/shared/search/search-configuration.service'; import { SearchFilterService } from '../../../core/shared/search/search-filter.service'; @@ -84,12 +89,17 @@ export class AdvancedSearchComponent implements OnInit, OnDestroy { protected searchService: SearchService, protected searchConfigurationService: SearchConfigurationService, protected searchFilterService: SearchFilterService, + @Inject(APP_CONFIG) protected appConfig: AppConfig, ) { } ngOnInit(): void { this.advancedFilters$ = this.searchConfigurationService.getConfigurationSearchConfig(this.configuration).pipe( - map((searchConfiguration: SearchConfig) => searchConfiguration.filters.filter((filter: FilterConfig) => filter.type !== FilterType.range)), + map((searchConfiguration: SearchConfig) => { + return searchConfiguration.filters + .filter((filter: FilterConfig) => this.appConfig.search.advancedFilters.filter.includes(filter.filter)) + .filter((filter: FilterConfig) => filter.type !== FilterType.range); + }), ); this.subs.push(this.advancedFilters$.subscribe((filters: FilterConfig[]) => { const filterMap: Map = new Map(); diff --git a/src/app/shared/search/search-filters/search-filters.component.spec.ts b/src/app/shared/search/search-filters/search-filters.component.spec.ts index e81da7a8654..0277551eea1 100644 --- a/src/app/shared/search/search-filters/search-filters.component.spec.ts +++ b/src/app/shared/search/search-filters/search-filters.component.spec.ts @@ -1,6 +1,6 @@ import { ChangeDetectionStrategy, - NO_ERRORS_SCHEMA, + CUSTOM_ELEMENTS_SCHEMA, } from '@angular/core'; import { ComponentFixture, @@ -8,48 +8,41 @@ import { waitForAsync, } from '@angular/core/testing'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; -import { RouterTestingModule } from '@angular/router/testing'; +import { RouterModule } from '@angular/router'; import { TranslateModule } from '@ngx-translate/core'; -import { APP_CONFIG } from 'src/config/app-config.interface'; -import { environment } from 'src/environments/environment'; import { SearchService } from '../../../core/shared/search/search.service'; import { SearchFilterService } from '../../../core/shared/search/search-filter.service'; import { SEARCH_CONFIG_SERVICE } from '../../../my-dspace-page/my-dspace-configuration.service'; import { SearchConfigurationServiceStub } from '../../testing/search-configuration-service.stub'; +import { SearchFilterServiceStub } from '../../testing/search-filter-service.stub'; +import { SearchServiceStub } from '../../testing/search-service.stub'; import { SearchFiltersComponent } from './search-filters.component'; describe('SearchFiltersComponent', () => { let comp: SearchFiltersComponent; let fixture: ComponentFixture; - let searchService: SearchService; - const searchServiceStub = { - /* eslint-disable no-empty,@typescript-eslint/no-empty-function */ - getClearFiltersQueryParams: () => { - }, - getSearchLink: () => { - }, - getConfigurationSearchConfig: () => { }, - /* eslint-enable no-empty, @typescript-eslint/no-empty-function */ - }; - - const searchFiltersStub = { - getSelectedValuesForFilter: (filter) => - [], - }; + let searchService: SearchServiceStub; + let searchFilters: SearchFilterServiceStub; beforeEach(waitForAsync(() => { + searchService = new SearchServiceStub(); + searchFilters = new SearchFilterServiceStub(); + TestBed.configureTestingModule({ - imports: [TranslateModule.forRoot(), RouterTestingModule.withRoutes([]), NoopAnimationsModule, SearchFiltersComponent], + imports: [ + TranslateModule.forRoot(), + RouterModule.forRoot([]), + NoopAnimationsModule, + SearchFiltersComponent, + ], providers: [ - { provide: SearchService, useValue: searchServiceStub }, + { provide: SearchService, useValue: searchService }, { provide: SEARCH_CONFIG_SERVICE, useValue: new SearchConfigurationServiceStub() }, - { provide: SearchFilterService, useValue: searchFiltersStub }, - { provide: APP_CONFIG, useValue: environment }, - + { provide: SearchFilterService, useValue: searchFilters }, ], - schemas: [NO_ERRORS_SCHEMA], + schemas: [CUSTOM_ELEMENTS_SCHEMA], }).overrideComponent(SearchFiltersComponent, { set: { changeDetection: ChangeDetectionStrategy.Default }, }).compileComponents(); @@ -59,13 +52,12 @@ describe('SearchFiltersComponent', () => { fixture = TestBed.createComponent(SearchFiltersComponent); comp = fixture.componentInstance; // SearchFiltersComponent test instance fixture.detectChanges(); - searchService = (comp as any).searchService; }); describe('when the getSearchLink method is called', () => { beforeEach(() => { spyOn(searchService, 'getSearchLink'); - (comp as any).getSearchLink(); + comp.getSearchLink(); }); it('should call getSearchLink on the searchService', () => { diff --git a/src/app/shared/search/search-filters/search-filters.component.ts b/src/app/shared/search/search-filters/search-filters.component.ts index bbd02979213..f8d3f574237 100644 --- a/src/app/shared/search/search-filters/search-filters.component.ts +++ b/src/app/shared/search/search-filters/search-filters.component.ts @@ -19,10 +19,6 @@ import { Observable, } from 'rxjs'; import { map } from 'rxjs/operators'; -import { - APP_CONFIG, - AppConfig, -} from 'src/config/app-config.interface'; import { RemoteData } from '../../../core/data/remote-data'; import { SearchService } from '../../../core/shared/search/search.service'; @@ -32,7 +28,6 @@ import { SEARCH_CONFIG_SERVICE } from '../../../my-dspace-page/my-dspace-configu import { currentPath } from '../../utils/route.utils'; import { AdvancedSearchComponent } from '../advanced-search/advanced-search.component'; import { AppliedFilter } from '../models/applied-filter.model'; -import { PaginatedSearchOptions } from '../models/paginated-search-options.model'; import { SearchFilterConfig } from '../models/search-filter-config.model'; import { SearchFilterComponent } from './search-filter/search-filter.component'; @@ -52,7 +47,7 @@ export class SearchFiltersComponent implements OnInit { * An observable containing configuration about which filters are shown and how they are shown */ @Input() filters: Observable>; - @Input() searchOptions: PaginatedSearchOptions; + /** * List of all filters that are currently active with their value set to null. * Used to reset all filters at once @@ -90,7 +85,6 @@ export class SearchFiltersComponent implements OnInit { filterLabel = 'search'; constructor( - @Inject(APP_CONFIG) protected appConfig: AppConfig, protected searchService: SearchService, protected searchFilterService: SearchFilterService, protected router: Router, diff --git a/src/app/shared/search/search-labels/search-label/search-label.component.html b/src/app/shared/search/search-labels/search-label/search-label.component.html index 24e8b0dc15b..58308d49280 100644 --- a/src/app/shared/search/search-labels/search-label/search-label.component.html +++ b/src/app/shared/search/search-labels/search-label/search-label.component.html @@ -4,7 +4,7 @@ [queryParams]="(removeParameters$ | async)" (click)="searchFilterService.minimizeAll()"> - {{ ('search.filters.applied.f.' + appliedFilter.filter) | translate}}: {{'search.filters.' + appliedFilter.filter + '.' + appliedFilter.label | translate: { default: appliedFilter.label } }} + {{ ('search.filters.applied.f.' + appliedFilter.filter) | translate}}{{'search.filters.applied.operator.' + appliedFilter.operator | translate}}: {{'search.filters.' + appliedFilter.filter + '.' + appliedFilter.label | translate: { default: appliedFilter.label } }} diff --git a/src/app/shared/search/search-sidebar/search-sidebar.component.html b/src/app/shared/search/search-sidebar/search-sidebar.component.html index ecd9dd9492a..b2ba43869de 100644 --- a/src/app/shared/search/search-sidebar/search-sidebar.component.html +++ b/src/app/shared/search/search-sidebar/search-sidebar.component.html @@ -24,7 +24,8 @@ [refreshFilters]="refreshFilters" [inPlaceSearch]="inPlaceSearch"> - { NgbCollapseModule, SearchSidebarComponent, ], + providers: [ + { provide: APP_CONFIG, useValue: environment }, + ], schemas: [CUSTOM_ELEMENTS_SCHEMA], }) .overrideComponent(SearchSidebarComponent, { diff --git a/src/app/shared/search/search-sidebar/search-sidebar.component.ts b/src/app/shared/search/search-sidebar/search-sidebar.component.ts index ef45e581ca1..b9166e54ad7 100644 --- a/src/app/shared/search/search-sidebar/search-sidebar.component.ts +++ b/src/app/shared/search/search-sidebar/search-sidebar.component.ts @@ -5,6 +5,7 @@ import { import { Component, EventEmitter, + Inject, Input, Output, } from '@angular/core'; @@ -14,6 +15,10 @@ import { Observable, } from 'rxjs'; +import { + APP_CONFIG, + AppConfig, +} from '../../../../config/app-config.interface'; import { SortOptions } from '../../../core/cache/models/sort-options.model'; import { RemoteData } from '../../../core/data/remote-data'; import { ViewMode } from '../../../core/shared/view-mode.model'; @@ -120,4 +125,9 @@ export class SearchSidebarComponent { */ @Output() changeViewMode: EventEmitter = new EventEmitter(); + constructor( + @Inject(APP_CONFIG) protected appConfig: AppConfig, + ) { + } + } diff --git a/src/assets/i18n/en.json5 b/src/assets/i18n/en.json5 index e19e20d2d84..8e2f90f39e7 100644 --- a/src/assets/i18n/en.json5 +++ b/src/assets/i18n/en.json5 @@ -6058,24 +6058,6 @@ "admin.notifications.publicationclaim.page.title": "Publication Claim", - "filter.search.operator.placeholder": "Operator", - - "search.filters.filter.entityType.text": "Item Type", - - "search.filters.operator.equals.text": "Equals", - - "search.filters.operator.notequals.text": "Not Equals", - - "search.filters.operator.notcontains.text": "Not Contains", - - "search.filters.operator.contains.text": "Contains", - - "search.filters.filter.title.text": "Title", - - "search.filters.applied.f.title": "Title", - - "search.filters.filter.author.text": "Author", - "coar-notify-support.title": "COAR Notify Protocol", "coar-notify-support-title.content": "Here, we fully support the COAR Notify protocol, which is designed to enhance the communication between repositories. To learn more about the COAR Notify protocol, visit the COAR Notify website.", @@ -6370,14 +6352,6 @@ "type-equals-journal-article_condition.label": "Type equals Journal Article", - "search.filters.filter.subject.text": "Subject", - - "search.advanced.filters.head": "Advanced Search", - - "filter.search.text.placeholder": "Search text", - - "advancesearch.form.submit": "Add", - "ldn.no-filter.label": "None", "admin.notify.dashboard": "Dashboard",