mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[AAE-612] Support for Form Outcome Visibility Conditions (#5934)
This commit is contained in:
@@ -36,12 +36,14 @@
|
||||
</mat-card-content>
|
||||
<mat-card-actions *ngIf="form.hasOutcomes()" class="adf-form-mat-card-actions">
|
||||
<ng-content select="adf-cloud-form-custom-outcomes"></ng-content>
|
||||
<button [id]="'adf-form-'+ outcome.name | formatSpace" *ngFor="let outcome of form.outcomes"
|
||||
[color]="getColorForOutcome(outcome.name)" mat-button [disabled]="!isOutcomeButtonEnabled(outcome)"
|
||||
[class.adf-form-hide-button]="!isOutcomeButtonVisible(outcome, form.readOnly)"
|
||||
(click)="onOutcomeClicked(outcome)">
|
||||
{{outcome.name | translate | uppercase }}
|
||||
</button>
|
||||
<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)"
|
||||
[class.adf-form-hide-button]="!isOutcomeButtonVisible(outcome, form.readOnly)"
|
||||
(click)="onOutcomeClicked(outcome)">
|
||||
{{outcome.name | translate | uppercase }}
|
||||
</button>
|
||||
</ng-container>
|
||||
</mat-card-actions>
|
||||
</mat-card>
|
||||
</div>
|
||||
|
@@ -991,6 +991,29 @@ describe('FormCloudComponent', () => {
|
||||
const label = fixture.debugElement.query(By.css(`${container} label`));
|
||||
expect(label.nativeElement.innerText).toEqual('Attach file');
|
||||
});
|
||||
|
||||
it('should be able to set visibility conditions for Outcomes', async () => {
|
||||
spyOn(formCloudService, 'getForm').and.returnValue(of(conditionalUploadWidgetsMock));
|
||||
const formId = '123';
|
||||
const appName = 'test-app';
|
||||
formComponent.formId = formId;
|
||||
formComponent.appVersion = 1;
|
||||
|
||||
formComponent.ngOnChanges({ 'appName': new SimpleChange(null, appName, true) });
|
||||
expect(formCloudService.getForm).toHaveBeenCalledWith(appName, formId, 1);
|
||||
|
||||
fixture.detectChanges();
|
||||
let outcome = fixture.debugElement.query(By.css(`#adf-form-custom_outcome`));
|
||||
expect(outcome).toBeNull();
|
||||
|
||||
const inputElement = fixture.debugElement.query(By.css('[id="field-Text0xlk8n-container"] input'));
|
||||
inputElement.nativeElement.value = 'hi';
|
||||
inputElement.nativeElement.dispatchEvent(new Event('input'));
|
||||
fixture.detectChanges();
|
||||
|
||||
outcome = fixture.debugElement.query(By.css(`#adf-form-custom_outcome`));
|
||||
expect(outcome.nativeElement.innerText).toEqual('CUSTOM OUTCOME');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Multilingual Form', () => {
|
||||
|
@@ -826,7 +826,21 @@ export const conditionalUploadWidgetsMock = {
|
||||
}
|
||||
}
|
||||
],
|
||||
'outcomes': [],
|
||||
'outcomes': [
|
||||
{
|
||||
'id': '5f2f1c2d-5a79-4ed1-a262-4fef190d41eb',
|
||||
'name': 'Custom Outcome',
|
||||
'visibilityCondition': {
|
||||
'leftType': 'field',
|
||||
'leftValue': 'Text0xlk8n',
|
||||
'operator': '==',
|
||||
'rightValue': 'hi',
|
||||
'rightType': 'value',
|
||||
'nextConditionOperator': '',
|
||||
'nextCondition': null
|
||||
}
|
||||
}
|
||||
],
|
||||
'metadata': {},
|
||||
'variables': []
|
||||
}
|
||||
|
Reference in New Issue
Block a user