mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
[DURACOM-234] Remove assertions on isResponsePending in favour of remote data operators
This commit is contained in:
@@ -28,7 +28,10 @@ import { Community } from '../shared/community.model';
|
||||
import { ContentSource } from '../shared/content-source.model';
|
||||
import { HALEndpointService } from '../shared/hal-endpoint.service';
|
||||
import { Item } from '../shared/item.model';
|
||||
import { getFirstCompletedRemoteData } from '../shared/operators';
|
||||
import {
|
||||
getAllCompletedRemoteData,
|
||||
getFirstCompletedRemoteData,
|
||||
} from '../shared/operators';
|
||||
import { BitstreamDataService } from './bitstream-data.service';
|
||||
import { ComColDataService } from './comcol-data.service';
|
||||
import { CommunityDataService } from './community-data.service';
|
||||
@@ -84,7 +87,8 @@ export class CollectionDataService extends ComColDataService<Collection> {
|
||||
});
|
||||
|
||||
return this.searchBy(searchHref, options, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow).pipe(
|
||||
filter((collections: RemoteData<PaginatedList<Collection>>) => !collections.isResponsePending));
|
||||
getAllCompletedRemoteData(),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,7 +118,8 @@ export class CollectionDataService extends ComColDataService<Collection> {
|
||||
});
|
||||
|
||||
return this.searchBy(searchHref, options, true, reRequestOnStale, ...linksToFollow).pipe(
|
||||
filter((collections: RemoteData<PaginatedList<Collection>>) => !collections.isResponsePending));
|
||||
getAllCompletedRemoteData(),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -138,7 +143,8 @@ export class CollectionDataService extends ComColDataService<Collection> {
|
||||
});
|
||||
|
||||
return this.searchBy(searchHref, options, reRequestOnStale).pipe(
|
||||
filter((collections: RemoteData<PaginatedList<Collection>>) => !collections.isResponsePending));
|
||||
getAllCompletedRemoteData(),
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Get all collections the user is authorized to submit to, by community and has the metadata
|
||||
@@ -169,7 +175,8 @@ export class CollectionDataService extends ComColDataService<Collection> {
|
||||
});
|
||||
|
||||
return this.searchBy(searchHref, options, true, reRequestOnStale, ...linksToFollow).pipe(
|
||||
filter((collections: RemoteData<PaginatedList<Collection>>) => !collections.isResponsePending));
|
||||
getAllCompletedRemoteData(),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -184,9 +191,8 @@ export class CollectionDataService extends ComColDataService<Collection> {
|
||||
options.elementsPerPage = 1;
|
||||
|
||||
return this.searchBy(searchHref, options).pipe(
|
||||
filter((collections: RemoteData<PaginatedList<Collection>>) => !collections.isResponsePending),
|
||||
take(1),
|
||||
map((collections: RemoteData<PaginatedList<Collection>>) => collections.payload.totalElements > 0),
|
||||
getFirstCompletedRemoteData(),
|
||||
map((collections: RemoteData<PaginatedList<Collection>>) => collections?.payload?.totalElements > 0),
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -1,7 +1,6 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import {
|
||||
filter,
|
||||
map,
|
||||
switchMap,
|
||||
take,
|
||||
@@ -14,6 +13,7 @@ import { HALEndpointService } from '../shared/hal-endpoint.service';
|
||||
import { ItemType } from '../shared/item-relationships/item-type.model';
|
||||
import { RelationshipType } from '../shared/item-relationships/relationship-type.model';
|
||||
import {
|
||||
getAllCompletedRemoteData,
|
||||
getFirstSucceededRemoteData,
|
||||
getRemoteDataPayload,
|
||||
} from '../shared/operators';
|
||||
@@ -89,8 +89,7 @@ export class EntityTypeDataService extends BaseDataService<ItemType> implements
|
||||
getAllAuthorizedRelationshipType(options: FindListOptions = {}): Observable<RemoteData<PaginatedList<ItemType>>> {
|
||||
const searchHref = 'findAllByAuthorizedCollection';
|
||||
|
||||
return this.searchBy(searchHref, options).pipe(
|
||||
filter((type: RemoteData<PaginatedList<ItemType>>) => !type.isResponsePending));
|
||||
return this.searchBy(searchHref, options).pipe(getAllCompletedRemoteData());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -123,8 +122,7 @@ export class EntityTypeDataService extends BaseDataService<ItemType> implements
|
||||
getAllAuthorizedRelationshipTypeImport(options: FindListOptions = {}): Observable<RemoteData<PaginatedList<ItemType>>> {
|
||||
const searchHref = 'findAllByAuthorizedExternalSource';
|
||||
|
||||
return this.searchBy(searchHref, options).pipe(
|
||||
filter((type: RemoteData<PaginatedList<ItemType>>) => !type.isResponsePending));
|
||||
return this.searchBy(searchHref, options).pipe(getAllCompletedRemoteData());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -136,15 +134,8 @@ export class EntityTypeDataService extends BaseDataService<ItemType> implements
|
||||
currentPage: 1,
|
||||
};
|
||||
return this.getAllAuthorizedRelationshipTypeImport(findListOptions).pipe(
|
||||
map((result: RemoteData<PaginatedList<ItemType>>) => {
|
||||
let output: boolean;
|
||||
if (result.payload) {
|
||||
output = ( result.payload.page.length > 1 );
|
||||
} else {
|
||||
output = false;
|
||||
}
|
||||
return output;
|
||||
}),
|
||||
take(1),
|
||||
map((result: RemoteData<PaginatedList<ItemType>>) => result?.payload?.totalElements > 1),
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -7,13 +7,13 @@ import {
|
||||
Input,
|
||||
OnInit,
|
||||
} from '@angular/core';
|
||||
import { find } from 'rxjs/operators';
|
||||
|
||||
import { DSONameService } from '../../../../core/breadcrumbs/dso-name.service';
|
||||
import { RemoteData } from '../../../../core/data/remote-data';
|
||||
import { GroupDataService } from '../../../../core/eperson/group-data.service';
|
||||
import { Group } from '../../../../core/eperson/models/group.model';
|
||||
import { ResourcePolicy } from '../../../../core/resource-policy/models/resource-policy.model';
|
||||
import { getFirstCompletedRemoteData } from '../../../../core/shared/operators';
|
||||
import { isEmpty } from '../../../../shared/empty.util';
|
||||
|
||||
/**
|
||||
@@ -55,13 +55,15 @@ export class SubmissionSectionUploadAccessConditionsComponent implements OnInit
|
||||
this.accessConditions.forEach((accessCondition: ResourcePolicy) => {
|
||||
if (isEmpty(accessCondition.name)) {
|
||||
this.groupService.findByHref(accessCondition._links.group.href).pipe(
|
||||
find((rd: RemoteData<Group>) => !rd.isResponsePending && rd.hasSucceeded))
|
||||
.subscribe((rd: RemoteData<Group>) => {
|
||||
getFirstCompletedRemoteData(),
|
||||
).subscribe((rd: RemoteData<Group>) => {
|
||||
if (rd.hasSucceeded) {
|
||||
const group: Group = rd.payload;
|
||||
const accessConditionEntry = Object.assign({}, accessCondition);
|
||||
accessConditionEntry.name = this.dsoNameService.getName(group);
|
||||
this.accessConditionsList.push(accessConditionEntry);
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.accessConditionsList.push(accessCondition);
|
||||
}
|
||||
|
Reference in New Issue
Block a user