diff --git a/src/app/shared/form/builder/form-builder.service.ts b/src/app/shared/form/builder/form-builder.service.ts index f0baa3f8a3..a6100e7ce7 100644 --- a/src/app/shared/form/builder/form-builder.service.ts +++ b/src/app/shared/form/builder/form-builder.service.ts @@ -16,7 +16,7 @@ import { import { isObject, isString, mergeWith } from 'lodash'; import { hasValue, isEmpty, isNotEmpty, isNotNull, isNotUndefined, isNull } from '../../empty.util'; -import { DynamicQualdropModel } from './ds-dynamic-form-ui/models/ds-dynamic-qualdrop.model'; +import {DynamicQualdropModel} from './ds-dynamic-form-ui/models/ds-dynamic-qualdrop.model'; import { SubmissionFormsModel } from '../../../core/config/models/config-submission-forms.model'; import { DYNAMIC_FORM_CONTROL_TYPE_TAG } from './ds-dynamic-form-ui/models/tag/dynamic-tag.model'; import { RowParser } from './parsers/row-parser'; @@ -56,9 +56,7 @@ export class FormBuilderService extends DynamicFormService { } if (this.isConcatGroup(controlModel)) { - const concatGroupId = controlModel.id.replace(CONCAT_GROUP_SUFFIX, ''); - // if (concatGroupId === findId) { - if (concatGroupId.includes(findId)) { + if (controlModel.id.match(new RegExp(findId + CONCAT_GROUP_SUFFIX + `_\\d+$`))) { result = (controlModel as DynamicConcatModel).group[0]; break; } diff --git a/src/app/shared/form/form.component.html b/src/app/shared/form/form.component.html index 8ac2ca2d23..97879cc025 100644 --- a/src/app/shared/form/form.component.html +++ b/src/app/shared/form/form.component.html @@ -18,7 +18,7 @@ diff --git a/src/app/shared/testing/submission-service.stub.ts b/src/app/shared/testing/submission-service.stub.ts index 7550201c9f..35c3ddfee0 100644 --- a/src/app/shared/testing/submission-service.stub.ts +++ b/src/app/shared/testing/submission-service.stub.ts @@ -9,7 +9,6 @@ export class SubmissionServiceStub { dispatchDeposit = jasmine.createSpy('dispatchDeposit'); dispatchDiscard = jasmine.createSpy('dispatchDiscard'); dispatchSave = jasmine.createSpy('dispatchSave'); - dispatchManualSave = jasmine.createSpy('dispatchManualSave'); dispatchSaveForLater = jasmine.createSpy('dispatchSaveForLater'); dispatchSaveSection = jasmine.createSpy('dispatchSaveSection'); getActiveSectionId = jasmine.createSpy('getActiveSectionId'); diff --git a/src/app/submission/form/footer/submission-form-footer.component.spec.ts b/src/app/submission/form/footer/submission-form-footer.component.spec.ts index 8f278fe17a..c8860e3541 100644 --- a/src/app/submission/form/footer/submission-form-footer.component.spec.ts +++ b/src/app/submission/form/footer/submission-form-footer.component.spec.ts @@ -164,12 +164,12 @@ describe('SubmissionFormFooterComponent Component', () => { }); }); - it('should call dispatchManualSave on save', () => { + it('should call dispatchSave on save', () => { comp.save(null); fixture.detectChanges(); - expect(submissionServiceStub.dispatchManualSave).toHaveBeenCalledWith(submissionId); + expect(submissionServiceStub.dispatchSave).toHaveBeenCalledWith(submissionId, true); }); it('should call dispatchSaveForLater on save for later', () => { diff --git a/src/app/submission/form/footer/submission-form-footer.component.ts b/src/app/submission/form/footer/submission-form-footer.component.ts index 96179430b8..0636c3f6d3 100644 --- a/src/app/submission/form/footer/submission-form-footer.component.ts +++ b/src/app/submission/form/footer/submission-form-footer.component.ts @@ -80,7 +80,7 @@ export class SubmissionFormFooterComponent implements OnChanges { * Dispatch a submission save action */ save(event) { - this.submissionService.dispatchManualSave(this.submissionId); + this.submissionService.dispatchSave(this.submissionId, true); } /** diff --git a/src/app/submission/sections/form/section-form.component.html b/src/app/submission/sections/form/section-form.component.html index 894c8b1d17..166e52675b 100644 --- a/src/app/submission/sections/form/section-form.component.html +++ b/src/app/submission/sections/form/section-form.component.html @@ -3,7 +3,6 @@ [formId]="formId" [formModel]="formModel" [displaySubmit]="false" - (dfBlur)="onBlur($event)" (dfChange)="onChange($event)" (dfFocus)="onFocus($event)" (remove)="onRemove($event)" diff --git a/src/app/submission/sections/form/section-form.component.ts b/src/app/submission/sections/form/section-form.component.ts index 8a50d00b9f..c5d9999da5 100644 --- a/src/app/submission/sections/form/section-form.component.ts +++ b/src/app/submission/sections/form/section-form.component.ts @@ -131,12 +131,6 @@ export class SubmissionSectionformComponent extends SectionModelComponent { */ @ViewChild('formRef', {static: false}) private formRef: FormComponent; - /** - * Keep track whether the section is focused or not. - * @protected - */ - protected isFocused = false; - /** * Initialize instance variables * @@ -265,6 +259,7 @@ export class SubmissionSectionformComponent extends SectionModelComponent { Object.keys(diffObj) .forEach((key) => { diffObj[key].forEach((value) => { + // the findIndex extra check excludes values already present in the form but in different positions if (value.hasOwnProperty('value') && findIndex(this.formData[key], { value: value.value }) < 0) { diffResult.push(value); } @@ -407,7 +402,6 @@ export class SubmissionSectionformComponent extends SectionModelComponent { * the [[DynamicFormControlEvent]] emitted */ onFocus(event: DynamicFormControlEvent): void { - this.isFocused = true; const value = this.formOperationsService.getFieldValueFromChangeEvent(event); const path = this.formBuilderService.getPath(event.model); if (this.formBuilderService.hasMappedGroupValue(event.model)) { @@ -419,17 +413,6 @@ export class SubmissionSectionformComponent extends SectionModelComponent { } } - /** - * Method called when a form dfBlur event is fired. - * - * @param event - * the [[DynamicFormControlEvent]] emitted - */ - - onBlur(event: DynamicFormControlEvent): void { - this.isFocused = false; - } - /** * Method called when a form remove event is fired. * Dispatch form operations based on changes. diff --git a/src/app/submission/submission.service.spec.ts b/src/app/submission/submission.service.spec.ts index 076028d550..6455638eef 100644 --- a/src/app/submission/submission.service.spec.ts +++ b/src/app/submission/submission.service.spec.ts @@ -487,16 +487,14 @@ describe('SubmissionService test suite', () => { describe('dispatchSave', () => { it('should dispatch a new SaveSubmissionFormAction', () => { - service.dispatchSave(submissionId,); + service.dispatchSave(submissionId); const expected = new SaveSubmissionFormAction(submissionId); expect((service as any).store.dispatch).toHaveBeenCalledWith(expected); }); - }); - describe('dispatchManualSave', () => { - it('should dispatch a new SaveSubmissionFormAction', () => { - service.dispatchManualSave(submissionId,); + it('should dispatch a new SaveSubmissionFormAction with manual flag', () => { + service.dispatchSave(submissionId, true); const expected = new SaveSubmissionFormAction(submissionId, true); expect((service as any).store.dispatch).toHaveBeenCalledWith(expected); diff --git a/src/app/submission/submission.service.ts b/src/app/submission/submission.service.ts index 895e68dba6..0277ac6e5a 100644 --- a/src/app/submission/submission.service.ts +++ b/src/app/submission/submission.service.ts @@ -209,26 +209,14 @@ export class SubmissionService { * * @param submissionId * The submission id + * @param manual + * whether is a manual save, default false */ - dispatchManualSave(submissionId) { + dispatchSave(submissionId, manual?: boolean) { this.getSubmissionSaveProcessingStatus(submissionId).pipe( find((isPending: boolean) => !isPending) ).subscribe(() => { - this.store.dispatch(new SaveSubmissionFormAction(submissionId, true)); - }) - } - - /** - * Dispatch a new [SaveSubmissionFormAction] - * - * @param submissionId - * The submission id - */ - dispatchSave(submissionId) { - this.getSubmissionSaveProcessingStatus(submissionId).pipe( - find((isPending: boolean) => !isPending) - ).subscribe(() => { - this.store.dispatch(new SaveSubmissionFormAction(submissionId)); + this.store.dispatch(new SaveSubmissionFormAction(submissionId, manual)); }) }