mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
99053: Passed previousSearchQuery to AdvancedWorkflowActionSelectReviewerComponent
This commit is contained in:
@@ -3,6 +3,7 @@ import { ClaimedTaskActionsAbstractComponent } from './claimed-task-actions-abst
|
|||||||
import { getFirstSucceededRemoteDataPayload } from '../../../../core/shared/operators';
|
import { getFirstSucceededRemoteDataPayload } from '../../../../core/shared/operators';
|
||||||
import { WorkflowItem } from '../../../../core/submission/models/workflowitem.model';
|
import { WorkflowItem } from '../../../../core/submission/models/workflowitem.model';
|
||||||
import { getAdvancedWorkflowRoute } from '../../../../workflowitems-edit-page/workflowitems-edit-page-routing-paths';
|
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
|
* Abstract component for rendering an advanced claimed task's action
|
||||||
@@ -47,11 +48,18 @@ export abstract class AdvancedClaimedTaskActionsAbstractComponent extends Claime
|
|||||||
*/
|
*/
|
||||||
openAdvancedClaimedTaskTab(): void {
|
openAdvancedClaimedTaskTab(): void {
|
||||||
void this.router.navigate([this.workflowTaskPageRoute], {
|
void this.router.navigate([this.workflowTaskPageRoute], {
|
||||||
queryParams: {
|
queryParams: this.getQueryParams(),
|
||||||
workflow: this.workflowType,
|
|
||||||
claimedTask: this.object.id,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 {
|
import {
|
||||||
AdvancedClaimedTaskActionSelectReviewerComponent
|
AdvancedClaimedTaskActionSelectReviewerComponent
|
||||||
} from './advanced-claimed-task-action-select-reviewer.component';
|
} 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 { RouterStub } from '../../../testing/router.stub';
|
||||||
import { NotificationsServiceStub } from '../../../testing/notifications-service.stub';
|
import { NotificationsServiceStub } from '../../../testing/notifications-service.stub';
|
||||||
import { NotificationsService } from '../../../notifications/notifications.service';
|
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';
|
} 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 { WorkflowItem } from '../../../../core/submission/models/workflowitem.model';
|
||||||
import { of as observableOf } from 'rxjs';
|
import { of as observableOf } from 'rxjs';
|
||||||
|
import { ActivatedRouteStub } from '../../../testing/active-router.stub';
|
||||||
|
|
||||||
const taskId = 'claimed-task-1';
|
const taskId = 'claimed-task-1';
|
||||||
const workflowId = 'workflow-1';
|
const workflowId = 'workflow-1';
|
||||||
@@ -36,12 +37,14 @@ describe('AdvancedClaimedTaskActionSelectReviewerComponent', () => {
|
|||||||
let component: AdvancedClaimedTaskActionSelectReviewerComponent;
|
let component: AdvancedClaimedTaskActionSelectReviewerComponent;
|
||||||
let fixture: ComponentFixture<AdvancedClaimedTaskActionSelectReviewerComponent>;
|
let fixture: ComponentFixture<AdvancedClaimedTaskActionSelectReviewerComponent>;
|
||||||
|
|
||||||
|
let route: ActivatedRouteStub;
|
||||||
let claimedTaskDataService: ClaimedTaskDataServiceStub;
|
let claimedTaskDataService: ClaimedTaskDataServiceStub;
|
||||||
let notificationService: NotificationsServiceStub;
|
let notificationService: NotificationsServiceStub;
|
||||||
let router: RouterStub;
|
let router: RouterStub;
|
||||||
let searchService: SearchServiceStub;
|
let searchService: SearchServiceStub;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
|
route = new ActivatedRouteStub();
|
||||||
claimedTaskDataService = new ClaimedTaskDataServiceStub();
|
claimedTaskDataService = new ClaimedTaskDataServiceStub();
|
||||||
notificationService = new NotificationsServiceStub();
|
notificationService = new NotificationsServiceStub();
|
||||||
router = new RouterStub();
|
router = new RouterStub();
|
||||||
@@ -56,6 +59,7 @@ describe('AdvancedClaimedTaskActionSelectReviewerComponent', () => {
|
|||||||
NgbTooltip,
|
NgbTooltip,
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
|
{ provide: ActivatedRoute, useValue: route },
|
||||||
{ provide: ClaimedTaskDataService, useValue: claimedTaskDataService },
|
{ provide: ClaimedTaskDataService, useValue: claimedTaskDataService },
|
||||||
{ provide: NotificationsService, useValue: notificationService },
|
{ provide: NotificationsService, useValue: notificationService },
|
||||||
{ provide: RequestService, useValue: {} },
|
{ 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 {
|
import {
|
||||||
AdvancedClaimedTaskActionsAbstractComponent
|
AdvancedClaimedTaskActionsAbstractComponent
|
||||||
} from '../abstract/advanced-claimed-task-actions-abstract.component';
|
} 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 { NotificationsService } from '../../../notifications/notifications.service';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { SearchService } from '../../../../core/shared/search/search.service';
|
import { SearchService } from '../../../../core/shared/search/search.service';
|
||||||
@@ -12,6 +12,7 @@ import {
|
|||||||
ADVANCED_WORKFLOW_ACTION_SELECT_REVIEWER,
|
ADVANCED_WORKFLOW_ACTION_SELECT_REVIEWER,
|
||||||
ADVANCED_WORKFLOW_TASK_OPTION_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';
|
} 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}
|
* Advanced Workflow button that redirect to the {@link AdvancedWorkflowActionSelectReviewerComponent}
|
||||||
@@ -38,8 +39,17 @@ export class AdvancedClaimedTaskActionSelectReviewerComponent extends AdvancedCl
|
|||||||
protected translate: TranslateService,
|
protected translate: TranslateService,
|
||||||
protected searchService: SearchService,
|
protected searchService: SearchService,
|
||||||
protected requestService: RequestService,
|
protected requestService: RequestService,
|
||||||
|
protected route: ActivatedRoute,
|
||||||
) {
|
) {
|
||||||
super(injector, router, notificationsService, translate, searchService, requestService);
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -54,7 +54,8 @@ export class ActivatedRouteStub {
|
|||||||
get snapshot() {
|
get snapshot() {
|
||||||
return {
|
return {
|
||||||
params: this.testParams,
|
params: this.testParams,
|
||||||
queryParamMap: convertToParamMap(this.testParams)
|
queryParamMap: convertToParamMap(this.testParams),
|
||||||
|
queryParams: {} as Params,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,12 +1,11 @@
|
|||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
import {
|
import {
|
||||||
AdvancedWorkflowActionSelectReviewerComponent,
|
AdvancedWorkflowActionSelectReviewerComponent,
|
||||||
ADVANCED_WORKFLOW_TASK_OPTION_SELECT_REVIEWER
|
ADVANCED_WORKFLOW_TASK_OPTION_SELECT_REVIEWER,
|
||||||
} from './advanced-workflow-action-select-reviewer.component';
|
} 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 { WorkflowItemDataService } from '../../../core/submission/workflowitem-data.service';
|
||||||
import { WorkflowItemDataServiceStub } from '../../../shared/testing/workflow-item-data-service.stub';
|
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 { WorkflowActionDataServiceStub } from '../../../shared/testing/workflow-action-data-service.stub';
|
||||||
import { WorkflowActionDataService } from '../../../core/data/workflow-action-data.service';
|
import { WorkflowActionDataService } from '../../../core/data/workflow-action-data.service';
|
||||||
import { RouteService } from '../../../core/services/route.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 { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||||
import { RequestService } from '../../../core/data/request.service';
|
import { RequestService } from '../../../core/data/request.service';
|
||||||
import { RequestServiceStub } from '../../../shared/testing/request-service.stub';
|
import { RequestServiceStub } from '../../../shared/testing/request-service.stub';
|
||||||
|
import { RouterStub } from '../../../shared/testing/router.stub';
|
||||||
|
|
||||||
const claimedTaskId = '2';
|
const claimedTaskId = '2';
|
||||||
const workflowId = '1';
|
const workflowId = '1';
|
||||||
@@ -37,18 +37,19 @@ describe('AdvancedWorkflowActionSelectReviewerComponent', () => {
|
|||||||
|
|
||||||
let claimedTaskDataService: ClaimedTaskDataServiceStub;
|
let claimedTaskDataService: ClaimedTaskDataServiceStub;
|
||||||
let notificationService: NotificationsServiceStub;
|
let notificationService: NotificationsServiceStub;
|
||||||
|
let router: RouterStub;
|
||||||
let workflowActionDataService: WorkflowItemDataServiceStub;
|
let workflowActionDataService: WorkflowItemDataServiceStub;
|
||||||
let workflowItemDataService: WorkflowItemDataServiceStub;
|
let workflowItemDataService: WorkflowItemDataServiceStub;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
claimedTaskDataService = new ClaimedTaskDataServiceStub();
|
claimedTaskDataService = new ClaimedTaskDataServiceStub();
|
||||||
notificationService = new NotificationsServiceStub();
|
notificationService = new NotificationsServiceStub();
|
||||||
|
router = new RouterStub();
|
||||||
workflowActionDataService = new WorkflowActionDataServiceStub();
|
workflowActionDataService = new WorkflowActionDataServiceStub();
|
||||||
workflowItemDataService = new WorkflowItemDataServiceStub();
|
workflowItemDataService = new WorkflowItemDataServiceStub();
|
||||||
|
|
||||||
await TestBed.configureTestingModule({
|
await TestBed.configureTestingModule({
|
||||||
imports: [
|
imports: [
|
||||||
RouterTestingModule,
|
|
||||||
TranslateModule.forRoot(),
|
TranslateModule.forRoot(),
|
||||||
],
|
],
|
||||||
declarations: [
|
declarations: [
|
||||||
@@ -66,10 +67,12 @@ describe('AdvancedWorkflowActionSelectReviewerComponent', () => {
|
|||||||
queryParams: {
|
queryParams: {
|
||||||
claimedTask: claimedTaskId,
|
claimedTask: claimedTaskId,
|
||||||
workflow: 'testaction',
|
workflow: 'testaction',
|
||||||
|
previousSearchQuery: 'Thor%20Love%20and%20Thunder',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{ provide: Router, useValue: router },
|
||||||
{ provide: ClaimedTaskDataService, useValue: claimedTaskDataService },
|
{ provide: ClaimedTaskDataService, useValue: claimedTaskDataService },
|
||||||
{ provide: NotificationsService, useValue: notificationService },
|
{ provide: NotificationsService, useValue: notificationService },
|
||||||
{ provide: RouteService, useValue: routeServiceStub },
|
{ provide: RouteService, useValue: routeServiceStub },
|
||||||
@@ -85,14 +88,30 @@ describe('AdvancedWorkflowActionSelectReviewerComponent', () => {
|
|||||||
fixture = TestBed.createComponent(AdvancedWorkflowActionSelectReviewerComponent);
|
fixture = TestBed.createComponent(AdvancedWorkflowActionSelectReviewerComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
spyOn(component, 'previousPage');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
fixture.debugElement.nativeElement.remove();
|
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', () => {
|
describe('performAction', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
spyOn(component, 'previousPage');
|
||||||
|
});
|
||||||
|
|
||||||
it('should call the claimedTaskDataService with the list of selected ePersons', () => {
|
it('should call the claimedTaskDataService with the list of selected ePersons', () => {
|
||||||
spyOn(claimedTaskDataService, 'submitTask').and.returnValue(observableOf(new ProcessTaskResponse(true)));
|
spyOn(claimedTaskDataService, 'submitTask').and.returnValue(observableOf(new ProcessTaskResponse(true)));
|
||||||
component.selectedReviewers = [EPersonMock, EPersonMock2];
|
component.selectedReviewers = [EPersonMock, EPersonMock2];
|
||||||
|
@@ -12,15 +12,15 @@ import {
|
|||||||
} from '../../../access-control/group-registry/group-form/members-list/members-list.component';
|
} from '../../../access-control/group-registry/group-form/members-list/members-list.component';
|
||||||
import { Subscription } from 'rxjs';
|
import { Subscription } from 'rxjs';
|
||||||
import { EPerson } from '../../../core/eperson/models/eperson.model';
|
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 { WorkflowItemDataService } from '../../../core/submission/workflowitem-data.service';
|
||||||
import { RouteService } from '../../../core/services/route.service';
|
import { RouteService } from '../../../core/services/route.service';
|
||||||
import { NotificationsService } from '../../../shared/notifications/notifications.service';
|
import { NotificationsService } from '../../../shared/notifications/notifications.service';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { WorkflowActionDataService } from '../../../core/data/workflow-action-data.service';
|
import { WorkflowActionDataService } from '../../../core/data/workflow-action-data.service';
|
||||||
import { ClaimedTaskDataService } from '../../../core/tasks/claimed-task-data.service';
|
import { ClaimedTaskDataService } from '../../../core/tasks/claimed-task-data.service';
|
||||||
import { ReviewersListComponent } from './reviewers-list/reviewers-list.component';
|
import { RequestService } from '../../../core/data/request.service';
|
||||||
import { RequestService } from 'src/app/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_TASK_OPTION_SELECT_REVIEWER = 'submit_select_reviewer';
|
||||||
export const ADVANCED_WORKFLOW_ACTION_SELECT_REVIEWER = 'selectrevieweraction';
|
export const ADVANCED_WORKFLOW_ACTION_SELECT_REVIEWER = 'selectrevieweraction';
|
||||||
@@ -138,7 +138,13 @@ export class AdvancedWorkflowActionSelectReviewerComponent extends AdvancedWorkf
|
|||||||
* switching between the different pages
|
* switching between the different pages
|
||||||
*/
|
*/
|
||||||
previousPage(): void {
|
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 });
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user