mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[AAE-15522] Fix - Dropdown variable error messages are displayed at modeling part 2 (#8734)
* Revert preview flag changes * add get preview state method to form cloud service
This commit is contained in:
@@ -1093,30 +1093,6 @@ describe('FormCloudComponent', () => {
|
||||
expect(formComponent.disableSaveButton).toBeTrue();
|
||||
});
|
||||
|
||||
it('should set form preview state', () => {
|
||||
const formModel = new FormModel();
|
||||
formComponent.form = formModel;
|
||||
formComponent.preview = true;
|
||||
formComponent.ngOnChanges({
|
||||
preview: {
|
||||
currentValue: true,
|
||||
previousValue: undefined,
|
||||
firstChange: false,
|
||||
isFirstChange: () => false
|
||||
}
|
||||
});
|
||||
|
||||
expect(formComponent.form.preview).toBe(true);
|
||||
});
|
||||
|
||||
it('should form preview state be false as default', () => {
|
||||
const formModel = new FormModel();
|
||||
formComponent.form = formModel;
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(formComponent.form.preview).toBe(false);
|
||||
});
|
||||
|
||||
describe('form validations', () => {
|
||||
it('should be able to set visibility conditions for Attach File widget', async () => {
|
||||
spyOn(formCloudService, 'getForm').and.returnValue(of(conditionalUploadWidgetsMock));
|
||||
|
@@ -82,9 +82,6 @@ export class FormCloudComponent extends FormBaseComponent implements OnChanges,
|
||||
@Input()
|
||||
fieldValidators: FormFieldValidator[] = [...FORM_FIELD_VALIDATORS];
|
||||
|
||||
@Input()
|
||||
preview: boolean = false;
|
||||
|
||||
/** Emitted when the form is submitted with the `Save` or custom outcomes. */
|
||||
@Output()
|
||||
formSaved = new EventEmitter<FormModel>();
|
||||
@@ -179,10 +176,6 @@ export class FormCloudComponent extends FormBaseComponent implements OnChanges,
|
||||
this.refreshFormData();
|
||||
return;
|
||||
}
|
||||
|
||||
if (changes?.preview?.currentValue) {
|
||||
this.setFormPreviewState();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -364,10 +357,6 @@ export class FormCloudComponent extends FormBaseComponent implements OnChanges,
|
||||
this.onFormDataRefreshed(this.form);
|
||||
}
|
||||
|
||||
private setFormPreviewState(): void {
|
||||
this.form.preview = this.preview;
|
||||
}
|
||||
|
||||
protected onFormLoaded(form: FormModel) {
|
||||
this.formLoaded.emit(form);
|
||||
}
|
||||
|
@@ -1023,18 +1023,9 @@ describe('DropdownCloudWidgetComponent', () => {
|
||||
expect(logServiceSpy).toHaveBeenCalledWith('variables.json-variable not found');
|
||||
});
|
||||
|
||||
it('should NOT display errors if field is in the preview state', () => {
|
||||
widget.field = getVariableDropdownWidget('variables.json-variable', 'response.wrongPath.players', 'playerId', 'playerFullName', mockProcessVariablesWithJson);
|
||||
widget.field.preview = true;
|
||||
fixture.detectChanges();
|
||||
|
||||
const failedErrorMsgElement = fixture.debugElement.query(By.css('.adf-dropdown-failed-message'));
|
||||
expect(failedErrorMsgElement).toBeNull();
|
||||
});
|
||||
|
||||
it('should NOT display errors if form is in the preview state', () => {
|
||||
widget.field = getVariableDropdownWidget('variables.json-variable', 'response.wrongPath.players', 'playerId', 'playerFullName', mockProcessVariablesWithJson);
|
||||
widget.field.form.preview = true;
|
||||
spyOn(formCloudService, 'getPreviewState').and.returnValue(true);
|
||||
fixture.detectChanges();
|
||||
|
||||
const failedErrorMsgElement = fixture.debugElement.query(By.css('.adf-dropdown-failed-message'));
|
||||
|
@@ -375,11 +375,13 @@ export class DropdownCloudWidgetComponent extends WidgetComponent implements OnI
|
||||
}
|
||||
|
||||
private setPreviewState(): void {
|
||||
this.previewState = this.field?.form?.preview ||this.field?.preview;
|
||||
this.previewState = this.formCloudService.getPreviewState();
|
||||
}
|
||||
|
||||
private handleError(error: any) {
|
||||
this.logService.error(error);
|
||||
if (!this.previewState) {
|
||||
this.logService.error(error);
|
||||
}
|
||||
}
|
||||
|
||||
isReadOnlyType(): boolean {
|
||||
|
@@ -229,4 +229,8 @@ export class FormCloudService extends BaseCloudService implements FormCloudServi
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
getPreviewState(): boolean {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user