mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-10 03:23:07 +00:00
fix issue where editing template rows caused invald patch requests
This commit is contained in:
@@ -11,7 +11,7 @@ import { FormComponent } from '../../../shared/form/form.component';
|
|||||||
import { FormService } from '../../../shared/form/form.service';
|
import { FormService } from '../../../shared/form/form.service';
|
||||||
import { SectionModelComponent } from '../models/section.model';
|
import { SectionModelComponent } from '../models/section.model';
|
||||||
import { SubmissionFormsConfigService } from '../../../core/config/submission-forms-config.service';
|
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 { ConfigData } from '../../../core/config/config-data';
|
||||||
import { JsonPatchOperationPathCombiner } from '../../../core/json-patch/builder/json-patch-operation-path-combiner';
|
import { JsonPatchOperationPathCombiner } from '../../../core/json-patch/builder/json-patch-operation-path-combiner';
|
||||||
import { SubmissionFormsModel } from '../../../core/config/models/config-submission-forms.model';
|
import { SubmissionFormsModel } from '../../../core/config/models/config-submission-forms.model';
|
||||||
@@ -344,16 +344,19 @@ export class SubmissionSectionformComponent extends SectionModelComponent {
|
|||||||
* the [[DynamicFormControlEvent]] emitted
|
* the [[DynamicFormControlEvent]] emitted
|
||||||
*/
|
*/
|
||||||
onChange(event: DynamicFormControlEvent): void {
|
onChange(event: DynamicFormControlEvent): void {
|
||||||
this.formOperationsService.dispatchOperationsFromEvent(
|
// don't handle change events for things with an index < 0, those are template rows.
|
||||||
this.pathCombiner,
|
if (hasNoValue(event.context) || hasNoValue(event.context.index) || event.context.index >= 0) {
|
||||||
event,
|
this.formOperationsService.dispatchOperationsFromEvent(
|
||||||
this.previousValue,
|
this.pathCombiner,
|
||||||
this.hasStoredValue(this.formBuilderService.getId(event.model), this.formOperationsService.getArrayIndexFromEvent(event)));
|
event,
|
||||||
const metadata = this.formOperationsService.getFieldPathSegmentedFromChangeEvent(event);
|
this.previousValue,
|
||||||
const value = this.formOperationsService.getFieldValueFromChangeEvent(event);
|
this.hasStoredValue(this.formBuilderService.getId(event.model), this.formOperationsService.getArrayIndexFromEvent(event)));
|
||||||
|
const metadata = this.formOperationsService.getFieldPathSegmentedFromChangeEvent(event);
|
||||||
|
const value = this.formOperationsService.getFieldValueFromChangeEvent(event);
|
||||||
|
|
||||||
if (this.EnvConfig.submission.autosave.metadata.indexOf(metadata) !== -1 && isNotEmpty(value)) {
|
if (this.EnvConfig.submission.autosave.metadata.indexOf(metadata) !== -1 && isNotEmpty(value)) {
|
||||||
this.submissionService.dispatchSave(this.submissionId);
|
this.submissionService.dispatchSave(this.submissionId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user