From e14610914a760c566a020a072fca308df87046b7 Mon Sep 17 00:00:00 2001 From: Andrea Barbasso <´andrea.barbasso@4science.com´> Date: Tue, 21 May 2024 12:31:30 +0200 Subject: [PATCH 1/2] [DURACOM-263] fix redirect to submission form on new item version creation --- .../workspaceitem-data.service.spec.ts | 20 ++++++++++++++----- .../submission/workspaceitem-data.service.ts | 5 +++-- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/app/core/submission/workspaceitem-data.service.spec.ts b/src/app/core/submission/workspaceitem-data.service.spec.ts index 43a61bef991..8837792a786 100644 --- a/src/app/core/submission/workspaceitem-data.service.spec.ts +++ b/src/app/core/submission/workspaceitem-data.service.spec.ts @@ -2,13 +2,18 @@ import { HttpClient, HttpHeaders, } from '@angular/common/http'; +import { waitForAsync } from '@angular/core/testing'; import { Store } from '@ngrx/store'; import { cold, getTestScheduler, hot, } from 'jasmine-marbles'; -import { of as observableOf } from 'rxjs'; +import { + of as observableOf, + of, +} from 'rxjs'; +import { map } from 'rxjs/operators'; import { TestScheduler } from 'rxjs/testing'; import { getMockHrefOnlyDataService } from '../../shared/mocks/href-only-data.service.mock'; @@ -151,12 +156,17 @@ describe('WorkspaceitemDataService test', () => { }); describe('findByItem', () => { - it('should proxy the call to UpdateDataServiceImpl.findByHref', () => { + it('should proxy the call to UpdateDataServiceImpl.findByHref', waitForAsync(() => { scheduler.schedule(() => service.findByItem('1234-1234', true, true, pageInfo)); scheduler.flush(); - const searchUrl = service.getIDHref('item', [new RequestParam('uuid', '1234-1234')]); - expect((service as any).findByHref).toHaveBeenCalledWith(searchUrl, true, true); - }); + const searchUrl$ = + of('https://rest.api/rest/api/submission/workspaceitems/search/item') + .pipe(map(href => service.buildHrefFromFindOptions(href, { searchParams: [new RequestParam('uuid', '1234-1234')] }, []))); + searchUrl$.subscribe((url) => { + expect(url).toEqual('https://rest.api/rest/api/submission/workspaceitems/search/item?uuid=1234-1234'); + }); + expect((service as any).findByHref).toHaveBeenCalled(); + })); it('should return a RemoteData for the search', () => { const result = service.findByItem('1234-1234', true, true, pageInfo); diff --git a/src/app/core/submission/workspaceitem-data.service.ts b/src/app/core/submission/workspaceitem-data.service.ts index 1e22c87d591..2972cb9b522 100644 --- a/src/app/core/submission/workspaceitem-data.service.ts +++ b/src/app/core/submission/workspaceitem-data.service.ts @@ -43,7 +43,7 @@ import { WorkspaceItem } from './models/workspaceitem.model'; @Injectable({ providedIn: 'root' }) export class WorkspaceitemDataService extends IdentifiableDataService implements DeleteData, SearchData{ protected linkPath = 'workspaceitems'; - protected searchByItemLinkPath = 'item'; + protected searchByItemLinkPath = 'workspaceitems/search/item'; private deleteData: DeleteData; private searchData: SearchData; @@ -91,7 +91,8 @@ export class WorkspaceitemDataService extends IdentifiableDataService[]): Observable> { const findListOptions = new FindListOptions(); findListOptions.searchParams = [new RequestParam('uuid', uuid)]; - const href$ = this.getIDHref(this.searchByItemLinkPath, findListOptions, ...linksToFollow); + const href$ = this.halService.getEndpoint(this.searchByItemLinkPath) + .pipe(map((href) => this.buildHrefFromFindOptions(href, findListOptions, [], ...linksToFollow))); return this.findByHref(href$, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow); } From 7581c9b6eae0f4b0dee59fb00cc0b8c1a7166eb1 Mon Sep 17 00:00:00 2001 From: Simone Ramundi Date: Tue, 21 May 2024 18:08:08 +0200 Subject: [PATCH 2/2] [DURACOM-263] - NEW - fix redirect to submission form on new item version --- src/app/core/submission/workspaceitem-data.service.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/app/core/submission/workspaceitem-data.service.ts b/src/app/core/submission/workspaceitem-data.service.ts index 2972cb9b522..17aafaf6514 100644 --- a/src/app/core/submission/workspaceitem-data.service.ts +++ b/src/app/core/submission/workspaceitem-data.service.ts @@ -43,9 +43,9 @@ import { WorkspaceItem } from './models/workspaceitem.model'; @Injectable({ providedIn: 'root' }) export class WorkspaceitemDataService extends IdentifiableDataService implements DeleteData, SearchData{ protected linkPath = 'workspaceitems'; - protected searchByItemLinkPath = 'workspaceitems/search/item'; + protected searchByItemLinkPath = 'item'; private deleteData: DeleteData; - private searchData: SearchData; + private searchData: SearchDataImpl; constructor( protected comparator: DSOChangeAnalyzer, @@ -91,8 +91,7 @@ export class WorkspaceitemDataService extends IdentifiableDataService[]): Observable> { const findListOptions = new FindListOptions(); findListOptions.searchParams = [new RequestParam('uuid', uuid)]; - const href$ = this.halService.getEndpoint(this.searchByItemLinkPath) - .pipe(map((href) => this.buildHrefFromFindOptions(href, findListOptions, [], ...linksToFollow))); + const href$ = this.searchData.getSearchByHref(this.searchByItemLinkPath, findListOptions, ...linksToFollow); return this.findByHref(href$, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow); }