mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
[CST-12109] "refresh" page refactor
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnChanges, SimpleChanges } from '@angular/core';
|
import { ChangeDetectionStrategy, Component, Input, OnChanges, SimpleChanges } from '@angular/core';
|
||||||
import { Item } from '../../../core/shared/item.model';
|
import { Item } from '../../../core/shared/item.model';
|
||||||
import { getFirstCompletedRemoteData } from '../../../core/shared/operators';
|
import { getFirstCompletedRemoteData } from '../../../core/shared/operators';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
@@ -10,7 +10,6 @@ import { map } from 'rxjs/operators';
|
|||||||
import { RemoteData } from '../../../core/data/remote-data';
|
import { RemoteData } from '../../../core/data/remote-data';
|
||||||
import { getNotificatioQualityAssuranceRoute } from '../../../admin/admin-routing-paths';
|
import { getNotificatioQualityAssuranceRoute } from '../../../admin/admin-routing-paths';
|
||||||
import { PaginatedList } from 'src/app/core/data/paginated-list.model';
|
import { PaginatedList } from 'src/app/core/data/paginated-list.model';
|
||||||
import { NavigationEnd, Router } from '@angular/router';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-qa-event-notification',
|
selector: 'ds-qa-event-notification',
|
||||||
@@ -37,16 +36,7 @@ export class QaEventNotificationComponent implements OnChanges {
|
|||||||
*/
|
*/
|
||||||
constructor(
|
constructor(
|
||||||
private qualityAssuranceSourceDataService: QualityAssuranceSourceDataService,
|
private qualityAssuranceSourceDataService: QualityAssuranceSourceDataService,
|
||||||
private router: Router,
|
) { }
|
||||||
private chd: ChangeDetectorRef
|
|
||||||
) {
|
|
||||||
this.router.events.pipe().subscribe((event) => {
|
|
||||||
if (event instanceof NavigationEnd) {
|
|
||||||
this.sources$ = this.getQualityAssuranceSources$();
|
|
||||||
this.chd.markForCheck();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Detect changes to the item input and update the sources$ observable.
|
* Detect changes to the item input and update the sources$ observable.
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
|
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
|
||||||
import { QualityAssuranceSourceDataService } from '../../core/notifications/qa/source/quality-assurance-source-data.service';
|
import { QualityAssuranceSourceDataService } from '../../core/notifications/qa/source/quality-assurance-source-data.service';
|
||||||
import { getFirstCompletedRemoteData, getPaginatedListPayload, getRemoteDataPayload } from '../../core/shared/operators';
|
import { getFirstCompletedRemoteData, getPaginatedListPayload, getRemoteDataPayload } from '../../core/shared/operators';
|
||||||
import { Observable, of, tap } from 'rxjs';
|
import { Observable, of } from 'rxjs';
|
||||||
import { QualityAssuranceSourceObject } from 'src/app/core/notifications/qa/models/quality-assurance-source.model';
|
import { QualityAssuranceSourceObject } from 'src/app/core/notifications/qa/models/quality-assurance-source.model';
|
||||||
import { getNotificatioQualityAssuranceRoute } from '../../admin/admin-routing-paths';
|
import { getNotificatioQualityAssuranceRoute } from '../../admin/admin-routing-paths';
|
||||||
|
|
||||||
@@ -30,11 +30,6 @@ export class MyDspaceQaEventsNotificationsComponent implements OnInit {
|
|||||||
this.sources$ = this.qualityAssuranceSourceDataService.getSources()
|
this.sources$ = this.qualityAssuranceSourceDataService.getSources()
|
||||||
.pipe(
|
.pipe(
|
||||||
getFirstCompletedRemoteData(),
|
getFirstCompletedRemoteData(),
|
||||||
tap((rd) => {
|
|
||||||
if (rd.hasFailed) {
|
|
||||||
throw new Error('Can\'t retrieve Quality Assurance sources');
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
getRemoteDataPayload(),
|
getRemoteDataPayload(),
|
||||||
getPaginatedListPayload(),
|
getPaginatedListPayload(),
|
||||||
);
|
);
|
||||||
|
@@ -50,6 +50,15 @@ export class DsoWithdrawnReinstateModalService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a quality assurance request.
|
||||||
|
*
|
||||||
|
* @param target - The target - the item's UUID.
|
||||||
|
* @param correctionType - The type of correction.
|
||||||
|
* @param reason - The reason for the request.
|
||||||
|
* Reloads the current page in order to update the withdrawn/reinstate button.
|
||||||
|
* and desplay a notification box.
|
||||||
|
*/
|
||||||
sendQARequest(target: string, correctionType: string, reason: string): void {
|
sendQARequest(target: string, correctionType: string, reason: string): void {
|
||||||
this.qaEventDataService.postData(target, correctionType, '', reason)
|
this.qaEventDataService.postData(target, correctionType, '', reason)
|
||||||
.pipe (
|
.pipe (
|
||||||
@@ -62,11 +71,24 @@ export class DsoWithdrawnReinstateModalService {
|
|||||||
const message = (correctionType === 'request-withdrawn') ? withdrawnMessage : reinstateMessage;
|
const message = (correctionType === 'request-withdrawn') ? withdrawnMessage : reinstateMessage;
|
||||||
this.notificationsService.success(this.translateService.get(message));
|
this.notificationsService.success(this.translateService.get(message));
|
||||||
this.authorizationService.invalidateAuthorizationsRequestCache();
|
this.authorizationService.invalidateAuthorizationsRequestCache();
|
||||||
this.router.navigate([this.router.url]); // refresh page
|
this.reloadPage(true);
|
||||||
} else {
|
} else {
|
||||||
this.notificationsService.error(this.translateService.get('correction-type.manage-relation.action.notification.error'));
|
this.notificationsService.error(this.translateService.get('correction-type.manage-relation.action.notification.error'));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reloads the current page or navigates to a specified URL.
|
||||||
|
* @param self - A boolean indicating whether to reload the current page (true) or navigate to a specified URL (false).
|
||||||
|
* @param urlToNavigateTo - The URL to navigate to if `self` is false.
|
||||||
|
* skipLocationChange:true means dont update the url to / when navigating
|
||||||
|
*/
|
||||||
|
reloadPage(self: boolean, urlToNavigateTo?: string) {
|
||||||
|
const url = self ? this.router.url : urlToNavigateTo;
|
||||||
|
this.router.navigateByUrl('/', { skipLocationChange: true }).then(() => {
|
||||||
|
this.router.navigate([`/${url}`]);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user