diff --git a/lib/core/src/lib/form/components/form-base.component.ts b/lib/core/src/lib/form/components/form-base.component.ts index 48475aabcc..3e90bb04db 100644 --- a/lib/core/src/lib/form/components/form-base.component.ts +++ b/lib/core/src/lib/form/components/form-base.component.ts @@ -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; } diff --git a/lib/core/src/lib/form/components/widgets/core/form-outcome.model.ts b/lib/core/src/lib/form/components/widgets/core/form-outcome.model.ts index c71355e215..dc20823f50 100644 --- a/lib/core/src/lib/form/components/widgets/core/form-outcome.model.ts +++ b/lib/core/src/lib/form/components/widgets/core/form-outcome.model.ts @@ -15,20 +15,20 @@ * limitations under the License. */ - /* eslint-disable @angular-eslint/component-selector */ +/* eslint-disable @angular-eslint/component-selector */ 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 + 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 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); } diff --git a/lib/process-services-cloud/src/lib/form/components/form-cloud.component.html b/lib/process-services-cloud/src/lib/form/components/form-cloud.component.html index 8cc4a6ade3..c2c15fef4b 100644 --- a/lib/process-services-cloud/src/lib/form/components/form-cloud.component.html +++ b/lib/process-services-cloud/src/lib/form/components/form-cloud.component.html @@ -69,10 +69,15 @@ - diff --git a/lib/process-services-cloud/src/lib/form/components/form-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/form/components/form-cloud.component.spec.ts index 39fed03064..17999130dd 100644 --- a/lib/process-services-cloud/src/lib/form/components/form-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/form/components/form-cloud.component.spec.ts @@ -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;