Added more tests

This commit is contained in:
Giuseppe Digilio
2018-06-19 15:10:56 +02:00
parent 4a2e2b754b
commit 3fdb074d05
7 changed files with 801 additions and 36 deletions

View File

@@ -3,12 +3,12 @@ import { DynamicSelectModel, DynamicSelectModelConfig } from '@ng-dynamic-forms/
import { FieldParser } from './field-parser';
import { FormFieldModel } from '../models/form-field.model';
import {
COMBOBOX_GROUP_SUFFIX,
COMBOBOX_METADATA_SUFFIX,
COMBOBOX_VALUE_SUFFIX,
DsDynamicComboboxModelConfig,
DynamicComboboxModel
} from '../ds-dynamic-form-ui/models/ds-dynamic-combobox.model';
QUALDROP_GROUP_SUFFIX,
QUALDROP_METADATA_SUFFIX,
QUALDROP_VALUE_SUFFIX,
DsDynamicQualdropModelConfig,
DynamicQualdropModel
} from '../ds-dynamic-form-ui/models/ds-dynamic-qualdrop.model';
import { FormFieldMetadataValueObject } from '../models/form-field-metadata-value.model';
import { isNotEmpty } from '../../../empty.util';
import { DsDynamicInputModel, DsDynamicInputModelConfig } from '../ds-dynamic-form-ui/models/ds-dynamic-input.model';
@@ -58,25 +58,25 @@ export class OneboxFieldParser extends FieldParser {
.slice(0, this.configData.selectableMetadata[0].metadata.split('.').length - 1)
.join('.');
const inputSelectGroup: DsDynamicComboboxModelConfig = Object.create(null);
inputSelectGroup.id = newId.replace(/\./g, '_') + COMBOBOX_GROUP_SUFFIX;
const inputSelectGroup: DsDynamicQualdropModelConfig = Object.create(null);
inputSelectGroup.id = newId.replace(/\./g, '_') + QUALDROP_GROUP_SUFFIX;
inputSelectGroup.group = [];
inputSelectGroup.legend = this.configData.label;
const selectModelConfig: DynamicSelectModelConfig<any> = this.initModel(newId + COMBOBOX_METADATA_SUFFIX);
const selectModelConfig: DynamicSelectModelConfig<any> = this.initModel(newId + QUALDROP_METADATA_SUFFIX);
this.setOptions(selectModelConfig);
if (isNotEmpty(fieldValue)) {
selectModelConfig.value = fieldValue.metadata;
}
inputSelectGroup.group.push(new DynamicSelectModel(selectModelConfig, clsSelect));
const inputModelConfig: DsDynamicInputModelConfig = this.initModel(newId + COMBOBOX_VALUE_SUFFIX, true, true);
const inputModelConfig: DsDynamicInputModelConfig = this.initModel(newId + QUALDROP_VALUE_SUFFIX, true, true);
this.setValues(inputModelConfig, fieldValue);
inputSelectGroup.readOnly = selectModelConfig.disabled && inputModelConfig.readOnly;
inputSelectGroup.group.push(new DsDynamicInputModel(inputModelConfig, clsInput));
return new DynamicComboboxModel(inputSelectGroup, clsGroup);
return new DynamicQualdropModel(inputSelectGroup, clsGroup);
} else if (this.configData.selectableMetadata[0].authority) {
const typeaheadModelConfig: DsDynamicTypeaheadModelConfig = this.initModel();
this.setAuthorityOptions(typeaheadModelConfig, this.authorityUuid);