fix issue where editing template rows caused invald patch requests

This commit is contained in:
Art Lowel
2020-04-22 15:13:12 +02:00
parent 53fd559a7c
commit dd7fc2aa6f

View File

@@ -11,7 +11,7 @@ import { FormComponent } from '../../../shared/form/form.component';
import { FormService } from '../../../shared/form/form.service';
import { SectionModelComponent } from '../models/section.model';
import { SubmissionFormsConfigService } from '../../../core/config/submission-forms-config.service';
import { hasValue, isNotEmpty, isUndefined } from '../../../shared/empty.util';
import { hasValue, isNotEmpty, isUndefined, hasNoValue } from '../../../shared/empty.util';
import { ConfigData } from '../../../core/config/config-data';
import { JsonPatchOperationPathCombiner } from '../../../core/json-patch/builder/json-patch-operation-path-combiner';
import { SubmissionFormsModel } from '../../../core/config/models/config-submission-forms.model';
@@ -344,6 +344,8 @@ export class SubmissionSectionformComponent extends SectionModelComponent {
* the [[DynamicFormControlEvent]] emitted
*/
onChange(event: DynamicFormControlEvent): void {
// don't handle change events for things with an index < 0, those are template rows.
if (hasNoValue(event.context) || hasNoValue(event.context.index) || event.context.index >= 0) {
this.formOperationsService.dispatchOperationsFromEvent(
this.pathCombiner,
event,
@@ -356,6 +358,7 @@ export class SubmissionSectionformComponent extends SectionModelComponent {
this.submissionService.dispatchSave(this.submissionId);
}
}
}
/**
* Method called when a form dfFocus event is fired.