mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
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:
@@ -118,12 +118,15 @@ export abstract class FormBaseComponent {
|
|||||||
return outcomeName === FormBaseComponent.COMPLETE_OUTCOME_NAME ? FormBaseComponent.COMPLETE_BUTTON_COLOR : null;
|
return outcomeName === FormBaseComponent.COMPLETE_OUTCOME_NAME ? FormBaseComponent.COMPLETE_BUTTON_COLOR : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
isOutcomeButtonEnabled(outcome: FormOutcomeModel): boolean {
|
isOutcomeButtonEnabled(outcome?: FormOutcomeModel): boolean {
|
||||||
if (this.form.readOnly) {
|
if (this.form.readOnly) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (outcome) {
|
if (outcome) {
|
||||||
|
if (outcome.skipValidation) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (outcome.name === FormOutcomeModel.SAVE_ACTION) {
|
if (outcome.name === FormOutcomeModel.SAVE_ACTION) {
|
||||||
return !this.disableSaveButton;
|
return !this.disableSaveButton;
|
||||||
}
|
}
|
||||||
@@ -135,6 +138,7 @@ export abstract class FormBaseComponent {
|
|||||||
}
|
}
|
||||||
return this.form.isValid;
|
return this.form.isValid;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -15,20 +15,20 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* eslint-disable @angular-eslint/component-selector */
|
/* eslint-disable @angular-eslint/component-selector */
|
||||||
|
|
||||||
import { FormWidgetModel } from './form-widget.model';
|
import { FormWidgetModel } from './form-widget.model';
|
||||||
import { WidgetVisibilityModel } from '../../../models/widget-visibility.model';
|
import { WidgetVisibilityModel } from '../../../models/widget-visibility.model';
|
||||||
|
|
||||||
export class FormOutcomeModel extends FormWidgetModel {
|
export class FormOutcomeModel extends FormWidgetModel {
|
||||||
|
static SAVE_ACTION: string = 'SAVE'; // Activiti 'Save' action name
|
||||||
static SAVE_ACTION: string = 'SAVE'; // Activiti 'Save' action name
|
static COMPLETE_ACTION: string = 'COMPLETE'; // Activiti 'Complete' action name
|
||||||
static COMPLETE_ACTION: string = 'COMPLETE'; // Activiti 'Complete' action name
|
static START_PROCESS_ACTION: string = 'START PROCESS'; // Activiti 'Start Process' action name
|
||||||
static START_PROCESS_ACTION: string = 'START PROCESS'; // Activiti 'Start Process' action name
|
|
||||||
|
|
||||||
isSystem: boolean = false;
|
isSystem: boolean = false;
|
||||||
isSelected: boolean = false;
|
isSelected: boolean = false;
|
||||||
isVisible: boolean = true;
|
isVisible: boolean = true;
|
||||||
|
skipValidation: boolean = false;
|
||||||
visibilityCondition: WidgetVisibilityModel;
|
visibilityCondition: WidgetVisibilityModel;
|
||||||
|
|
||||||
constructor(form: any, json?: any) {
|
constructor(form: any, json?: any) {
|
||||||
@@ -36,6 +36,7 @@ export class FormOutcomeModel extends FormWidgetModel {
|
|||||||
|
|
||||||
if (json) {
|
if (json) {
|
||||||
this.isSystem = json.isSystem ? true : false;
|
this.isSystem = json.isSystem ? true : false;
|
||||||
|
this.skipValidation = json.skipValidation ?? false;
|
||||||
this.isSelected = form && json.name === form.selectedOutcome ? true : false;
|
this.isSelected = form && json.name === form.selectedOutcome ? true : false;
|
||||||
this.visibilityCondition = new WidgetVisibilityModel(json.visibilityCondition);
|
this.visibilityCondition = new WidgetVisibilityModel(json.visibilityCondition);
|
||||||
}
|
}
|
||||||
|
@@ -69,10 +69,15 @@
|
|||||||
<mat-card-actions *ngIf="form.hasOutcomes()" class="adf-form-mat-card-actions">
|
<mat-card-actions *ngIf="form.hasOutcomes()" class="adf-form-mat-card-actions">
|
||||||
<ng-content select="adf-cloud-form-custom-outcomes"></ng-content>
|
<ng-content select="adf-cloud-form-custom-outcomes"></ng-content>
|
||||||
<ng-container *ngFor="let outcome of form.outcomes">
|
<ng-container *ngFor="let outcome of form.outcomes">
|
||||||
<button *ngIf="outcome.isVisible" [id]="'adf-form-'+ outcome.name | formatSpace" [color]="getColorForOutcome(outcome.name)"
|
<button
|
||||||
mat-button [disabled]="!isOutcomeButtonEnabled(outcome)"
|
*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)"
|
[class.adf-form-hide-button]="!isOutcomeButtonVisible(outcome, form.readOnly)"
|
||||||
(click)="onOutcomeClicked(outcome)">
|
(click)="onOutcomeClicked(outcome)"
|
||||||
|
>
|
||||||
{{outcome.name | translate | uppercase }}
|
{{outcome.name | translate | uppercase }}
|
||||||
</button>
|
</button>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
@@ -990,6 +990,20 @@ describe('FormCloudComponent', () => {
|
|||||||
expect(formComponent.isOutcomeButtonEnabled(saveOutcome)).toBeTruthy();
|
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', () => {
|
it('should disable start process outcome button when disableStartProcessButton is true', () => {
|
||||||
const formModel = new FormModel(cloudFormMock);
|
const formModel = new FormModel(cloudFormMock);
|
||||||
formComponent.form = formModel;
|
formComponent.form = formModel;
|
||||||
|
Reference in New Issue
Block a user