AAE-22720 Add a new "Skip validation" option in outcome properties (#9752)

* AAE-22720 Add a new "Skip validation" option in outcome properties

* cr
This commit is contained in:
Bartosz Sekula
2024-06-03 09:38:44 +02:00
committed by GitHub
parent f411754ede
commit 0ea35b1f12
4 changed files with 33 additions and 9 deletions

View File

@@ -118,12 +118,15 @@ export abstract class FormBaseComponent {
return outcomeName === FormBaseComponent.COMPLETE_OUTCOME_NAME ? FormBaseComponent.COMPLETE_BUTTON_COLOR : null;
}
isOutcomeButtonEnabled(outcome: FormOutcomeModel): boolean {
isOutcomeButtonEnabled(outcome?: FormOutcomeModel): boolean {
if (this.form.readOnly) {
return false;
}
if (outcome) {
if (outcome.skipValidation) {
return true;
}
if (outcome.name === FormOutcomeModel.SAVE_ACTION) {
return !this.disableSaveButton;
}
@@ -135,6 +138,7 @@ export abstract class FormBaseComponent {
}
return this.form.isValid;
}
return false;
}

View File

@@ -21,7 +21,6 @@ import { FormWidgetModel } from './form-widget.model';
import { WidgetVisibilityModel } from '../../../models/widget-visibility.model';
export class FormOutcomeModel extends FormWidgetModel {
static SAVE_ACTION: string = 'SAVE'; // Activiti 'Save' action name
static COMPLETE_ACTION: string = 'COMPLETE'; // Activiti 'Complete' action name
static START_PROCESS_ACTION: string = 'START PROCESS'; // Activiti 'Start Process' action name
@@ -29,6 +28,7 @@ export class FormOutcomeModel extends FormWidgetModel {
isSystem: boolean = false;
isSelected: boolean = false;
isVisible: boolean = true;
skipValidation: boolean = false;
visibilityCondition: WidgetVisibilityModel;
constructor(form: any, json?: any) {
@@ -36,6 +36,7 @@ export class FormOutcomeModel extends FormWidgetModel {
if (json) {
this.isSystem = json.isSystem ? true : false;
this.skipValidation = json.skipValidation ?? false;
this.isSelected = form && json.name === form.selectedOutcome ? true : false;
this.visibilityCondition = new WidgetVisibilityModel(json.visibilityCondition);
}

View File

@@ -69,10 +69,15 @@
<mat-card-actions *ngIf="form.hasOutcomes()" class="adf-form-mat-card-actions">
<ng-content select="adf-cloud-form-custom-outcomes"></ng-content>
<ng-container *ngFor="let outcome of form.outcomes">
<button *ngIf="outcome.isVisible" [id]="'adf-form-'+ outcome.name | formatSpace" [color]="getColorForOutcome(outcome.name)"
mat-button [disabled]="!isOutcomeButtonEnabled(outcome)"
<button
*ngIf="outcome.isVisible"
[id]="'adf-form-'+ outcome.name | formatSpace"
[color]="getColorForOutcome(outcome.name)"
mat-button
[disabled]="!isOutcomeButtonEnabled(outcome)"
[class.adf-form-hide-button]="!isOutcomeButtonVisible(outcome, form.readOnly)"
(click)="onOutcomeClicked(outcome)">
(click)="onOutcomeClicked(outcome)"
>
{{outcome.name | translate | uppercase }}
</button>
</ng-container>

View File

@@ -990,6 +990,20 @@ describe('FormCloudComponent', () => {
expect(formComponent.isOutcomeButtonEnabled(saveOutcome)).toBeTruthy();
});
it('should enable outcome with skip validation property, even if the form is not valid', () => {
const formModel = new FormModel(cloudFormMock);
formComponent.form = formModel;
formModel.isValid = false;
const customOutcome = new FormOutcomeModel(new FormModel(), {
id: FormCloudComponent.CUSTOM_OUTCOME_ID,
name: 'Custom',
skipValidation: true
});
expect(formComponent.isOutcomeButtonEnabled(customOutcome)).toBeTruthy();
});
it('should disable start process outcome button when disableStartProcessButton is true', () => {
const formModel = new FormModel(cloudFormMock);
formComponent.form = formModel;