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
|
host: api7.dspace.org
|
||||||
port: 443
|
port: 443
|
||||||
nameSpace: /server
|
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 { VocabularyService } from '../../../../../core/submission/vocabularies/vocabulary.service';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { PageInfo } from '../../../../../core/shared/page-info.model';
|
import { PageInfo } from '../../../../../core/shared/page-info.model';
|
||||||
|
import { environment } from '../../../../../../environments/environment';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component that represents a hierarchy facet for a specific filter configuration.
|
* Component that represents a hierarchy facet for a specific filter configuration.
|
||||||
@@ -63,7 +64,7 @@ export class OkrSearchHierarchyFilterComponent extends SearchHierarchyFilterComp
|
|||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
super.ngOnInit();
|
super.ngOnInit();
|
||||||
this.vocabularyExists$ = this.vocabularyService.searchTopEntries(
|
this.vocabularyExists$ = this.vocabularyService.searchTopEntries(
|
||||||
this.filterConfig.name, new PageInfo(), true, false,
|
this.getVocabularyEntry(), new PageInfo(), true, false,
|
||||||
).pipe(
|
).pipe(
|
||||||
filter(rd => rd.hasCompleted),
|
filter(rd => rd.hasCompleted),
|
||||||
take(1),
|
take(1),
|
||||||
@@ -83,7 +84,7 @@ export class OkrSearchHierarchyFilterComponent extends SearchHierarchyFilterComp
|
|||||||
windowClass: 'treeview'
|
windowClass: 'treeview'
|
||||||
});
|
});
|
||||||
modalRef.componentInstance.vocabularyOptions = {
|
modalRef.componentInstance.vocabularyOptions = {
|
||||||
name: this.filterConfig.name,
|
name: this.getVocabularyEntry(),
|
||||||
closed: true
|
closed: true
|
||||||
};
|
};
|
||||||
modalRef.componentInstance.select.subscribe((detail: VocabularyEntryDetail) => {
|
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 { UIServerConfig } from './ui-server-config.interface';
|
||||||
import { MediaViewerConfig } from './media-viewer-config.interface';
|
import { MediaViewerConfig } from './media-viewer-config.interface';
|
||||||
import { BrowseByConfig } from './browse-by-config.interface';
|
import { BrowseByConfig } from './browse-by-config.interface';
|
||||||
|
import { FilterVocabularyConfig } from './FilterVocabularyConfig';
|
||||||
|
|
||||||
interface AppConfig extends Config {
|
interface AppConfig extends Config {
|
||||||
ui: UIServerConfig;
|
ui: UIServerConfig;
|
||||||
@@ -34,6 +35,7 @@ interface AppConfig extends Config {
|
|||||||
collection: CollectionPageConfig;
|
collection: CollectionPageConfig;
|
||||||
themes: ThemeConfig[];
|
themes: ThemeConfig[];
|
||||||
mediaViewer: MediaViewerConfig;
|
mediaViewer: MediaViewerConfig;
|
||||||
|
vocabularies: FilterVocabularyConfig[];
|
||||||
}
|
}
|
||||||
|
|
||||||
const APP_CONFIG = new InjectionToken<AppConfig>('APP_CONFIG');
|
const APP_CONFIG = new InjectionToken<AppConfig>('APP_CONFIG');
|
||||||
|
@@ -15,6 +15,7 @@ import { SubmissionConfig } from './submission-config.interface';
|
|||||||
import { ThemeConfig } from './theme.model';
|
import { ThemeConfig } from './theme.model';
|
||||||
import { UIServerConfig } from './ui-server-config.interface';
|
import { UIServerConfig } from './ui-server-config.interface';
|
||||||
import { UniversalConfig } from './universal-config.interface';
|
import { UniversalConfig } from './universal-config.interface';
|
||||||
|
import { FilterVocabularyConfig } from './FilterVocabularyConfig';
|
||||||
|
|
||||||
export class DefaultAppConfig implements AppConfig {
|
export class DefaultAppConfig implements AppConfig {
|
||||||
production = false;
|
production = false;
|
||||||
@@ -314,4 +315,12 @@ export class DefaultAppConfig implements AppConfig {
|
|||||||
image: false,
|
image: false,
|
||||||
video: false
|
video: false
|
||||||
};
|
};
|
||||||
|
|
||||||
|
vocabularies: FilterVocabularyConfig[] = [
|
||||||
|
{
|
||||||
|
filter: 'subject',
|
||||||
|
vocabulary: 'srsc',
|
||||||
|
enabled: true
|
||||||
|
}
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
@@ -227,5 +227,13 @@ export const environment: AppConfig = {
|
|||||||
mediaViewer: {
|
mediaViewer: {
|
||||||
image: true,
|
image: true,
|
||||||
video: true
|
video: true
|
||||||
|
},
|
||||||
|
|
||||||
|
vocabularies: [
|
||||||
|
{
|
||||||
|
filter: 'subject',
|
||||||
|
vocabulary: 'srsc',
|
||||||
|
enabled: true
|
||||||
}
|
}
|
||||||
|
]
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user