From 8b4eedef322a59a10c5b8d5e3cb9030d8dbce114 Mon Sep 17 00:00:00 2001 From: Giuseppe Digilio Date: Wed, 13 Mar 2024 14:51:02 +0100 Subject: [PATCH] [DURACOM-191] Remove admin-notify-dashboard.module --- .../admin-notify-dashboard.module.ts | 51 ------------------- .../admin-notify-search-result.component.ts | 6 --- .../tabulatable-objects.decorator.ts | 39 +++++--------- 3 files changed, 12 insertions(+), 84 deletions(-) delete mode 100644 src/app/admin/admin-notify-dashboard/admin-notify-dashboard.module.ts diff --git a/src/app/admin/admin-notify-dashboard/admin-notify-dashboard.module.ts b/src/app/admin/admin-notify-dashboard/admin-notify-dashboard.module.ts deleted file mode 100644 index 555da7acc3..0000000000 --- a/src/app/admin/admin-notify-dashboard/admin-notify-dashboard.module.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { - CommonModule, - DatePipe, -} from '@angular/common'; -import { NgModule } from '@angular/core'; -import { RouterModule } from '@angular/router'; - -import { SearchPageModule } from '../../search-page/search-page.module'; -import { SearchModule } from '../../shared/search/search.module'; -import { AdminNotifyDashboardComponent } from './admin-notify-dashboard.component'; -import { AdminNotifyDashboardRoutingModule } from './admin-notify-dashboard-routing.module'; -import { AdminNotifyDetailModalComponent } from './admin-notify-detail-modal/admin-notify-detail-modal.component'; -import { AdminNotifyIncomingComponent } from './admin-notify-logs/admin-notify-incoming/admin-notify-incoming.component'; -import { AdminNotifyLogsResultComponent } from './admin-notify-logs/admin-notify-logs-result/admin-notify-logs-result.component'; -import { AdminNotifyOutgoingComponent } from './admin-notify-logs/admin-notify-outgoing/admin-notify-outgoing.component'; -import { AdminNotifyMetricsComponent } from './admin-notify-metrics/admin-notify-metrics.component'; -import { AdminNotifySearchResultComponent } from './admin-notify-search-result/admin-notify-search-result.component'; -import { AdminNotifyMessagesService } from './services/admin-notify-messages.service'; - -const ENTRY_COMPONENTS = [ - AdminNotifySearchResultComponent, -]; -@NgModule({ - imports: [ - CommonModule, - RouterModule, - AdminNotifyDashboardRoutingModule, - SearchModule, - SearchPageModule, - ...ENTRY_COMPONENTS, - AdminNotifyDashboardComponent, - AdminNotifyMetricsComponent, - AdminNotifyIncomingComponent, - AdminNotifyOutgoingComponent, - AdminNotifyDetailModalComponent, - AdminNotifySearchResultComponent, - AdminNotifyLogsResultComponent, - ], - providers: [ - AdminNotifyMessagesService, - DatePipe, - ], -}) -export class AdminNotifyDashboardModule { - static withEntryComponents() { - return { - ngModule: AdminNotifyDashboardModule, - providers: ENTRY_COMPONENTS.map((component) => ({ provide: component })), - }; - } -} diff --git a/src/app/admin/admin-notify-dashboard/admin-notify-search-result/admin-notify-search-result.component.ts b/src/app/admin/admin-notify-dashboard/admin-notify-search-result/admin-notify-search-result.component.ts index 9c8db7cc9f..bc81aad227 100644 --- a/src/app/admin/admin-notify-dashboard/admin-notify-search-result/admin-notify-search-result.component.ts +++ b/src/app/admin/admin-notify-dashboard/admin-notify-search-result/admin-notify-search-result.component.ts @@ -19,11 +19,8 @@ import { } from 'rxjs'; import { PaginatedList } from '../../../core/data/paginated-list.model'; -import { Context } from '../../../core/shared/context.model'; import { SearchConfigurationService } from '../../../core/shared/search/search-configuration.service'; -import { ViewMode } from '../../../core/shared/view-mode.model'; import { SEARCH_CONFIG_SERVICE } from '../../../my-dspace-page/my-dspace-configuration.service'; -import { tabulatableObjectsComponent } from '../../../shared/object-collection/shared/tabulatable-objects/tabulatable-objects.decorator'; import { TabulatableResultListElementsComponent } from '../../../shared/object-list/search-result-list-element/tabulatable-search-result/tabulatable-result-list-elements.component'; import { TruncatableComponent } from '../../../shared/truncatable/truncatable.component'; import { TruncatablePartComponent } from '../../../shared/truncatable/truncatable-part/truncatable-part.component'; @@ -32,7 +29,6 @@ import { AdminNotifyMessage } from '../models/admin-notify-message.model'; import { AdminNotifySearchResult } from '../models/admin-notify-message-search-result.model'; import { AdminNotifyMessagesService } from '../services/admin-notify-messages.service'; -@tabulatableObjectsComponent(PaginatedList, ViewMode.Table, Context.CoarNotify) @Component({ selector: 'ds-admin-notify-search-result', templateUrl: './admin-notify-search-result.component.html', @@ -57,8 +53,6 @@ import { AdminNotifyMessagesService } from '../services/admin-notify-messages.se /** * Component for visualization in table format of the search results related to the AdminNotifyDashboardComponent */ - - export class AdminNotifySearchResultComponent extends TabulatableResultListElementsComponent, AdminNotifySearchResult> implements OnInit, OnDestroy{ public messagesSubject$: BehaviorSubject = new BehaviorSubject([]); public reprocessStatus = 'QUEUE_STATUS_QUEUED_FOR_RETRY'; diff --git a/src/app/shared/object-collection/shared/tabulatable-objects/tabulatable-objects.decorator.ts b/src/app/shared/object-collection/shared/tabulatable-objects/tabulatable-objects.decorator.ts index fe40a99d9c..6828ddd97f 100644 --- a/src/app/shared/object-collection/shared/tabulatable-objects/tabulatable-objects.decorator.ts +++ b/src/app/shared/object-collection/shared/tabulatable-objects/tabulatable-objects.decorator.ts @@ -1,4 +1,4 @@ -import { PaginatedList } from '../../../../core/data/paginated-list.model'; +import { AdminNotifySearchResult } from '../../../../admin/admin-notify-dashboard/models/admin-notify-message-search-result.model'; import { Context } from '../../../../core/shared/context.model'; import { GenericConstructor } from '../../../../core/shared/generic-constructor'; import { ViewMode } from '../../../../core/shared/view-mode.model'; @@ -6,6 +6,7 @@ import { hasNoValue, hasValue, } from '../../../empty.util'; +import { TabulatableResultListElementsComponent } from '../../../object-list/search-result-list-element/tabulatable-search-result/tabulatable-result-list-elements.component'; import { ListableObject } from '../listable-object.model'; import { DEFAULT_CONTEXT, @@ -15,32 +16,16 @@ import { MatchRelevancy, } from '../listable-object/listable-object.decorator'; -const map = new Map(); +type TabulatableComponentType = typeof TabulatableResultListElementsComponent; -/** - * Decorator used for rendering tabulatable objects - * @param objectsType The object type or entity type the component represents - * @param viewMode The view mode the component represents - * @param context The optional context the component represents - * @param theme The optional theme for the component - */ -export function tabulatableObjectsComponent(objectsType: string | GenericConstructor>, viewMode: ViewMode, context: Context = DEFAULT_CONTEXT, theme = DEFAULT_THEME) { - return function decorator(component: any) { - if (hasNoValue(objectsType)) { - return; - } - if (hasNoValue(map.get(objectsType))) { - map.set(objectsType, new Map()); - } - if (hasNoValue(map.get(objectsType).get(viewMode))) { - map.get(objectsType).set(viewMode, new Map()); - } - if (hasNoValue(map.get(objectsType).get(viewMode).get(context))) { - map.get(objectsType).get(viewMode).set(context, new Map()); - } - map.get(objectsType).get(viewMode).get(context).set(theme, component); - }; -} +export const TABUTABLE_DECORATOR_MAP = + new Map, Map>>>([ + [AdminNotifySearchResult, new Map([ + [ViewMode.Table, new Map([ + [Context.CoarNotify, new Map([[DEFAULT_THEME, TabulatableResultListElementsComponent as any]])] + ])], + ])], + ]); /** * Getter to retrieve the matching tabulatable objects component @@ -56,7 +41,7 @@ export function tabulatableObjectsComponent(objectsType: string | GenericConstru export function getTabulatableObjectsComponent(types: (string | GenericConstructor)[], viewMode: ViewMode, context: Context = DEFAULT_CONTEXT, theme: string = DEFAULT_THEME) { let currentBestMatch: MatchRelevancy = null; for (const type of types) { - const typeMap = map.get(PaginatedList); + const typeMap = TABUTABLE_DECORATOR_MAP.get(type); if (hasValue(typeMap)) { const match = getMatch(typeMap, [viewMode, context, theme], [DEFAULT_VIEW_MODE, DEFAULT_CONTEXT, DEFAULT_THEME]);