mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-14 21:43:04 +00:00
98376: Added rating button to ratingreviewaction claimed task and created page
This commit is contained in:
@@ -1 +0,0 @@
|
||||
<p>advanced-workflow-action-rating-reviewer works!</p>
|
@@ -1,15 +0,0 @@
|
||||
import { Component } from '@angular/core';
|
||||
import {
|
||||
rendersAdvancedWorkflowTaskOption
|
||||
} from '../../../shared/mydspace-actions/claimed-task/switcher/claimed-task-actions-decorator';
|
||||
|
||||
export const ADVANCED_WORKFLOW_ACTION_RATING_REVIEWER = 'ratingrevieweraction';
|
||||
|
||||
@rendersAdvancedWorkflowTaskOption(ADVANCED_WORKFLOW_ACTION_RATING_REVIEWER)
|
||||
@Component({
|
||||
selector: 'ds-advanced-workflow-action-rating-reviewer',
|
||||
templateUrl: './advanced-workflow-action-rating-reviewer.component.html',
|
||||
styleUrls: ['./advanced-workflow-action-rating-reviewer.component.scss']
|
||||
})
|
||||
export class AdvancedWorkflowActionRatingReviewerComponent {
|
||||
}
|
@@ -0,0 +1,44 @@
|
||||
<div *ngVar="getAdvancedInfo(workflowAction$ | async) as advancedInfo">
|
||||
<p *ngIf="advancedInfo?.descriptionRequired">
|
||||
{{ 'advanced-workflow-action.rating.description-requiredDescription' | translate }}
|
||||
</p>
|
||||
<p *ngIf="!advancedInfo?.descriptionRequired">
|
||||
{{ 'advanced-workflow-action.rating.description' | translate }}
|
||||
</p>
|
||||
|
||||
<form (ngSubmit)="performAction()" *ngIf="ratingForm" [formGroup]="ratingForm">
|
||||
<div *ngVar="ratingForm.get('review').touched && !ratingForm.get('review').valid as invalid" class="form-group">
|
||||
<label class="control-label">
|
||||
<span>{{ 'advanced-workflow-action.rating.form.review.label' | translate }}</span>
|
||||
<span *ngIf="advancedInfo?.descriptionRequired">*</span>
|
||||
</label>
|
||||
<textarea [ngClass]="invalid ? 'is-invalid' : ''" [required]="advancedInfo?.descriptionRequired"
|
||||
class="form-control" formControlName="review">
|
||||
</textarea>
|
||||
<small *ngIf="invalid" class="invalid-feedback d-block">
|
||||
{{ 'advanced-workflow-action.rating.form.review.error' | translate }}
|
||||
</small>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label">
|
||||
{{ 'advanced-workflow-action.rating.form.rating.label' | translate }}*
|
||||
</label>
|
||||
<rating [max]="advancedInfo?.maxValue" class="d-block" formControlName="rating">
|
||||
</rating>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<ds-modify-item-overview *ngIf="item$ | async"
|
||||
[item]="item$ | async">
|
||||
</ds-modify-item-overview>
|
||||
|
||||
<div class="d-flex flex-wrap justify-content-end">
|
||||
<button (click)="previousPage()" class="btn btn-default">
|
||||
{{'workflow-item.' + getType() + '.button.cancel' | translate}}
|
||||
</button>
|
||||
<button (click)="performAction()" class="btn btn-primary">
|
||||
{{'workflow-item.' + getType() + '.button.confirm' | translate}}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
@@ -1,6 +1,6 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { AdvancedWorkflowActionRatingReviewerComponent } from './advanced-workflow-action-rating-reviewer.component';
|
||||
import { ActivatedRoute, convertToParamMap } from '@angular/router';
|
||||
import { AdvancedWorkflowActionRatingComponent } from './advanced-workflow-action-rating.component';
|
||||
import { ActivatedRoute, convertToParamMap, Router } from '@angular/router';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { ClaimedTaskDataService } from '../../../core/tasks/claimed-task-data.service';
|
||||
import { NotificationsService } from '../../../shared/notifications/notifications.service';
|
||||
@@ -12,12 +12,17 @@ import { ClaimedTaskDataServiceStub } from '../../../shared/testing/claimed-task
|
||||
import { NotificationsServiceStub } from '../../../shared/testing/notifications-service.stub';
|
||||
import { WorkflowActionDataServiceStub } from '../../../shared/testing/workflow-action-data-service.stub';
|
||||
import { WorkflowItemDataServiceStub } from '../../../shared/testing/workflow-item-data-service.stub';
|
||||
import { RouterStub } from '../../../shared/testing/router.stub';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { VarDirective } from '../../../shared/utils/var.directive';
|
||||
import { RatingModule } from 'ngx-bootstrap/rating';
|
||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||
|
||||
const workflowId = '1';
|
||||
|
||||
describe('AdvancedWorkflowActionRatingReviewerComponent', () => {
|
||||
let component: AdvancedWorkflowActionRatingReviewerComponent;
|
||||
let fixture: ComponentFixture<AdvancedWorkflowActionRatingReviewerComponent>;
|
||||
describe('AdvancedWorkflowActionRatingComponent', () => {
|
||||
let component: AdvancedWorkflowActionRatingComponent;
|
||||
let fixture: ComponentFixture<AdvancedWorkflowActionRatingComponent>;
|
||||
|
||||
let claimedTaskDataService: ClaimedTaskDataServiceStub;
|
||||
let notificationService: NotificationsServiceStub;
|
||||
@@ -31,8 +36,15 @@ describe('AdvancedWorkflowActionRatingReviewerComponent', () => {
|
||||
workflowItemDataService = new WorkflowItemDataServiceStub();
|
||||
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [
|
||||
FormsModule,
|
||||
RatingModule,
|
||||
ReactiveFormsModule,
|
||||
TranslateModule.forRoot(),
|
||||
],
|
||||
declarations: [
|
||||
AdvancedWorkflowActionRatingReviewerComponent,
|
||||
AdvancedWorkflowActionRatingComponent,
|
||||
VarDirective,
|
||||
],
|
||||
providers: [
|
||||
{
|
||||
@@ -51,6 +63,7 @@ describe('AdvancedWorkflowActionRatingReviewerComponent', () => {
|
||||
{ provide: ClaimedTaskDataService, useValue: claimedTaskDataService },
|
||||
{ provide: NotificationsService, useValue: notificationService },
|
||||
{ provide: RouteService, useValue: routeServiceStub },
|
||||
{ provide: Router, useValue: new RouterStub() },
|
||||
{ provide: WorkflowActionDataService, useValue: workflowActionDataService },
|
||||
{ provide: WorkflowItemDataService, useValue: workflowItemDataService },
|
||||
],
|
||||
@@ -58,11 +71,15 @@ describe('AdvancedWorkflowActionRatingReviewerComponent', () => {
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(AdvancedWorkflowActionRatingReviewerComponent);
|
||||
fixture = TestBed.createComponent(AdvancedWorkflowActionRatingComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
fixture.debugElement.nativeElement.remove();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
@@ -0,0 +1,66 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import {
|
||||
rendersAdvancedWorkflowTaskOption
|
||||
} from '../../../shared/mydspace-actions/claimed-task/switcher/claimed-task-actions-decorator';
|
||||
import { AdvancedWorkflowActionComponent } from '../advanced-workflow-action/advanced-workflow-action.component';
|
||||
import { FormGroup, FormControl } from '@angular/forms';
|
||||
import { WorkflowAction } from '../../../core/tasks/models/workflow-action-object.model';
|
||||
import {
|
||||
RatingReviewerActionAdvancedInfo
|
||||
} from '../../../core/tasks/models/rating-reviewer-action-advanced-info.model';
|
||||
|
||||
export const WORKFLOW_ADVANCED_TASK_OPTION_RATING = 'rating';
|
||||
export const ADVANCED_WORKFLOW_ACTION_RATING = 'ratingreviewaction';
|
||||
|
||||
@rendersAdvancedWorkflowTaskOption(ADVANCED_WORKFLOW_ACTION_RATING)
|
||||
@Component({
|
||||
selector: 'ds-advanced-workflow-action-rating-reviewer',
|
||||
templateUrl: './advanced-workflow-action-rating.component.html',
|
||||
styleUrls: ['./advanced-workflow-action-rating.component.scss'],
|
||||
preserveWhitespaces: false,
|
||||
})
|
||||
export class AdvancedWorkflowActionRatingComponent extends AdvancedWorkflowActionComponent implements OnInit {
|
||||
|
||||
ratingForm: FormGroup;
|
||||
|
||||
ngOnInit() {
|
||||
super.ngOnInit();
|
||||
this.ratingForm = new FormGroup({
|
||||
review: new FormControl(''),
|
||||
rating: new FormControl(0),
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Only run **performAction()** when the form has been correctly filled in
|
||||
*/
|
||||
performAction(): void {
|
||||
this.ratingForm.updateValueAndValidity();
|
||||
if (this.ratingForm.valid) {
|
||||
super.performAction();
|
||||
} else {
|
||||
this.ratingForm.markAllAsTouched();
|
||||
}
|
||||
}
|
||||
|
||||
createBody(): any {
|
||||
const body = {
|
||||
[WORKFLOW_ADVANCED_TASK_OPTION_RATING]: true,
|
||||
score: this.ratingForm.get('rating').value,
|
||||
};
|
||||
if (this.ratingForm.get('review').value !== '') {
|
||||
const description: string = this.ratingForm.get('review').value;
|
||||
Object.assign(body, { description });
|
||||
}
|
||||
return body;
|
||||
}
|
||||
|
||||
getType(): string {
|
||||
return ADVANCED_WORKFLOW_ACTION_RATING;
|
||||
}
|
||||
|
||||
getAdvancedInfo(workflowAction: WorkflowAction | null): RatingReviewerActionAdvancedInfo | null {
|
||||
return workflowAction ? (workflowAction.advancedInfo[0] as RatingReviewerActionAdvancedInfo) : null;
|
||||
}
|
||||
|
||||
}
|
@@ -44,7 +44,7 @@ export abstract class AdvancedWorkflowActionComponent extends WorkflowItemAction
|
||||
/**
|
||||
* Performs the action and shows a notification based on the outcome of the action
|
||||
*/
|
||||
performAction() {
|
||||
performAction(): void {
|
||||
this.sendRequest(this.route.snapshot.queryParams.claimedTask).subscribe((successful: boolean) => {
|
||||
if (successful) {
|
||||
const title = this.translationService.get('workflow-item.' + this.type + '.notification.success.title');
|
||||
|
@@ -6,15 +6,23 @@ import { SubmissionModule } from '../submission/submission.module';
|
||||
import { WorkflowItemDeleteComponent } from './workflow-item-delete/workflow-item-delete.component';
|
||||
import { WorkflowItemSendBackComponent } from './workflow-item-send-back/workflow-item-send-back.component';
|
||||
import { ThemedWorkflowItemDeleteComponent } from './workflow-item-delete/themed-workflow-item-delete.component';
|
||||
import { ThemedWorkflowItemSendBackComponent } from './workflow-item-send-back/themed-workflow-item-send-back.component';
|
||||
import {
|
||||
ThemedWorkflowItemSendBackComponent
|
||||
} from './workflow-item-send-back/themed-workflow-item-send-back.component';
|
||||
import { StatisticsModule } from '../statistics/statistics.module';
|
||||
import { ItemPageModule } from '../item-page/item-page.module';
|
||||
import {
|
||||
AdvancedWorkflowActionsLoaderComponent
|
||||
} from './advanced-workflow-action/advanced-workflow-actions-loader/advanced-workflow-actions-loader.component';
|
||||
import { AdvancedWorkflowActionRatingReviewerComponent } from './advanced-workflow-action/advanced-workflow-action-rating-reviewer/advanced-workflow-action-rating-reviewer.component';
|
||||
import { AdvancedWorkflowActionSelectReviewerComponent } from './advanced-workflow-action/advanced-workflow-action-select-reviewer/advanced-workflow-action-select-reviewer.component';
|
||||
import { AdvancedWorkflowActionPageComponent } from './advanced-workflow-action/advanced-workflow-action-page/advanced-workflow-action-page.component';
|
||||
import {
|
||||
AdvancedWorkflowActionRatingComponent
|
||||
} from './advanced-workflow-action/advanced-workflow-action-rating/advanced-workflow-action-rating.component';
|
||||
import {
|
||||
AdvancedWorkflowActionSelectReviewerComponent
|
||||
} from './advanced-workflow-action/advanced-workflow-action-select-reviewer/advanced-workflow-action-select-reviewer.component';
|
||||
import {
|
||||
AdvancedWorkflowActionPageComponent
|
||||
} from './advanced-workflow-action/advanced-workflow-action-page/advanced-workflow-action-page.component';
|
||||
import {
|
||||
AdvancedClaimedTaskActionsDirective
|
||||
} from './advanced-workflow-action/advanced-workflow-actions-loader/advanced-claimed-task-actions.directive';
|
||||
@@ -22,24 +30,28 @@ import { AccessControlModule } from '../access-control/access-control.module';
|
||||
import {
|
||||
ReviewersListComponent
|
||||
} from './advanced-workflow-action/advanced-workflow-action-select-reviewer/reviewers-list/reviewers-list.component';
|
||||
import { FormModule } from '../shared/form/form.module';
|
||||
import { RatingModule } from 'ngx-bootstrap/rating';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
WorkflowItemsEditPageRoutingModule,
|
||||
CommonModule,
|
||||
SharedModule,
|
||||
SubmissionModule,
|
||||
StatisticsModule,
|
||||
ItemPageModule,
|
||||
AccessControlModule
|
||||
],
|
||||
imports: [
|
||||
WorkflowItemsEditPageRoutingModule,
|
||||
CommonModule,
|
||||
SharedModule,
|
||||
SubmissionModule,
|
||||
StatisticsModule,
|
||||
ItemPageModule,
|
||||
AccessControlModule,
|
||||
FormModule,
|
||||
RatingModule,
|
||||
],
|
||||
declarations: [
|
||||
WorkflowItemDeleteComponent,
|
||||
ThemedWorkflowItemDeleteComponent,
|
||||
WorkflowItemSendBackComponent,
|
||||
ThemedWorkflowItemSendBackComponent,
|
||||
AdvancedWorkflowActionsLoaderComponent,
|
||||
AdvancedWorkflowActionRatingReviewerComponent,
|
||||
AdvancedWorkflowActionRatingComponent,
|
||||
AdvancedWorkflowActionSelectReviewerComponent,
|
||||
AdvancedWorkflowActionPageComponent,
|
||||
AdvancedClaimedTaskActionsDirective,
|
||||
|
Reference in New Issue
Block a user