mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
99053: Fixed AdvancedWorkflowActionRatingComponent's rating from validation
This commit is contained in:
@@ -7,15 +7,15 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<form (ngSubmit)="performAction()" *ngIf="ratingForm" [formGroup]="ratingForm">
|
<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">
|
<label class="control-label">
|
||||||
<span>{{ 'advanced-workflow-action.rating.form.review.label' | translate }}</span>
|
<span>{{ 'advanced-workflow-action.rating.form.review.label' | translate }}</span>
|
||||||
<span *ngIf="advancedInfo?.descriptionRequired">*</span>
|
<span *ngIf="advancedInfo?.descriptionRequired">*</span>
|
||||||
</label>
|
</label>
|
||||||
<textarea [ngClass]="invalid ? 'is-invalid' : ''" [required]="advancedInfo?.descriptionRequired"
|
<textarea [ngClass]="{ 'is-invalid' : isInvalid('review') }"
|
||||||
class="form-control" formControlName="review">
|
[required]="advancedInfo?.descriptionRequired" class="form-control" formControlName="review">
|
||||||
</textarea>
|
</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 }}
|
{{ 'advanced-workflow-action.rating.form.review.error' | translate }}
|
||||||
</small>
|
</small>
|
||||||
</div>
|
</div>
|
||||||
@@ -24,8 +24,12 @@
|
|||||||
<label class="control-label">
|
<label class="control-label">
|
||||||
{{ 'advanced-workflow-action.rating.form.rating.label' | translate }}*
|
{{ 'advanced-workflow-action.rating.form.rating.label' | translate }}*
|
||||||
</label>
|
</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>
|
</rating>
|
||||||
|
<small *ngIf="isInvalid('rating')" class="invalid-feedback d-block">
|
||||||
|
{{ 'advanced-workflow-action.rating.form.rating.error' | translate }}
|
||||||
|
</small>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
@@ -3,11 +3,9 @@ import {
|
|||||||
rendersAdvancedWorkflowTaskOption
|
rendersAdvancedWorkflowTaskOption
|
||||||
} from '../../../shared/mydspace-actions/claimed-task/switcher/claimed-task-actions-decorator';
|
} from '../../../shared/mydspace-actions/claimed-task/switcher/claimed-task-actions-decorator';
|
||||||
import { AdvancedWorkflowActionComponent } from '../advanced-workflow-action/advanced-workflow-action.component';
|
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 { WorkflowAction } from '../../../core/tasks/models/workflow-action-object.model';
|
||||||
import {
|
import { RatingAdvancedWorkflowInfo } from '../../../core/tasks/models/rating-advanced-workflow-info.model';
|
||||||
RatingAdvancedWorkflowInfo
|
|
||||||
} from '../../../core/tasks/models/rating-advanced-workflow-info.model';
|
|
||||||
|
|
||||||
export const ADVANCED_WORKFLOW_TASK_OPTION_RATING = 'submit_score';
|
export const ADVANCED_WORKFLOW_TASK_OPTION_RATING = 'submit_score';
|
||||||
export const ADVANCED_WORKFLOW_ACTION_RATING = 'scorereviewaction';
|
export const ADVANCED_WORKFLOW_ACTION_RATING = 'scorereviewaction';
|
||||||
@@ -30,7 +28,7 @@ export class AdvancedWorkflowActionRatingComponent extends AdvancedWorkflowActio
|
|||||||
super.ngOnInit();
|
super.ngOnInit();
|
||||||
this.ratingForm = new FormGroup({
|
this.ratingForm = new FormGroup({
|
||||||
review: new FormControl(''),
|
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;
|
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.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.label": "Review",
|
||||||
|
|
||||||
"advanced-workflow-action.rating.form.review.error": "You must enter a review to submit this rating",
|
"advanced-workflow-action.rating.form.review.error": "You must enter a review to submit this rating",
|
||||||
|
Reference in New Issue
Block a user