mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
99053: Fixed AdvancedWorkflowActionRatingComponent's rating from validation
This commit is contained in:
@@ -7,15 +7,15 @@
|
||||
</p>
|
||||
|
||||
<form (ngSubmit)="performAction()" *ngIf="ratingForm" [formGroup]="ratingForm">
|
||||
<div *ngVar="ratingForm.get('review').touched && !ratingForm.get('review').valid as invalid" class="form-group">
|
||||
<div 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 [ngClass]="{ 'is-invalid' : isInvalid('review') }"
|
||||
[required]="advancedInfo?.descriptionRequired" class="form-control" formControlName="review">
|
||||
</textarea>
|
||||
<small *ngIf="invalid" class="invalid-feedback d-block">
|
||||
<small *ngIf="isInvalid('review')" class="invalid-feedback d-block">
|
||||
{{ 'advanced-workflow-action.rating.form.review.error' | translate }}
|
||||
</small>
|
||||
</div>
|
||||
@@ -24,8 +24,12 @@
|
||||
<label class="control-label">
|
||||
{{ 'advanced-workflow-action.rating.form.rating.label' | translate }}*
|
||||
</label>
|
||||
<rating [max]="advancedInfo?.maxValue" class="d-block" formControlName="rating">
|
||||
<rating [max]="advancedInfo?.maxValue" [ngClass]="{ 'text-danger': isInvalid('rating') }"
|
||||
class="d-block" formControlName="rating">
|
||||
</rating>
|
||||
<small *ngIf="isInvalid('rating')" class="invalid-feedback d-block">
|
||||
{{ 'advanced-workflow-action.rating.form.rating.error' | translate }}
|
||||
</small>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
@@ -3,11 +3,9 @@ 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 { FormGroup, FormControl, Validators } from '@angular/forms';
|
||||
import { WorkflowAction } from '../../../core/tasks/models/workflow-action-object.model';
|
||||
import {
|
||||
RatingAdvancedWorkflowInfo
|
||||
} from '../../../core/tasks/models/rating-advanced-workflow-info.model';
|
||||
import { RatingAdvancedWorkflowInfo } from '../../../core/tasks/models/rating-advanced-workflow-info.model';
|
||||
|
||||
export const ADVANCED_WORKFLOW_TASK_OPTION_RATING = 'submit_score';
|
||||
export const ADVANCED_WORKFLOW_ACTION_RATING = 'scorereviewaction';
|
||||
@@ -30,7 +28,7 @@ export class AdvancedWorkflowActionRatingComponent extends AdvancedWorkflowActio
|
||||
super.ngOnInit();
|
||||
this.ratingForm = new FormGroup({
|
||||
review: new FormControl(''),
|
||||
rating: new FormControl(0),
|
||||
rating: new FormControl(0, Validators.min(1)),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -69,4 +67,13 @@ export class AdvancedWorkflowActionRatingComponent extends AdvancedWorkflowActio
|
||||
return workflowAction ? (workflowAction.advancedInfo[0] as RatingAdvancedWorkflowInfo) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the field is valid or not.
|
||||
*
|
||||
* @param formControlName The input field
|
||||
*/
|
||||
isInvalid(formControlName: string): boolean {
|
||||
return this.ratingForm.get(formControlName).touched && !this.ratingForm.get(formControlName).valid;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -541,6 +541,8 @@
|
||||
|
||||
"advanced-workflow-action.rating.form.rating.label": "Rating",
|
||||
|
||||
"advanced-workflow-action.rating.form.rating.error": "You must rate the item",
|
||||
|
||||
"advanced-workflow-action.rating.form.review.label": "Review",
|
||||
|
||||
"advanced-workflow-action.rating.form.review.error": "You must enter a review to submit this rating",
|
||||
|
Reference in New Issue
Block a user