Skip to content

Commit 288a918

Browse files
authored
Merge pull request DSpace#2962 from atmire/fix-submission-lost-changes-after-save-8.0.0-next
Fix submission lost changes after save
2 parents d453105 + af2e097 commit 288a918

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

src/app/core/submission/submission-json-patch-operations.service.spec.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ describe('SubmissionJsonPatchOperationsService', () => {
1717
const rdbService = {} as RemoteDataBuildService;
1818
const halEndpointService = {} as HALEndpointService;
1919

20+
const uuid = '91ecbeda-99fe-42ac-9430-b9b75af56f78';
21+
const href = 'https://rest.api/some/self/link?with=maybe&a=few&other=parameters';
22+
2023
function initTestService() {
2124
return new SubmissionJsonPatchOperationsService(
2225
requestService,
@@ -36,4 +39,16 @@ describe('SubmissionJsonPatchOperationsService', () => {
3639
expect((service as any).patchRequestConstructor).toEqual(SubmissionPatchRequest);
3740
});
3841

42+
describe(`getRequestInstance`, () => {
43+
it(`should add a parameter to embed the item to the request URL`, () => {
44+
const result = (service as any).getRequestInstance(uuid, href);
45+
const resultURL = new URL(result.href);
46+
expect(resultURL.searchParams.get('embed')).toEqual('item');
47+
48+
// if we delete the embed item param, it should be identical to the original url
49+
resultURL.searchParams.delete('embed', 'item');
50+
expect(href).toEqual(resultURL.toString());
51+
});
52+
});
53+
3954
});

src/app/core/submission/submission-json-patch-operations.service.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { RequestService } from '../data/request.service';
88
import { JsonPatchOperationsService } from '../json-patch/json-patch-operations.service';
99
import { HALEndpointService } from '../shared/hal-endpoint.service';
1010
import { SubmitDataResponseDefinitionObject } from '../shared/submit-data-response-definition.model';
11+
import { URLCombiner } from '../url-combiner/url-combiner';
1112

1213
/**
1314
* A service that provides methods to make JSON Patch requests.
@@ -26,4 +27,20 @@ export class SubmissionJsonPatchOperationsService extends JsonPatchOperationsSer
2627
super();
2728
}
2829

30+
/**
31+
* Return an instance for RestRequest class
32+
*
33+
* @param uuid
34+
* The request uuid
35+
* @param href
36+
* The request href
37+
* @param body
38+
* The request body
39+
* @return Object<PatchRequestDefinition>
40+
* instance of PatchRequestDefinition
41+
*/
42+
protected getRequestInstance(uuid: string, href: string, body?: any): SubmissionPatchRequest {
43+
return new this.patchRequestConstructor(uuid, new URLCombiner(href, '?embed=item').toString(), body);
44+
}
45+
2946
}

0 commit comments

Comments
 (0)