mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
solved final caching/debounce issues, working on getting the submission to work with the rest endpoint again
This commit is contained in:
@@ -6,5 +6,4 @@ export class MockResponseMap extends Map<string, any> {};
|
|||||||
export const MOCK_RESPONSE_MAP: InjectionToken<MockResponseMap> = new InjectionToken<MockResponseMap>('mockResponseMap');
|
export const MOCK_RESPONSE_MAP: InjectionToken<MockResponseMap> = new InjectionToken<MockResponseMap>('mockResponseMap');
|
||||||
|
|
||||||
export const mockResponseMap: MockResponseMap = new Map([
|
export const mockResponseMap: MockResponseMap = new Map([
|
||||||
[ '/config/submissionforms/traditionalpageone', mockSubmissionResponse ]
|
|
||||||
]);
|
]);
|
||||||
|
@@ -25,6 +25,11 @@ export class RelationshipEffects {
|
|||||||
[identifier: string]: BehaviorSubject<boolean>
|
[identifier: string]: BehaviorSubject<boolean>
|
||||||
} = {};
|
} = {};
|
||||||
|
|
||||||
|
private initialStateMap: {
|
||||||
|
[identifier: string]: boolean
|
||||||
|
} = {};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Effect that makes sure all last fired ObjectUpdatesActions are stored in the map of this service, with the url as their key
|
* Effect that makes sure all last fired ObjectUpdatesActions are stored in the map of this service, with the url as their key
|
||||||
*/
|
*/
|
||||||
@@ -35,9 +40,19 @@ export class RelationshipEffects {
|
|||||||
const { item1, item2, relationshipType } = action.payload;
|
const { item1, item2, relationshipType } = action.payload;
|
||||||
const identifier: string = this.createIdentifier(item1, item2, relationshipType);
|
const identifier: string = this.createIdentifier(item1, item2, relationshipType);
|
||||||
if (hasNoValue(this.debounceMap[identifier])) {
|
if (hasNoValue(this.debounceMap[identifier])) {
|
||||||
|
this.initialStateMap[identifier] = !action.exists;
|
||||||
this.debounceMap[identifier] = new BehaviorSubject<boolean>(action.exists);
|
this.debounceMap[identifier] = new BehaviorSubject<boolean>(action.exists);
|
||||||
this.debounceMap[identifier].pipe(debounceTime(DEBOUNCE_TIME)).subscribe(
|
this.debounceMap[identifier].pipe(
|
||||||
(exists) => exists ? this.addRelationship(item1, item2, relationshipType) : this.removeRelationship(item1, item2, relationshipType)
|
debounceTime(DEBOUNCE_TIME),
|
||||||
|
take(1)
|
||||||
|
).subscribe(
|
||||||
|
(exists) => {
|
||||||
|
if (this.initialStateMap[identifier] !== exists) {
|
||||||
|
exists ? this.addRelationship(item1, item2, relationshipType) : this.removeRelationship(item1, item2, relationshipType);
|
||||||
|
}
|
||||||
|
delete this.debounceMap[identifier];
|
||||||
|
delete this.initialStateMap[identifier];
|
||||||
|
}
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
this.debounceMap[identifier].next(action.exists);
|
this.debounceMap[identifier].next(action.exists);
|
||||||
@@ -59,7 +74,6 @@ export class RelationshipEffects {
|
|||||||
|
|
||||||
|
|
||||||
private addRelationship(item1: Item, item2: Item, relationshipType: string) {
|
private addRelationship(item1: Item, item2: Item, relationshipType: string) {
|
||||||
console.log('add', item2.uuid);
|
|
||||||
const type1: string = item1.firstMetadataValue('relationship.type');
|
const type1: string = item1.firstMetadataValue('relationship.type');
|
||||||
const type2: string = item2.firstMetadataValue('relationship.type');
|
const type2: string = item2.firstMetadataValue('relationship.type');
|
||||||
return this.relationshipTypeService.getRelationshipTypeByLabelAndTypes(relationshipType, type1, type2)
|
return this.relationshipTypeService.getRelationshipTypeByLabelAndTypes(relationshipType, type1, type2)
|
||||||
@@ -78,9 +92,7 @@ export class RelationshipEffects {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private removeRelationship(item1: Item, item2: Item, relationshipType: string) {
|
private removeRelationship(item1: Item, item2: Item, relationshipType: string) {
|
||||||
console.log('remove', item2.uuid);
|
|
||||||
this.relationshipService.getRelationshipByItemsAndLabel(item1, item2, relationshipType).pipe(
|
this.relationshipService.getRelationshipByItemsAndLabel(item1, item2, relationshipType).pipe(
|
||||||
tap(t => console.log(t)),
|
|
||||||
take(1),
|
take(1),
|
||||||
hasValueOperator(),
|
hasValueOperator(),
|
||||||
mergeMap((relationship: Relationship) => this.relationshipService.deleteRelationship(relationship.id)),
|
mergeMap((relationship: Relationship) => this.relationshipService.deleteRelationship(relationship.id)),
|
||||||
|
@@ -197,7 +197,7 @@ export class SubmissionFormCollectionComponent implements OnChanges, OnInit {
|
|||||||
new PaginatedSearchOptions({
|
new PaginatedSearchOptions({
|
||||||
dsoType: DSpaceObjectType.COLLECTION,
|
dsoType: DSpaceObjectType.COLLECTION,
|
||||||
pagination: new PaginationComponentOptions(),
|
pagination: new PaginationComponentOptions(),
|
||||||
scope: 'c0e4de93-f506-4990-a840-d406f6f2ada7'
|
// scope: 'c0e4de93-f506-4990-a840-d406f6f2ada7'
|
||||||
})
|
})
|
||||||
).pipe(
|
).pipe(
|
||||||
getSucceededRemoteData(),
|
getSucceededRemoteData(),
|
||||||
|
Reference in New Issue
Block a user