mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
fixed reordering request
This commit is contained in:
@@ -17,6 +17,7 @@ import { NormalizedObjectBuildService } from '../cache/builders/normalized-objec
|
|||||||
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
||||||
import { Item } from '../shared/item.model';
|
import { Item } from '../shared/item.model';
|
||||||
import * as uuidv4 from 'uuid/v4';
|
import * as uuidv4 from 'uuid/v4';
|
||||||
|
import { createSuccessfulRemoteDataObject$ } from '../../shared/testing/utils';
|
||||||
|
|
||||||
const endpoint = 'https://rest.api/core';
|
const endpoint = 'https://rest.api/core';
|
||||||
|
|
||||||
@@ -191,8 +192,7 @@ describe('DataService', () => {
|
|||||||
dso2.self = selfLink;
|
dso2.self = selfLink;
|
||||||
dso2.metadata = [{ key: 'dc.title', value: name2 }];
|
dso2.metadata = [{ key: 'dc.title', value: name2 }];
|
||||||
|
|
||||||
spyOn(service, 'findByHref').and.returnValues(observableOf(dso));
|
spyOn(service, 'findByHref').and.returnValues(createSuccessfulRemoteDataObject$(dso));
|
||||||
spyOn(objectCache, 'getObjectBySelfLink').and.returnValues(observableOf(dso));
|
|
||||||
spyOn(objectCache, 'addPatch');
|
spyOn(objectCache, 'addPatch');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -337,25 +337,20 @@ export class DsDynamicFormControlContainerComponent extends DynamicFormControlCo
|
|||||||
moveSelection(event: CdkDragDrop<Relationship>) {
|
moveSelection(event: CdkDragDrop<Relationship>) {
|
||||||
moveItemInArray(this.reorderables, event.previousIndex, event.currentIndex);
|
moveItemInArray(this.reorderables, event.previousIndex, event.currentIndex);
|
||||||
this.zone.runOutsideAngular(() => {
|
this.zone.runOutsideAngular(() => {
|
||||||
observableCombineLatest(
|
const relationships = this.reorderables.map((reo: Reorderable, index: number) => {
|
||||||
this.reorderables.map((reo: Reorderable, index: number) => {
|
|
||||||
reo.oldIndex = reo.getPlace();
|
reo.oldIndex = reo.getPlace();
|
||||||
reo.newIndex = index;
|
reo.newIndex = index;
|
||||||
return reo;
|
return reo;
|
||||||
}
|
}
|
||||||
)
|
);
|
||||||
).pipe(
|
return observableCombineLatest(relationships.map((rel: ReorderableRelationship) => {
|
||||||
switchMap((relationships: Array<{ relationship: Relationship, left: boolean, oldIndex: number, newIndex: number }>) =>
|
console.log(rel);
|
||||||
observableCombineLatest(relationships.map((rel: { relationship: Relationship, left: boolean, oldIndex: number, newIndex: number }) => {
|
|
||||||
if (rel.oldIndex !== rel.newIndex) {
|
if (rel.oldIndex !== rel.newIndex) {
|
||||||
return this.relationshipService.updatePlace(rel.relationship, rel.newIndex, rel.left);
|
return this.relationshipService.updatePlace(rel.relationship, rel.newIndex, !rel.useLeftItem);
|
||||||
} else {
|
} else {
|
||||||
observableOf(undefined);
|
return observableOf(undefined);
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
).subscribe();
|
).subscribe();
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user