From 1c3776b2d3bf8efe71132c7deae4371a36447f30 Mon Sep 17 00:00:00 2001 From: Mykhaylo Boychuk Date: Fri, 24 Nov 2023 11:28:38 +0100 Subject: [PATCH] [CST-12109] porting missing code --- config/config.yml | 6 +- .../admin-notifications-routing.module.ts | 5 +- src/app/admin/admin-routing.module.ts | 22 +++++-- src/app/app-routing.module.ts | 5 +- .../data/feature-authorization/feature-id.ts | 3 +- .../quality-assurance-source-data.service.ts | 3 +- .../quality-assurance-topic-data.service.ts | 39 ++++++++----- .../qa-event-notification.component.html | 9 +-- .../qa-event-notification.component.ts | 18 ++++-- .../shared/dso-page/dso-edit-menu.resolver.ts | 35 ++++++++--- .../dso-withdrawn-reinstate-modal.service.ts | 2 +- src/app/shared/shared.module.ts | 6 +- .../quality-assurance-topics.actions.ts | 8 ++- .../quality-assurance-topics.component.html | 8 ++- .../quality-assurance-topics.component.ts | 58 ++++++++++++++++--- .../quality-assurance-topics.effects.ts | 4 +- .../quality-assurance-topics.service.ts | 29 +++++----- .../suggestion-notifications-state.service.ts | 4 +- src/assets/i18n/en.json5 | 4 ++ 19 files changed, 185 insertions(+), 83 deletions(-) diff --git a/config/config.yml b/config/config.yml index b5eecd112f..a5337cdd0d 100644 --- a/config/config.yml +++ b/config/config.yml @@ -1,5 +1,5 @@ rest: - ssl: true - host: api7.dspace.org - port: 443 + ssl: false + host: localhost + port: 8080 nameSpace: /server diff --git a/src/app/admin/admin-notifications/admin-notifications-routing.module.ts b/src/app/admin/admin-notifications/admin-notifications-routing.module.ts index dc0d82c1d9..ab4d3f09fa 100644 --- a/src/app/admin/admin-notifications/admin-notifications-routing.module.ts +++ b/src/app/admin/admin-notifications/admin-notifications-routing.module.ts @@ -12,6 +12,9 @@ import { AdminQualityAssuranceEventsPageResolver } from './admin-quality-assuran import { AdminQualityAssuranceSourcePageComponent } from './admin-quality-assurance-source-page-component/admin-quality-assurance-source-page.component'; import { AdminQualityAssuranceSourcePageResolver } from './admin-quality-assurance-source-page-component/admin-quality-assurance-source-page-resolver.service'; import { SourceDataResolver } from './admin-quality-assurance-source-page-component/admin-quality-assurance-source-data.reslover'; +import { + SiteAdministratorGuard +} from '../../core/data/feature-authorization/feature-authorization-guard/site-administrator.guard'; @NgModule({ imports: [ @@ -32,7 +35,7 @@ import { SourceDataResolver } from './admin-quality-assurance-source-page-compon } }, { - canActivate: [ AuthenticatedGuard ], + canActivate: [ SiteAdministratorGuard ], path: `${QUALITY_ASSURANCE_EDIT_PATH}`, component: AdminQualityAssuranceSourcePageComponent, pathMatch: 'full', diff --git a/src/app/admin/admin-routing.module.ts b/src/app/admin/admin-routing.module.ts index a7d19a6935..65b16139c1 100644 --- a/src/app/admin/admin-routing.module.ts +++ b/src/app/admin/admin-routing.module.ts @@ -8,6 +8,9 @@ import { I18nBreadcrumbsService } from '../core/breadcrumbs/i18n-breadcrumbs.ser import { AdminCurationTasksComponent } from './admin-curation-tasks/admin-curation-tasks.component'; import { REGISTRIES_MODULE_PATH, NOTIFICATIONS_MODULE_PATH } from './admin-routing-paths'; import { BatchImportPageComponent } from './admin-import-batch-page/batch-import-page.component'; +import { + SiteAdministratorGuard +} from '../core/data/feature-authorization/feature-authorization-guard/site-administrator.guard'; @NgModule({ imports: [ @@ -21,42 +24,49 @@ import { BatchImportPageComponent } from './admin-import-batch-page/batch-import path: REGISTRIES_MODULE_PATH, loadChildren: () => import('./admin-registries/admin-registries.module') .then((m) => m.AdminRegistriesModule), + canActivate: [SiteAdministratorGuard] }, { path: 'search', resolve: { breadcrumb: I18nBreadcrumbResolver }, component: AdminSearchPageComponent, - data: { title: 'admin.search.title', breadcrumbKey: 'admin.search' } + data: { title: 'admin.search.title', breadcrumbKey: 'admin.search' }, + canActivate: [SiteAdministratorGuard] }, { path: 'workflow', resolve: { breadcrumb: I18nBreadcrumbResolver }, component: AdminWorkflowPageComponent, - data: { title: 'admin.workflow.title', breadcrumbKey: 'admin.workflow' } + data: { title: 'admin.workflow.title', breadcrumbKey: 'admin.workflow' }, + canActivate: [SiteAdministratorGuard] }, { path: 'curation-tasks', resolve: { breadcrumb: I18nBreadcrumbResolver }, component: AdminCurationTasksComponent, - data: { title: 'admin.curation-tasks.title', breadcrumbKey: 'admin.curation-tasks' } + data: { title: 'admin.curation-tasks.title', breadcrumbKey: 'admin.curation-tasks' }, + canActivate: [SiteAdministratorGuard] }, { path: 'metadata-import', resolve: { breadcrumb: I18nBreadcrumbResolver }, component: MetadataImportPageComponent, - data: { title: 'admin.metadata-import.title', breadcrumbKey: 'admin.metadata-import' } + data: { title: 'admin.metadata-import.title', breadcrumbKey: 'admin.metadata-import' }, + canActivate: [SiteAdministratorGuard] }, { path: 'batch-import', resolve: { breadcrumb: I18nBreadcrumbResolver }, component: BatchImportPageComponent, - data: { title: 'admin.batch-import.title', breadcrumbKey: 'admin.batch-import' } + data: { title: 'admin.batch-import.title', breadcrumbKey: 'admin.batch-import' }, + canActivate: [SiteAdministratorGuard] }, { path: 'system-wide-alert', resolve: { breadcrumb: I18nBreadcrumbResolver }, loadChildren: () => import('../system-wide-alert/system-wide-alert.module').then((m) => m.SystemWideAlertModule), - data: {title: 'admin.system-wide-alert.title', breadcrumbKey: 'admin.system-wide-alert'} + data: {title: 'admin.system-wide-alert.title', breadcrumbKey: 'admin.system-wide-alert'}, + canActivate: [SiteAdministratorGuard] }, ]) ], diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 0d7a0bd0f0..6c247eb9bf 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -3,9 +3,6 @@ import { RouterModule, NoPreloading } from '@angular/router'; import { AuthBlockingGuard } from './core/auth/auth-blocking.guard'; import { AuthenticatedGuard } from './core/auth/authenticated.guard'; -import { - SiteAdministratorGuard -} from './core/data/feature-authorization/feature-authorization-guard/site-administrator.guard'; import { ACCESS_CONTROL_MODULE_PATH, ADMIN_MODULE_PATH, @@ -154,7 +151,7 @@ import { ThemedPageErrorComponent } from './page-error/themed-page-error.compone path: ADMIN_MODULE_PATH, loadChildren: () => import('./admin/admin.module') .then((m) => m.AdminModule), - canActivate: [SiteAdministratorGuard, EndUserAgreementCurrentUserGuard] + canActivate: [EndUserAgreementCurrentUserGuard] }, { path: 'login', diff --git a/src/app/core/data/feature-authorization/feature-id.ts b/src/app/core/data/feature-authorization/feature-id.ts index 8fef45a953..248698c105 100644 --- a/src/app/core/data/feature-authorization/feature-id.ts +++ b/src/app/core/data/feature-authorization/feature-id.ts @@ -33,5 +33,6 @@ export enum FeatureID { CanSubmit = 'canSubmit', CanEditItem = 'canEditItem', CanRegisterDOI = 'canRegisterDOI', - CanSubscribe = 'canSubscribeDso', + CanSubscribe = 'canSubscribeDso' + } diff --git a/src/app/core/suggestion-notifications/qa/source/quality-assurance-source-data.service.ts b/src/app/core/suggestion-notifications/qa/source/quality-assurance-source-data.service.ts index 30f3b848f4..aed7f7541f 100644 --- a/src/app/core/suggestion-notifications/qa/source/quality-assurance-source-data.service.ts +++ b/src/app/core/suggestion-notifications/qa/source/quality-assurance-source-data.service.ts @@ -16,7 +16,7 @@ import { PaginatedList } from '../../../data/paginated-list.model'; import { FindListOptions } from '../../../data/find-list-options.model'; import { IdentifiableDataService } from '../../../data/base/identifiable-data.service'; import { FindAllData, FindAllDataImpl } from '../../../data/base/find-all-data'; -import { SearchData } from '../../../data/base/search-data'; +import { SearchData, SearchDataImpl } from '../../../data/base/search-data'; /** * The service handling all Quality Assurance source REST requests. @@ -47,6 +47,7 @@ export class QualityAssuranceSourceDataService extends IdentifiableDataService { private findAllData: FindAllData; + private searchData: SearchData; + + private searchByTargetMethod = 'byTarget'; + private searchBySourceMethod = 'bySource'; /** * Initialize service variables @@ -43,23 +48,31 @@ export class QualityAssuranceTopicDataService extends IdentifiableDataService>> - * The list of Quality Assurance topics. + * Search for Quality Assurance topics. + * @param options The search options. + * @param useCachedVersionIfAvailable Whether to use cached version if available. + * @param reRequestOnStale Whether to re-request on stale. + * @param linksToFollow The links to follow. + * @returns An observable of remote data containing a paginated list of Quality Assurance topics. */ - public getTopics(options: FindListOptions = {}, useCachedVersionIfAvailable = true, reRequestOnStale = true, ...linksToFollow: FollowLinkConfig[]): Observable>> { - return this.findAllData.findAll(options, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow); + public searchTopicsByTarget(options: FindListOptions = {}, useCachedVersionIfAvailable = true, reRequestOnStale = true, ...linksToFollow: FollowLinkConfig[]): Observable>> { + return this.searchData.searchBy(this.searchByTargetMethod, options, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow); + } + + /** + * Searches for quality assurance topics by source. + * @param options The search options. + * @param useCachedVersionIfAvailable Whether to use a cached version if available. + * @param reRequestOnStale Whether to re-request the data if it's stale. + * @param linksToFollow The links to follow. + * @returns An observable of the remote data containing the paginated list of quality assurance topics. + */ + public searchTopicsBySource(options: FindListOptions = {}, useCachedVersionIfAvailable = true, reRequestOnStale = true, ...linksToFollow: FollowLinkConfig[]): Observable>> { + return this.searchData.searchBy(this.searchBySourceMethod, options, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow); } /** diff --git a/src/app/item-page/simple/qa-event-notification/qa-event-notification.component.html b/src/app/item-page/simple/qa-event-notification/qa-event-notification.component.html index f2a06bd4fd..1024700149 100644 --- a/src/app/item-page/simple/qa-event-notification/qa-event-notification.component.html +++ b/src/app/item-page/simple/qa-event-notification/qa-event-notification.component.html @@ -1,15 +1,12 @@
-
-
{{'item.qa-event-notification.check.notification-info' | translate : {num: - source.totalEvents } }}
-
-Added file diff --git a/src/app/item-page/simple/qa-event-notification/qa-event-notification.component.ts b/src/app/item-page/simple/qa-event-notification/qa-event-notification.component.ts index c48d30851e..fb6bad1b46 100644 --- a/src/app/item-page/simple/qa-event-notification/qa-event-notification.component.ts +++ b/src/app/item-page/simple/qa-event-notification/qa-event-notification.component.ts @@ -1,12 +1,13 @@ import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; import { Item } from '../../../core/shared/item.model'; -import { getFirstCompletedRemoteData, getPaginatedListPayload, getRemoteDataPayload } from '../../../core/shared/operators'; +import { getFirstCompletedRemoteData } from '../../../core/shared/operators'; import { Observable } from 'rxjs'; -import { AlertType } from '../../../shared/alert/aletr-type'; import { FindListOptions } from '../../../core/data/find-list-options.model'; import { RequestParam } from '../../../core/cache/models/request-param.model'; import { QualityAssuranceSourceDataService } from '../../../core/suggestion-notifications/qa/source/quality-assurance-source-data.service'; import { QualityAssuranceSourceObject } from '../../../core/suggestion-notifications/qa/models/quality-assurance-source.model'; +import { map, tap } from 'rxjs/operators'; +import { RemoteData } from '../../../core/data/remote-data'; @Component({ selector: 'ds-qa-event-notification', templateUrl: './qa-event-notification.component.html', @@ -25,9 +26,8 @@ export class QaEventNotificationComponent { /** * The type of alert to display for the notification. */ - AlertTypeInfo = AlertType.Info; constructor( - private qualityAssuranceSourceDataService: QualityAssuranceSourceDataService, + private qualityAssuranceSourceDataService: QualityAssuranceSourceDataService ) { } /** * Returns an Observable of QualityAssuranceSourceObject[] for the current item. @@ -35,14 +35,20 @@ export class QaEventNotificationComponent { * Note: sourceId is composed as: id: "sourceName:" */ getQualityAssuranceSources$(): Observable { + console.log('ciao'); const findListTopicOptions: FindListOptions = { searchParams: [new RequestParam('target', this.item.uuid)] }; return this.qualityAssuranceSourceDataService.getSourcesByTarget(findListTopicOptions) .pipe( getFirstCompletedRemoteData(), - getRemoteDataPayload(), - getPaginatedListPayload(), + tap(console.log), + map((data: RemoteData) => { + if (data.hasSucceeded) { + return data.payload.page; + } + return []; + }) ); } } diff --git a/src/app/shared/dso-page/dso-edit-menu.resolver.ts b/src/app/shared/dso-page/dso-edit-menu.resolver.ts index 2b270abc76..6e4985cfa3 100644 --- a/src/app/shared/dso-page/dso-edit-menu.resolver.ts +++ b/src/app/shared/dso-page/dso-edit-menu.resolver.ts @@ -8,7 +8,10 @@ import { LinkMenuItemModel } from '../menu/menu-item/models/link.model'; import { Item } from '../../core/shared/item.model'; import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; import { OnClickMenuItemModel } from '../menu/menu-item/models/onclick.model'; -import { getFirstCompletedRemoteData } from '../../core/shared/operators'; +import { + getFirstCompletedRemoteData, + getRemoteDataPayload +} from '../../core/shared/operators'; import { map, switchMap } from 'rxjs/operators'; import { DSpaceObjectDataService } from '../../core/data/dspace-object-data.service'; import { URLCombiner } from '../../core/url-combiner/url-combiner'; @@ -22,6 +25,13 @@ import { ResearcherProfileDataService } from '../../core/profile/researcher-prof import { NotificationsService } from '../notifications/notifications.service'; import { TranslateService } from '@ngx-translate/core'; import { DsoWithdrawnReinstateModalService } from './dso-withdrawn-reinstate-service/dso-withdrawn-reinstate-modal.service'; +import { EPerson } from '../../core/eperson/models/eperson.model'; +import { AuthService } from '../../core/auth/auth.service'; +import { + QualityAssuranceSourceDataService +} from '../../core/suggestion-notifications/qa/source/quality-assurance-source-data.service'; +import { FindListOptions } from '../../core/data/find-list-options.model'; +import { RequestParam } from '../../core/cache/models/request-param.model'; /** * Creates the menus for the dspace object pages @@ -40,7 +50,9 @@ export class DSOEditMenuResolver implements Resolve<{ [key: string]: MenuSection protected researcherProfileService: ResearcherProfileDataService, protected notificationsService: NotificationsService, protected translate: TranslateService, - protected dsoWithdrawnReinstateModalService: DsoWithdrawnReinstateModalService + protected dsoWithdrawnReinstateModalService: DsoWithdrawnReinstateModalService, + private auth: AuthService, + private qualityAssuranceSourceDataService: QualityAssuranceSourceDataService ) { } @@ -121,16 +133,20 @@ export class DSOEditMenuResolver implements Resolve<{ [key: string]: MenuSection */ protected getItemMenu(dso): Observable { if (dso instanceof Item) { + const findListTopicOptions: FindListOptions = { + searchParams: [new RequestParam('target', dso.uuid)] + }; return combineLatest([ this.authorizationService.isAuthorized(FeatureID.CanCreateVersion, dso.self), this.dsoVersioningModalService.isNewVersionButtonDisabled(dso), this.dsoVersioningModalService.getVersioningTooltipMessage(dso, 'item.page.version.hasDraft', 'item.page.version.create'), this.authorizationService.isAuthorized(FeatureID.CanSynchronizeWithORCID, dso.self), this.authorizationService.isAuthorized(FeatureID.CanClaimItem, dso.self), - this.authorizationService.isAuthorized(FeatureID.WithdrawItem, dso.self,), - this.authorizationService.isAuthorized(FeatureID.ReinstateItem, dso.self) + this.qualityAssuranceSourceDataService.getSourcesByTarget(findListTopicOptions).pipe( + getFirstCompletedRemoteData(), + getRemoteDataPayload()) ]).pipe( - map(([canCreateVersion, disableVersioning, versionTooltip, canSynchronizeWithOrcid, canClaimItem, canWithdrawItem, canReinstateItem]) => { + map(([canCreateVersion, disableVersioning, versionTooltip, canSynchronizeWithOrcid, canClaimItem, correction]) => { const isPerson = this.getDsoType(dso) === 'person'; return [ { @@ -177,12 +193,12 @@ export class DSOEditMenuResolver implements Resolve<{ [key: string]: MenuSection { id: 'withdrawn-item', active: false, - visible: canWithdrawItem, + visible: dso.isArchived && correction.totalElements === 0, model: { type: MenuItemType.ONCLICK, text:'item.page.withdrawn', function: () => { - this.dsoWithdrawnReinstateModalService.openCreateWithdrawnReinstateModal(dso, 'request-withdrawn', canWithdrawItem); + this.dsoWithdrawnReinstateModalService.openCreateWithdrawnReinstateModal(dso, 'request-withdrawn', dso.isArchived && correction.totalElements === 0); } } as OnClickMenuItemModel, icon: 'lock', @@ -191,12 +207,12 @@ export class DSOEditMenuResolver implements Resolve<{ [key: string]: MenuSection { id: 'reinstate-item', active: false, - visible: canReinstateItem, + visible: dso.isWithdrawn && correction.totalElements === 0, model: { type: MenuItemType.ONCLICK, text:'item.page.reinstate', function: () => { - this.dsoWithdrawnReinstateModalService.openCreateWithdrawnReinstateModal(dso, 'request-reinstate', canWithdrawItem); + this.dsoWithdrawnReinstateModalService.openCreateWithdrawnReinstateModal(dso, 'request-reinstate', dso.isWithdrawn && correction.totalElements === 0); } } as OnClickMenuItemModel, icon: 'unlock-keyhole', @@ -258,4 +274,5 @@ export class DSOEditMenuResolver implements Resolve<{ [key: string]: MenuSection return menu; }); } + } diff --git a/src/app/shared/dso-page/dso-withdrawn-reinstate-service/dso-withdrawn-reinstate-modal.service.ts b/src/app/shared/dso-page/dso-withdrawn-reinstate-service/dso-withdrawn-reinstate-modal.service.ts index ce491a89a5..242a5c1fc4 100644 --- a/src/app/shared/dso-page/dso-withdrawn-reinstate-service/dso-withdrawn-reinstate-modal.service.ts +++ b/src/app/shared/dso-page/dso-withdrawn-reinstate-service/dso-withdrawn-reinstate-modal.service.ts @@ -38,7 +38,7 @@ export class DsoWithdrawnReinstateModalService { const target = dso.id; // Open modal const activeModal = this.modalService.open(ItemWithdrawnReinstateModalComponent); - (activeModal.componentInstance as ItemWithdrawnReinstateModalComponent).setWithdraw(!state); + (activeModal.componentInstance as ItemWithdrawnReinstateModalComponent).setWithdraw(state); (activeModal.componentInstance as ItemWithdrawnReinstateModalComponent).createQAEvent .pipe( take(1) diff --git a/src/app/shared/shared.module.ts b/src/app/shared/shared.module.ts index 2881d46c2b..b2b2420f10 100644 --- a/src/app/shared/shared.module.ts +++ b/src/app/shared/shared.module.ts @@ -288,6 +288,9 @@ import { QualityAssuranceEventDataService } from '../core/suggestion-notifications/qa/events/quality-assurance-event-data.service'; import { SplitPipe } from './utils/split.pipe'; +import { + QualityAssuranceSourceDataService +} from '../core/suggestion-notifications/qa/source/quality-assurance-source-data.service'; const MODULES = [ CommonModule, @@ -477,7 +480,8 @@ const PROVIDERS = [ TruncatableService, MockAdminGuard, AbstractTrackableComponent, - QualityAssuranceEventDataService + QualityAssuranceEventDataService, + QualityAssuranceSourceDataService ]; const DIRECTIVES = [ diff --git a/src/app/suggestion-notifications/qa/topics/quality-assurance-topics.actions.ts b/src/app/suggestion-notifications/qa/topics/quality-assurance-topics.actions.ts index 2459d4352a..482a85a988 100644 --- a/src/app/suggestion-notifications/qa/topics/quality-assurance-topics.actions.ts +++ b/src/app/suggestion-notifications/qa/topics/quality-assurance-topics.actions.ts @@ -25,6 +25,8 @@ export class RetrieveAllTopicsAction implements Action { payload: { elementsPerPage: number; currentPage: number; + source: string; + target?: string; }; /** @@ -35,10 +37,12 @@ export class RetrieveAllTopicsAction implements Action { * @param currentPage * The page number to retrieve */ - constructor(elementsPerPage: number, currentPage: number) { + constructor(elementsPerPage: number, currentPage: number, source: string, target?: string) { this.payload = { elementsPerPage, - currentPage + currentPage, + source, + target }; } } diff --git a/src/app/suggestion-notifications/qa/topics/quality-assurance-topics.component.html b/src/app/suggestion-notifications/qa/topics/quality-assurance-topics.component.html index db8586f264..ed91bbf6ca 100644 --- a/src/app/suggestion-notifications/qa/topics/quality-assurance-topics.component.html +++ b/src/app/suggestion-notifications/qa/topics/quality-assurance-topics.component.html @@ -2,7 +2,11 @@

{{'quality-assurance.title'| translate}}

- {{'quality-assurance.topics.description'| translate:{source: sourceId} }} + {{'quality-assurance.topics.description'| translate:{source: sourceId} }} + + {{'quality-assurance.topics.description-with-target'| translate:{source: sourceId} }} + {{(getTargetItemTitle() | async)}} +
@@ -15,7 +19,7 @@ [collectionSize]="(totalElements$ | async)" [hideGear]="false" [hideSortOptions]="true" - (paginationChange)="getQualityAssuranceTopics()"> + (paginationChange)="getQualityAssuranceTopics(sourceId, targetId)"> diff --git a/src/app/suggestion-notifications/qa/topics/quality-assurance-topics.component.ts b/src/app/suggestion-notifications/qa/topics/quality-assurance-topics.component.ts index 3c8b4f8f38..0f7a111089 100644 --- a/src/app/suggestion-notifications/qa/topics/quality-assurance-topics.component.ts +++ b/src/app/suggestion-notifications/qa/topics/quality-assurance-topics.component.ts @@ -1,7 +1,7 @@ import { Component, OnInit } from '@angular/core'; import { Observable, Subscription } from 'rxjs'; -import { distinctUntilChanged, take } from 'rxjs/operators'; +import { distinctUntilChanged, map, take, tap } from 'rxjs/operators'; import { SortOptions } from '../../../core/cache/models/sort-options.model'; import { @@ -15,7 +15,10 @@ import { } from '../../../admin/admin-notifications/admin-quality-assurance-topics-page/admin-quality-assurance-topics-page-resolver.service'; import { PaginationService } from '../../../core/pagination/pagination.service'; import { ActivatedRoute } from '@angular/router'; -import { QualityAssuranceTopicsService } from './quality-assurance-topics.service'; +import { ItemDataService } from '../../../core/data/item-data.service'; +import { getFirstCompletedRemoteData, getRemoteDataPayload } from '../../../core/shared/operators'; +import { Item } from '../../../core/shared/item.model'; +import { getItemPageRoute } from '../../../item-page/item-page-routing-paths'; /** * Component to display the Quality Assurance topic list. @@ -60,6 +63,17 @@ export class QualityAssuranceTopicsComponent implements OnInit { */ public sourceId: string; + /** + * This property represents a targetId (item-id) which is used to retrive a topic + * @type {string} + */ + public targetId: string; + + /** + * The URL of the item page. + */ + public itemPageUrl: string; + /** * Initialize the component variables. * @param {PaginationService} paginationService @@ -71,16 +85,16 @@ export class QualityAssuranceTopicsComponent implements OnInit { private paginationService: PaginationService, private activatedRoute: ActivatedRoute, private notificationsStateService: SuggestionNotificationsStateService, - private qualityAssuranceTopicsService: QualityAssuranceTopicsService + private itemService: ItemDataService ) { + this.sourceId = this.activatedRoute.snapshot.params.sourceId; + this.targetId = this.activatedRoute.snapshot.params.targetId; } /** * Component initialization. */ ngOnInit(): void { - this.sourceId = this.activatedRoute.snapshot.paramMap.get('sourceId'); - this.qualityAssuranceTopicsService.setSourceId(this.sourceId); this.topics$ = this.notificationsStateService.getQualityAssuranceTopics(); this.totalElements$ = this.notificationsStateService.getQualityAssuranceTopicsTotals(); } @@ -93,7 +107,7 @@ export class QualityAssuranceTopicsComponent implements OnInit { this.notificationsStateService.isQualityAssuranceTopicsLoaded().pipe( take(1) ).subscribe(() => { - this.getQualityAssuranceTopics(); + this.getQualityAssuranceTopics(this.sourceId, this.targetId); }) ); } @@ -121,13 +135,15 @@ export class QualityAssuranceTopicsComponent implements OnInit { /** * Dispatch the Quality Assurance topics retrival. */ - public getQualityAssuranceTopics(): void { + public getQualityAssuranceTopics(source: string, target?: string): void { this.paginationService.getCurrentPagination(this.paginationConfig.id, this.paginationConfig).pipe( distinctUntilChanged(), ).subscribe((options: PaginationComponentOptions) => { this.notificationsStateService.dispatchRetrieveQualityAssuranceTopics( options.pageSize, - options.currentPage + options.currentPage, + source, + target ); }); } @@ -150,6 +166,32 @@ export class QualityAssuranceTopicsComponent implements OnInit { } } + /** + * Returns an Observable that emits the title of the target item. + * The target item is retrieved by its ID using the itemService. + * The title is extracted from the first metadata value of the item. + * The item page URL is also set in the component. + * @returns An Observable that emits the title of the target item. + */ + getTargetItemTitle(): Observable { + return this.itemService.findById(this.targetId).pipe( + take(1), + getFirstCompletedRemoteData(), + getRemoteDataPayload(), + tap((item: Item) => this.itemPageUrl = getItemPageRoute(item)), + map((item: Item) => item.firstMetadataValue('dc.title')) + ); + } + + /** + * Returns the page route for the given item. + * @param item The item to get the page route for. + * @returns The page route for the given item. + */ + getItemPageRoute(item: Item): string { + return getItemPageRoute(item); + } + /** * Unsubscribe from all subscriptions. */ diff --git a/src/app/suggestion-notifications/qa/topics/quality-assurance-topics.effects.ts b/src/app/suggestion-notifications/qa/topics/quality-assurance-topics.effects.ts index 13e3670000..92d7dc9e21 100644 --- a/src/app/suggestion-notifications/qa/topics/quality-assurance-topics.effects.ts +++ b/src/app/suggestion-notifications/qa/topics/quality-assurance-topics.effects.ts @@ -37,7 +37,9 @@ export class QualityAssuranceTopicsEffects { switchMap(([action, currentState]: [RetrieveAllTopicsAction, any]) => { return this.qualityAssuranceTopicService.getTopics( action.payload.elementsPerPage, - action.payload.currentPage + action.payload.currentPage, + action.payload.source, + action.payload.target ).pipe( map((topics: PaginatedList) => new AddTopicsAction(topics.page, topics.totalPages, topics.currentPage, topics.totalElements) diff --git a/src/app/suggestion-notifications/qa/topics/quality-assurance-topics.service.ts b/src/app/suggestion-notifications/qa/topics/quality-assurance-topics.service.ts index 6820791dff..4144cd8875 100644 --- a/src/app/suggestion-notifications/qa/topics/quality-assurance-topics.service.ts +++ b/src/app/suggestion-notifications/qa/topics/quality-assurance-topics.service.ts @@ -13,6 +13,7 @@ import { import { RequestParam } from '../../../core/cache/models/request-param.model'; import { FindListOptions } from '../../../core/data/find-list-options.model'; import { getFirstCompletedRemoteData } from '../../../core/shared/operators'; +import { hasValue } from '../../../shared/empty.util'; /** * The service handling all Quality Assurance topic requests to the REST service. @@ -28,10 +29,6 @@ export class QualityAssuranceTopicsService { private qualityAssuranceTopicRestService: QualityAssuranceTopicDataService ) { } - /** - * sourceId used to get topics - */ - sourceId: string; /** * Return the list of Quality Assurance topics managing pagination and errors. @@ -43,17 +40,25 @@ export class QualityAssuranceTopicsService { * @return Observable> * The list of Quality Assurance topics. */ - public getTopics(elementsPerPage, currentPage): Observable> { + public getTopics(elementsPerPage, currentPage, source: string, target?: string): Observable> { const sortOptions = new SortOptions('name', SortDirection.ASC); - const findListOptions: FindListOptions = { elementsPerPage: elementsPerPage, currentPage: currentPage, sort: sortOptions, - searchParams: [new RequestParam('source', this.sourceId)] + searchParams: [new RequestParam('source', source)] }; - return this.qualityAssuranceTopicRestService.getTopics(findListOptions).pipe( + let request$: Observable>>; + + if (hasValue(target)) { + findListOptions.searchParams.push(new RequestParam('target', target)); + request$ = this.qualityAssuranceTopicRestService.searchTopicsByTarget(findListOptions); + } else { + request$ = this.qualityAssuranceTopicRestService.searchTopicsBySource(findListOptions); + } + + return request$.pipe( getFirstCompletedRemoteData(), map((rd: RemoteData>) => { if (rd.hasSucceeded) { @@ -64,12 +69,4 @@ export class QualityAssuranceTopicsService { }) ); } - - /** - * set sourceId which is used to get topics - * @param sourceId string - */ - setSourceId(sourceId: string) { - this.sourceId = sourceId; - } } diff --git a/src/app/suggestion-notifications/suggestion-notifications-state.service.ts b/src/app/suggestion-notifications/suggestion-notifications-state.service.ts index ec1ea2e039..1fc5422018 100644 --- a/src/app/suggestion-notifications/suggestion-notifications-state.service.ts +++ b/src/app/suggestion-notifications/suggestion-notifications-state.service.ts @@ -118,8 +118,8 @@ export class SuggestionNotificationsStateService { * @param currentPage * The number of the current page. */ - public dispatchRetrieveQualityAssuranceTopics(elementsPerPage: number, currentPage: number): void { - this.store.dispatch(new RetrieveAllTopicsAction(elementsPerPage, currentPage)); + public dispatchRetrieveQualityAssuranceTopics(elementsPerPage: number, currentPage: number, sourceId: string, targteId?: string): void { + this.store.dispatch(new RetrieveAllTopicsAction(elementsPerPage, currentPage, sourceId, targteId)); } // Quality Assurance source diff --git a/src/assets/i18n/en.json5 b/src/assets/i18n/en.json5 index 435e0a3058..f277a93423 100644 --- a/src/assets/i18n/en.json5 +++ b/src/assets/i18n/en.json5 @@ -2604,6 +2604,10 @@ "item.qa.withdrawn.modal.submitted.header": "Sending withdrawn request...", + "item.qa-event-notification.check.notification-withdrawn": "You have requested to withdrawn this item.", + + "item.qa-event-notification-undo-withdrawn.check.button": "Undo request withdrawal", + "item.version.create.modal.submitted.text": "The new version is being created. This may take some time if the item has a lot of relationships.", "item.version.create.notification.success": "New version has been created with version number {{version}}",