[TLC-254] Get Type Bind config from backend

This commit is contained in:
Kim Shepherd
2022-05-03 14:10:33 +12:00
parent 8cd07de4fc
commit 833637c215
23 changed files with 123 additions and 52 deletions

View File

@@ -77,11 +77,6 @@ submission:
# NOTE: after how many time (milliseconds) submission is saved automatically # NOTE: after how many time (milliseconds) submission is saved automatically
# eg. timer: 5 * (1000 * 60); // 5 minutes # eg. timer: 5 * (1000 * 60); // 5 minutes
timer: 0 timer: 0
typeBind:
# NOTE: which field to use when matching to type-bind configuration,
# eg. dc.type, local.publicationType
# default: dc.type
field: dc.type
icons: icons:
metadata: metadata:
# NOTE: example of configuration # NOTE: example of configuration

View File

@@ -2,7 +2,7 @@ import { Inject, Injectable, Injector, Optional } from '@angular/core';
import { FormControl } from '@angular/forms'; import { FormControl } from '@angular/forms';
import { Subscription } from 'rxjs'; import { Subscription } from 'rxjs';
import { startWith } from 'rxjs/operators'; import {map, startWith} from 'rxjs/operators';
import { import {
AND_OPERATOR, AND_OPERATOR,
@@ -15,10 +15,12 @@ import {
OR_OPERATOR OR_OPERATOR
} from '@ng-dynamic-forms/core'; } from '@ng-dynamic-forms/core';
import { hasNoValue, hasValue } from '../../../empty.util'; import {hasNoValue, hasValue, isEmpty} from '../../../empty.util';
import { FormBuilderService } from '../form-builder.service'; import { FormBuilderService } from '../form-builder.service';
import { FormFieldMetadataValueObject } from '../models/form-field-metadata-value.model'; import { FormFieldMetadataValueObject } from '../models/form-field-metadata-value.model';
import { DYNAMIC_FORM_CONTROL_TYPE_RELATION_GROUP } from './ds-dynamic-form-constants'; import { DYNAMIC_FORM_CONTROL_TYPE_RELATION_GROUP } from './ds-dynamic-form-constants';
import {getFirstCompletedRemoteData} from "../../../../core/shared/operators";
import {ConfigurationDataService} from "../../../../core/data/configuration-data.service";
/** /**
* Service to manage type binding for submission input fields * Service to manage type binding for submission input fields
@@ -31,7 +33,6 @@ export class DsDynamicTypeBindRelationService {
protected dynamicFormRelationService: DynamicFormRelationService, protected dynamicFormRelationService: DynamicFormRelationService,
protected formBuilderService: FormBuilderService, protected formBuilderService: FormBuilderService,
protected injector: Injector) { protected injector: Injector) {
} }
/** /**
@@ -53,6 +54,7 @@ export class DsDynamicTypeBindRelationService {
return value; return value;
} }
/** /**
* Get models for this bind type * Get models for this bind type
* @param model * @param model

View File

@@ -48,12 +48,18 @@ import { DynamicConcatModel } from './ds-dynamic-form-ui/models/ds-dynamic-conca
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 { 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 {ConfigurationDataService} from "../../../core/data/configuration-data.service";
import {createSuccessfulRemoteDataObject$} from "../../remote-data.utils";
import {ConfigurationProperty} from "../../../core/shared/configuration-property.model";
describe('FormBuilderService test suite', () => { describe('FormBuilderService test suite', () => {
let testModel: DynamicFormControlModel[]; let testModel: DynamicFormControlModel[];
let testFormConfiguration: SubmissionFormsModel; let testFormConfiguration: SubmissionFormsModel;
let service: FormBuilderService; let service: FormBuilderService;
let configSpy: ConfigurationDataService;
const typeFieldProp = 'submit.type-bind.field';
const typeFieldTestValue = 'dc.type';
const submissionId = '1234'; const submissionId = '1234';
@@ -65,15 +71,24 @@ describe('FormBuilderService test suite', () => {
return new Promise<boolean>((resolve) => setTimeout(() => resolve(true), 0)); return new Promise<boolean>((resolve) => setTimeout(() => resolve(true), 0));
} }
beforeEach(() => { const createConfigSuccessSpy = (...values: string[]) => jasmine.createSpyObj('configurationDataService', {
findByPropertyName: createSuccessfulRemoteDataObject$({
... new ConfigurationProperty(),
name: typeFieldProp,
values: values,
}),
});
beforeEach(() => {
configSpy = createConfigSuccessSpy(typeFieldTestValue);
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [ReactiveFormsModule], imports: [ReactiveFormsModule],
providers: [ providers: [
{ provide: FormBuilderService, useClass: FormBuilderService }, { provide: FormBuilderService, useClass: FormBuilderService },
{ 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 }
] ]
}); });
@@ -881,4 +896,11 @@ describe('FormBuilderService test suite', () => {
expect(formArray.length === 0).toBe(true); expect(formArray.length === 0).toBe(true);
}); });
it(`should request the ${typeFieldProp} property and set value "dc_type"`, () => {
service.setTypeBindFieldFromConfig();
expect(configSpy.findByPropertyName).toHaveBeenCalledTimes(1);
expect(configSpy.findByPropertyName).toHaveBeenCalledWith(typeFieldProp);
expect(service.getTypeField()).toEqual('dc_type');
});
}); });

View File

@@ -1,4 +1,4 @@
import { Injectable } from '@angular/core'; import {Injectable, Optional} from '@angular/core';
import { AbstractControl, FormControl, FormGroup } from '@angular/forms'; import { AbstractControl, FormControl, FormGroup } from '@angular/forms';
import { import {
@@ -42,6 +42,8 @@ import { DYNAMIC_FORM_CONTROL_TYPE_RELATION_GROUP } from './ds-dynamic-form-ui/d
import { CONCAT_GROUP_SUFFIX, DynamicConcatModel } from './ds-dynamic-form-ui/models/ds-dynamic-concat.model'; import { CONCAT_GROUP_SUFFIX, DynamicConcatModel } from './ds-dynamic-form-ui/models/ds-dynamic-concat.model';
import { VIRTUAL_METADATA_PREFIX } from '../../../core/shared/metadata.models'; import { VIRTUAL_METADATA_PREFIX } from '../../../core/shared/metadata.models';
import { environment } from '../../../../environments/environment'; import { environment } from '../../../../environments/environment';
import {ConfigurationDataService} from "../../../core/data/configuration-data.service";
import {getFirstCompletedRemoteData} from "../../../core/shared/operators";
@Injectable() @Injectable()
export class FormBuilderService extends DynamicFormService { export class FormBuilderService extends DynamicFormService {
@@ -66,13 +68,17 @@ export class FormBuilderService extends DynamicFormService {
constructor( constructor(
componentService: DynamicFormComponentService, componentService: DynamicFormComponentService,
validationService: DynamicFormValidationService, validationService: DynamicFormValidationService,
protected rowParser: RowParser protected rowParser: RowParser,
@Optional() protected configService: ConfigurationDataService,
) { ) {
super(componentService, validationService); super(componentService, validationService);
this.formModels = new Map(); this.formModels = new Map();
this.formGroups = new Map(); this.formGroups = new Map();
// Replace . with _ in configured type field here, to make configuration more simple and user-friendly if (hasValue(configService)) {
this.typeField = environment.submission.typeBind.field.replace(/\./g, '_'); this.setTypeBindFieldFromConfig();
} else {
this.typeField = 'dc_type';
}
} }
createDynamicFormControlEvent(control: FormControl, group: FormGroup, model: DynamicFormControlModel, type: string): DynamicFormControlEvent { createDynamicFormControlEvent(control: FormControl, group: FormGroup, model: DynamicFormControlModel, type: string): DynamicFormControlEvent {
@@ -278,7 +284,8 @@ export class FormBuilderService extends DynamicFormService {
const rawData = typeof json === 'string' ? JSON.parse(json, parseReviver) : json; const rawData = typeof json === 'string' ? JSON.parse(json, parseReviver) : json;
if (rawData.rows && !isEmpty(rawData.rows)) { if (rawData.rows && !isEmpty(rawData.rows)) {
rawData.rows.forEach((currentRow) => { rawData.rows.forEach((currentRow) => {
const rowParsed = this.rowParser.parse(submissionId, currentRow, scopeUUID, sectionData, submissionScope, readOnly); const rowParsed = this.rowParser.parse(submissionId, currentRow, scopeUUID, sectionData, submissionScope,
readOnly, this.typeField);
if (isNotNull(rowParsed)) { if (isNotNull(rowParsed)) {
if (Array.isArray(rowParsed)) { if (Array.isArray(rowParsed)) {
rows = rows.concat(rowParsed); rows = rows.concat(rowParsed);
@@ -489,4 +496,30 @@ export class FormBuilderService extends DynamicFormService {
return Object.keys(result); return Object.keys(result);
} }
/**
* Get the type bind field from config
*/
setTypeBindFieldFromConfig(): void {
this.configService.findByPropertyName('submit.type-bind.field').pipe(
getFirstCompletedRemoteData(),
).subscribe((remoteData: any) => {
// make sure we got a success response from the backend
if (!remoteData.hasSucceeded) {
this.typeField = 'dc_type';
return;
}
// Read type bind value from response and set if non-empty
const typeFieldConfig = remoteData.payload.values[0];
if (isEmpty(typeFieldConfig)) {
this.typeField = 'dc_type';
} else {
this.typeField = typeFieldConfig.replace(/\./g, '_');
}
});
}
getTypeField(): string {
return this.typeField;
}
} }

View File

@@ -1,4 +1,4 @@
import { Inject } from '@angular/core'; import {Inject} from '@angular/core';
import { FormFieldModel } from '../models/form-field.model'; import { FormFieldModel } from '../models/form-field.model';
import { FormFieldMetadataValueObject } from '../models/form-field-metadata-value.model'; import { FormFieldMetadataValueObject } from '../models/form-field-metadata-value.model';
import { import {

View File

@@ -12,7 +12,8 @@ describe('DateFieldParser test suite', () => {
const parserOptions: ParserOptions = { const parserOptions: ParserOptions = {
readOnly: false, readOnly: false,
submissionScope: null, submissionScope: null,
collectionUUID: null collectionUUID: null,
typeField: 'dc_type'
}; };
beforeEach(() => { beforeEach(() => {

View File

@@ -11,7 +11,8 @@ describe('DisabledFieldParser test suite', () => {
const parserOptions: ParserOptions = { const parserOptions: ParserOptions = {
readOnly: false, readOnly: false,
submissionScope: null, submissionScope: null,
collectionUUID: null collectionUUID: null,
typeField: 'dc_type'
}; };
beforeEach(() => { beforeEach(() => {

View File

@@ -11,7 +11,8 @@ describe('DropdownFieldParser test suite', () => {
const parserOptions: ParserOptions = { const parserOptions: ParserOptions = {
readOnly: false, readOnly: false,
submissionScope: 'testScopeUUID', submissionScope: 'testScopeUUID',
collectionUUID: null collectionUUID: null,
typeField: 'dc_type'
}; };
beforeEach(() => { beforeEach(() => {

View File

@@ -1,4 +1,4 @@
import { Inject } from '@angular/core'; import {Inject} from '@angular/core';
import { FormFieldModel } from '../models/form-field.model'; import { FormFieldModel } from '../models/form-field.model';
import { import {
CONFIG_DATA, CONFIG_DATA,
@@ -22,7 +22,7 @@ export class DropdownFieldParser extends FieldParser {
@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,
) { ) {
super(submissionId, configData, initFormValues, parserOptions); super(submissionId, configData, initFormValues, parserOptions);
} }

View File

@@ -1,9 +1,9 @@
import { Inject, InjectionToken } from '@angular/core'; import {Inject, InjectionToken} from '@angular/core';
import { uniqueId } from 'lodash'; import { uniqueId } from 'lodash';
import {DynamicFormControlLayout, DynamicFormControlRelation, MATCH_VISIBLE, OR_OPERATOR} from '@ng-dynamic-forms/core'; import {DynamicFormControlLayout, DynamicFormControlRelation, MATCH_VISIBLE, OR_OPERATOR} from '@ng-dynamic-forms/core';
import { hasValue, isNotEmpty, isNotNull, isNotUndefined } from '../../../empty.util'; import {hasValue, isEmpty, isNotEmpty, isNotNull, isNotUndefined} from '../../../empty.util';
import { FormFieldModel } from '../models/form-field.model'; import { FormFieldModel } from '../models/form-field.model';
import { FormFieldMetadataValueObject } from '../models/form-field-metadata-value.model'; import { FormFieldMetadataValueObject } from '../models/form-field-metadata-value.model';
import { import {
@@ -18,6 +18,8 @@ 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 { environment } from '../../../../../environments/environment'; import { environment } from '../../../../../environments/environment';
import {getFirstCompletedRemoteData} from "../../../../core/shared/operators";
import {map} from "rxjs/operators";
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');
@@ -39,8 +41,6 @@ export abstract class FieldParser {
@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
) { ) {
// Replace . with _ in configured type field here, to make configuration more simple and user-friendly
this.typeField = environment.submission.typeBind.field.replace(/\./g, '_');
} }
public abstract modelFactory(fieldValue?: FormFieldMetadataValueObject, label?: boolean): any; public abstract modelFactory(fieldValue?: FormFieldMetadataValueObject, label?: boolean): any;
@@ -75,7 +75,8 @@ export abstract class FieldParser {
metadataFields: this.getAllFieldIds(), metadataFields: this.getAllFieldIds(),
hasSelectableMetadata: isNotEmpty(this.configData.selectableMetadata), hasSelectableMetadata: isNotEmpty(this.configData.selectableMetadata),
isDraggable, isDraggable,
typeBindRelations: isNotEmpty(this.configData.typeBind) ? this.getTypeBindRelations(this.configData.typeBind) : null, typeBindRelations: isNotEmpty(this.configData.typeBind) ? this.getTypeBindRelations(this.configData.typeBind,
this.parserOptions.typeField) : null,
groupFactory: () => { groupFactory: () => {
let model; let model;
if ((arrayCounter === 0)) { if ((arrayCounter === 0)) {
@@ -303,7 +304,8 @@ export abstract class FieldParser {
// If typeBind is configured // If typeBind is configured
if (isNotEmpty(this.configData.typeBind)) { if (isNotEmpty(this.configData.typeBind)) {
(controlModel as DsDynamicInputModel).typeBindRelations = this.getTypeBindRelations(this.configData.typeBind); (controlModel as DsDynamicInputModel).typeBindRelations = this.getTypeBindRelations(this.configData.typeBind,
this.parserOptions.typeField);
} }
return controlModel; return controlModel;
@@ -319,11 +321,11 @@ export abstract class FieldParser {
* @private * @private
* @return DynamicFormControlRelation[] array with one relation in it, for type bind matching to show a field * @return DynamicFormControlRelation[] array with one relation in it, for type bind matching to show a field
*/ */
private getTypeBindRelations(configuredTypeBindValues: string[]): DynamicFormControlRelation[] { private getTypeBindRelations(configuredTypeBindValues: string[], typeField: string): DynamicFormControlRelation[] {
const bindValues = []; const bindValues = [];
configuredTypeBindValues.forEach((value) => { configuredTypeBindValues.forEach((value) => {
bindValues.push({ bindValues.push({
id: this.typeField, id: typeField,
value: value value: value
}); });
}); });

View File

@@ -13,7 +13,8 @@ describe('ListFieldParser test suite', () => {
const parserOptions: ParserOptions = { const parserOptions: ParserOptions = {
readOnly: false, readOnly: false,
submissionScope: 'testScopeUUID', submissionScope: 'testScopeUUID',
collectionUUID: null collectionUUID: null,
typeField: 'dc_type'
}; };
beforeEach(() => { beforeEach(() => {

View File

@@ -12,7 +12,8 @@ describe('LookupFieldParser test suite', () => {
const parserOptions: ParserOptions = { const parserOptions: ParserOptions = {
readOnly: false, readOnly: false,
submissionScope: 'testScopeUUID', submissionScope: 'testScopeUUID',
collectionUUID: null collectionUUID: null,
typeField: 'dc_type'
}; };
beforeEach(() => { beforeEach(() => {

View File

@@ -12,7 +12,8 @@ describe('LookupNameFieldParser test suite', () => {
const parserOptions: ParserOptions = { const parserOptions: ParserOptions = {
readOnly: false, readOnly: false,
submissionScope: 'testScopeUUID', submissionScope: 'testScopeUUID',
collectionUUID: null collectionUUID: null,
typeField: 'dc_type'
}; };
beforeEach(() => { beforeEach(() => {

View File

@@ -14,7 +14,8 @@ describe('NameFieldParser test suite', () => {
const parserOptions: ParserOptions = { const parserOptions: ParserOptions = {
readOnly: false, readOnly: false,
submissionScope: 'testScopeUUID', submissionScope: 'testScopeUUID',
collectionUUID: null collectionUUID: null,
typeField: 'dc_type'
}; };
beforeEach(() => { beforeEach(() => {

View File

@@ -15,7 +15,8 @@ describe('OneboxFieldParser test suite', () => {
const parserOptions: ParserOptions = { const parserOptions: ParserOptions = {
readOnly: false, readOnly: false,
submissionScope: 'testScopeUUID', submissionScope: 'testScopeUUID',
collectionUUID: null collectionUUID: null,
typeField: 'dc_type'
}; };
beforeEach(() => { beforeEach(() => {

View File

@@ -2,4 +2,5 @@ export interface ParserOptions {
readOnly: boolean; readOnly: boolean;
submissionScope: string; submissionScope: string;
collectionUUID: string; collectionUUID: string;
typeField: string;
} }

View File

@@ -12,7 +12,8 @@ describe('RelationGroupFieldParser test suite', () => {
const parserOptions: ParserOptions = { const parserOptions: ParserOptions = {
readOnly: false, readOnly: false,
submissionScope: 'testScopeUUID', submissionScope: 'testScopeUUID',
collectionUUID: 'WORKSPACE' collectionUUID: 'WORKSPACE',
typeField: 'dc_type'
}; };
beforeEach(() => { beforeEach(() => {

View File

@@ -22,6 +22,7 @@ describe('RowParser test suite', () => {
const initFormValues = {}; const initFormValues = {};
const submissionScope = 'WORKSPACE'; const submissionScope = 'WORKSPACE';
const readOnly = false; const readOnly = false;
const typeField = 'dc_type';
beforeEach(() => { beforeEach(() => {
row1 = { row1 = {
@@ -338,7 +339,7 @@ describe('RowParser test suite', () => {
it('should return a DynamicRowGroupModel object', () => { it('should return a DynamicRowGroupModel object', () => {
const parser = new RowParser(undefined); const parser = new RowParser(undefined);
const rowModel = parser.parse(submissionId, row1, scopeUUID, initFormValues, submissionScope, readOnly); const rowModel = parser.parse(submissionId, row1, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
expect(rowModel instanceof DynamicRowGroupModel).toBe(true); expect(rowModel instanceof DynamicRowGroupModel).toBe(true);
}); });
@@ -346,7 +347,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(undefined);
const rowModel = parser.parse(submissionId, row1, scopeUUID, initFormValues, submissionScope, readOnly); const rowModel = parser.parse(submissionId, row1, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
expect((rowModel as DynamicRowGroupModel).group.length).toBe(3); expect((rowModel as DynamicRowGroupModel).group.length).toBe(3);
}); });
@@ -354,7 +355,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(undefined);
const rowModel = parser.parse(submissionId, row2, scopeUUID, initFormValues, submissionScope, readOnly); const rowModel = parser.parse(submissionId, row2, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
expect(rowModel instanceof DynamicRowArrayModel).toBe(true); expect(rowModel instanceof DynamicRowArrayModel).toBe(true);
}); });
@@ -362,7 +363,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(undefined);
const rowModel = parser.parse(submissionId, row3, scopeUUID, initFormValues, submissionScope, readOnly); const rowModel = parser.parse(submissionId, row3, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
expect((rowModel as DynamicRowGroupModel).group.length).toBe(1); expect((rowModel as DynamicRowGroupModel).group.length).toBe(1);
}); });
@@ -370,7 +371,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(undefined);
const rowModel = parser.parse(submissionId, row4, scopeUUID, initFormValues, submissionScope, readOnly); const rowModel = parser.parse(submissionId, row4, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
expect(rowModel).toBeDefined(); expect(rowModel).toBeDefined();
}); });
@@ -378,7 +379,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(undefined);
const rowModel = parser.parse(submissionId, row5, scopeUUID, initFormValues, submissionScope, readOnly); const rowModel = parser.parse(submissionId, row5, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
expect(rowModel).toBeDefined(); expect(rowModel).toBeDefined();
}); });
@@ -386,7 +387,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(undefined);
const rowModel = parser.parse(submissionId, row6, scopeUUID, initFormValues, submissionScope, readOnly); const rowModel = parser.parse(submissionId, row6, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
expect(rowModel).toBeDefined(); expect(rowModel).toBeDefined();
}); });
@@ -394,7 +395,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(undefined);
const rowModel = parser.parse(submissionId, row7, scopeUUID, initFormValues, submissionScope, readOnly); const rowModel = parser.parse(submissionId, row7, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
expect(rowModel).toBeDefined(); expect(rowModel).toBeDefined();
}); });
@@ -402,7 +403,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(undefined);
const rowModel = parser.parse(submissionId, row8, scopeUUID, initFormValues, submissionScope, readOnly); const rowModel = parser.parse(submissionId, row8, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
expect(rowModel).toBeDefined(); expect(rowModel).toBeDefined();
}); });
@@ -410,7 +411,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(undefined);
const rowModel = parser.parse(submissionId, row9, scopeUUID, initFormValues, submissionScope, readOnly); const rowModel = parser.parse(submissionId, row9, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
expect(rowModel).toBeDefined(); expect(rowModel).toBeDefined();
}); });
@@ -418,7 +419,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(undefined);
const rowModel = parser.parse(submissionId, row10, scopeUUID, initFormValues, submissionScope, readOnly); const rowModel = parser.parse(submissionId, row10, scopeUUID, initFormValues, submissionScope, readOnly, typeField);
expect(rowModel).toBeDefined(); expect(rowModel).toBeDefined();
}); });

View File

@@ -31,7 +31,8 @@ export class RowParser {
scopeUUID, scopeUUID,
initFormValues: any, initFormValues: any,
submissionScope, submissionScope,
readOnly: boolean): DynamicRowGroupModel { readOnly: boolean,
typeField: string): DynamicRowGroupModel {
let fieldModel: any = null; let fieldModel: any = null;
let parsedResult = null; let parsedResult = null;
const config: DynamicFormGroupModelConfig = { const config: DynamicFormGroupModelConfig = {
@@ -47,7 +48,8 @@ export class RowParser {
const parserOptions: ParserOptions = { const parserOptions: ParserOptions = {
readOnly: readOnly, readOnly: readOnly,
submissionScope: submissionScope, submissionScope: submissionScope,
collectionUUID: scopeUUID collectionUUID: scopeUUID,
typeField: typeField
}; };
// Iterate over row's fields // Iterate over row's fields

View File

@@ -12,7 +12,8 @@ describe('SeriesFieldParser test suite', () => {
const parserOptions: ParserOptions = { const parserOptions: ParserOptions = {
readOnly: false, readOnly: false,
submissionScope: 'testScopeUUID', submissionScope: 'testScopeUUID',
collectionUUID: null collectionUUID: null,
typeField: 'dc_type'
}; };
beforeEach(() => { beforeEach(() => {

View File

@@ -12,7 +12,8 @@ describe('TagFieldParser test suite', () => {
const parserOptions: ParserOptions = { const parserOptions: ParserOptions = {
readOnly: false, readOnly: false,
submissionScope: 'testScopeUUID', submissionScope: 'testScopeUUID',
collectionUUID: null collectionUUID: null,
typeField: 'dc_type'
}; };
beforeEach(() => { beforeEach(() => {

View File

@@ -12,7 +12,8 @@ describe('TextareaFieldParser test suite', () => {
const parserOptions: ParserOptions = { const parserOptions: ParserOptions = {
readOnly: false, readOnly: false,
submissionScope: null, submissionScope: null,
collectionUUID: null collectionUUID: null,
typeField: 'dc_type'
}; };
beforeEach(() => { beforeEach(() => {

View File

@@ -42,6 +42,7 @@ import { NgbAccordionModule, NgbModalModule } from '@ng-bootstrap/ng-bootstrap';
import { SubmissionSectionAccessesComponent } from './sections/accesses/section-accesses.component'; import { SubmissionSectionAccessesComponent } from './sections/accesses/section-accesses.component';
import { SubmissionAccessesConfigService } from '../core/config/submission-accesses-config.service'; import { SubmissionAccessesConfigService } from '../core/config/submission-accesses-config.service';
import { SectionAccessesService } from './sections/accesses/section-accesses.service'; import { SectionAccessesService } from './sections/accesses/section-accesses.service';
import {ConfigurationDataService} from "../core/data/configuration-data.service";
const ENTRY_COMPONENTS = [ const ENTRY_COMPONENTS = [
// put only entry components that use custom decorator // put only entry components that use custom decorator
@@ -97,7 +98,7 @@ const DECLARATIONS = [
SectionsService, SectionsService,
SubmissionUploadsConfigService, SubmissionUploadsConfigService,
SubmissionAccessesConfigService, SubmissionAccessesConfigService,
SectionAccessesService SectionAccessesService,
] ]
}) })