mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-14 13:33:03 +00:00
97049: Refactor how to obtain vocabularies for filter (configurable)
This commit is contained in:
@@ -3,3 +3,8 @@ rest:
|
||||
host: api7.dspace.org
|
||||
port: 443
|
||||
nameSpace: /server
|
||||
|
||||
vocabularies:
|
||||
- filter: 'subject'
|
||||
vocabulary: 'srsc'
|
||||
enabled: true
|
||||
|
@@ -23,6 +23,7 @@ import { filter, map, take } from 'rxjs/operators';
|
||||
import { VocabularyService } from '../../../../../core/submission/vocabularies/vocabulary.service';
|
||||
import { Observable } from 'rxjs';
|
||||
import { PageInfo } from '../../../../../core/shared/page-info.model';
|
||||
import { environment } from '../../../../../../environments/environment';
|
||||
|
||||
/**
|
||||
* Component that represents a hierarchy facet for a specific filter configuration.
|
||||
@@ -63,7 +64,7 @@ export class OkrSearchHierarchyFilterComponent extends SearchHierarchyFilterComp
|
||||
ngOnInit() {
|
||||
super.ngOnInit();
|
||||
this.vocabularyExists$ = this.vocabularyService.searchTopEntries(
|
||||
this.filterConfig.name, new PageInfo(), true, false,
|
||||
this.getVocabularyEntry(), new PageInfo(), true, false,
|
||||
).pipe(
|
||||
filter(rd => rd.hasCompleted),
|
||||
take(1),
|
||||
@@ -83,7 +84,7 @@ export class OkrSearchHierarchyFilterComponent extends SearchHierarchyFilterComp
|
||||
windowClass: 'treeview'
|
||||
});
|
||||
modalRef.componentInstance.vocabularyOptions = {
|
||||
name: this.filterConfig.name,
|
||||
name: this.getVocabularyEntry(),
|
||||
closed: true
|
||||
};
|
||||
modalRef.componentInstance.select.subscribe((detail: VocabularyEntryDetail) => {
|
||||
@@ -103,4 +104,15 @@ export class OkrSearchHierarchyFilterComponent extends SearchHierarchyFilterComp
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the matching vocabulary entry for the given search filter.
|
||||
* These are configurable in the config file.
|
||||
*/
|
||||
getVocabularyEntry() {
|
||||
const foundVocabularyConfig = environment.vocabularies.filter((v) => v.filter === this.filterConfig.name);
|
||||
if (foundVocabularyConfig.length > 0 && foundVocabularyConfig[0].enabled === true) {
|
||||
return foundVocabularyConfig[0].vocabulary;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
7
src/config/FilterVocabularyConfig.ts
Normal file
7
src/config/FilterVocabularyConfig.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { Config } from './config.interface';
|
||||
|
||||
export interface FilterVocabularyConfig extends Config {
|
||||
filter: string;
|
||||
vocabulary: string;
|
||||
enabled: boolean;
|
||||
}
|
@@ -15,6 +15,7 @@ import { AuthConfig } from './auth-config.interfaces';
|
||||
import { UIServerConfig } from './ui-server-config.interface';
|
||||
import { MediaViewerConfig } from './media-viewer-config.interface';
|
||||
import { BrowseByConfig } from './browse-by-config.interface';
|
||||
import { FilterVocabularyConfig } from './FilterVocabularyConfig';
|
||||
|
||||
interface AppConfig extends Config {
|
||||
ui: UIServerConfig;
|
||||
@@ -34,6 +35,7 @@ interface AppConfig extends Config {
|
||||
collection: CollectionPageConfig;
|
||||
themes: ThemeConfig[];
|
||||
mediaViewer: MediaViewerConfig;
|
||||
vocabularies: FilterVocabularyConfig[];
|
||||
}
|
||||
|
||||
const APP_CONFIG = new InjectionToken<AppConfig>('APP_CONFIG');
|
||||
|
@@ -15,6 +15,7 @@ import { SubmissionConfig } from './submission-config.interface';
|
||||
import { ThemeConfig } from './theme.model';
|
||||
import { UIServerConfig } from './ui-server-config.interface';
|
||||
import { UniversalConfig } from './universal-config.interface';
|
||||
import { FilterVocabularyConfig } from './FilterVocabularyConfig';
|
||||
|
||||
export class DefaultAppConfig implements AppConfig {
|
||||
production = false;
|
||||
@@ -314,4 +315,12 @@ export class DefaultAppConfig implements AppConfig {
|
||||
image: false,
|
||||
video: false
|
||||
};
|
||||
|
||||
vocabularies: FilterVocabularyConfig[] = [
|
||||
{
|
||||
filter: 'subject',
|
||||
vocabulary: 'srsc',
|
||||
enabled: true
|
||||
}
|
||||
];
|
||||
}
|
||||
|
@@ -227,5 +227,13 @@ export const environment: AppConfig = {
|
||||
mediaViewer: {
|
||||
image: true,
|
||||
video: true
|
||||
},
|
||||
|
||||
vocabularies: [
|
||||
{
|
||||
filter: 'subject',
|
||||
vocabulary: 'srsc',
|
||||
enabled: true
|
||||
}
|
||||
]
|
||||
};
|
||||
|
Reference in New Issue
Block a user