mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
Merge remote-tracking branch 'atmire/w2p-98211_advanced-workflow-actions-7.2' into w2p-98211_advanced-workflow-actions-main
# Conflicts: # src/app/shared/testing/active-router.stub.ts # src/app/workflowitems-edit-page/advanced-workflow-action/advanced-workflow-action-select-reviewer/advanced-workflow-action-select-reviewer.component.ts
This commit is contained in:
@@ -3,6 +3,7 @@ import { ClaimedTaskActionsAbstractComponent } from './claimed-task-actions-abst
|
||||
import { getFirstSucceededRemoteDataPayload } from '../../../../core/shared/operators';
|
||||
import { WorkflowItem } from '../../../../core/submission/models/workflowitem.model';
|
||||
import { getAdvancedWorkflowRoute } from '../../../../workflowitems-edit-page/workflowitems-edit-page-routing-paths';
|
||||
import { Params } from '@angular/router';
|
||||
|
||||
/**
|
||||
* Abstract component for rendering an advanced claimed task's action
|
||||
@@ -47,11 +48,18 @@ export abstract class AdvancedClaimedTaskActionsAbstractComponent extends Claime
|
||||
*/
|
||||
openAdvancedClaimedTaskTab(): void {
|
||||
void this.router.navigate([this.workflowTaskPageRoute], {
|
||||
queryParams: {
|
||||
workflow: this.workflowType,
|
||||
claimedTask: this.object.id,
|
||||
},
|
||||
queryParams: this.getQueryParams(),
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* The {@link Params} that need to be given to the workflow page.
|
||||
*/
|
||||
getQueryParams(): Params {
|
||||
return {
|
||||
workflow: this.workflowType,
|
||||
claimedTask: this.object.id,
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import {
|
||||
AdvancedClaimedTaskActionSelectReviewerComponent
|
||||
} from './advanced-claimed-task-action-select-reviewer.component';
|
||||
import { Router } from '@angular/router';
|
||||
import { Router, ActivatedRoute } from '@angular/router';
|
||||
import { RouterStub } from '../../../testing/router.stub';
|
||||
import { NotificationsServiceStub } from '../../../testing/notifications-service.stub';
|
||||
import { NotificationsService } from '../../../notifications/notifications.service';
|
||||
@@ -22,6 +22,7 @@ import {
|
||||
} from '../../../../workflowitems-edit-page/advanced-workflow-action/advanced-workflow-action-select-reviewer/advanced-workflow-action-select-reviewer.component';
|
||||
import { WorkflowItem } from '../../../../core/submission/models/workflowitem.model';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { ActivatedRouteStub } from '../../../testing/active-router.stub';
|
||||
|
||||
const taskId = 'claimed-task-1';
|
||||
const workflowId = 'workflow-1';
|
||||
@@ -36,12 +37,14 @@ describe('AdvancedClaimedTaskActionSelectReviewerComponent', () => {
|
||||
let component: AdvancedClaimedTaskActionSelectReviewerComponent;
|
||||
let fixture: ComponentFixture<AdvancedClaimedTaskActionSelectReviewerComponent>;
|
||||
|
||||
let route: ActivatedRouteStub;
|
||||
let claimedTaskDataService: ClaimedTaskDataServiceStub;
|
||||
let notificationService: NotificationsServiceStub;
|
||||
let router: RouterStub;
|
||||
let searchService: SearchServiceStub;
|
||||
|
||||
beforeEach(async () => {
|
||||
route = new ActivatedRouteStub();
|
||||
claimedTaskDataService = new ClaimedTaskDataServiceStub();
|
||||
notificationService = new NotificationsServiceStub();
|
||||
router = new RouterStub();
|
||||
@@ -56,6 +59,7 @@ describe('AdvancedClaimedTaskActionSelectReviewerComponent', () => {
|
||||
NgbTooltip,
|
||||
],
|
||||
providers: [
|
||||
{ provide: ActivatedRoute, useValue: route },
|
||||
{ provide: ClaimedTaskDataService, useValue: claimedTaskDataService },
|
||||
{ provide: NotificationsService, useValue: notificationService },
|
||||
{ provide: RequestService, useValue: {} },
|
||||
@@ -95,4 +99,22 @@ describe('AdvancedClaimedTaskActionSelectReviewerComponent', () => {
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it('should navigate to the advanced workflow page with a previousSearchQuery when clicked anq a query is defined', () => {
|
||||
spyOnProperty(route, 'snapshot').and.returnValue({
|
||||
queryParams: {
|
||||
query: 'Thor%20Love%20and%20Thunder',
|
||||
}
|
||||
});
|
||||
component.workflowTaskPageRoute = `/workflowitems/${workflowId}/advanced`;
|
||||
fixture.debugElement.query(By.css('.selectReviewerAction')).nativeElement.click();
|
||||
|
||||
expect(router.navigate).toHaveBeenCalledWith([`/workflowitems/${workflowId}/advanced`], {
|
||||
queryParams: {
|
||||
workflow: ADVANCED_WORKFLOW_ACTION_SELECT_REVIEWER,
|
||||
claimedTask: taskId,
|
||||
previousSearchQuery: 'Thor%20Love%20and%20Thunder',
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -3,7 +3,7 @@ import { rendersWorkflowTaskOption } from '../switcher/claimed-task-actions-deco
|
||||
import {
|
||||
AdvancedClaimedTaskActionsAbstractComponent
|
||||
} from '../abstract/advanced-claimed-task-actions-abstract.component';
|
||||
import { Router } from '@angular/router';
|
||||
import { Router, Params, ActivatedRoute } from '@angular/router';
|
||||
import { NotificationsService } from '../../../notifications/notifications.service';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { SearchService } from '../../../../core/shared/search/search.service';
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
ADVANCED_WORKFLOW_ACTION_SELECT_REVIEWER,
|
||||
ADVANCED_WORKFLOW_TASK_OPTION_SELECT_REVIEWER
|
||||
} from '../../../../workflowitems-edit-page/advanced-workflow-action/advanced-workflow-action-select-reviewer/advanced-workflow-action-select-reviewer.component';
|
||||
import { hasValue } from '../../../empty.util';
|
||||
|
||||
/**
|
||||
* Advanced Workflow button that redirect to the {@link AdvancedWorkflowActionSelectReviewerComponent}
|
||||
@@ -38,8 +39,17 @@ export class AdvancedClaimedTaskActionSelectReviewerComponent extends AdvancedCl
|
||||
protected translate: TranslateService,
|
||||
protected searchService: SearchService,
|
||||
protected requestService: RequestService,
|
||||
protected route: ActivatedRoute,
|
||||
) {
|
||||
super(injector, router, notificationsService, translate, searchService, requestService);
|
||||
}
|
||||
|
||||
getQueryParams(): Params {
|
||||
const params: Params = super.getQueryParams();
|
||||
if (hasValue(this.route.snapshot.queryParams.query)) {
|
||||
params.previousSearchQuery = this.route.snapshot.queryParams.query;
|
||||
}
|
||||
return params;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -55,7 +55,8 @@ export class ActivatedRouteStub {
|
||||
return {
|
||||
params: this.testParams,
|
||||
paramMap: convertToParamMap(this.params),
|
||||
queryParamMap: convertToParamMap(this.testParams)
|
||||
queryParamMap: convertToParamMap(this.testParams),
|
||||
queryParams: {} as Params,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -1,12 +1,11 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import {
|
||||
AdvancedWorkflowActionSelectReviewerComponent,
|
||||
ADVANCED_WORKFLOW_TASK_OPTION_SELECT_REVIEWER
|
||||
ADVANCED_WORKFLOW_TASK_OPTION_SELECT_REVIEWER,
|
||||
} from './advanced-workflow-action-select-reviewer.component';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { WorkflowItemDataService } from '../../../core/submission/workflowitem-data.service';
|
||||
import { WorkflowItemDataServiceStub } from '../../../shared/testing/workflow-item-data-service.stub';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { WorkflowActionDataServiceStub } from '../../../shared/testing/workflow-action-data-service.stub';
|
||||
import { WorkflowActionDataService } from '../../../core/data/workflow-action-data.service';
|
||||
import { RouteService } from '../../../core/services/route.service';
|
||||
@@ -25,6 +24,7 @@ import { ProcessTaskResponse } from '../../../core/tasks/models/process-task-res
|
||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { RequestService } from '../../../core/data/request.service';
|
||||
import { RequestServiceStub } from '../../../shared/testing/request-service.stub';
|
||||
import { RouterStub } from '../../../shared/testing/router.stub';
|
||||
|
||||
const claimedTaskId = '2';
|
||||
const workflowId = '1';
|
||||
@@ -37,18 +37,19 @@ describe('AdvancedWorkflowActionSelectReviewerComponent', () => {
|
||||
|
||||
let claimedTaskDataService: ClaimedTaskDataServiceStub;
|
||||
let notificationService: NotificationsServiceStub;
|
||||
let router: RouterStub;
|
||||
let workflowActionDataService: WorkflowItemDataServiceStub;
|
||||
let workflowItemDataService: WorkflowItemDataServiceStub;
|
||||
|
||||
beforeEach(async () => {
|
||||
claimedTaskDataService = new ClaimedTaskDataServiceStub();
|
||||
notificationService = new NotificationsServiceStub();
|
||||
router = new RouterStub();
|
||||
workflowActionDataService = new WorkflowActionDataServiceStub();
|
||||
workflowItemDataService = new WorkflowItemDataServiceStub();
|
||||
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [
|
||||
RouterTestingModule,
|
||||
TranslateModule.forRoot(),
|
||||
],
|
||||
declarations: [
|
||||
@@ -66,10 +67,12 @@ describe('AdvancedWorkflowActionSelectReviewerComponent', () => {
|
||||
queryParams: {
|
||||
claimedTask: claimedTaskId,
|
||||
workflow: 'testaction',
|
||||
previousSearchQuery: 'Thor%20Love%20and%20Thunder',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{ provide: Router, useValue: router },
|
||||
{ provide: ClaimedTaskDataService, useValue: claimedTaskDataService },
|
||||
{ provide: NotificationsService, useValue: notificationService },
|
||||
{ provide: RouteService, useValue: routeServiceStub },
|
||||
@@ -85,14 +88,30 @@ describe('AdvancedWorkflowActionSelectReviewerComponent', () => {
|
||||
fixture = TestBed.createComponent(AdvancedWorkflowActionSelectReviewerComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
spyOn(component, 'previousPage');
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
fixture.debugElement.nativeElement.remove();
|
||||
});
|
||||
|
||||
describe('previousPage', () => {
|
||||
it('should navigate back to the Workflow tasks page with the previous query', () => {
|
||||
component.previousPage();
|
||||
|
||||
expect(router.navigate).toHaveBeenCalledWith(['/mydspace'], {
|
||||
queryParams: {
|
||||
configuration: 'workflow',
|
||||
query: 'Thor Love and Thunder',
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('performAction', () => {
|
||||
beforeEach(() => {
|
||||
spyOn(component, 'previousPage');
|
||||
});
|
||||
|
||||
it('should call the claimedTaskDataService with the list of selected ePersons', () => {
|
||||
spyOn(claimedTaskDataService, 'submitTask').and.returnValue(observableOf(new ProcessTaskResponse(true)));
|
||||
component.selectedReviewers = [EPersonMock, EPersonMock2];
|
||||
|
@@ -12,14 +12,15 @@ import {
|
||||
} from '../../../access-control/group-registry/group-form/members-list/members-list.component';
|
||||
import { Subscription } from 'rxjs';
|
||||
import { EPerson } from '../../../core/eperson/models/eperson.model';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { ActivatedRoute, Params, Router } from '@angular/router';
|
||||
import { WorkflowItemDataService } from '../../../core/submission/workflowitem-data.service';
|
||||
import { RouteService } from '../../../core/services/route.service';
|
||||
import { NotificationsService } from '../../../shared/notifications/notifications.service';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { WorkflowActionDataService } from '../../../core/data/workflow-action-data.service';
|
||||
import { ClaimedTaskDataService } from '../../../core/tasks/claimed-task-data.service';
|
||||
import { RequestService } from 'src/app/core/data/request.service';
|
||||
import { RequestService } from '../../../core/data/request.service';
|
||||
import { hasValue } from '../../../shared/empty.util';
|
||||
|
||||
export const ADVANCED_WORKFLOW_TASK_OPTION_SELECT_REVIEWER = 'submit_select_reviewer';
|
||||
export const ADVANCED_WORKFLOW_ACTION_SELECT_REVIEWER = 'selectrevieweraction';
|
||||
@@ -137,7 +138,13 @@ export class AdvancedWorkflowActionSelectReviewerComponent extends AdvancedWorkf
|
||||
* switching between the different pages
|
||||
*/
|
||||
previousPage(): void {
|
||||
void this.router.navigate(['/mydspace'], { queryParams: { configuration: 'workflow' } });
|
||||
const queryParams: Params = {
|
||||
configuration: 'workflow',
|
||||
};
|
||||
if (hasValue(this.route.snapshot.queryParams.previousSearchQuery)) {
|
||||
queryParams.query = decodeURIComponent(this.route.snapshot.queryParams.previousSearchQuery);
|
||||
}
|
||||
void this.router.navigate(['/mydspace'], { queryParams: queryParams });
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -78,7 +78,7 @@ export abstract class WorkflowItemActionPageComponent implements OnInit {
|
||||
const params: Params = {};
|
||||
if (url.split('?').length > 1) {
|
||||
for (const param of url.split('?')[1].split('&')) {
|
||||
params[param.split('=')[0]] = param.split('=')[1];
|
||||
params[param.split('=')[0]] = decodeURIComponent(param.split('=')[1]);
|
||||
}
|
||||
}
|
||||
void this.router.navigate([url.split('?')[0]], { queryParams: params });
|
||||
|
Reference in New Issue
Block a user