mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-18 15:33:04 +00:00
73014: Remove sending patch to cache + small refactoring changes
This commit is contained in:
@@ -20,7 +20,6 @@ import { AlertType } from '../../../shared/alert/aletr-type';
|
||||
import { Operation } from 'fast-json-patch';
|
||||
import { METADATA_PATCH_OPERATION_SERVICE_TOKEN } from '../../../core/data/object-updates/patch-operation-service/metadata-patch-operation.service';
|
||||
import { DSOSuccessResponse } from '../../../core/cache/response.models';
|
||||
import { ObjectCacheService } from '../../../core/cache/object-cache.service';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-item-metadata',
|
||||
@@ -57,7 +56,6 @@ export class ItemMetadataComponent extends AbstractItemUpdateComponent {
|
||||
public translateService: TranslateService,
|
||||
public route: ActivatedRoute,
|
||||
public metadataFieldService: RegistryService,
|
||||
public objectCacheService: ObjectCacheService,
|
||||
) {
|
||||
super(itemService, objectUpdatesService, router, notificationsService, translateService, route);
|
||||
}
|
||||
@@ -115,9 +113,7 @@ export class ItemMetadataComponent extends AbstractItemUpdateComponent {
|
||||
return this.updateService.patch(this.item, patch).pipe(
|
||||
switchMap((response: DSOSuccessResponse) => {
|
||||
if (isNotEmpty(response.resourceSelfLinks)) {
|
||||
const selfLink = response.resourceSelfLinks[0];
|
||||
this.objectCacheService.addPatch(selfLink, patch, false);
|
||||
return this.itemService.findByHref(selfLink);
|
||||
return this.itemService.findByHref(response.resourceSelfLinks[0]);
|
||||
}
|
||||
}),
|
||||
getSucceededRemoteData()
|
||||
|
10
src/app/core/cache/object-cache.service.ts
vendored
10
src/app/core/cache/object-cache.service.ts
vendored
@@ -270,17 +270,15 @@ export class ObjectCacheService {
|
||||
/**
|
||||
* Add operations to the existing list of operations for an ObjectCacheEntry
|
||||
* Makes sure the ServerSyncBuffer for this ObjectCacheEntry is updated
|
||||
* @param {string} uuid
|
||||
* @param selfLink
|
||||
* the uuid of the ObjectCacheEntry
|
||||
* @param {Operation[]} patch
|
||||
* list of operations to perform
|
||||
*/
|
||||
public addPatch(selfLink: string, patch: Operation[], addToSSD = true) {
|
||||
public addPatch(selfLink: string, patch: Operation[]) {
|
||||
this.store.dispatch(new AddPatchObjectCacheAction(selfLink, patch));
|
||||
if (addToSSD) {
|
||||
this.store.dispatch(new AddToSSBAction(selfLink, RestRequestMethod.PATCH));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether there are any unperformed operations for an ObjectCacheEntry
|
||||
@@ -297,8 +295,8 @@ export class ObjectCacheService {
|
||||
/**
|
||||
* Apply the existing operations on an ObjectCacheEntry in the store
|
||||
* NB: this does not make any server side changes
|
||||
* @param {string} uuid
|
||||
* the uuid of the ObjectCacheEntry
|
||||
* @param selfLink
|
||||
* the link of the ObjectCacheEntry
|
||||
*/
|
||||
private applyPatchesToCachedObject(selfLink: string) {
|
||||
this.store.dispatch(new ApplyPatchObjectCacheAction(selfLink));
|
||||
|
@@ -22,7 +22,6 @@ export class MetadataPatchAddOperation extends MetadataPatchOperation {
|
||||
* using the information provided.
|
||||
*/
|
||||
toOperation(): Operation {
|
||||
const path = `/metadata/${this.field}/-`;
|
||||
return { op: this.op as any, path, value: this.value };
|
||||
return { op: this.op as any, path: `/metadata/${this.field}/-`, value: this.value };
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,5 @@
|
||||
import { MetadataPatchOperation } from './metadata-patch-operation.model';
|
||||
import { Operation } from 'fast-json-patch';
|
||||
import { hasValue } from '../../../../../../shared/empty.util';
|
||||
|
||||
/**
|
||||
* Wrapper object for a metadata patch remove Operation
|
||||
@@ -23,10 +22,6 @@ export class MetadataPatchRemoveOperation extends MetadataPatchOperation {
|
||||
* using the information provided.
|
||||
*/
|
||||
toOperation(): Operation {
|
||||
let path = `/metadata/${this.field}`;
|
||||
if (hasValue(this.place)) {
|
||||
path += `/${this.place}`;
|
||||
}
|
||||
return { op: this.op as any, path };
|
||||
return { op: this.op as any, path: `/metadata/${this.field}/${this.place}` };
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,5 @@
|
||||
import { MetadataPatchOperation } from './metadata-patch-operation.model';
|
||||
import { Operation } from 'fast-json-patch';
|
||||
import { hasValue } from '../../../../../../shared/empty.util';
|
||||
|
||||
/**
|
||||
* Wrapper object for a metadata patch replace Operation
|
||||
@@ -29,10 +28,6 @@ export class MetadataPatchReplaceOperation extends MetadataPatchOperation {
|
||||
* using the information provided.
|
||||
*/
|
||||
toOperation(): Operation {
|
||||
let path = `/metadata/${this.field}`;
|
||||
if (hasValue(this.place)) {
|
||||
path += `/${this.place}`;
|
||||
}
|
||||
return { op: this.op as any, path, value: this.value };
|
||||
return { op: this.op as any, path: `/metadata/${this.field}/${this.place}`, value: this.value };
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user