mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-17 15:03:07 +00:00
ESLint: fix dangling commas
This commit is contained in:
@@ -5,7 +5,7 @@ import {
|
||||
DYNAMIC_FORM_CONTROL_TYPE_ARRAY,
|
||||
DYNAMIC_FORM_CONTROL_TYPE_GROUP,
|
||||
DynamicFormControlEvent,
|
||||
DynamicInputModel
|
||||
DynamicInputModel,
|
||||
} from '@ng-dynamic-forms/core';
|
||||
|
||||
import { FormBuilderService } from '../../../shared/form/builder/form-builder.service';
|
||||
@@ -25,7 +25,7 @@ import {
|
||||
mockQualdropInputModel,
|
||||
MockQualdropModel,
|
||||
MockRelationModel,
|
||||
mockRowGroupModel
|
||||
mockRowGroupModel,
|
||||
} from '../../../shared/mocks/form-models.mock';
|
||||
import { FormFieldMetadataValueObject } from '../../../shared/form/builder/models/form-field-metadata-value.model';
|
||||
import { VocabularyEntry } from '../../../core/submission/vocabularies/models/vocabulary-entry.model';
|
||||
@@ -49,7 +49,7 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
control: null,
|
||||
group: null,
|
||||
model: null,
|
||||
type: 'change'
|
||||
type: 'change',
|
||||
};
|
||||
|
||||
const dynamicFormControlRemoveEvent: DynamicFormControlEvent = {
|
||||
@@ -58,7 +58,7 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
control: null,
|
||||
group: null,
|
||||
model: null,
|
||||
type: 'remove'
|
||||
type: 'remove',
|
||||
};
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
@@ -67,15 +67,15 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
TranslateModule.forRoot({
|
||||
loader: {
|
||||
provide: TranslateLoader,
|
||||
useClass: TranslateLoaderMock
|
||||
}
|
||||
})
|
||||
useClass: TranslateLoaderMock,
|
||||
},
|
||||
}),
|
||||
],
|
||||
providers: [
|
||||
{ provide: FormBuilderService, useValue: getMockFormBuilderService() },
|
||||
{ provide: JsonPatchOperationsBuilder, useValue: jsonPatchOpBuilder },
|
||||
SectionFormOperationsService
|
||||
]
|
||||
SectionFormOperationsService,
|
||||
],
|
||||
}).compileComponents().then();
|
||||
}));
|
||||
|
||||
@@ -114,8 +114,8 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
it('should return the index of the array to which the element belongs', () => {
|
||||
const event = Object.assign({}, dynamicFormControlChangeEvent, {
|
||||
context: {
|
||||
index: 1
|
||||
}
|
||||
index: 1,
|
||||
},
|
||||
});
|
||||
|
||||
expect(service.getArrayIndexFromEvent(event)).toBe(1);
|
||||
@@ -126,10 +126,10 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
model: {
|
||||
parent: {
|
||||
parent: {
|
||||
index: 2
|
||||
}
|
||||
}
|
||||
}
|
||||
index: 2,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
spyOn(serviceAsAny, 'isPartOfArrayOfGroup').and.returnValue(true);
|
||||
|
||||
@@ -157,10 +157,10 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
type: DYNAMIC_FORM_CONTROL_TYPE_GROUP,
|
||||
parent: {
|
||||
context: {
|
||||
type: DYNAMIC_FORM_CONTROL_TYPE_ARRAY
|
||||
}
|
||||
}
|
||||
}
|
||||
type: DYNAMIC_FORM_CONTROL_TYPE_ARRAY,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
expect(service.isPartOfArrayOfGroup(model as any)).toBeTruthy();
|
||||
@@ -168,7 +168,7 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
|
||||
it('should return false when parent element doesn\'t belong to an array group element', () => {
|
||||
const model = {
|
||||
parent: null
|
||||
parent: null,
|
||||
};
|
||||
|
||||
expect(service.isPartOfArrayOfGroup(model as any)).toBeFalsy();
|
||||
@@ -181,19 +181,19 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
const context = {
|
||||
groups: [
|
||||
{
|
||||
group: [MockQualdropModel]
|
||||
}
|
||||
]
|
||||
group: [MockQualdropModel],
|
||||
},
|
||||
],
|
||||
};
|
||||
const model = {
|
||||
parent: {
|
||||
parent: {
|
||||
context: context
|
||||
}
|
||||
}
|
||||
context: context,
|
||||
},
|
||||
},
|
||||
};
|
||||
const event = Object.assign({}, dynamicFormControlChangeEvent, {
|
||||
model: model
|
||||
model: model,
|
||||
});
|
||||
const expectMap = new Map();
|
||||
expectMap.set(MockQualdropModel.qualdropId, [MockQualdropModel.value]);
|
||||
@@ -207,17 +207,17 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
const context = {
|
||||
groups: [
|
||||
{
|
||||
group: [MockQualdropModel]
|
||||
}
|
||||
]
|
||||
group: [MockQualdropModel],
|
||||
},
|
||||
],
|
||||
};
|
||||
const model = {
|
||||
parent: {
|
||||
context: context
|
||||
}
|
||||
context: context,
|
||||
},
|
||||
};
|
||||
const event = Object.assign({}, dynamicFormControlChangeEvent, {
|
||||
model: model
|
||||
model: model,
|
||||
});
|
||||
const expectMap = new Map();
|
||||
expectMap.set(MockQualdropModel.qualdropId, [MockQualdropModel.value]);
|
||||
@@ -247,19 +247,19 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
const context = {
|
||||
groups: [
|
||||
{
|
||||
group: [MockQualdropModel]
|
||||
}
|
||||
]
|
||||
group: [MockQualdropModel],
|
||||
},
|
||||
],
|
||||
};
|
||||
const model = {
|
||||
parent: {
|
||||
parent: {
|
||||
context: context
|
||||
}
|
||||
}
|
||||
context: context,
|
||||
},
|
||||
},
|
||||
};
|
||||
const event = Object.assign({}, dynamicFormControlChangeEvent, {
|
||||
model: model
|
||||
model: model,
|
||||
});
|
||||
const expectPath = 'dc.identifier.issn/0';
|
||||
spyOn(serviceAsAny, 'getArrayIndexFromEvent').and.returnValue(0);
|
||||
@@ -273,17 +273,17 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
const context = {
|
||||
groups: [
|
||||
{
|
||||
group: [MockQualdropModel]
|
||||
}
|
||||
]
|
||||
group: [MockQualdropModel],
|
||||
},
|
||||
],
|
||||
};
|
||||
const model = {
|
||||
parent: {
|
||||
context: context
|
||||
}
|
||||
context: context,
|
||||
},
|
||||
};
|
||||
const event = Object.assign({}, dynamicFormControlChangeEvent, {
|
||||
model: model
|
||||
model: model,
|
||||
});
|
||||
const expectPath = 'dc.identifier.issn/0';
|
||||
spyOn(serviceAsAny, 'getArrayIndexFromEvent').and.returnValue(0);
|
||||
@@ -297,7 +297,7 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
describe('getFieldPathSegmentedFromChangeEvent', () => {
|
||||
it('should return field segmented path properly', () => {
|
||||
const event = Object.assign({}, dynamicFormControlChangeEvent, {
|
||||
model: mockQualdropInputModel
|
||||
model: mockQualdropInputModel,
|
||||
});
|
||||
formBuilderService.isQualdropGroup.and.returnValues(false, false);
|
||||
|
||||
@@ -306,7 +306,7 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
|
||||
it('should return field segmented path properly when model is DynamicQualdropModel', () => {
|
||||
const event = Object.assign({}, dynamicFormControlChangeEvent, {
|
||||
model: MockQualdropModel
|
||||
model: MockQualdropModel,
|
||||
});
|
||||
formBuilderService.isQualdropGroup.and.returnValue(true);
|
||||
|
||||
@@ -316,8 +316,8 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
it('should return field segmented path properly when model belongs to a DynamicQualdropModel', () => {
|
||||
const event = Object.assign({}, dynamicFormControlChangeEvent, {
|
||||
model: {
|
||||
parent: MockQualdropModel
|
||||
}
|
||||
parent: MockQualdropModel,
|
||||
},
|
||||
});
|
||||
formBuilderService.isQualdropGroup.and.returnValues(false, true);
|
||||
|
||||
@@ -330,8 +330,8 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
it('should return field value properly when model belongs to a DynamicQualdropModel', () => {
|
||||
const event = Object.assign({}, dynamicFormControlChangeEvent, {
|
||||
model: {
|
||||
parent: MockQualdropModel
|
||||
}
|
||||
parent: MockQualdropModel,
|
||||
},
|
||||
});
|
||||
formBuilderService.isModelInCustomGroup.and.returnValue(true);
|
||||
const expectedValue = 'test';
|
||||
@@ -341,18 +341,18 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
|
||||
it('should return field value properly when model is DynamicRelationGroupModel', () => {
|
||||
const event = Object.assign({}, dynamicFormControlChangeEvent, {
|
||||
model: MockRelationModel
|
||||
model: MockRelationModel,
|
||||
});
|
||||
formBuilderService.isModelInCustomGroup.and.returnValue(false);
|
||||
formBuilderService.isRelationGroup.and.returnValue(true);
|
||||
const expectedValue = {
|
||||
journal: [
|
||||
'journal test 1',
|
||||
'journal test 2'
|
||||
'journal test 2',
|
||||
],
|
||||
issue: [
|
||||
'issue test 1',
|
||||
'issue test 2'
|
||||
'issue test 2',
|
||||
],
|
||||
};
|
||||
|
||||
@@ -361,7 +361,7 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
|
||||
it('should return field value properly when model has language', () => {
|
||||
let event = Object.assign({}, dynamicFormControlChangeEvent, {
|
||||
model: mockInputWithLanguageModel
|
||||
model: mockInputWithLanguageModel,
|
||||
});
|
||||
formBuilderService.isModelInCustomGroup.and.returnValue(false);
|
||||
formBuilderService.isRelationGroup.and.returnValue(false);
|
||||
@@ -370,19 +370,19 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
expect(service.getFieldValueFromChangeEvent(event)).toEqual(expectedValue);
|
||||
|
||||
event = Object.assign({}, dynamicFormControlChangeEvent, {
|
||||
model: mockInputWithLanguageAndAuthorityModel
|
||||
model: mockInputWithLanguageAndAuthorityModel,
|
||||
});
|
||||
expectedValue = Object.assign(new VocabularyEntry(), mockInputWithLanguageAndAuthorityModel.value, {language: mockInputWithLanguageAndAuthorityModel.language});
|
||||
|
||||
expect(service.getFieldValueFromChangeEvent(event)).toEqual(expectedValue);
|
||||
|
||||
event = Object.assign({}, dynamicFormControlChangeEvent, {
|
||||
model: mockInputWithLanguageAndAuthorityArrayModel
|
||||
model: mockInputWithLanguageAndAuthorityArrayModel,
|
||||
});
|
||||
expectedValue = [
|
||||
Object.assign(new VocabularyEntry(), mockInputWithLanguageAndAuthorityArrayModel.value[0],
|
||||
{ language: mockInputWithLanguageAndAuthorityArrayModel.language }
|
||||
)
|
||||
{ language: mockInputWithLanguageAndAuthorityArrayModel.language },
|
||||
),
|
||||
];
|
||||
|
||||
expect(service.getFieldValueFromChangeEvent(event)).toEqual(expectedValue);
|
||||
@@ -390,7 +390,7 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
|
||||
it('should return field value properly when model has an object as value', () => {
|
||||
let event = Object.assign({}, dynamicFormControlChangeEvent, {
|
||||
model: mockInputWithFormFieldValueModel
|
||||
model: mockInputWithFormFieldValueModel,
|
||||
});
|
||||
formBuilderService.isModelInCustomGroup.and.returnValue(false);
|
||||
formBuilderService.isRelationGroup.and.returnValue(false);
|
||||
@@ -399,14 +399,14 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
expect(service.getFieldValueFromChangeEvent(event)).toEqual(expectedValue);
|
||||
|
||||
event = Object.assign({}, dynamicFormControlChangeEvent, {
|
||||
model: mockInputWithAuthorityValueModel
|
||||
model: mockInputWithAuthorityValueModel,
|
||||
});
|
||||
expectedValue = mockInputWithAuthorityValueModel.value;
|
||||
|
||||
expect(service.getFieldValueFromChangeEvent(event)).toEqual(expectedValue);
|
||||
|
||||
event = Object.assign({}, dynamicFormControlChangeEvent, {
|
||||
model: mockInputWithObjectValueModel
|
||||
model: mockInputWithObjectValueModel,
|
||||
});
|
||||
expectedValue = mockInputWithObjectValueModel.value;
|
||||
|
||||
@@ -461,8 +461,8 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
const previousValue = new FormFieldPreviousValueObject(['path', 'test'], 'value');
|
||||
const event = Object.assign({}, dynamicFormControlChangeEvent, {
|
||||
model: {
|
||||
parent: MockQualdropModel
|
||||
}
|
||||
parent: MockQualdropModel,
|
||||
},
|
||||
});
|
||||
spyOn(service, 'getFieldPathFromEvent').and.returnValue('path/0');
|
||||
spyOn(service, 'getFieldPathSegmentedFromChangeEvent').and.returnValue('path');
|
||||
@@ -481,8 +481,8 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
const previousValue = new FormFieldPreviousValueObject(['path', 'test'], 'value');
|
||||
const event = Object.assign({}, dynamicFormControlChangeEvent, {
|
||||
model: {
|
||||
parent: MockRelationModel
|
||||
}
|
||||
parent: MockRelationModel,
|
||||
},
|
||||
});
|
||||
spyOn(service, 'getFieldPathFromEvent').and.returnValue('path/0');
|
||||
spyOn(service, 'getFieldPathSegmentedFromChangeEvent').and.returnValue('path');
|
||||
@@ -502,8 +502,8 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
const previousValue = new FormFieldPreviousValueObject(['path', 'test'], 'value');
|
||||
const event = Object.assign({}, dynamicFormControlChangeEvent, {
|
||||
model: {
|
||||
parent: mockRowGroupModel
|
||||
}
|
||||
parent: mockRowGroupModel,
|
||||
},
|
||||
});
|
||||
spyOn(service, 'getFieldPathFromEvent').and.returnValue('path/0');
|
||||
spyOn(service, 'getFieldPathSegmentedFromChangeEvent').and.returnValue('path');
|
||||
@@ -523,8 +523,8 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
const previousValue = new FormFieldPreviousValueObject(['path', 'test'], 'value');
|
||||
const event = Object.assign({}, dynamicFormControlChangeEvent, {
|
||||
model: {
|
||||
parent: mockRowGroupModel
|
||||
}
|
||||
parent: mockRowGroupModel,
|
||||
},
|
||||
});
|
||||
const spyPath = spyOn(service, 'getFieldPathFromEvent').and.returnValue('path/0');
|
||||
spyOn(service, 'getFieldPathSegmentedFromChangeEvent').and.returnValue('path');
|
||||
@@ -552,8 +552,8 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
const previousValue = new FormFieldPreviousValueObject(['path', 'test'], 'value');
|
||||
const event = Object.assign({}, dynamicFormControlChangeEvent, {
|
||||
model: {
|
||||
parent: mockRowGroupModel
|
||||
}
|
||||
parent: mockRowGroupModel,
|
||||
},
|
||||
});
|
||||
spyOn(service, 'getFieldPathFromEvent').and.returnValue('path/0');
|
||||
spyOn(service, 'getFieldPathSegmentedFromChangeEvent').and.returnValue('path');
|
||||
@@ -577,8 +577,8 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
let previousValue = new FormFieldPreviousValueObject(['path', 'test'], 'value');
|
||||
const event = Object.assign({}, dynamicFormControlChangeEvent, {
|
||||
model: {
|
||||
parent: mockRowGroupModel
|
||||
}
|
||||
parent: mockRowGroupModel,
|
||||
},
|
||||
});
|
||||
const spyPath = spyOn(service, 'getFieldPathFromEvent').and.returnValue('path/0');
|
||||
spyOn(service, 'getFieldPathSegmentedFromChangeEvent').and.returnValue('path');
|
||||
@@ -607,8 +607,8 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
const previousValue = new FormFieldPreviousValueObject(['path', 'test'], 'value');
|
||||
const event = Object.assign({}, dynamicFormControlChangeEvent, {
|
||||
model: {
|
||||
parent: mockRowGroupModel
|
||||
}
|
||||
parent: mockRowGroupModel,
|
||||
},
|
||||
});
|
||||
spyOn(service, 'getFieldPathFromEvent').and.returnValue('path/0');
|
||||
spyOn(service, 'getFieldPathSegmentedFromChangeEvent').and.returnValue('path');
|
||||
@@ -632,8 +632,8 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
const previousValue = new FormFieldPreviousValueObject(['path', 'test'], null);
|
||||
const event = Object.assign({}, dynamicFormControlChangeEvent, {
|
||||
model: {
|
||||
parent: mockRowGroupModel
|
||||
}
|
||||
parent: mockRowGroupModel,
|
||||
},
|
||||
});
|
||||
spyOn(service, 'getFieldPathFromEvent').and.returnValue('path/0');
|
||||
spyOn(service, 'getFieldPathSegmentedFromChangeEvent').and.returnValue('path');
|
||||
@@ -658,8 +658,8 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
const previousValue = new FormFieldPreviousValueObject(['path', 'test'], 'value');
|
||||
const event = Object.assign({}, dynamicFormControlChangeEvent, {
|
||||
model: {
|
||||
parent: mockRowGroupModel
|
||||
}
|
||||
parent: mockRowGroupModel,
|
||||
},
|
||||
});
|
||||
const spyPath = spyOn(service, 'getFieldPathFromEvent').and.returnValue('path/0');
|
||||
spyOn(service, 'getFieldPathSegmentedFromChangeEvent').and.returnValue('path');
|
||||
@@ -693,8 +693,8 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
const previousValue = new FormFieldPreviousValueObject(['path', 'test'], 'value');
|
||||
const event = Object.assign({}, dynamicFormControlChangeEvent, {
|
||||
model: {
|
||||
parent: mockRowGroupModel
|
||||
}
|
||||
parent: mockRowGroupModel,
|
||||
},
|
||||
});
|
||||
spyOn(service, 'getFieldPathFromEvent').and.returnValue('path/1');
|
||||
spyOn(service, 'getFieldPathSegmentedFromChangeEvent').and.returnValue('path');
|
||||
@@ -712,7 +712,7 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
expect(jsonPatchOpBuilder.add).toHaveBeenCalledWith(
|
||||
pathCombiner.getPath('path'),
|
||||
new FormFieldMetadataValueObject('test'),
|
||||
true
|
||||
true,
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -808,7 +808,7 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
isDraggable: true,
|
||||
groupFactory: () => {
|
||||
return [
|
||||
new DynamicInputModel({ id: 'testFormRowArrayGroupInput' })
|
||||
new DynamicInputModel({ id: 'testFormRowArrayGroupInput' }),
|
||||
];
|
||||
},
|
||||
required: false,
|
||||
@@ -816,8 +816,8 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
metadataFields: ['dc.contributor.author'],
|
||||
hasSelectableMetadata: true,
|
||||
showButtons: true,
|
||||
typeBindRelations: []
|
||||
}
|
||||
typeBindRelations: [],
|
||||
},
|
||||
);
|
||||
spyOn(serviceAsAny, 'getFieldPathSegmentedFromChangeEvent').and.returnValue('path');
|
||||
previousValue = new FormFieldPreviousValueObject(['path'], null);
|
||||
@@ -831,7 +831,7 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
pathCombiner,
|
||||
dynamicFormControlChangeEvent,
|
||||
arrayModel,
|
||||
previousValue
|
||||
previousValue,
|
||||
);
|
||||
|
||||
expect(jsonPatchOpBuilder.add).not.toHaveBeenCalled();
|
||||
@@ -841,10 +841,10 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
it('should dispatch a json-path add operation when a array value is not empty', () => {
|
||||
const pathValue = [
|
||||
new FormFieldMetadataValueObject('test'),
|
||||
new FormFieldMetadataValueObject('test two')
|
||||
new FormFieldMetadataValueObject('test two'),
|
||||
];
|
||||
formBuilderService.getValueFromModel.and.returnValue({
|
||||
path:pathValue
|
||||
path:pathValue,
|
||||
});
|
||||
spyOn(previousValue, 'isPathEqual').and.returnValue(false);
|
||||
|
||||
@@ -852,13 +852,13 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
pathCombiner,
|
||||
dynamicFormControlChangeEvent,
|
||||
arrayModel,
|
||||
previousValue
|
||||
previousValue,
|
||||
);
|
||||
|
||||
expect(jsonPatchOpBuilder.add).toHaveBeenCalledWith(
|
||||
pathCombiner.getPath('path'),
|
||||
pathValue,
|
||||
false
|
||||
false,
|
||||
);
|
||||
expect(jsonPatchOpBuilder.remove).not.toHaveBeenCalled();
|
||||
});
|
||||
@@ -871,7 +871,7 @@ describe('SectionFormOperationsService test suite', () => {
|
||||
pathCombiner,
|
||||
dynamicFormControlChangeEvent,
|
||||
arrayModel,
|
||||
previousValue
|
||||
previousValue,
|
||||
);
|
||||
|
||||
expect(jsonPatchOpBuilder.add).not.toHaveBeenCalled();
|
||||
|
@@ -8,7 +8,7 @@ import {
|
||||
DynamicFormArrayGroupModel,
|
||||
DynamicFormControlEvent,
|
||||
DynamicFormControlModel,
|
||||
isDynamicFormControlEvent
|
||||
isDynamicFormControlEvent,
|
||||
} from '@ng-dynamic-forms/core';
|
||||
|
||||
import { hasValue, isNotEmpty, isNotNull, isNotUndefined, isNull, isUndefined } from '../../../shared/empty.util';
|
||||
@@ -321,7 +321,7 @@ export class SectionFormOperationsService {
|
||||
*/
|
||||
protected dispatchOperationsFromAddEvent(
|
||||
pathCombiner: JsonPatchOperationPathCombiner,
|
||||
event: DynamicFormControlEvent
|
||||
event: DynamicFormControlEvent,
|
||||
): void {
|
||||
const path = this.getFieldPathSegmentedFromChangeEvent(event);
|
||||
const value = deepClone(this.getFieldValueFromChangeEvent(event));
|
||||
@@ -399,7 +399,7 @@ export class SectionFormOperationsService {
|
||||
if (isNotEmpty(moveFrom.path) && isNotEmpty(moveTo.path) && moveFrom.path !== moveTo.path) {
|
||||
this.operationsBuilder.move(
|
||||
moveTo,
|
||||
moveFrom.path
|
||||
moveFrom.path,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -522,7 +522,7 @@ export class SectionFormOperationsService {
|
||||
this.operationsBuilder.add(
|
||||
pathCombiner.getPath(segmentedPath),
|
||||
arrayValue[segmentedPath],
|
||||
false
|
||||
false,
|
||||
);
|
||||
} else if (previousValue.isPathEqual(this.formBuilder.getPath(event.model))) {
|
||||
this.operationsBuilder.remove(pathCombiner.getPath(segmentedPath));
|
||||
|
@@ -63,7 +63,7 @@ const sectionObject: SectionDataObject = {
|
||||
serverValidationErrors: [],
|
||||
header: 'submit.progressbar.describe.stepone',
|
||||
id: 'traditionalpageone',
|
||||
sectionType: SectionsType.SubmissionForm
|
||||
sectionType: SectionsType.SubmissionForm,
|
||||
};
|
||||
|
||||
const testFormConfiguration = {
|
||||
@@ -73,7 +73,7 @@ const testFormConfiguration = {
|
||||
fields: [
|
||||
{
|
||||
input: {
|
||||
type: 'onebox'
|
||||
type: 'onebox',
|
||||
},
|
||||
label: 'Title',
|
||||
mandatory: 'true',
|
||||
@@ -81,18 +81,18 @@ const testFormConfiguration = {
|
||||
hints: ' Enter Title.',
|
||||
selectableMetadata: [
|
||||
{
|
||||
metadata: 'dc.title'
|
||||
}
|
||||
metadata: 'dc.title',
|
||||
},
|
||||
],
|
||||
languageCodes: []
|
||||
} as FormFieldModel
|
||||
]
|
||||
languageCodes: [],
|
||||
} as FormFieldModel,
|
||||
],
|
||||
} as FormRowModel,
|
||||
{
|
||||
fields: [
|
||||
{
|
||||
input: {
|
||||
type: 'onebox'
|
||||
type: 'onebox',
|
||||
},
|
||||
label: 'Author',
|
||||
mandatory: 'false',
|
||||
@@ -100,20 +100,20 @@ const testFormConfiguration = {
|
||||
hints: ' Enter Author.',
|
||||
selectableMetadata: [
|
||||
{
|
||||
metadata: 'dc.contributor'
|
||||
}
|
||||
metadata: 'dc.contributor',
|
||||
},
|
||||
],
|
||||
languageCodes: []
|
||||
} as FormFieldModel
|
||||
]
|
||||
languageCodes: [],
|
||||
} as FormFieldModel,
|
||||
],
|
||||
} as FormRowModel,
|
||||
],
|
||||
type: 'submissionform',
|
||||
_links: {
|
||||
self: {
|
||||
href: 'testFormConfiguration.url'
|
||||
}
|
||||
}
|
||||
href: 'testFormConfiguration.url',
|
||||
},
|
||||
},
|
||||
} as any;
|
||||
|
||||
const testFormModel = [
|
||||
@@ -124,7 +124,7 @@ const testFormModel = [
|
||||
new DynamicRowGroupModel({
|
||||
id: 'df-row-group-config-2',
|
||||
group: [new DsDynamicInputModel({ id: 'dc.contributor', metadataFields: [], repeatable: false, submissionId: '1234', hasSelectableMetadata: false })],
|
||||
})
|
||||
}),
|
||||
];
|
||||
|
||||
const dynamicFormControlEvent: DynamicFormControlEvent = {
|
||||
@@ -133,7 +133,7 @@ const dynamicFormControlEvent: DynamicFormControlEvent = {
|
||||
control: null,
|
||||
group: testFormModel[0] as any,
|
||||
model: testFormModel[0].group[0],
|
||||
type: DynamicFormControlEventType.Change
|
||||
type: DynamicFormControlEventType.Change,
|
||||
};
|
||||
|
||||
describe('SubmissionSectionFormComponent test suite', () => {
|
||||
@@ -162,12 +162,12 @@ describe('SubmissionSectionFormComponent test suite', () => {
|
||||
CommonModule,
|
||||
FormsModule,
|
||||
ReactiveFormsModule,
|
||||
TranslateModule.forRoot()
|
||||
TranslateModule.forRoot(),
|
||||
],
|
||||
declarations: [
|
||||
FormComponent,
|
||||
SubmissionSectionFormComponent,
|
||||
TestComponent
|
||||
TestComponent,
|
||||
],
|
||||
providers: [
|
||||
{ provide: FormBuilderService, useValue: getMockFormBuilderService() },
|
||||
@@ -185,9 +185,9 @@ describe('SubmissionSectionFormComponent test suite', () => {
|
||||
{ provide: 'submissionIdProvider', useValue: submissionId },
|
||||
{ provide: SubmissionObjectDataService, useValue: { getHrefByID: () => observableOf('testUrl'), findById: () => createSuccessfulRemoteDataObject$(new WorkspaceItem()) } },
|
||||
ChangeDetectorRef,
|
||||
SubmissionSectionFormComponent
|
||||
SubmissionSectionFormComponent,
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
schemas: [NO_ERRORS_SCHEMA],
|
||||
}).compileComponents().then();
|
||||
}));
|
||||
|
||||
@@ -281,7 +281,7 @@ describe('SubmissionSectionFormComponent test suite', () => {
|
||||
const sectionData = {};
|
||||
const sectionError: SubmissionSectionError = {
|
||||
message: 'test' + 'Error: test',
|
||||
path: '/sections/' + sectionObject.id
|
||||
path: '/sections/' + sectionObject.id,
|
||||
};
|
||||
|
||||
comp.initForm(sectionData);
|
||||
@@ -293,11 +293,11 @@ describe('SubmissionSectionFormComponent test suite', () => {
|
||||
|
||||
it('should return true when has Metadata Enrichment', () => {
|
||||
const newSectionData = {
|
||||
'dc.title': [new FormFieldMetadataValueObject('test')]
|
||||
'dc.title': [new FormFieldMetadataValueObject('test')],
|
||||
};
|
||||
compAsAny.formData = {};
|
||||
compAsAny.sectionData.data = {
|
||||
'dc.title': [new FormFieldMetadataValueObject('test')]
|
||||
'dc.title': [new FormFieldMetadataValueObject('test')],
|
||||
};
|
||||
spyOn(compAsAny, 'inCurrentSubmissionScope').and.callThrough();
|
||||
|
||||
@@ -307,11 +307,11 @@ describe('SubmissionSectionFormComponent test suite', () => {
|
||||
|
||||
it('should return false when has not Metadata Enrichment', () => {
|
||||
const newSectionData = {
|
||||
'dc.title': [new FormFieldMetadataValueObject('test')]
|
||||
'dc.title': [new FormFieldMetadataValueObject('test')],
|
||||
};
|
||||
compAsAny.formData = newSectionData;
|
||||
compAsAny.sectionData.data = {
|
||||
'dc.title': [new FormFieldMetadataValueObject('test')]
|
||||
'dc.title': [new FormFieldMetadataValueObject('test')],
|
||||
};
|
||||
spyOn(compAsAny, 'inCurrentSubmissionScope').and.callThrough();
|
||||
|
||||
@@ -321,7 +321,7 @@ describe('SubmissionSectionFormComponent test suite', () => {
|
||||
|
||||
it('should return false when metadata has Metadata Enrichment but not belonging to sectionMetadata', () => {
|
||||
const newSectionData = {
|
||||
'dc.title': [new FormFieldMetadataValueObject('test')]
|
||||
'dc.title': [new FormFieldMetadataValueObject('test')],
|
||||
};
|
||||
compAsAny.formData = newSectionData;
|
||||
compAsAny.sectionMetadata = [];
|
||||
@@ -338,16 +338,16 @@ describe('SubmissionSectionFormComponent test suite', () => {
|
||||
{
|
||||
selectableMetadata: [{ metadata: 'scoped.workflow' }],
|
||||
scope: 'WORKFLOW',
|
||||
} as FormFieldModel
|
||||
]
|
||||
} as FormFieldModel,
|
||||
],
|
||||
},
|
||||
{
|
||||
fields: [
|
||||
{
|
||||
selectableMetadata: [{ metadata: 'scoped.workspace' }],
|
||||
scope: 'WORKSPACE',
|
||||
} as FormFieldModel
|
||||
]
|
||||
} as FormFieldModel,
|
||||
],
|
||||
},
|
||||
{
|
||||
fields: [
|
||||
@@ -369,10 +369,10 @@ describe('SubmissionSectionFormComponent test suite', () => {
|
||||
fields: [
|
||||
{
|
||||
selectableMetadata: [{ metadata: 'dc.title' }],
|
||||
} as FormFieldModel
|
||||
]
|
||||
}
|
||||
]
|
||||
} as FormFieldModel,
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
});
|
||||
|
||||
@@ -435,7 +435,7 @@ describe('SubmissionSectionFormComponent test suite', () => {
|
||||
spyOn(comp, 'initForm');
|
||||
spyOn(comp, 'checksForErrors');
|
||||
const sectionData: any = {
|
||||
'dc.title': [new FormFieldMetadataValueObject('test')]
|
||||
'dc.title': [new FormFieldMetadataValueObject('test')],
|
||||
};
|
||||
const sectionError = [];
|
||||
comp.sectionData.data = {};
|
||||
@@ -456,7 +456,7 @@ describe('SubmissionSectionFormComponent test suite', () => {
|
||||
spyOn(comp, 'initForm');
|
||||
spyOn(comp, 'checksForErrors');
|
||||
const sectionData: any = {
|
||||
'dc.title': [new FormFieldMetadataValueObject('test')]
|
||||
'dc.title': [new FormFieldMetadataValueObject('test')],
|
||||
};
|
||||
comp.sectionData.data = {};
|
||||
comp.sectionData.errorsToShow = [];
|
||||
@@ -495,7 +495,7 @@ describe('SubmissionSectionFormComponent test suite', () => {
|
||||
sectionObject.id,
|
||||
'test',
|
||||
parsedSectionErrors,
|
||||
[]
|
||||
[],
|
||||
);
|
||||
expect(comp.sectionData.errorsToShow).toEqual(parsedSectionErrors);
|
||||
});
|
||||
@@ -504,7 +504,7 @@ describe('SubmissionSectionFormComponent test suite', () => {
|
||||
formService.isValid.and.returnValue(observableOf(true));
|
||||
sectionsServiceStub.getSectionServerErrors.and.returnValue(observableOf([]));
|
||||
const expected = cold('(b|)', {
|
||||
b: true
|
||||
b: true,
|
||||
});
|
||||
|
||||
expect(compAsAny.getSectionStatus()).toBeObservable(expected);
|
||||
@@ -514,7 +514,7 @@ describe('SubmissionSectionFormComponent test suite', () => {
|
||||
formService.isValid.and.returnValue(observableOf(true));
|
||||
sectionsServiceStub.getSectionServerErrors.and.returnValue(observableOf(parsedSectionErrors));
|
||||
const expected = cold('(b|)', {
|
||||
b: false
|
||||
b: false,
|
||||
});
|
||||
|
||||
expect(compAsAny.getSectionStatus()).toBeObservable(expected);
|
||||
@@ -524,7 +524,7 @@ describe('SubmissionSectionFormComponent test suite', () => {
|
||||
formService.isValid.and.returnValue(observableOf(false));
|
||||
sectionsServiceStub.getSectionServerErrors.and.returnValue(observableOf([]));
|
||||
const expected = cold('(b|)', {
|
||||
b: false
|
||||
b: false,
|
||||
});
|
||||
|
||||
expect(compAsAny.getSectionStatus()).toBeObservable(expected);
|
||||
@@ -533,14 +533,14 @@ describe('SubmissionSectionFormComponent test suite', () => {
|
||||
it('should subscribe to state properly', () => {
|
||||
spyOn(comp, 'updateForm');
|
||||
const formData = {
|
||||
'dc.title': [new FormFieldMetadataValueObject('test')]
|
||||
'dc.title': [new FormFieldMetadataValueObject('test')],
|
||||
};
|
||||
const sectionData: any = {
|
||||
'dc.title': [new FormFieldMetadataValueObject('test')]
|
||||
'dc.title': [new FormFieldMetadataValueObject('test')],
|
||||
};
|
||||
const sectionState = {
|
||||
data: sectionData,
|
||||
errorsToShow: parsedSectionErrors
|
||||
errorsToShow: parsedSectionErrors,
|
||||
};
|
||||
|
||||
formService.getFormData.and.returnValue(observableOf(formData));
|
||||
@@ -617,7 +617,7 @@ describe('SubmissionSectionFormComponent test suite', () => {
|
||||
|
||||
it('should check if has stored value in the section state', () => {
|
||||
comp.sectionData.data = {
|
||||
'dc.title': [new FormFieldMetadataValueObject('test')]
|
||||
'dc.title': [new FormFieldMetadataValueObject('test')],
|
||||
} as any;
|
||||
|
||||
expect(comp.hasStoredValue('dc.title', 0)).toBeTruthy();
|
||||
@@ -631,7 +631,7 @@ describe('SubmissionSectionFormComponent test suite', () => {
|
||||
// declare a test component
|
||||
@Component({
|
||||
selector: 'ds-test-cmp',
|
||||
template: ``
|
||||
template: ``,
|
||||
})
|
||||
class TestComponent {
|
||||
|
||||
|
@@ -183,7 +183,7 @@ export class SubmissionSectionFormComponent extends SectionModelComponent {
|
||||
this.submissionObjectService.findById(this.submissionId, true, false, followLink('item')).pipe(
|
||||
getFirstSucceededRemoteData(),
|
||||
getRemoteDataPayload()),
|
||||
this.sectionService.isSectionReadOnly(this.submissionId, this.sectionData.id, this.submissionService.getSubmissionScope())
|
||||
this.sectionService.isSectionReadOnly(this.submissionId, this.sectionData.id, this.submissionService.getSubmissionScope()),
|
||||
])),
|
||||
take(1))
|
||||
.subscribe(([sectionData, submissionObject, isSectionReadOnly]: [WorkspaceitemSectionFormObject, SubmissionObject, boolean]) => {
|
||||
@@ -219,11 +219,11 @@ export class SubmissionSectionFormComponent extends SectionModelComponent {
|
||||
protected getSectionStatus(): Observable<boolean> {
|
||||
const formStatus$ = this.formService.isValid(this.formId);
|
||||
const serverValidationStatus$ = this.sectionService.getSectionServerErrors(this.submissionId, this.sectionData.id).pipe(
|
||||
map((validationErrors) => isEmpty(validationErrors))
|
||||
map((validationErrors) => isEmpty(validationErrors)),
|
||||
);
|
||||
|
||||
return observableCombineLatest([formStatus$, serverValidationStatus$]).pipe(
|
||||
map(([formValidation, serverSideValidation]: [boolean, boolean]) => formValidation && serverSideValidation)
|
||||
map(([formValidation, serverSideValidation]: [boolean, boolean]) => formValidation && serverSideValidation),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -304,7 +304,7 @@ export class SubmissionSectionFormComponent extends SectionModelComponent {
|
||||
this.collectionId,
|
||||
sectionData,
|
||||
this.submissionService.getSubmissionScope(),
|
||||
this.isSectionReadonly
|
||||
this.isSectionReadonly,
|
||||
);
|
||||
const sectionMetadata = this.sectionService.computeSectionConfiguredMetadata(this.formConfig);
|
||||
this.sectionService.updateSectionData(this.submissionId, this.sectionData.id, sectionData, this.sectionData.errorsToShow, this.sectionData.serverValidationErrors, sectionMetadata);
|
||||
@@ -312,7 +312,7 @@ export class SubmissionSectionFormComponent extends SectionModelComponent {
|
||||
const msg: string = this.translate.instant('error.submission.sections.init-form-error') + e.toString();
|
||||
const sectionError: SubmissionSectionError = {
|
||||
message: msg,
|
||||
path: '/sections/' + this.sectionData.id
|
||||
path: '/sections/' + this.sectionData.id,
|
||||
};
|
||||
console.error(e.stack);
|
||||
this.sectionService.setSectionError(this.submissionId, this.sectionData.id, sectionError);
|
||||
@@ -390,7 +390,7 @@ export class SubmissionSectionFormComponent extends SectionModelComponent {
|
||||
this.fieldsOnTheirWayToBeRemoved = new Map();
|
||||
this.sectionMetadata = sectionState.metadata;
|
||||
this.updateForm(sectionState.data as WorkspaceitemSectionFormObject, sectionState.errorsToShow);
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user