mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-15 14:03:06 +00:00
[TLC-254] Take config data service out of constructor, make optional
This commit is contained in:
@@ -897,10 +897,10 @@ describe('FormBuilderService test suite', () => {
|
||||
});
|
||||
|
||||
it(`should request the ${typeFieldProp} property and set value "dc_type"`, () => {
|
||||
// This should have been called in the service constructor
|
||||
const typeValue = service.getTypeField();
|
||||
expect(configSpy.findByPropertyName).toHaveBeenCalledTimes(1);
|
||||
expect(configSpy.findByPropertyName).toHaveBeenCalledWith(typeFieldProp);
|
||||
expect(service.getTypeField()).toEqual('dc_type');
|
||||
expect(typeValue).toEqual('dc_type');
|
||||
});
|
||||
|
||||
});
|
||||
|
@@ -74,11 +74,6 @@ export class FormBuilderService extends DynamicFormService {
|
||||
super(componentService, validationService);
|
||||
this.formModels = new Map();
|
||||
this.formGroups = new Map();
|
||||
if (hasValue(configService) || true) {
|
||||
this.setTypeBindFieldFromConfig();
|
||||
} else {
|
||||
this.typeField = 'dc_type';
|
||||
}
|
||||
}
|
||||
|
||||
createDynamicFormControlEvent(control: FormControl, group: FormGroup, model: DynamicFormControlModel, type: string): DynamicFormControlEvent {
|
||||
@@ -285,7 +280,7 @@ export class FormBuilderService extends DynamicFormService {
|
||||
if (rawData.rows && !isEmpty(rawData.rows)) {
|
||||
rawData.rows.forEach((currentRow) => {
|
||||
const rowParsed = this.rowParser.parse(submissionId, currentRow, scopeUUID, sectionData, submissionScope,
|
||||
readOnly, this.typeField);
|
||||
readOnly, this.getTypeField());
|
||||
if (isNotNull(rowParsed)) {
|
||||
if (Array.isArray(rowParsed)) {
|
||||
rows = rows.concat(rowParsed);
|
||||
@@ -518,7 +513,16 @@ export class FormBuilderService extends DynamicFormService {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get type field. If the type isn't already set, and a ConfigurationDataService is provided, set (with subscribe)
|
||||
* from back end. Otherwise, get/set a default "dc_type" value
|
||||
*/
|
||||
getTypeField(): string {
|
||||
if (hasValue(this.configService) && hasNoValue(this.typeField)) {
|
||||
this.setTypeBindFieldFromConfig();
|
||||
} else if (hasNoValue(this.typeField)) {
|
||||
this.typeField = 'dc_type';
|
||||
}
|
||||
return this.typeField;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user