mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
98344: Fixed workflow id passed to backend instead of claimed task id
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ClaimedTaskActionsAbstractComponent } from './claimed-task-actions-abstract.component';
|
||||
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';
|
||||
|
||||
/**
|
||||
* Abstract component for rendering an advanced claimed task's action
|
||||
@@ -12,7 +15,7 @@ import { ClaimedTaskActionsAbstractComponent } from './claimed-task-actions-abst
|
||||
selector: 'ds-advanced-claimed-task-action-abstract',
|
||||
template: ''
|
||||
})
|
||||
export abstract class AdvancedClaimedTaskActionsAbstractComponent extends ClaimedTaskActionsAbstractComponent {
|
||||
export abstract class AdvancedClaimedTaskActionsAbstractComponent extends ClaimedTaskActionsAbstractComponent implements OnInit {
|
||||
|
||||
workflowType: string;
|
||||
|
||||
@@ -21,10 +24,27 @@ export abstract class AdvancedClaimedTaskActionsAbstractComponent extends Claime
|
||||
*/
|
||||
workflowTaskPageRoute: string;
|
||||
|
||||
ngOnInit(): void {
|
||||
super.ngOnInit();
|
||||
this.initPageRoute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise the route to the advanced workflow page
|
||||
*/
|
||||
initPageRoute() {
|
||||
this.subs.push(this.object.workflowitem.pipe(
|
||||
getFirstSucceededRemoteDataPayload()
|
||||
).subscribe((workflowItem: WorkflowItem) => {
|
||||
this.workflowTaskPageRoute = getAdvancedWorkflowRoute(workflowItem.id);
|
||||
}));
|
||||
}
|
||||
|
||||
openAdvancedClaimedTaskTab(): void {
|
||||
void this.router.navigate([this.workflowTaskPageRoute], {
|
||||
queryParams: {
|
||||
workflow: this.workflowType,
|
||||
claimedTask: this.object.id,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
@@ -19,11 +19,19 @@ import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import {
|
||||
ADVANCED_WORKFLOW_ACTION_RATING_REVIEWER
|
||||
} from '../../../../workflowitems-edit-page/advanced-workflow-action/advanced-workflow-action-rating-reviewer/advanced-workflow-action-rating-reviewer.component';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { WorkflowItem } from '../../../../core/submission/models/workflowitem.model';
|
||||
|
||||
const taskId = 'claimed-task-1';
|
||||
const workflowId = 'workflow-1';
|
||||
|
||||
describe('AdvancedClaimedTaskActionRatingReviewerComponent', () => {
|
||||
const object = Object.assign(new ClaimedTask(), { id: taskId });
|
||||
const object = Object.assign(new ClaimedTask(), {
|
||||
id: taskId,
|
||||
workflowitem: observableOf(Object.assign(new WorkflowItem(), {
|
||||
id: workflowId,
|
||||
})),
|
||||
});
|
||||
let component: AdvancedClaimedTaskActionRatingReviewerComponent;
|
||||
let fixture: ComponentFixture<AdvancedClaimedTaskActionRatingReviewerComponent>;
|
||||
|
||||
@@ -75,11 +83,13 @@ describe('AdvancedClaimedTaskActionRatingReviewerComponent', () => {
|
||||
});
|
||||
|
||||
it('should navigate to the advanced workflow page when clicked', () => {
|
||||
component.workflowTaskPageRoute = `/workflowitems/${workflowId}/advanced`;
|
||||
fixture.debugElement.query(By.css('.ratingReviewerAction')).nativeElement.click();
|
||||
|
||||
expect(router.navigate).toHaveBeenCalledWith([`/workflowitems/${taskId}/advanced`], {
|
||||
expect(router.navigate).toHaveBeenCalledWith([`/workflowitems/${workflowId}/advanced`], {
|
||||
queryParams: {
|
||||
workflow: ADVANCED_WORKFLOW_ACTION_RATING_REVIEWER,
|
||||
claimedTask: taskId,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
@@ -4,7 +4,6 @@ import { NotificationsService } from '../../../notifications/notifications.servi
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { SearchService } from '../../../../core/shared/search/search.service';
|
||||
import { RequestService } from '../../../../core/data/request.service';
|
||||
import { getAdvancedWorkflowRoute } from '../../../../workflowitems-edit-page/workflowitems-edit-page-routing-paths';
|
||||
import {
|
||||
AdvancedClaimedTaskActionsAbstractComponent
|
||||
} from '../abstract/advanced-claimed-task-actions-abstract.component';
|
||||
@@ -28,11 +27,6 @@ export class AdvancedClaimedTaskActionRatingReviewerComponent extends AdvancedCl
|
||||
|
||||
workflowType = ADVANCED_WORKFLOW_ACTION_RATING_REVIEWER;
|
||||
|
||||
/**
|
||||
* Route to the workflow's task page
|
||||
*/
|
||||
workflowTaskPageRoute: string;
|
||||
|
||||
constructor(
|
||||
protected injector: Injector,
|
||||
protected router: Router,
|
||||
@@ -44,15 +38,4 @@ export class AdvancedClaimedTaskActionRatingReviewerComponent extends AdvancedCl
|
||||
super(injector, router, notificationsService, translate, searchService, requestService);
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.initPageRoute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise the route to the rating reviewer's page
|
||||
*/
|
||||
initPageRoute(): void {
|
||||
this.workflowTaskPageRoute = getAdvancedWorkflowRoute(this.object.id);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -20,11 +20,19 @@ import { Location } from '@angular/common';
|
||||
import {
|
||||
ADVANCED_WORKFLOW_ACTION_SELECT_REVIEWER
|
||||
} 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';
|
||||
|
||||
const taskId = 'claimed-task-1';
|
||||
const workflowId = 'workflow-1';
|
||||
|
||||
describe('AdvancedClaimedTaskActionSelectReviewerComponent', () => {
|
||||
const object = Object.assign(new ClaimedTask(), { id: taskId });
|
||||
const object = Object.assign(new ClaimedTask(), {
|
||||
id: taskId,
|
||||
workflowitem: observableOf(Object.assign(new WorkflowItem(), {
|
||||
id: workflowId,
|
||||
})),
|
||||
});
|
||||
let component: AdvancedClaimedTaskActionSelectReviewerComponent;
|
||||
let fixture: ComponentFixture<AdvancedClaimedTaskActionSelectReviewerComponent>;
|
||||
|
||||
@@ -77,11 +85,13 @@ describe('AdvancedClaimedTaskActionSelectReviewerComponent', () => {
|
||||
});
|
||||
|
||||
it('should navigate to the advanced workflow page when clicked', () => {
|
||||
component.workflowTaskPageRoute = `/workflowitems/${workflowId}/advanced`;
|
||||
fixture.debugElement.query(By.css('.selectReviewerAction')).nativeElement.click();
|
||||
|
||||
expect(router.navigate).toHaveBeenCalledWith([`/workflowitems/${taskId}/advanced`], {
|
||||
expect(router.navigate).toHaveBeenCalledWith([`/workflowitems/${workflowId}/advanced`], {
|
||||
queryParams: {
|
||||
workflow: ADVANCED_WORKFLOW_ACTION_SELECT_REVIEWER,
|
||||
claimedTask: taskId,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
@@ -8,7 +8,6 @@ import { NotificationsService } from '../../../notifications/notifications.servi
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { SearchService } from '../../../../core/shared/search/search.service';
|
||||
import { RequestService } from '../../../../core/data/request.service';
|
||||
import { getAdvancedWorkflowRoute } from '../../../../workflowitems-edit-page/workflowitems-edit-page-routing-paths';
|
||||
import {
|
||||
ADVANCED_WORKFLOW_ACTION_SELECT_REVIEWER,
|
||||
WORKFLOW_ADVANCED_TASK_OPTION_SELECT_REVIEWER
|
||||
@@ -40,15 +39,4 @@ export class AdvancedClaimedTaskActionSelectReviewerComponent extends AdvancedCl
|
||||
super(injector, router, notificationsService, translate, searchService, requestService);
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.initPageRoute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise the route to the select reviewer's page
|
||||
*/
|
||||
initPageRoute() {
|
||||
this.workflowTaskPageRoute = getAdvancedWorkflowRoute(this.object.id);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -26,7 +26,7 @@ export class AdvancedWorkflowActionSelectReviewerComponent extends AdvancedWorkf
|
||||
|
||||
multipleReviewers = true;
|
||||
|
||||
selectedReviewers: EPerson[];
|
||||
selectedReviewers: EPerson[] = [];
|
||||
|
||||
reviewersListActionConfig: EPersonListActionConfig;
|
||||
|
||||
|
@@ -41,6 +41,24 @@ export abstract class AdvancedWorkflowActionComponent extends WorkflowItemAction
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs the action and shows a notification based on the outcome of the action
|
||||
*/
|
||||
performAction() {
|
||||
this.sendRequest(this.route.snapshot.queryParams.claimedTask).subscribe((successful: boolean) => {
|
||||
if (successful) {
|
||||
const title = this.translationService.get('workflow-item.' + this.type + '.notification.success.title');
|
||||
const content = this.translationService.get('workflow-item.' + this.type + '.notification.success.content');
|
||||
this.notificationsService.success(title, content);
|
||||
this.previousPage();
|
||||
} else {
|
||||
const title = this.translationService.get('workflow-item.' + this.type + '.notification.error.title');
|
||||
const content = this.translationService.get('workflow-item.' + this.type + '.notification.error.content');
|
||||
this.notificationsService.error(title, content);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Submits the task with the given {@link createBody}.
|
||||
*
|
||||
|
Reference in New Issue
Block a user