From bdb807d3e05332e860f6e395f38dd4b8344ca051 Mon Sep 17 00:00:00 2001 From: szewczyw Date: Fri, 24 Jan 2025 11:57:44 +0100 Subject: [PATCH] bugfix --- .../src/components/XsltParamComponent.vue | 19 ++++++++++++++----- .../components/xml/XmlInputFieldComponent.vue | 2 +- .../xml/XmlOutputFieldComponent.vue | 6 +++--- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/Frontend/src/components/XsltParamComponent.vue b/Frontend/src/components/XsltParamComponent.vue index ac50b28..57608ea 100644 --- a/Frontend/src/components/XsltParamComponent.vue +++ b/Frontend/src/components/XsltParamComponent.vue @@ -27,11 +27,20 @@ const selectedFunction = () => { } if (selectOption(selectedOption.value) === 'Remove Param') { - const currentIndex = options.value.indexOf(selectedOption.value) - options.value.splice(currentIndex, 1); - selectedOption.value= options.value[0].name - valueInput.value = "" - nameInput.value = "" + const foundOption = options.value.find(option => option.name === selectedOption.value); + if (foundOption) { + const currentIndex = options.value.indexOf(foundOption); + if (currentIndex !== -1) { + options.value.splice(currentIndex, 1); + } + } + if (options.value.length > 0) { + selectedOption.value = options.value[0].name; + } else { + selectedOption.value = ""; + } + valueInput.value = ""; + nameInput.value = ""; } sendToParent() /* diff --git a/Frontend/src/components/xml/XmlInputFieldComponent.vue b/Frontend/src/components/xml/XmlInputFieldComponent.vue index fd3fd4e..d1f01a0 100644 --- a/Frontend/src/components/xml/XmlInputFieldComponent.vue +++ b/Frontend/src/components/xml/XmlInputFieldComponent.vue @@ -63,7 +63,7 @@ function readFile(file: any) { const handleUpdateValue = (options: { name: string }[]) => { console.log("from parent" +options.length) params.value = options - updateParams(params) + updateParams(params.value) }; diff --git a/Frontend/src/components/xml/XmlOutputFieldComponent.vue b/Frontend/src/components/xml/XmlOutputFieldComponent.vue index f4f5a63..dd074e1 100644 --- a/Frontend/src/components/xml/XmlOutputFieldComponent.vue +++ b/Frontend/src/components/xml/XmlOutputFieldComponent.vue @@ -127,10 +127,10 @@ function selectRequestBodyType() : string { return prepareRequestBodySingleXml(props.xml!); } function formatParams() { - return props.params.map(param => { + return props.params?.slice(1).map(param => { const [key, value] = param.name.split(" = "); - return {key, value}; - }); + return { key, value }; + }) ?? []; } function prepareRequestBodySingleXml(data: string):string {