mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
[CST-5337] Fix issue with list that wasn't updated after last element has been processed
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnDestroy, OnInit } from '@angular/core';
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { ActivatedRoute } from '@angular/router';
|
||||||
|
|
||||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
||||||
@@ -10,25 +10,27 @@ import { SortDirection, SortOptions } from '../../../core/cache/models/sort-opti
|
|||||||
import { PaginatedList } from '../../../core/data/paginated-list.model';
|
import { PaginatedList } from '../../../core/data/paginated-list.model';
|
||||||
import { RemoteData } from '../../../core/data/remote-data';
|
import { RemoteData } from '../../../core/data/remote-data';
|
||||||
import {
|
import {
|
||||||
QualityAssuranceEventObject,
|
OpenaireQualityAssuranceEventMessageObject,
|
||||||
OpenaireQualityAssuranceEventMessageObject
|
QualityAssuranceEventObject
|
||||||
} from '../../../core/suggestion-notifications/qa/models/quality-assurance-event.model';
|
} from '../../../core/suggestion-notifications/qa/models/quality-assurance-event.model';
|
||||||
import { QualityAssuranceEventRestService } from '../../../core/suggestion-notifications/qa/events/quality-assurance-event-rest.service';
|
import {
|
||||||
|
QualityAssuranceEventRestService
|
||||||
|
} from '../../../core/suggestion-notifications/qa/events/quality-assurance-event-rest.service';
|
||||||
import { PaginationComponentOptions } from '../../../shared/pagination/pagination-component-options.model';
|
import { PaginationComponentOptions } from '../../../shared/pagination/pagination-component-options.model';
|
||||||
import { Metadata } from '../../../core/shared/metadata.utils';
|
import { Metadata } from '../../../core/shared/metadata.utils';
|
||||||
import { followLink } from '../../../shared/utils/follow-link-config.model';
|
import { followLink } from '../../../shared/utils/follow-link-config.model';
|
||||||
import { hasValue } from '../../../shared/empty.util';
|
import { hasValue, isEmpty } from '../../../shared/empty.util';
|
||||||
import { ItemSearchResult } from '../../../shared/object-collection/shared/item-search-result.model';
|
import { ItemSearchResult } from '../../../shared/object-collection/shared/item-search-result.model';
|
||||||
import { NotificationsService } from '../../../shared/notifications/notifications.service';
|
import { NotificationsService } from '../../../shared/notifications/notifications.service';
|
||||||
import {
|
import {
|
||||||
QualityAssuranceEventData,
|
ProjectEntryImportModalComponent,
|
||||||
ProjectEntryImportModalComponent
|
QualityAssuranceEventData
|
||||||
} from '../project-entry-import-modal/project-entry-import-modal.component';
|
} from '../project-entry-import-modal/project-entry-import-modal.component';
|
||||||
import { getFirstCompletedRemoteData } from '../../../core/shared/operators';
|
import { getFirstCompletedRemoteData } from '../../../core/shared/operators';
|
||||||
import { PaginationService } from '../../../core/pagination/pagination.service';
|
import { PaginationService } from '../../../core/pagination/pagination.service';
|
||||||
import { combineLatest } from 'rxjs/internal/observable/combineLatest';
|
import { combineLatest } from 'rxjs/internal/observable/combineLatest';
|
||||||
import { Item } from '../../../core/shared/item.model';
|
import { Item } from '../../../core/shared/item.model';
|
||||||
import {FindListOptions} from '../../../core/data/find-list-options.model';
|
import { FindListOptions } from '../../../core/data/find-list-options.model';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component to display the Quality Assurance event list.
|
* Component to display the Quality Assurance event list.
|
||||||
@@ -38,7 +40,7 @@ import {FindListOptions} from '../../../core/data/find-list-options.model';
|
|||||||
templateUrl: './quality-assurance-events.component.html',
|
templateUrl: './quality-assurance-events.component.html',
|
||||||
styleUrls: ['./quality-assurance-events.scomponent.scss'],
|
styleUrls: ['./quality-assurance-events.scomponent.scss'],
|
||||||
})
|
})
|
||||||
export class QualityAssuranceEventsComponent implements OnInit {
|
export class QualityAssuranceEventsComponent implements OnInit, OnDestroy {
|
||||||
/**
|
/**
|
||||||
* The pagination system configuration for HTML listing.
|
* The pagination system configuration for HTML listing.
|
||||||
* @type {PaginationComponentOptions}
|
* @type {PaginationComponentOptions}
|
||||||
@@ -376,47 +378,50 @@ export class QualityAssuranceEventsComponent implements OnInit {
|
|||||||
* the Quality Assurance event item
|
* the Quality Assurance event item
|
||||||
*/
|
*/
|
||||||
protected setEventUpdated(events: QualityAssuranceEventObject[]): void {
|
protected setEventUpdated(events: QualityAssuranceEventObject[]): void {
|
||||||
this.subs.push(
|
if (isEmpty(events)) {
|
||||||
from(events).pipe(
|
this.eventsUpdated$.next([]);
|
||||||
mergeMap((event: QualityAssuranceEventObject) => {
|
} else {
|
||||||
const related$ = event.related.pipe(
|
this.subs.push(
|
||||||
getFirstCompletedRemoteData(),
|
from(events).pipe(
|
||||||
);
|
mergeMap((event: QualityAssuranceEventObject) => {
|
||||||
const target$ = event.target.pipe(
|
const related$ = event.related.pipe(
|
||||||
getFirstCompletedRemoteData()
|
getFirstCompletedRemoteData(),
|
||||||
);
|
);
|
||||||
return combineLatest([related$, target$]).pipe(
|
const target$ = event.target.pipe(
|
||||||
map(([relatedItemRD, targetItemRD]: [RemoteData<Item>, RemoteData<Item>]) => {
|
getFirstCompletedRemoteData()
|
||||||
const data: QualityAssuranceEventData = {
|
);
|
||||||
event: event,
|
return combineLatest([related$, target$]).pipe(
|
||||||
id: event.id,
|
map(([relatedItemRD, targetItemRD]: [RemoteData<Item>, RemoteData<Item>]) => {
|
||||||
title: event.title,
|
const data: QualityAssuranceEventData = {
|
||||||
hasProject: false,
|
event: event,
|
||||||
projectTitle: null,
|
id: event.id,
|
||||||
projectId: null,
|
title: event.title,
|
||||||
handle: null,
|
hasProject: false,
|
||||||
reason: null,
|
projectTitle: null,
|
||||||
isRunning: false,
|
projectId: null,
|
||||||
target: (targetItemRD?.hasSucceeded) ? targetItemRD.payload : null,
|
handle: null,
|
||||||
};
|
reason: null,
|
||||||
if (relatedItemRD?.hasSucceeded && relatedItemRD?.payload?.id) {
|
isRunning: false,
|
||||||
data.hasProject = true;
|
target: (targetItemRD?.hasSucceeded) ? targetItemRD.payload : null,
|
||||||
data.projectTitle = event.message.title;
|
};
|
||||||
data.projectId = relatedItemRD?.payload?.id;
|
if (relatedItemRD?.hasSucceeded && relatedItemRD?.payload?.id) {
|
||||||
data.handle = relatedItemRD?.payload?.handle;
|
data.hasProject = true;
|
||||||
}
|
data.projectTitle = event.message.title;
|
||||||
return data;
|
data.projectId = relatedItemRD?.payload?.id;
|
||||||
})
|
data.handle = relatedItemRD?.payload?.handle;
|
||||||
);
|
}
|
||||||
}),
|
return data;
|
||||||
scan((acc: any, value: any) => [...acc, value], []),
|
})
|
||||||
take(events.length)
|
);
|
||||||
).subscribe(
|
}),
|
||||||
(eventsReduced) => {
|
scan((acc: any, value: any) => [...acc, value], []),
|
||||||
this.eventsUpdated$.next(eventsReduced);
|
take(events.length)
|
||||||
}
|
).subscribe((eventsReduced) => {
|
||||||
)
|
this.eventsUpdated$.next(eventsReduced);
|
||||||
);
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected computePIDHref(event: OpenaireQualityAssuranceEventMessageObject) {
|
protected computePIDHref(event: OpenaireQualityAssuranceEventMessageObject) {
|
||||||
|
Reference in New Issue
Block a user