mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
111731: Migrated the renderSearchLabelFor to standalone form
This commit is contained in:
@@ -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) {
|
export const LABEL_DECORATOR_MAP: Map<string, Type<Component>> = new Map([
|
||||||
return function decorator(objectElement: any) {
|
[DEFAULT_LABEL_OPERATOR, SearchLabelComponent as Type<Component>],
|
||||||
if (!objectElement) {
|
['range', SearchLabelRangeComponent as Type<Component>],
|
||||||
return;
|
]);
|
||||||
}
|
|
||||||
map.set(operator, objectElement);
|
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);
|
||||||
export function getSearchLabelByOperator(operator: string): GenericConstructor<Component> {
|
}
|
||||||
return map.get(operator);
|
return comp;
|
||||||
}
|
}
|
||||||
|
@@ -21,7 +21,6 @@ import { SearchService } from '../../../../core/shared/search/search.service';
|
|||||||
import { SearchConfigurationService } from '../../../../core/shared/search/search-configuration.service';
|
import { SearchConfigurationService } from '../../../../core/shared/search/search-configuration.service';
|
||||||
import { currentPath } from '../../../utils/route.utils';
|
import { currentPath } from '../../../utils/route.utils';
|
||||||
import { AppliedFilter } from '../../models/applied-filter.model';
|
import { AppliedFilter } from '../../models/applied-filter.model';
|
||||||
import { renderSearchLabelFor } from '../search-label-loader/search-label-loader.decorator';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component that represents the label containing the currently active filters
|
* Component that represents the label containing the currently active filters
|
||||||
@@ -38,7 +37,6 @@ import { renderSearchLabelFor } from '../search-label-loader/search-label-loader
|
|||||||
TranslateModule,
|
TranslateModule,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
@renderSearchLabelFor('range')
|
|
||||||
export class SearchLabelRangeComponent implements OnInit {
|
export class SearchLabelRangeComponent implements OnInit {
|
||||||
|
|
||||||
@Input() inPlaceSearch: boolean;
|
@Input() inPlaceSearch: boolean;
|
||||||
|
@@ -18,7 +18,6 @@ import { SearchService } from '../../../../core/shared/search/search.service';
|
|||||||
import { SearchConfigurationService } from '../../../../core/shared/search/search-configuration.service';
|
import { SearchConfigurationService } from '../../../../core/shared/search/search-configuration.service';
|
||||||
import { currentPath } from '../../../utils/route.utils';
|
import { currentPath } from '../../../utils/route.utils';
|
||||||
import { AppliedFilter } from '../../models/applied-filter.model';
|
import { AppliedFilter } from '../../models/applied-filter.model';
|
||||||
import { renderSearchLabelFor } from '../search-label-loader/search-label-loader.decorator';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component that represents the label containing the currently active filters
|
* Component that represents the label containing the currently active filters
|
||||||
@@ -30,13 +29,6 @@ import { renderSearchLabelFor } from '../search-label-loader/search-label-loader
|
|||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [RouterLink, AsyncPipe, TranslateModule],
|
imports: [RouterLink, AsyncPipe, TranslateModule],
|
||||||
})
|
})
|
||||||
@renderSearchLabelFor('equals')
|
|
||||||
@renderSearchLabelFor('notequals')
|
|
||||||
@renderSearchLabelFor('authority')
|
|
||||||
@renderSearchLabelFor('notauthority')
|
|
||||||
@renderSearchLabelFor('contains')
|
|
||||||
@renderSearchLabelFor('notcontains')
|
|
||||||
@renderSearchLabelFor('query')
|
|
||||||
export class SearchLabelComponent implements OnInit {
|
export class SearchLabelComponent implements OnInit {
|
||||||
@Input() inPlaceSearch: boolean;
|
@Input() inPlaceSearch: boolean;
|
||||||
@Input() appliedFilter: AppliedFilter;
|
@Input() appliedFilter: AppliedFilter;
|
||||||
|
Reference in New Issue
Block a user