Merge remote-tracking branch 'remotes/origin/main' into authorities_and_controlled_vocabularies

This commit is contained in:
Giuseppe Digilio
2020-07-23 11:41:03 +02:00
163 changed files with 2132 additions and 1140 deletions

View File

@@ -56,10 +56,10 @@ describe('FormBuilderService test suite', () => {
let testFormConfiguration: SubmissionFormsModel;
let service: FormBuilderService;
const submissionId = '1234';
const submissionId = '1234';
function testValidator() {
return {testValidator: {valid: true}};
return { testValidator: { valid: true } };
}
function testAsyncValidator() {
@@ -71,10 +71,10 @@ describe('FormBuilderService test suite', () => {
TestBed.configureTestingModule({
imports: [ReactiveFormsModule],
providers: [
{provide: FormBuilderService, useClass: FormBuilderService},
{provide: DynamicFormValidationService, useValue: {}},
{provide: NG_VALIDATORS, useValue: testValidator, multi: true},
{provide: NG_ASYNC_VALIDATORS, useValue: testAsyncValidator, multi: true}
{ provide: FormBuilderService, useClass: FormBuilderService },
{ provide: DynamicFormValidationService, useValue: {} },
{ provide: NG_VALIDATORS, useValue: testValidator, multi: true },
{ provide: NG_ASYNC_VALIDATORS, useValue: testAsyncValidator, multi: true }
]
});
@@ -148,9 +148,9 @@ describe('FormBuilderService test suite', () => {
}
),
new DynamicTextAreaModel({id: 'testTextArea'}),
new DynamicTextAreaModel({ id: 'testTextArea' }),
new DynamicCheckboxModel({id: 'testCheckbox'}),
new DynamicCheckboxModel({ id: 'testCheckbox' }),
new DynamicFormArrayModel(
{
@@ -158,10 +158,10 @@ describe('FormBuilderService test suite', () => {
initialCount: 5,
groupFactory: () => {
return [
new DynamicInputModel({id: 'testFormArrayGroupInput'}),
new DynamicInputModel({ id: 'testFormArrayGroupInput' }),
new DynamicFormArrayModel({
id: 'testNestedFormArray', groupFactory: () => [
new DynamicInputModel({id: 'testNestedFormArrayGroupInput'})
new DynamicInputModel({ id: 'testNestedFormArrayGroupInput' })
]
})
];
@@ -173,33 +173,33 @@ describe('FormBuilderService test suite', () => {
{
id: 'testFormGroup',
group: [
new DynamicInputModel({id: 'nestedTestInput'}),
new DynamicTextAreaModel({id: 'nestedTestTextArea'})
new DynamicInputModel({ id: 'nestedTestInput' }),
new DynamicTextAreaModel({ id: 'nestedTestTextArea' })
]
}
),
new DynamicSliderModel({id: 'testSlider'}),
new DynamicSliderModel({ id: 'testSlider' }),
new DynamicSwitchModel({id: 'testSwitch'}),
new DynamicSwitchModel({ id: 'testSwitch' }),
new DynamicDatePickerModel({id: 'testDatepicker', value: new Date()}),
new DynamicDatePickerModel({ id: 'testDatepicker', value: new Date() }),
new DynamicFileUploadModel({id: 'testFileUpload'}),
new DynamicFileUploadModel({ id: 'testFileUpload' }),
new DynamicEditorModel({id: 'testEditor'}),
new DynamicEditorModel({ id: 'testEditor' }),
new DynamicTimePickerModel({id: 'testTimePicker'}),
new DynamicTimePickerModel({ id: 'testTimePicker' }),
new DynamicRatingModel({id: 'testRating'}),
new DynamicRatingModel({ id: 'testRating' }),
new DynamicColorPickerModel({id: 'testColorPicker'}),
new DynamicColorPickerModel({ id: 'testColorPicker' }),
new DynamicOneboxModel({id: 'testOnebox', repeatable: false, metadataFields: [], submissionId: '1234'}),
new DynamicOneboxModel({ id: 'testOnebox', repeatable: false, metadataFields: [], submissionId: '1234', hasSelectableMetadata: false }),
new DynamicScrollableDropdownModel({id: 'testScrollableDropdown', vocabularyOptions: vocabularyOptions, repeatable: false, metadataFields: [], submissionId: '1234'}),
new DynamicScrollableDropdownModel({ id: 'testScrollableDropdown', vocabularyOptions: vocabularyOptions, repeatable: false, metadataFields: [], submissionId: '1234', hasSelectableMetadata: false }),
new DynamicTagModel({id: 'testTag', repeatable: false, metadataFields: [], submissionId: '1234'}),
new DynamicTagModel({ id: 'testTag', repeatable: false, metadataFields: [], submissionId: '1234', hasSelectableMetadata: false }),
new DynamicListCheckboxGroupModel({id: 'testCheckboxList', vocabularyOptions: vocabularyOptions, repeatable: true}),
@@ -211,7 +211,7 @@ describe('FormBuilderService test suite', () => {
formConfiguration: [{
fields: [{
hints: 'Enter the name of the author.',
input: {type: 'onebox'},
input: { type: 'onebox' },
label: 'Authors',
languageCodes: [],
mandatory: 'true',
@@ -221,12 +221,12 @@ describe('FormBuilderService test suite', () => {
controlledVocabulary: 'RPAuthority',
closed: false,
metadata: 'dc.contributor.author'
}],
}]
} as FormFieldModel]
} as FormRowModel, {
fields: [{
hints: 'Enter the affiliation of the author.',
input: {type: 'onebox'},
input: { type: 'onebox' },
label: 'Affiliation',
languageCodes: [],
mandatory: 'false',
@@ -244,29 +244,35 @@ describe('FormBuilderService test suite', () => {
scopeUUID: '',
submissionScope: '',
repeatable: false,
metadataFields: []
metadataFields: [],
hasSelectableMetadata: true
}),
new DynamicDsDatePickerModel({id: 'testDate'}),
new DynamicDsDatePickerModel({ id: 'testDate' }),
new DynamicLookupModel({id: 'testLookup', repeatable: false, metadataFields: [], submissionId: '1234'}),
new DynamicLookupModel({ id: 'testLookup', repeatable: false, metadataFields: [], submissionId: '1234', hasSelectableMetadata: true }),
new DynamicLookupNameModel({id: 'testLookupName', repeatable: false, metadataFields: [], submissionId: '1234'}),
new DynamicLookupNameModel({ id: 'testLookupName', repeatable: false, metadataFields: [], submissionId: '1234', hasSelectableMetadata: true }),
new DynamicQualdropModel({id: 'testCombobox', readOnly: false, required: false}),
new DynamicQualdropModel({ id: 'testCombobox', readOnly: false, required: false }),
new DynamicRowArrayModel(
{
id: 'testFormRowArray',
initialCount: 5,
notRepeatable: false,
relationshipConfig: undefined,
submissionId: '1234',
groupFactory: () => {
return [
new DynamicInputModel({id: 'testFormRowArrayGroupInput'})
new DynamicInputModel({ id: 'testFormRowArrayGroupInput' })
];
},
required: false
}
required: false,
metadataKey: 'dc.contributor.author',
metadataFields: ['dc.contributor.author'],
hasSelectableMetadata: true
},
),
];
@@ -628,7 +634,7 @@ describe('FormBuilderService test suite', () => {
it('should throw when unknown DynamicFormControlModel id is specified in JSON', () => {
expect(() => service.fromJSON([{id: 'test'}]))
expect(() => service.fromJSON([{ id: 'test' }]))
.toThrow(new Error(`unknown form control model type defined on JSON object with id "test"`));
});
@@ -648,8 +654,8 @@ describe('FormBuilderService test suite', () => {
const formGroup = service.createFormGroup(testModel);
const nestedFormGroup = formGroup.controls.testFormGroup as FormGroup;
const nestedFormGroupModel = testModel[7] as DynamicFormGroupModel;
const newModel1 = new DynamicInputModel({id: 'newInput1'});
const newModel2 = new DynamicInputModel({id: 'newInput2'});
const newModel1 = new DynamicInputModel({ id: 'newInput1' });
const newModel2 = new DynamicInputModel({ id: 'newInput2' });
service.addFormGroupControl(formGroup, testModel, newModel1);
service.addFormGroupControl(nestedFormGroup, nestedFormGroupModel, newModel2);
@@ -666,8 +672,8 @@ describe('FormBuilderService test suite', () => {
const formGroup = service.createFormGroup(testModel);
const nestedFormGroup = formGroup.controls.testFormGroup as FormGroup;
const nestedFormGroupModel = testModel[7] as DynamicFormGroupModel;
const newModel1 = new DynamicInputModel({id: 'newInput1'});
const newModel2 = new DynamicInputModel({id: 'newInput2'});
const newModel1 = new DynamicInputModel({ id: 'newInput1' });
const newModel2 = new DynamicInputModel({ id: 'newInput2' });
service.insertFormGroupControl(4, formGroup, testModel, newModel1);
service.insertFormGroupControl(0, nestedFormGroup, nestedFormGroupModel, newModel2);