mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
This reverts commit d91fba7259
.
This commit is contained in:
@@ -808,14 +808,6 @@ describe('DropdownCloudWidgetComponent', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const getVariableDropdownWidgetWithoutConfig = () =>
|
|
||||||
new FormFieldModel(new FormModel({ taskId: 'fake-task-id', readOnly: 'false' }), {
|
|
||||||
id: 'variable-dropdown-id',
|
|
||||||
name: 'variable-options-dropdown',
|
|
||||||
type: 'dropdown',
|
|
||||||
optionType: 'variable'
|
|
||||||
});
|
|
||||||
|
|
||||||
const checkDropdownVariableOptionsFailed = () => {
|
const checkDropdownVariableOptionsFailed = () => {
|
||||||
const failedErrorMsgElement = fixture.debugElement.query(By.css('.adf-dropdown-failed-message'));
|
const failedErrorMsgElement = fixture.debugElement.query(By.css('.adf-dropdown-failed-message'));
|
||||||
expect(failedErrorMsgElement.nativeElement.textContent.trim()).toBe(errorIcon.concat('FORM.FIELD.VARIABLE_DROPDOWN_OPTIONS_FAILED'));
|
expect(failedErrorMsgElement.nativeElement.textContent.trim()).toBe(errorIcon.concat('FORM.FIELD.VARIABLE_DROPDOWN_OPTIONS_FAILED'));
|
||||||
@@ -823,16 +815,6 @@ describe('DropdownCloudWidgetComponent', () => {
|
|||||||
expect(widget.field.options.length).toEqual(0);
|
expect(widget.field.options.length).toEqual(0);
|
||||||
};
|
};
|
||||||
|
|
||||||
it('should add default variable config when variable config property is not provided', () => {
|
|
||||||
widget.field = getVariableDropdownWidgetWithoutConfig();
|
|
||||||
fixture.detectChanges();
|
|
||||||
|
|
||||||
expect(widget.field.json.variableConfig.variableName).toBe('');
|
|
||||||
expect(widget.field.json.variableConfig.optionsPath).toBe('data');
|
|
||||||
expect(widget.field.json.variableConfig.optionsId).toBe('id');
|
|
||||||
expect(widget.field.json.variableConfig.optionsLabel).toBe('name');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should display options persisted from process variable', async () => {
|
it('should display options persisted from process variable', async () => {
|
||||||
widget.field = getVariableDropdownWidget(
|
widget.field = getVariableDropdownWidget(
|
||||||
'variables.json-variable',
|
'variables.json-variable',
|
||||||
|
@@ -24,7 +24,6 @@ import {
|
|||||||
FormFieldTypes,
|
FormFieldTypes,
|
||||||
FormService,
|
FormService,
|
||||||
RuleEntry,
|
RuleEntry,
|
||||||
VariableConfig,
|
|
||||||
WidgetComponent
|
WidgetComponent
|
||||||
} from '@alfresco/adf-core';
|
} from '@alfresco/adf-core';
|
||||||
import { FormCloudService } from '../../../services/form-cloud.service';
|
import { FormCloudService } from '../../../services/form-cloud.service';
|
||||||
@@ -67,7 +66,6 @@ export class DropdownCloudWidgetComponent extends WidgetComponent implements OnI
|
|||||||
list$: Observable<FormFieldOption[]>;
|
list$: Observable<FormFieldOption[]>;
|
||||||
filter$ = new BehaviorSubject<string>('');
|
filter$ = new BehaviorSubject<string>('');
|
||||||
|
|
||||||
private readonly defaultVariableName = '';
|
|
||||||
private readonly defaultVariableOptionId = 'id';
|
private readonly defaultVariableOptionId = 'id';
|
||||||
private readonly defaultVariableOptionLabel = 'name';
|
private readonly defaultVariableOptionLabel = 'name';
|
||||||
private readonly defaultVariableOptionPath = 'data';
|
private readonly defaultVariableOptionPath = 'data';
|
||||||
@@ -82,7 +80,6 @@ export class DropdownCloudWidgetComponent extends WidgetComponent implements OnI
|
|||||||
this.setPreviewState();
|
this.setPreviewState();
|
||||||
this.checkFieldOptionsSource();
|
this.checkFieldOptionsSource();
|
||||||
this.updateOptions();
|
this.updateOptions();
|
||||||
this.setDefaultVariableConfig();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private checkFieldOptionsSource(): void {
|
private checkFieldOptionsSource(): void {
|
||||||
@@ -106,19 +103,6 @@ export class DropdownCloudWidgetComponent extends WidgetComponent implements OnI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private setDefaultVariableConfig(): void {
|
|
||||||
if (!this.field.json) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.field.json.variableConfig = {
|
|
||||||
variableName: this.field.json?.variableConfig?.variableName || this.defaultVariableName,
|
|
||||||
optionsPath: this.field.json?.variableConfig?.optionsPath || this.defaultVariableOptionPath,
|
|
||||||
optionsId: this.field.json?.variableConfig?.optionsId || this.defaultVariableOptionId,
|
|
||||||
optionsLabel: this.field.json?.variableConfig?.optionsLabel || this.defaultVariableOptionLabel
|
|
||||||
} as VariableConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
private persistFieldOptionsFromVariable(): void {
|
private persistFieldOptionsFromVariable(): void {
|
||||||
const optionsPath = this.field?.variableConfig?.optionsPath ?? this.defaultVariableOptionPath;
|
const optionsPath = this.field?.variableConfig?.optionsPath ?? this.defaultVariableOptionPath;
|
||||||
const variableName = this.field?.variableConfig?.variableName;
|
const variableName = this.field?.variableConfig?.variableName;
|
||||||
|
Reference in New Issue
Block a user