mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
Merge pull request #2641 from hutattedonmyarm/regex-error-messages-backport-dspace7x
[Port dspace-7_x] More meaningful regex error messages
This commit is contained in:
@@ -51,6 +51,8 @@ import { FormRowModel } from '../../../core/config/models/config-submission-form
|
|||||||
import {ConfigurationDataService} from '../../../core/data/configuration-data.service';
|
import {ConfigurationDataService} from '../../../core/data/configuration-data.service';
|
||||||
import {createSuccessfulRemoteDataObject$} from '../../remote-data.utils';
|
import {createSuccessfulRemoteDataObject$} from '../../remote-data.utils';
|
||||||
import {ConfigurationProperty} from '../../../core/shared/configuration-property.model';
|
import {ConfigurationProperty} from '../../../core/shared/configuration-property.model';
|
||||||
|
import { getMockTranslateService } from '../../mocks/translate.service.mock';
|
||||||
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
|
||||||
describe('FormBuilderService test suite', () => {
|
describe('FormBuilderService test suite', () => {
|
||||||
|
|
||||||
@@ -81,6 +83,7 @@ describe('FormBuilderService test suite', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
configSpy = createConfigSuccessSpy(typeFieldTestValue);
|
configSpy = createConfigSuccessSpy(typeFieldTestValue);
|
||||||
|
let translateService = getMockTranslateService();
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [ReactiveFormsModule],
|
imports: [ReactiveFormsModule],
|
||||||
providers: [
|
providers: [
|
||||||
@@ -88,7 +91,8 @@ describe('FormBuilderService test suite', () => {
|
|||||||
{ provide: DynamicFormValidationService, useValue: {} },
|
{ provide: DynamicFormValidationService, useValue: {} },
|
||||||
{ provide: NG_VALIDATORS, useValue: testValidator, multi: true },
|
{ provide: NG_VALIDATORS, useValue: testValidator, multi: true },
|
||||||
{ provide: NG_ASYNC_VALIDATORS, useValue: testAsyncValidator, multi: true },
|
{ provide: NG_ASYNC_VALIDATORS, useValue: testAsyncValidator, multi: true },
|
||||||
{ provide: ConfigurationDataService, useValue: configSpy }
|
{ provide: ConfigurationDataService, useValue: configSpy },
|
||||||
|
{ provide: TranslateService, useValue: translateService },
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -19,6 +19,7 @@ import {
|
|||||||
SUBMISSION_ID
|
SUBMISSION_ID
|
||||||
} from './field-parser';
|
} from './field-parser';
|
||||||
import { DsDynamicInputModel, DsDynamicInputModelConfig } from '../ds-dynamic-form-ui/models/ds-dynamic-input.model';
|
import { DsDynamicInputModel, DsDynamicInputModelConfig } from '../ds-dynamic-form-ui/models/ds-dynamic-input.model';
|
||||||
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
|
||||||
export class ConcatFieldParser extends FieldParser {
|
export class ConcatFieldParser extends FieldParser {
|
||||||
|
|
||||||
@@ -27,10 +28,11 @@ export class ConcatFieldParser extends FieldParser {
|
|||||||
@Inject(CONFIG_DATA) configData: FormFieldModel,
|
@Inject(CONFIG_DATA) configData: FormFieldModel,
|
||||||
@Inject(INIT_FORM_VALUES) initFormValues,
|
@Inject(INIT_FORM_VALUES) initFormValues,
|
||||||
@Inject(PARSER_OPTIONS) parserOptions: ParserOptions,
|
@Inject(PARSER_OPTIONS) parserOptions: ParserOptions,
|
||||||
|
translate: TranslateService,
|
||||||
protected separator: string,
|
protected separator: string,
|
||||||
protected firstPlaceholder: string = null,
|
protected firstPlaceholder: string = null,
|
||||||
protected secondPlaceholder: string = null) {
|
protected secondPlaceholder: string = null) {
|
||||||
super(submissionId, configData, initFormValues, parserOptions);
|
super(submissionId, configData, initFormValues, parserOptions, translate);
|
||||||
|
|
||||||
this.separator = separator;
|
this.separator = separator;
|
||||||
this.firstPlaceholder = firstPlaceholder;
|
this.firstPlaceholder = firstPlaceholder;
|
||||||
|
@@ -3,10 +3,14 @@ import { DateFieldParser } from './date-field-parser';
|
|||||||
import { DynamicDsDatePickerModel } from '../ds-dynamic-form-ui/models/date-picker/date-picker.model';
|
import { DynamicDsDatePickerModel } from '../ds-dynamic-form-ui/models/date-picker/date-picker.model';
|
||||||
import { FormFieldMetadataValueObject } from '../models/form-field-metadata-value.model';
|
import { FormFieldMetadataValueObject } from '../models/form-field-metadata-value.model';
|
||||||
import { ParserOptions } from './parser-options';
|
import { ParserOptions } from './parser-options';
|
||||||
|
import { getMockTranslateService } from 'src/app/shared/mocks/translate.service.mock';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
describe('DateFieldParser test suite', () => {
|
describe('DateFieldParser test suite', () => {
|
||||||
let field: FormFieldModel;
|
let field: FormFieldModel;
|
||||||
let initFormValues: any = {};
|
let initFormValues: any = {};
|
||||||
|
let translateService = getMockTranslateService();
|
||||||
|
|
||||||
const submissionId = '1234';
|
const submissionId = '1234';
|
||||||
const parserOptions: ParserOptions = {
|
const parserOptions: ParserOptions = {
|
||||||
@@ -37,13 +41,13 @@ describe('DateFieldParser test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should init parser properly', () => {
|
it('should init parser properly', () => {
|
||||||
const parser = new DateFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new DateFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
expect(parser instanceof DateFieldParser).toBe(true);
|
expect(parser instanceof DateFieldParser).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return a DynamicDsDatePickerModel object when repeatable option is false', () => {
|
it('should return a DynamicDsDatePickerModel object when repeatable option is false', () => {
|
||||||
const parser = new DateFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new DateFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
|
|
||||||
@@ -56,7 +60,7 @@ describe('DateFieldParser test suite', () => {
|
|||||||
};
|
};
|
||||||
const expectedValue = '1983-11-18';
|
const expectedValue = '1983-11-18';
|
||||||
|
|
||||||
const parser = new DateFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new DateFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
|
|
||||||
|
@@ -2,10 +2,12 @@ import { FormFieldModel } from '../models/form-field.model';
|
|||||||
import { ParserOptions } from './parser-options';
|
import { ParserOptions } from './parser-options';
|
||||||
import { DisabledFieldParser } from './disabled-field-parser';
|
import { DisabledFieldParser } from './disabled-field-parser';
|
||||||
import { DynamicDisabledModel } from '../ds-dynamic-form-ui/models/disabled/dynamic-disabled.model';
|
import { DynamicDisabledModel } from '../ds-dynamic-form-ui/models/disabled/dynamic-disabled.model';
|
||||||
|
import { getMockTranslateService } from 'src/app/shared/mocks/translate.service.mock';
|
||||||
|
|
||||||
describe('DisabledFieldParser test suite', () => {
|
describe('DisabledFieldParser test suite', () => {
|
||||||
let field: FormFieldModel;
|
let field: FormFieldModel;
|
||||||
let initFormValues: any = {};
|
let initFormValues: any = {};
|
||||||
|
let translateService = getMockTranslateService();
|
||||||
|
|
||||||
const submissionId = '1234';
|
const submissionId = '1234';
|
||||||
const parserOptions: ParserOptions = {
|
const parserOptions: ParserOptions = {
|
||||||
@@ -35,13 +37,13 @@ describe('DisabledFieldParser test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should init parser properly', () => {
|
it('should init parser properly', () => {
|
||||||
const parser = new DisabledFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new DisabledFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
expect(parser instanceof DisabledFieldParser).toBe(true);
|
expect(parser instanceof DisabledFieldParser).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return a DynamicDisabledModel object when repeatable option is false', () => {
|
it('should return a DynamicDisabledModel object when repeatable option is false', () => {
|
||||||
const parser = new DisabledFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new DisabledFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
|
|
||||||
@@ -56,7 +58,7 @@ describe('DisabledFieldParser test suite', () => {
|
|||||||
};
|
};
|
||||||
const expectedValue = 'test description';
|
const expectedValue = 'test description';
|
||||||
|
|
||||||
const parser = new DisabledFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new DisabledFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
expect(fieldModel.value.value).toEqual(expectedValue);
|
expect(fieldModel.value.value).toEqual(expectedValue);
|
||||||
|
@@ -2,9 +2,11 @@ import { FormFieldModel } from '../models/form-field.model';
|
|||||||
import { DropdownFieldParser } from './dropdown-field-parser';
|
import { DropdownFieldParser } from './dropdown-field-parser';
|
||||||
import { DynamicScrollableDropdownModel } from '../ds-dynamic-form-ui/models/scrollable-dropdown/dynamic-scrollable-dropdown.model';
|
import { DynamicScrollableDropdownModel } from '../ds-dynamic-form-ui/models/scrollable-dropdown/dynamic-scrollable-dropdown.model';
|
||||||
import { ParserOptions } from './parser-options';
|
import { ParserOptions } from './parser-options';
|
||||||
|
import { getMockTranslateService } from 'src/app/shared/mocks/translate.service.mock';
|
||||||
|
|
||||||
describe('DropdownFieldParser test suite', () => {
|
describe('DropdownFieldParser test suite', () => {
|
||||||
let field: FormFieldModel;
|
let field: FormFieldModel;
|
||||||
|
let translateService = getMockTranslateService();
|
||||||
|
|
||||||
const submissionId = '1234';
|
const submissionId = '1234';
|
||||||
const initFormValues = {};
|
const initFormValues = {};
|
||||||
@@ -37,13 +39,13 @@ describe('DropdownFieldParser test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should init parser properly', () => {
|
it('should init parser properly', () => {
|
||||||
const parser = new DropdownFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new DropdownFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
expect(parser instanceof DropdownFieldParser).toBe(true);
|
expect(parser instanceof DropdownFieldParser).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return a DynamicScrollableDropdownModel object when repeatable option is false', () => {
|
it('should return a DynamicScrollableDropdownModel object when repeatable option is false', () => {
|
||||||
const parser = new DropdownFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new DropdownFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
|
|
||||||
@@ -52,7 +54,7 @@ describe('DropdownFieldParser test suite', () => {
|
|||||||
|
|
||||||
it('should throw when authority is not passed', () => {
|
it('should throw when authority is not passed', () => {
|
||||||
field.selectableMetadata[0].controlledVocabulary = null;
|
field.selectableMetadata[0].controlledVocabulary = null;
|
||||||
const parser = new DropdownFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new DropdownFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
expect(() => parser.parse())
|
expect(() => parser.parse())
|
||||||
.toThrow();
|
.toThrow();
|
||||||
|
@@ -15,6 +15,7 @@ import {
|
|||||||
import { isNotEmpty } from '../../../empty.util';
|
import { isNotEmpty } from '../../../empty.util';
|
||||||
import { FormFieldMetadataValueObject } from '../models/form-field-metadata-value.model';
|
import { FormFieldMetadataValueObject } from '../models/form-field-metadata-value.model';
|
||||||
import { ParserOptions } from './parser-options';
|
import { ParserOptions } from './parser-options';
|
||||||
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
|
||||||
export class DropdownFieldParser extends FieldParser {
|
export class DropdownFieldParser extends FieldParser {
|
||||||
|
|
||||||
@@ -23,8 +24,9 @@ export class DropdownFieldParser extends FieldParser {
|
|||||||
@Inject(CONFIG_DATA) configData: FormFieldModel,
|
@Inject(CONFIG_DATA) configData: FormFieldModel,
|
||||||
@Inject(INIT_FORM_VALUES) initFormValues,
|
@Inject(INIT_FORM_VALUES) initFormValues,
|
||||||
@Inject(PARSER_OPTIONS) parserOptions: ParserOptions,
|
@Inject(PARSER_OPTIONS) parserOptions: ParserOptions,
|
||||||
|
translate: TranslateService
|
||||||
) {
|
) {
|
||||||
super(submissionId, configData, initFormValues, parserOptions);
|
super(submissionId, configData, initFormValues, parserOptions, translate);
|
||||||
}
|
}
|
||||||
|
|
||||||
public modelFactory(fieldValue?: FormFieldMetadataValueObject | any, label?: boolean): any {
|
public modelFactory(fieldValue?: FormFieldMetadataValueObject | any, label?: boolean): any {
|
||||||
|
@@ -25,6 +25,7 @@ import { VocabularyOptions } from '../../../../core/submission/vocabularies/mode
|
|||||||
import { ParserType } from './parser-type';
|
import { ParserType } from './parser-type';
|
||||||
import { isNgbDateStruct } from '../../../date.util';
|
import { isNgbDateStruct } from '../../../date.util';
|
||||||
import { SubmissionScopeType } from '../../../../core/submission/submission-scope-type';
|
import { SubmissionScopeType } from '../../../../core/submission/submission-scope-type';
|
||||||
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
|
||||||
export const SUBMISSION_ID: InjectionToken<string> = new InjectionToken<string>('submissionId');
|
export const SUBMISSION_ID: InjectionToken<string> = new InjectionToken<string>('submissionId');
|
||||||
export const CONFIG_DATA: InjectionToken<FormFieldModel> = new InjectionToken<FormFieldModel>('configData');
|
export const CONFIG_DATA: InjectionToken<FormFieldModel> = new InjectionToken<FormFieldModel>('configData');
|
||||||
@@ -50,7 +51,8 @@ export abstract class FieldParser {
|
|||||||
@Inject(SUBMISSION_ID) protected submissionId: string,
|
@Inject(SUBMISSION_ID) protected submissionId: string,
|
||||||
@Inject(CONFIG_DATA) protected configData: FormFieldModel,
|
@Inject(CONFIG_DATA) protected configData: FormFieldModel,
|
||||||
@Inject(INIT_FORM_VALUES) protected initFormValues: any,
|
@Inject(INIT_FORM_VALUES) protected initFormValues: any,
|
||||||
@Inject(PARSER_OPTIONS) protected parserOptions: ParserOptions
|
@Inject(PARSER_OPTIONS) protected parserOptions: ParserOptions,
|
||||||
|
protected translate: TranslateService
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -395,11 +397,14 @@ export abstract class FieldParser {
|
|||||||
} else {
|
} else {
|
||||||
regex = new RegExp(this.configData.input.regex);
|
regex = new RegExp(this.configData.input.regex);
|
||||||
}
|
}
|
||||||
|
const baseTranslationKey = 'error.validation.pattern';
|
||||||
|
const fieldranslationKey = `${baseTranslationKey}.${controlModel.id}`;
|
||||||
|
const fieldTranslationExists = this.translate.instant(fieldranslationKey) !== fieldranslationKey;
|
||||||
controlModel.validators = Object.assign({}, controlModel.validators, { pattern: regex });
|
controlModel.validators = Object.assign({}, controlModel.validators, { pattern: regex });
|
||||||
controlModel.errorMessages = Object.assign(
|
controlModel.errorMessages = Object.assign(
|
||||||
{},
|
{},
|
||||||
controlModel.errorMessages,
|
controlModel.errorMessages,
|
||||||
{ pattern: 'error.validation.pattern' });
|
{ pattern: fieldTranslationExists ? fieldranslationKey : baseTranslationKey });
|
||||||
}
|
}
|
||||||
|
|
||||||
protected markAsRequired(controlModel) {
|
protected markAsRequired(controlModel) {
|
||||||
|
@@ -4,10 +4,12 @@ import { ListFieldParser } from './list-field-parser';
|
|||||||
import { DynamicListCheckboxGroupModel } from '../ds-dynamic-form-ui/models/list/dynamic-list-checkbox-group.model';
|
import { DynamicListCheckboxGroupModel } from '../ds-dynamic-form-ui/models/list/dynamic-list-checkbox-group.model';
|
||||||
import { DynamicListRadioGroupModel } from '../ds-dynamic-form-ui/models/list/dynamic-list-radio-group.model';
|
import { DynamicListRadioGroupModel } from '../ds-dynamic-form-ui/models/list/dynamic-list-radio-group.model';
|
||||||
import { ParserOptions } from './parser-options';
|
import { ParserOptions } from './parser-options';
|
||||||
|
import { getMockTranslateService } from 'src/app/shared/mocks/translate.service.mock';
|
||||||
|
|
||||||
describe('ListFieldParser test suite', () => {
|
describe('ListFieldParser test suite', () => {
|
||||||
let field: FormFieldModel;
|
let field: FormFieldModel;
|
||||||
let initFormValues = {};
|
let initFormValues = {};
|
||||||
|
let translateService = getMockTranslateService();
|
||||||
|
|
||||||
const submissionId = '1234';
|
const submissionId = '1234';
|
||||||
const parserOptions: ParserOptions = {
|
const parserOptions: ParserOptions = {
|
||||||
@@ -39,13 +41,13 @@ describe('ListFieldParser test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should init parser properly', () => {
|
it('should init parser properly', () => {
|
||||||
const parser = new ListFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new ListFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
expect(parser instanceof ListFieldParser).toBe(true);
|
expect(parser instanceof ListFieldParser).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return a DynamicListCheckboxGroupModel object when repeatable option is true', () => {
|
it('should return a DynamicListCheckboxGroupModel object when repeatable option is true', () => {
|
||||||
const parser = new ListFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new ListFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
|
|
||||||
@@ -54,7 +56,7 @@ describe('ListFieldParser test suite', () => {
|
|||||||
|
|
||||||
it('should return a DynamicListRadioGroupModel object when repeatable option is false', () => {
|
it('should return a DynamicListRadioGroupModel object when repeatable option is false', () => {
|
||||||
field.repeatable = false;
|
field.repeatable = false;
|
||||||
const parser = new ListFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new ListFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
|
|
||||||
@@ -67,7 +69,7 @@ describe('ListFieldParser test suite', () => {
|
|||||||
};
|
};
|
||||||
const expectedValue = [new FormFieldMetadataValueObject('test type')];
|
const expectedValue = [new FormFieldMetadataValueObject('test type')];
|
||||||
|
|
||||||
const parser = new ListFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new ListFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
|
|
||||||
|
@@ -3,10 +3,12 @@ import { FormFieldMetadataValueObject } from '../models/form-field-metadata-valu
|
|||||||
import { LookupFieldParser } from './lookup-field-parser';
|
import { LookupFieldParser } from './lookup-field-parser';
|
||||||
import { DynamicLookupModel } from '../ds-dynamic-form-ui/models/lookup/dynamic-lookup.model';
|
import { DynamicLookupModel } from '../ds-dynamic-form-ui/models/lookup/dynamic-lookup.model';
|
||||||
import { ParserOptions } from './parser-options';
|
import { ParserOptions } from './parser-options';
|
||||||
|
import { getMockTranslateService } from 'src/app/shared/mocks/translate.service.mock';
|
||||||
|
|
||||||
describe('LookupFieldParser test suite', () => {
|
describe('LookupFieldParser test suite', () => {
|
||||||
let field: FormFieldModel;
|
let field: FormFieldModel;
|
||||||
let initFormValues = {};
|
let initFormValues = {};
|
||||||
|
let translateService = getMockTranslateService();
|
||||||
|
|
||||||
const submissionId = '1234';
|
const submissionId = '1234';
|
||||||
const parserOptions: ParserOptions = {
|
const parserOptions: ParserOptions = {
|
||||||
@@ -38,13 +40,13 @@ describe('LookupFieldParser test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should init parser properly', () => {
|
it('should init parser properly', () => {
|
||||||
const parser = new LookupFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new LookupFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
expect(parser instanceof LookupFieldParser).toBe(true);
|
expect(parser instanceof LookupFieldParser).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return a DynamicLookupModel object when repeatable option is false', () => {
|
it('should return a DynamicLookupModel object when repeatable option is false', () => {
|
||||||
const parser = new LookupFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new LookupFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
|
|
||||||
@@ -57,7 +59,7 @@ describe('LookupFieldParser test suite', () => {
|
|||||||
};
|
};
|
||||||
const expectedValue = new FormFieldMetadataValueObject('test journal');
|
const expectedValue = new FormFieldMetadataValueObject('test journal');
|
||||||
|
|
||||||
const parser = new LookupFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new LookupFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
|
|
||||||
|
@@ -3,10 +3,12 @@ import { FormFieldMetadataValueObject } from '../models/form-field-metadata-valu
|
|||||||
import { LookupNameFieldParser } from './lookup-name-field-parser';
|
import { LookupNameFieldParser } from './lookup-name-field-parser';
|
||||||
import { DynamicLookupNameModel } from '../ds-dynamic-form-ui/models/lookup/dynamic-lookup-name.model';
|
import { DynamicLookupNameModel } from '../ds-dynamic-form-ui/models/lookup/dynamic-lookup-name.model';
|
||||||
import { ParserOptions } from './parser-options';
|
import { ParserOptions } from './parser-options';
|
||||||
|
import { getMockTranslateService } from 'src/app/shared/mocks/translate.service.mock';
|
||||||
|
|
||||||
describe('LookupNameFieldParser test suite', () => {
|
describe('LookupNameFieldParser test suite', () => {
|
||||||
let field: FormFieldModel;
|
let field: FormFieldModel;
|
||||||
let initFormValues = {};
|
let initFormValues = {};
|
||||||
|
let translateService = getMockTranslateService();
|
||||||
|
|
||||||
const submissionId = '1234';
|
const submissionId = '1234';
|
||||||
const parserOptions: ParserOptions = {
|
const parserOptions: ParserOptions = {
|
||||||
@@ -38,13 +40,13 @@ describe('LookupNameFieldParser test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should init parser properly', () => {
|
it('should init parser properly', () => {
|
||||||
const parser = new LookupNameFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new LookupNameFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
expect(parser instanceof LookupNameFieldParser).toBe(true);
|
expect(parser instanceof LookupNameFieldParser).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return a DynamicLookupNameModel object when repeatable option is false', () => {
|
it('should return a DynamicLookupNameModel object when repeatable option is false', () => {
|
||||||
const parser = new LookupNameFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new LookupNameFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
|
|
||||||
@@ -57,7 +59,7 @@ describe('LookupNameFieldParser test suite', () => {
|
|||||||
};
|
};
|
||||||
const expectedValue = new FormFieldMetadataValueObject('test author');
|
const expectedValue = new FormFieldMetadataValueObject('test author');
|
||||||
|
|
||||||
const parser = new LookupNameFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new LookupNameFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
|
|
||||||
|
@@ -3,12 +3,14 @@ import { NameFieldParser } from './name-field-parser';
|
|||||||
import { DynamicConcatModel } from '../ds-dynamic-form-ui/models/ds-dynamic-concat.model';
|
import { DynamicConcatModel } from '../ds-dynamic-form-ui/models/ds-dynamic-concat.model';
|
||||||
import { FormFieldMetadataValueObject } from '../models/form-field-metadata-value.model';
|
import { FormFieldMetadataValueObject } from '../models/form-field-metadata-value.model';
|
||||||
import { ParserOptions } from './parser-options';
|
import { ParserOptions } from './parser-options';
|
||||||
|
import { getMockTranslateService } from 'src/app/shared/mocks/translate.service.mock';
|
||||||
|
|
||||||
describe('NameFieldParser test suite', () => {
|
describe('NameFieldParser test suite', () => {
|
||||||
let field1: FormFieldModel;
|
let field1: FormFieldModel;
|
||||||
let field2: FormFieldModel;
|
let field2: FormFieldModel;
|
||||||
let field3: FormFieldModel;
|
let field3: FormFieldModel;
|
||||||
let initFormValues: any = {};
|
let initFormValues: any = {};
|
||||||
|
let translateService = getMockTranslateService();
|
||||||
|
|
||||||
const submissionId = '1234';
|
const submissionId = '1234';
|
||||||
const parserOptions: ParserOptions = {
|
const parserOptions: ParserOptions = {
|
||||||
@@ -71,13 +73,13 @@ describe('NameFieldParser test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should init parser properly', () => {
|
it('should init parser properly', () => {
|
||||||
const parser = new NameFieldParser(submissionId, field1, initFormValues, parserOptions);
|
const parser = new NameFieldParser(submissionId, field1, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
expect(parser instanceof NameFieldParser).toBe(true);
|
expect(parser instanceof NameFieldParser).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return a DynamicConcatModel object when repeatable option is false', () => {
|
it('should return a DynamicConcatModel object when repeatable option is false', () => {
|
||||||
const parser = new NameFieldParser(submissionId, field2, initFormValues, parserOptions);
|
const parser = new NameFieldParser(submissionId, field2, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
|
|
||||||
@@ -85,7 +87,7 @@ describe('NameFieldParser test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should return a DynamicConcatModel object with the correct separator', () => {
|
it('should return a DynamicConcatModel object with the correct separator', () => {
|
||||||
const parser = new NameFieldParser(submissionId, field2, initFormValues, parserOptions);
|
const parser = new NameFieldParser(submissionId, field2, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
|
|
||||||
@@ -98,7 +100,7 @@ describe('NameFieldParser test suite', () => {
|
|||||||
};
|
};
|
||||||
const expectedValue = new FormFieldMetadataValueObject('test, name', undefined, undefined, 'test');
|
const expectedValue = new FormFieldMetadataValueObject('test, name', undefined, undefined, 'test');
|
||||||
|
|
||||||
const parser = new NameFieldParser(submissionId, field1, initFormValues, parserOptions);
|
const parser = new NameFieldParser(submissionId, field1, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
|
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
import { Inject } from '@angular/core';
|
import { Inject } from '@angular/core';
|
||||||
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { FormFieldModel } from '../models/form-field.model';
|
import { FormFieldModel } from '../models/form-field.model';
|
||||||
import { ConcatFieldParser } from './concat-field-parser';
|
import { ConcatFieldParser } from './concat-field-parser';
|
||||||
import { CONFIG_DATA, INIT_FORM_VALUES, PARSER_OPTIONS, SUBMISSION_ID } from './field-parser';
|
import { CONFIG_DATA, INIT_FORM_VALUES, PARSER_OPTIONS, SUBMISSION_ID } from './field-parser';
|
||||||
@@ -10,8 +11,9 @@ export class NameFieldParser extends ConcatFieldParser {
|
|||||||
@Inject(SUBMISSION_ID) submissionId: string,
|
@Inject(SUBMISSION_ID) submissionId: string,
|
||||||
@Inject(CONFIG_DATA) configData: FormFieldModel,
|
@Inject(CONFIG_DATA) configData: FormFieldModel,
|
||||||
@Inject(INIT_FORM_VALUES) initFormValues,
|
@Inject(INIT_FORM_VALUES) initFormValues,
|
||||||
@Inject(PARSER_OPTIONS) parserOptions: ParserOptions
|
@Inject(PARSER_OPTIONS) parserOptions: ParserOptions,
|
||||||
|
translate: TranslateService
|
||||||
) {
|
) {
|
||||||
super(submissionId, configData, initFormValues, parserOptions, ',', 'form.last-name', 'form.first-name');
|
super(submissionId, configData, initFormValues, parserOptions, translate, ',', 'form.last-name', 'form.first-name');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -5,11 +5,13 @@ import { DynamicOneboxModel } from '../ds-dynamic-form-ui/models/onebox/dynamic-
|
|||||||
import { DsDynamicInputModel } from '../ds-dynamic-form-ui/models/ds-dynamic-input.model';
|
import { DsDynamicInputModel } from '../ds-dynamic-form-ui/models/ds-dynamic-input.model';
|
||||||
import { ParserOptions } from './parser-options';
|
import { ParserOptions } from './parser-options';
|
||||||
import { FieldParser } from './field-parser';
|
import { FieldParser } from './field-parser';
|
||||||
|
import { getMockTranslateService } from 'src/app/shared/mocks/translate.service.mock';
|
||||||
|
|
||||||
describe('OneboxFieldParser test suite', () => {
|
describe('OneboxFieldParser test suite', () => {
|
||||||
let field1: FormFieldModel;
|
let field1: FormFieldModel;
|
||||||
let field2: FormFieldModel;
|
let field2: FormFieldModel;
|
||||||
let field3: FormFieldModel;
|
let field3: FormFieldModel;
|
||||||
|
let translateService = getMockTranslateService();
|
||||||
|
|
||||||
const submissionId = '1234';
|
const submissionId = '1234';
|
||||||
const initFormValues = {};
|
const initFormValues = {};
|
||||||
@@ -73,13 +75,13 @@ describe('OneboxFieldParser test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should init parser properly', () => {
|
it('should init parser properly', () => {
|
||||||
const parser = new OneboxFieldParser(submissionId, field1, initFormValues, parserOptions);
|
const parser = new OneboxFieldParser(submissionId, field1, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
expect(parser instanceof OneboxFieldParser).toBe(true);
|
expect(parser instanceof OneboxFieldParser).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return a DynamicQualdropModel object when selectableMetadata is multiple', () => {
|
it('should return a DynamicQualdropModel object when selectableMetadata is multiple', () => {
|
||||||
const parser = new OneboxFieldParser(submissionId, field2, initFormValues, parserOptions);
|
const parser = new OneboxFieldParser(submissionId, field2, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
|
|
||||||
@@ -87,7 +89,7 @@ describe('OneboxFieldParser test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should return a DsDynamicInputModel object when selectableMetadata is not multiple', () => {
|
it('should return a DsDynamicInputModel object when selectableMetadata is not multiple', () => {
|
||||||
const parser = new OneboxFieldParser(submissionId, field3, initFormValues, parserOptions);
|
const parser = new OneboxFieldParser(submissionId, field3, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
|
|
||||||
@@ -95,7 +97,7 @@ describe('OneboxFieldParser test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should return a DynamicOneboxModel object when selectableMetadata has authority', () => {
|
it('should return a DynamicOneboxModel object when selectableMetadata has authority', () => {
|
||||||
const parser = new OneboxFieldParser(submissionId, field1, initFormValues, parserOptions);
|
const parser = new OneboxFieldParser(submissionId, field1, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
|
|
||||||
@@ -124,7 +126,7 @@ describe('OneboxFieldParser test suite', () => {
|
|||||||
languageCodes: []
|
languageCodes: []
|
||||||
} as FormFieldModel;
|
} as FormFieldModel;
|
||||||
|
|
||||||
parser = new OneboxFieldParser(submissionId, regexField, initFormValues, parserOptions);
|
parser = new OneboxFieldParser(submissionId, regexField, initFormValues, parserOptions, translateService);
|
||||||
fieldModel = parser.parse();
|
fieldModel = parser.parse();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -19,12 +19,14 @@ import { SeriesFieldParser } from './series-field-parser';
|
|||||||
import { TagFieldParser } from './tag-field-parser';
|
import { TagFieldParser } from './tag-field-parser';
|
||||||
import { TextareaFieldParser } from './textarea-field-parser';
|
import { TextareaFieldParser } from './textarea-field-parser';
|
||||||
import { DisabledFieldParser } from './disabled-field-parser';
|
import { DisabledFieldParser } from './disabled-field-parser';
|
||||||
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
|
||||||
const fieldParserDeps = [
|
const fieldParserDeps = [
|
||||||
SUBMISSION_ID,
|
SUBMISSION_ID,
|
||||||
CONFIG_DATA,
|
CONFIG_DATA,
|
||||||
INIT_FORM_VALUES,
|
INIT_FORM_VALUES,
|
||||||
PARSER_OPTIONS,
|
PARSER_OPTIONS,
|
||||||
|
TranslateService
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -3,10 +3,12 @@ import { RelationGroupFieldParser } from './relation-group-field-parser';
|
|||||||
import { DynamicRelationGroupModel } from '../ds-dynamic-form-ui/models/relation-group/dynamic-relation-group.model';
|
import { DynamicRelationGroupModel } from '../ds-dynamic-form-ui/models/relation-group/dynamic-relation-group.model';
|
||||||
import { FormFieldMetadataValueObject } from '../models/form-field-metadata-value.model';
|
import { FormFieldMetadataValueObject } from '../models/form-field-metadata-value.model';
|
||||||
import { ParserOptions } from './parser-options';
|
import { ParserOptions } from './parser-options';
|
||||||
|
import { getMockTranslateService } from 'src/app/shared/mocks/translate.service.mock';
|
||||||
|
|
||||||
describe('RelationGroupFieldParser test suite', () => {
|
describe('RelationGroupFieldParser test suite', () => {
|
||||||
let field: FormFieldModel;
|
let field: FormFieldModel;
|
||||||
let initFormValues = {};
|
let initFormValues = {};
|
||||||
|
let translateService = getMockTranslateService();
|
||||||
|
|
||||||
const submissionId = '1234';
|
const submissionId = '1234';
|
||||||
const parserOptions: ParserOptions = {
|
const parserOptions: ParserOptions = {
|
||||||
@@ -73,13 +75,13 @@ describe('RelationGroupFieldParser test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should init parser properly', () => {
|
it('should init parser properly', () => {
|
||||||
const parser = new RelationGroupFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new RelationGroupFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
expect(parser instanceof RelationGroupFieldParser).toBe(true);
|
expect(parser instanceof RelationGroupFieldParser).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return a DynamicRelationGroupModel object', () => {
|
it('should return a DynamicRelationGroupModel object', () => {
|
||||||
const parser = new RelationGroupFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new RelationGroupFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
|
|
||||||
@@ -88,7 +90,7 @@ describe('RelationGroupFieldParser test suite', () => {
|
|||||||
|
|
||||||
it('should throw when rows configuration is empty', () => {
|
it('should throw when rows configuration is empty', () => {
|
||||||
field.rows = null;
|
field.rows = null;
|
||||||
const parser = new RelationGroupFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new RelationGroupFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
expect(() => parser.parse())
|
expect(() => parser.parse())
|
||||||
.toThrow();
|
.toThrow();
|
||||||
@@ -99,7 +101,7 @@ describe('RelationGroupFieldParser test suite', () => {
|
|||||||
author: [new FormFieldMetadataValueObject('test author')],
|
author: [new FormFieldMetadataValueObject('test author')],
|
||||||
affiliation: [new FormFieldMetadataValueObject('test affiliation')]
|
affiliation: [new FormFieldMetadataValueObject('test affiliation')]
|
||||||
};
|
};
|
||||||
const parser = new RelationGroupFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new RelationGroupFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
const expectedValue = [{
|
const expectedValue = [{
|
||||||
|
@@ -3,6 +3,9 @@ import { RowParser } from './row-parser';
|
|||||||
import { DynamicRowGroupModel } from '../ds-dynamic-form-ui/models/ds-dynamic-row-group-model';
|
import { DynamicRowGroupModel } from '../ds-dynamic-form-ui/models/ds-dynamic-row-group-model';
|
||||||
import { DynamicRowArrayModel } from '../ds-dynamic-form-ui/models/ds-dynamic-row-array-model';
|
import { DynamicRowArrayModel } from '../ds-dynamic-form-ui/models/ds-dynamic-row-array-model';
|
||||||
import { FormRowModel } from '../../../../core/config/models/config-submission-form.model';
|
import { FormRowModel } from '../../../../core/config/models/config-submission-form.model';
|
||||||
|
import { getMockTranslateService } from 'src/app/shared/mocks/translate.service.mock';
|
||||||
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
import { Injector } from '@angular/core';
|
||||||
|
|
||||||
describe('RowParser test suite', () => {
|
describe('RowParser test suite', () => {
|
||||||
|
|
||||||
@@ -16,6 +19,7 @@ describe('RowParser test suite', () => {
|
|||||||
let row8: FormRowModel;
|
let row8: FormRowModel;
|
||||||
let row9: FormRowModel;
|
let row9: FormRowModel;
|
||||||
let row10: FormRowModel;
|
let row10: FormRowModel;
|
||||||
|
let injector: Injector;
|
||||||
|
|
||||||
const submissionId = '1234';
|
const submissionId = '1234';
|
||||||
const scopeUUID = 'testScopeUUID';
|
const scopeUUID = 'testScopeUUID';
|
||||||
@@ -25,6 +29,12 @@ describe('RowParser test suite', () => {
|
|||||||
const typeField = 'dc_type';
|
const typeField = 'dc_type';
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
let translateService = getMockTranslateService();
|
||||||
|
injector = Injector.create({
|
||||||
|
providers: [
|
||||||
|
{ provide: TranslateService, useValue: translateService },
|
||||||
|
],
|
||||||
|
});
|
||||||
row1 = {
|
row1 = {
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
@@ -330,14 +340,14 @@ describe('RowParser test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should init parser properly', () => {
|
it('should init parser properly', () => {
|
||||||
const parser = new RowParser(undefined);
|
const parser = new RowParser(injector);
|
||||||
|
|
||||||
expect(parser instanceof RowParser).toBe(true);
|
expect(parser instanceof RowParser).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('parse', () => {
|
describe('parse', () => {
|
||||||
it('should return a DynamicRowGroupModel object', () => {
|
it('should return a DynamicRowGroupModel object', () => {
|
||||||
const parser = new RowParser(undefined);
|
const parser = new RowParser(injector);
|
||||||
|
|
||||||
const rowModel = parser.parse(submissionId, row1, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
|
const rowModel = parser.parse(submissionId, row1, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
|
||||||
|
|
||||||
@@ -345,7 +355,7 @@ describe('RowParser test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should return a row with three fields', () => {
|
it('should return a row with three fields', () => {
|
||||||
const parser = new RowParser(undefined);
|
const parser = new RowParser(injector);
|
||||||
|
|
||||||
const rowModel = parser.parse(submissionId, row1, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
|
const rowModel = parser.parse(submissionId, row1, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
|
||||||
|
|
||||||
@@ -353,7 +363,7 @@ describe('RowParser test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should return a DynamicRowArrayModel object', () => {
|
it('should return a DynamicRowArrayModel object', () => {
|
||||||
const parser = new RowParser(undefined);
|
const parser = new RowParser(injector);
|
||||||
|
|
||||||
const rowModel = parser.parse(submissionId, row2, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
|
const rowModel = parser.parse(submissionId, row2, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
|
||||||
|
|
||||||
@@ -361,7 +371,7 @@ describe('RowParser test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should return a row that contains only scoped fields', () => {
|
it('should return a row that contains only scoped fields', () => {
|
||||||
const parser = new RowParser(undefined);
|
const parser = new RowParser(injector);
|
||||||
|
|
||||||
const rowModel = parser.parse(submissionId, row3, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
|
const rowModel = parser.parse(submissionId, row3, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
|
||||||
|
|
||||||
@@ -369,7 +379,7 @@ describe('RowParser test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to parse a dropdown combo field', () => {
|
it('should be able to parse a dropdown combo field', () => {
|
||||||
const parser = new RowParser(undefined);
|
const parser = new RowParser(injector);
|
||||||
|
|
||||||
const rowModel = parser.parse(submissionId, row4, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
|
const rowModel = parser.parse(submissionId, row4, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
|
||||||
|
|
||||||
@@ -377,7 +387,7 @@ describe('RowParser test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to parse a lookup-name field', () => {
|
it('should be able to parse a lookup-name field', () => {
|
||||||
const parser = new RowParser(undefined);
|
const parser = new RowParser(injector);
|
||||||
|
|
||||||
const rowModel = parser.parse(submissionId, row5, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
|
const rowModel = parser.parse(submissionId, row5, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
|
||||||
|
|
||||||
@@ -385,7 +395,7 @@ describe('RowParser test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to parse a list field', () => {
|
it('should be able to parse a list field', () => {
|
||||||
const parser = new RowParser(undefined);
|
const parser = new RowParser(injector);
|
||||||
|
|
||||||
const rowModel = parser.parse(submissionId, row6, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
|
const rowModel = parser.parse(submissionId, row6, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
|
||||||
|
|
||||||
@@ -393,7 +403,7 @@ describe('RowParser test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to parse a date field', () => {
|
it('should be able to parse a date field', () => {
|
||||||
const parser = new RowParser(undefined);
|
const parser = new RowParser(injector);
|
||||||
|
|
||||||
const rowModel = parser.parse(submissionId, row7, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
|
const rowModel = parser.parse(submissionId, row7, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
|
||||||
|
|
||||||
@@ -401,7 +411,7 @@ describe('RowParser test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to parse a tag field', () => {
|
it('should be able to parse a tag field', () => {
|
||||||
const parser = new RowParser(undefined);
|
const parser = new RowParser(injector);
|
||||||
|
|
||||||
const rowModel = parser.parse(submissionId, row8, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
|
const rowModel = parser.parse(submissionId, row8, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
|
||||||
|
|
||||||
@@ -409,7 +419,7 @@ describe('RowParser test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to parse a textarea field', () => {
|
it('should be able to parse a textarea field', () => {
|
||||||
const parser = new RowParser(undefined);
|
const parser = new RowParser(injector);
|
||||||
|
|
||||||
const rowModel = parser.parse(submissionId, row9, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
|
const rowModel = parser.parse(submissionId, row9, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
|
||||||
|
|
||||||
@@ -417,7 +427,7 @@ describe('RowParser test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to parse a group field', () => {
|
it('should be able to parse a group field', () => {
|
||||||
const parser = new RowParser(undefined);
|
const parser = new RowParser(injector);
|
||||||
|
|
||||||
const rowModel = parser.parse(submissionId, row10, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
|
const rowModel = parser.parse(submissionId, row10, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
|
||||||
|
|
||||||
|
@@ -3,10 +3,12 @@ import { DynamicConcatModel } from '../ds-dynamic-form-ui/models/ds-dynamic-conc
|
|||||||
import { SeriesFieldParser } from './series-field-parser';
|
import { SeriesFieldParser } from './series-field-parser';
|
||||||
import { FormFieldMetadataValueObject } from '../models/form-field-metadata-value.model';
|
import { FormFieldMetadataValueObject } from '../models/form-field-metadata-value.model';
|
||||||
import { ParserOptions } from './parser-options';
|
import { ParserOptions } from './parser-options';
|
||||||
|
import { getMockTranslateService } from 'src/app/shared/mocks/translate.service.mock';
|
||||||
|
|
||||||
describe('SeriesFieldParser test suite', () => {
|
describe('SeriesFieldParser test suite', () => {
|
||||||
let field: FormFieldModel;
|
let field: FormFieldModel;
|
||||||
let initFormValues: any = {};
|
let initFormValues: any = {};
|
||||||
|
let translateService = getMockTranslateService();
|
||||||
|
|
||||||
const submissionId = '1234';
|
const submissionId = '1234';
|
||||||
const parserOptions: ParserOptions = {
|
const parserOptions: ParserOptions = {
|
||||||
@@ -34,13 +36,13 @@ describe('SeriesFieldParser test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should init parser properly', () => {
|
it('should init parser properly', () => {
|
||||||
const parser = new SeriesFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new SeriesFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
expect(parser instanceof SeriesFieldParser).toBe(true);
|
expect(parser instanceof SeriesFieldParser).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return a DynamicConcatModel object when repeatable option is false', () => {
|
it('should return a DynamicConcatModel object when repeatable option is false', () => {
|
||||||
const parser = new SeriesFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new SeriesFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
|
|
||||||
@@ -48,7 +50,7 @@ describe('SeriesFieldParser test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should return a DynamicConcatModel object with the correct separator', () => {
|
it('should return a DynamicConcatModel object with the correct separator', () => {
|
||||||
const parser = new SeriesFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new SeriesFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
|
|
||||||
@@ -61,7 +63,7 @@ describe('SeriesFieldParser test suite', () => {
|
|||||||
};
|
};
|
||||||
const expectedValue = new FormFieldMetadataValueObject('test; series', undefined, undefined, 'test');
|
const expectedValue = new FormFieldMetadataValueObject('test; series', undefined, undefined, 'test');
|
||||||
|
|
||||||
const parser = new SeriesFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new SeriesFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
|
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
import { Inject } from '@angular/core';
|
import { Inject } from '@angular/core';
|
||||||
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { FormFieldModel } from '../models/form-field.model';
|
import { FormFieldModel } from '../models/form-field.model';
|
||||||
import { ConcatFieldParser } from './concat-field-parser';
|
import { ConcatFieldParser } from './concat-field-parser';
|
||||||
import { CONFIG_DATA, INIT_FORM_VALUES, PARSER_OPTIONS, SUBMISSION_ID } from './field-parser';
|
import { CONFIG_DATA, INIT_FORM_VALUES, PARSER_OPTIONS, SUBMISSION_ID } from './field-parser';
|
||||||
@@ -10,8 +11,9 @@ export class SeriesFieldParser extends ConcatFieldParser {
|
|||||||
@Inject(SUBMISSION_ID) submissionId: string,
|
@Inject(SUBMISSION_ID) submissionId: string,
|
||||||
@Inject(CONFIG_DATA) configData: FormFieldModel,
|
@Inject(CONFIG_DATA) configData: FormFieldModel,
|
||||||
@Inject(INIT_FORM_VALUES) initFormValues,
|
@Inject(INIT_FORM_VALUES) initFormValues,
|
||||||
@Inject(PARSER_OPTIONS) parserOptions: ParserOptions
|
@Inject(PARSER_OPTIONS) parserOptions: ParserOptions,
|
||||||
|
translate: TranslateService
|
||||||
) {
|
) {
|
||||||
super(submissionId, configData, initFormValues, parserOptions, ';');
|
super(submissionId, configData, initFormValues, parserOptions, translate, ';');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -3,10 +3,12 @@ import { FormFieldMetadataValueObject } from '../models/form-field-metadata-valu
|
|||||||
import { TagFieldParser } from './tag-field-parser';
|
import { TagFieldParser } from './tag-field-parser';
|
||||||
import { DynamicTagModel } from '../ds-dynamic-form-ui/models/tag/dynamic-tag.model';
|
import { DynamicTagModel } from '../ds-dynamic-form-ui/models/tag/dynamic-tag.model';
|
||||||
import { ParserOptions } from './parser-options';
|
import { ParserOptions } from './parser-options';
|
||||||
|
import { getMockTranslateService } from 'src/app/shared/mocks/translate.service.mock';
|
||||||
|
|
||||||
describe('TagFieldParser test suite', () => {
|
describe('TagFieldParser test suite', () => {
|
||||||
let field: FormFieldModel;
|
let field: FormFieldModel;
|
||||||
let initFormValues: any = {};
|
let initFormValues: any = {};
|
||||||
|
let translateService = getMockTranslateService();
|
||||||
|
|
||||||
const submissionId = '1234';
|
const submissionId = '1234';
|
||||||
const parserOptions: ParserOptions = {
|
const parserOptions: ParserOptions = {
|
||||||
@@ -38,13 +40,13 @@ describe('TagFieldParser test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should init parser properly', () => {
|
it('should init parser properly', () => {
|
||||||
const parser = new TagFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new TagFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
expect(parser instanceof TagFieldParser).toBe(true);
|
expect(parser instanceof TagFieldParser).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return a DynamicTagModel object when repeatable option is false', () => {
|
it('should return a DynamicTagModel object when repeatable option is false', () => {
|
||||||
const parser = new TagFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new TagFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
|
|
||||||
@@ -59,7 +61,7 @@ describe('TagFieldParser test suite', () => {
|
|||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
const parser = new TagFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new TagFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
|
|
||||||
|
@@ -3,10 +3,12 @@ import { FormFieldMetadataValueObject } from '../models/form-field-metadata-valu
|
|||||||
import { TextareaFieldParser } from './textarea-field-parser';
|
import { TextareaFieldParser } from './textarea-field-parser';
|
||||||
import { DsDynamicTextAreaModel } from '../ds-dynamic-form-ui/models/ds-dynamic-textarea.model';
|
import { DsDynamicTextAreaModel } from '../ds-dynamic-form-ui/models/ds-dynamic-textarea.model';
|
||||||
import { ParserOptions } from './parser-options';
|
import { ParserOptions } from './parser-options';
|
||||||
|
import { getMockTranslateService } from 'src/app/shared/mocks/translate.service.mock';
|
||||||
|
|
||||||
describe('TextareaFieldParser test suite', () => {
|
describe('TextareaFieldParser test suite', () => {
|
||||||
let field: FormFieldModel;
|
let field: FormFieldModel;
|
||||||
let initFormValues: any = {};
|
let initFormValues: any = {};
|
||||||
|
let translateService = getMockTranslateService();
|
||||||
|
|
||||||
const submissionId = '1234';
|
const submissionId = '1234';
|
||||||
const parserOptions: ParserOptions = {
|
const parserOptions: ParserOptions = {
|
||||||
@@ -36,13 +38,13 @@ describe('TextareaFieldParser test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should init parser properly', () => {
|
it('should init parser properly', () => {
|
||||||
const parser = new TextareaFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new TextareaFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
expect(parser instanceof TextareaFieldParser).toBe(true);
|
expect(parser instanceof TextareaFieldParser).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return a DsDynamicTextAreaModel object when repeatable option is false', () => {
|
it('should return a DsDynamicTextAreaModel object when repeatable option is false', () => {
|
||||||
const parser = new TextareaFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new TextareaFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
|
|
||||||
@@ -57,7 +59,7 @@ describe('TextareaFieldParser test suite', () => {
|
|||||||
};
|
};
|
||||||
const expectedValue = 'test description';
|
const expectedValue = 'test description';
|
||||||
|
|
||||||
const parser = new TextareaFieldParser(submissionId, field, initFormValues, parserOptions);
|
const parser = new TextareaFieldParser(submissionId, field, initFormValues, parserOptions, translateService);
|
||||||
|
|
||||||
const fieldModel = parser.parse();
|
const fieldModel = parser.parse();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user