[CST-3782] qualdrop move restored

This commit is contained in:
Alessandro Martelli
2021-03-04 18:25:01 +01:00
parent 5eb0a8744f
commit 5201b4a31d
2 changed files with 24 additions and 5 deletions

View File

@@ -65,7 +65,7 @@ export class SectionFormOperationsService {
this.dispatchOperationsFromChangeEvent(pathCombiner, event, previousValue, hasStoredValue); this.dispatchOperationsFromChangeEvent(pathCombiner, event, previousValue, hasStoredValue);
break; break;
case 'move': case 'move':
this.dispatchOperationsFromMoveEvent(pathCombiner, event); this.dispatchOperationsFromMoveEvent(pathCombiner, event, previousValue);
break; break;
default: default:
break; break;
@@ -469,9 +469,28 @@ export class SectionFormOperationsService {
previousValue.delete(); previousValue.delete();
} }
/**
* Handle form move operations
*
* @param pathCombiner
* the [[JsonPatchOperationPathCombiner]] object for the specified operation
* @param event
* the [[DynamicFormControlEvent]] for the specified operation
* @param previousValue
* the [[FormFieldPreviousValueObject]] for the specified operation
*/
private dispatchOperationsFromMoveEvent(pathCombiner: JsonPatchOperationPathCombiner, private dispatchOperationsFromMoveEvent(pathCombiner: JsonPatchOperationPathCombiner,
event: DynamicFormControlEvent) { event: DynamicFormControlEvent,
previousValue: FormFieldPreviousValueObject) {
const customEvent = event.$event; const customEvent = event.$event;
if (this.formBuilder.isQualdropGroup(customEvent.model.parent as DynamicFormControlModel)
|| this.formBuilder.isQualdropGroup(customEvent.model as DynamicFormControlModel)) {
// It's a qualdrup model
this.dispatchOperationsFromMap(this.getQualdropValueMap(customEvent), pathCombiner, customEvent, previousValue);
return;
}
const path = this.getFieldPathFromEvent(customEvent); const path = this.getFieldPathFromEvent(customEvent);
const segmentedPath = this.getFieldPathSegmentedFromChangeEvent(customEvent); const segmentedPath = this.getFieldPathSegmentedFromChangeEvent(customEvent);
const moveTo = pathCombiner.getPath(path); const moveTo = pathCombiner.getPath(path);

View File

@@ -19,7 +19,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 { hasNoValue, hasValue, isNotEmpty, isUndefined } from '../../../shared/empty.util'; import { hasValue, isNotEmpty, isUndefined } from '../../../shared/empty.util';
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';
import { SubmissionSectionError, SubmissionSectionObject } from '../../objects/submission-objects.reducer'; import { SubmissionSectionError, SubmissionSectionObject } from '../../objects/submission-objects.reducer';
@@ -454,11 +454,11 @@ export class SubmissionSectionformComponent extends SectionModelComponent {
* The customEvent is stored inside event.$event * The customEvent is stored inside event.$event
* @param $event * @param $event
*/ */
onCustomEvent(event: any) { onCustomEvent(event: DynamicFormControlEvent) {
this.formOperationsService.dispatchOperationsFromEvent( this.formOperationsService.dispatchOperationsFromEvent(
this.pathCombiner, this.pathCombiner,
event, event,
null, this.previousValue,
null); null);
} }
} }