From 7033d89851afbad45c503366d7ce3b3bb2619acd Mon Sep 17 00:00:00 2001 From: ck-c8y Date: Wed, 30 Oct 2024 14:31:46 +0100 Subject: [PATCH] Fix for #278 --- .../mapping-stepper.component.ts | 46 ++++++++++++++++--- .../shared/editor2/jsoneditor2.component.ts | 3 +- 2 files changed, 41 insertions(+), 8 deletions(-) diff --git a/dynamic-mapping-ui/src/mapping/stepper-mapping/mapping-stepper.component.ts b/dynamic-mapping-ui/src/mapping/stepper-mapping/mapping-stepper.component.ts index c63bbb19..9b083e37 100644 --- a/dynamic-mapping-ui/src/mapping/stepper-mapping/mapping-stepper.component.ts +++ b/dynamic-mapping-ui/src/mapping/stepper-mapping/mapping-stepper.component.ts @@ -742,15 +742,25 @@ export class MappingStepperComponent implements OnInit, OnDestroy { } else if (this.step == 'Define substitutions') { this.expandTemplates(); this.getTemplateForm(); - const testSourceTemplate = this.editorSourceStep4 - ? this.editorSourceStep4.get() - : {}; - this.editorTestingPayloadTemplateEmitter.emit(testSourceTemplate); + // const testSourceTemplate = this.editorSourceStep4 + // ? this.editorSourceStep4.get() + // : {}; + // this.editorTestingPayloadTemplateEmitter.emit(testSourceTemplate); + this.editorTestingPayloadTemplateEmitter.emit(this.templateSource); this.onSelectSubstitution(0); event.stepper.next(); } else if (this.step == 'Select templates') { this.templateSource = this.editorSourceStep3.get(); this.templateTarget = this.editorTargetStep3.get(); + console.log( + 'onNextStep before', + event.step.label, + this.mapping, + this.editorSourceStep3.get(), + this.getCurrentMapping(true), + this.templateSource, + this.templateTarget + ); event.stepper.next(); } else { event.stepper.next(); @@ -761,7 +771,15 @@ export class MappingStepperComponent implements OnInit, OnDestroy { stepper: C8yStepper; step: CdkStep; }): Promise { - // console.log('onBackStep', event.step.label, this.mapping); + // console.log( + // 'onBackStep before', + // event.step.label, + // this.mapping, + // this.getCurrentMapping(false), + // this.getCurrentMapping(true), + // this.templateSource, + // this.templateTarget + // ); this.step = event.step.label; if (this.step == 'Test mapping') { const editorTestingRequestRef = @@ -770,10 +788,24 @@ export class MappingStepperComponent implements OnInit, OnDestroy { editorTestingRequestRef.setAttribute('schema', undefined); } } else if (this.step == 'Select templates') { - this.mapping = this.getCurrentMapping(false); + // this.mapping = this.getCurrentMapping(true); + // this.expandTemplates(); } else if (this.step == 'Define substitutions') { - this.mapping = this.getCurrentMapping(false); + // this.mapping = this.getCurrentMapping(true); + // this.expandTemplates(); } + + this.mapping = this.getCurrentMapping(true); + this.expandTemplates(); + // console.log( + // 'onBackStep after', + // event.step.label, + // this.mapping, + // this.getCurrentMapping(false), + // this.getCurrentMapping(true), + // this.templateSource, + // this.templateTarget + // ); event.stepper.previous(); } diff --git a/dynamic-mapping-ui/src/shared/editor2/jsoneditor2.component.ts b/dynamic-mapping-ui/src/shared/editor2/jsoneditor2.component.ts index 21242eaa..54cbbdc6 100644 --- a/dynamic-mapping-ui/src/shared/editor2/jsoneditor2.component.ts +++ b/dynamic-mapping-ui/src/shared/editor2/jsoneditor2.component.ts @@ -62,9 +62,10 @@ export class JsonEditor2Component implements OnInit, OnDestroy { @Input() options; @Input() set data(value: unknown) { - if (value) { + if (value && Object.keys(value).length != 0) { this.content['json'] = value; } + // console.log('on setData', value, this.content); if (this.editor) { this.editor.destroy();