forked from DSpace/dspace-angular
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
111731: Migrated the renderSearchLabelFor to standalone form
- Loading branch information
1 parent
f40a68f
commit 36ac600
Showing
3 changed files
with
18 additions
and
23 deletions.
There are no files selected for viewing
31 changes: 18 additions & 13 deletions
31
src/app/shared/search/search-labels/search-label-loader/search-label-loader.decorator.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,23 @@ | ||
import { Component } from '@angular/core'; | ||
import { | ||
Component, | ||
Type, | ||
} from '@angular/core'; | ||
|
||
import { GenericConstructor } from '../../../../core/shared/generic-constructor'; | ||
import { hasNoValue } from '../../../empty.util'; | ||
import { SearchLabelComponent } from '../search-label/search-label.component'; | ||
import { SearchLabelRangeComponent } from '../search-label-range/search-label-range.component'; | ||
|
||
export const map: Map<string, GenericConstructor<Component>> = new Map(); | ||
export const DEFAULT_LABEL_OPERATOR = undefined; | ||
|
||
export function renderSearchLabelFor(operator: string) { | ||
return function decorator(objectElement: any) { | ||
if (!objectElement) { | ||
return; | ||
} | ||
map.set(operator, objectElement); | ||
}; | ||
} | ||
export const LABEL_DECORATOR_MAP: Map<string, Type<Component>> = new Map([ | ||
[DEFAULT_LABEL_OPERATOR, SearchLabelComponent as Type<Component>], | ||
['range', SearchLabelRangeComponent as Type<Component>], | ||
]); | ||
|
||
export function getSearchLabelByOperator(operator: string): GenericConstructor<Component> { | ||
return map.get(operator); | ||
export function getSearchLabelByOperator(operator: string): Type<Component> { | ||
const comp: Type<Component> = LABEL_DECORATOR_MAP.get(operator); | ||
if (hasNoValue(comp)) { | ||
return LABEL_DECORATOR_MAP.get(DEFAULT_LABEL_OPERATOR); | ||
} | ||
return comp; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters