mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
111731: Used yml config to configure the visibility advanced search component & its filters
This commit is contained in:
@@ -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();
|
||||
|
||||
|
@@ -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<string, FilterConfig> = new Map();
|
||||
|
@@ -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<SearchFiltersComponent>;
|
||||
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(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [TranslateModule.forRoot(), RouterTestingModule.withRoutes([]), NoopAnimationsModule, SearchFiltersComponent],
|
||||
providers: [
|
||||
{ provide: SearchService, useValue: searchServiceStub },
|
||||
{ provide: SEARCH_CONFIG_SERVICE, useValue: new SearchConfigurationServiceStub() },
|
||||
{ provide: SearchFilterService, useValue: searchFiltersStub },
|
||||
{ provide: APP_CONFIG, useValue: environment },
|
||||
searchService = new SearchServiceStub();
|
||||
searchFilters = new SearchFilterServiceStub();
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
TranslateModule.forRoot(),
|
||||
RouterModule.forRoot([]),
|
||||
NoopAnimationsModule,
|
||||
SearchFiltersComponent,
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA],
|
||||
providers: [
|
||||
{ provide: SearchService, useValue: searchService },
|
||||
{ provide: SEARCH_CONFIG_SERVICE, useValue: new SearchConfigurationServiceStub() },
|
||||
{ provide: SearchFilterService, useValue: searchFilters },
|
||||
],
|
||||
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', () => {
|
||||
|
@@ -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<RemoteData<SearchFilterConfig[]>>;
|
||||
@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,
|
||||
|
@@ -4,7 +4,7 @@
|
||||
[queryParams]="(removeParameters$ | async)"
|
||||
(click)="searchFilterService.minimizeAll()">
|
||||
<span class="d-flex">
|
||||
<span class="flex-grow-1 text-left">{{ ('search.filters.applied.f.' + appliedFilter.filter) | translate}}: {{'search.filters.' + appliedFilter.filter + '.' + appliedFilter.label | translate: { default: appliedFilter.label } }}</span>
|
||||
<span class="flex-grow-1 text-left">{{ ('search.filters.applied.f.' + appliedFilter.filter) | translate}}{{'search.filters.applied.operator.' + appliedFilter.operator | translate}}: {{'search.filters.' + appliedFilter.filter + '.' + appliedFilter.label | translate: { default: appliedFilter.label } }}</span>
|
||||
<span class="pl-1" aria-hidden="true">×</span>
|
||||
</span>
|
||||
</a>
|
||||
|
@@ -24,7 +24,8 @@
|
||||
[refreshFilters]="refreshFilters"
|
||||
[inPlaceSearch]="inPlaceSearch">
|
||||
</ds-themed-search-filters>
|
||||
<ds-advanced-search [configuration]="configuration"
|
||||
<ds-advanced-search *ngIf="appConfig.search.advancedFilters.enabled"
|
||||
[configuration]="configuration"
|
||||
[filtersConfig]="(filters | async)?.payload">
|
||||
</ds-advanced-search>
|
||||
<ds-themed-search-settings *ngIf="inPlaceSearch"
|
||||
|
@@ -11,6 +11,8 @@ import { By } from '@angular/platform-browser';
|
||||
import { NgbCollapseModule } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
|
||||
import { APP_CONFIG } from '../../../../config/app-config.interface';
|
||||
import { environment } from '../../../../environments/environment.test';
|
||||
import { AdvancedSearchComponent } from '../advanced-search/advanced-search.component';
|
||||
import { ThemedSearchFiltersComponent } from '../search-filters/themed-search-filters.component';
|
||||
import { ThemedSearchSettingsComponent } from '../search-settings/themed-search-settings.component';
|
||||
@@ -27,6 +29,9 @@ describe('SearchSidebarComponent', () => {
|
||||
NgbCollapseModule,
|
||||
SearchSidebarComponent,
|
||||
],
|
||||
providers: [
|
||||
{ provide: APP_CONFIG, useValue: environment },
|
||||
],
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
||||
})
|
||||
.overrideComponent(SearchSidebarComponent, {
|
||||
|
@@ -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<ViewMode> = new EventEmitter<ViewMode>();
|
||||
|
||||
constructor(
|
||||
@Inject(APP_CONFIG) protected appConfig: AppConfig,
|
||||
) {
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -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 <a href=\\\"https://notify.coar-repositories.org/\\\">COAR Notify website</a>.",
|
||||
@@ -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",
|
||||
|
Reference in New Issue
Block a user