cleared code
This commit is contained in:
@@ -13,100 +13,32 @@ const sendToParent = () => {
|
||||
options.value.forEach((value) => {console.log("KID" + value + options.value.indexOf(value))})
|
||||
emit('update-value', options.value);
|
||||
};
|
||||
|
||||
|
||||
const nameInput = ref('')
|
||||
const valueInput = ref('')
|
||||
|
||||
|
||||
const selectedOption = ref(options.value[0].name)
|
||||
|
||||
const isNumeric = (string) => /^[+-]?\d+(\.\d+)?$/.test(string)
|
||||
|
||||
const selectedFunction = () => {
|
||||
if (selectOption(selectedOption.value) === 'Add Param') {
|
||||
if(!valueInput.value.length == 0 && !nameInput.value.length == 0){
|
||||
options.value.push({name: nameInput.value + " = " + valueInput.value});
|
||||
valueInput.value = "";
|
||||
nameInput.value = "";
|
||||
const action = selectOption(selectedOption.value);
|
||||
const name = nameInput.value.trim();
|
||||
const value = valueInput.value.trim();
|
||||
|
||||
if (action === "Add Param" && name && value && !isNumeric(name)) {
|
||||
options.value.push({ name: `${name} = ${value}` });
|
||||
nameInput.value = valueInput.value = "";
|
||||
}
|
||||
|
||||
if (action === "Remove Param") {
|
||||
options.value = options.value.filter(option => option.name !== selectedOption.value);
|
||||
selectedOption.value = options.value.length ? options.value[0].name : "";
|
||||
nameInput.value = valueInput.value = "";
|
||||
}
|
||||
if (selectOption(selectedOption.value) === 'Remove Param') {
|
||||
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()
|
||||
/*
|
||||
|
||||
if(selectedOption.value === "Add Param") {
|
||||
sendRequest("add");
|
||||
}
|
||||
else {
|
||||
sendRequest("remove");
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
const sendRequest = (type:string) => {
|
||||
console.log(type)
|
||||
let request: Request = prepareRequest(type)
|
||||
fetchRequest(request).then((body) => {
|
||||
|
||||
const {status} = body as any;
|
||||
console.log(status)
|
||||
if (status === "OK") {
|
||||
options.value.push({ name: nameInput.value + " = " + valueInput.value });
|
||||
}
|
||||
});
|
||||
}
|
||||
*/
|
||||
sendToParent();
|
||||
};
|
||||
function selectOption(option: string): string {
|
||||
return option == "Add Param" ? "Add Param" : "Remove Param"
|
||||
}
|
||||
|
||||
//
|
||||
// function prepareRequest(type :string): Request {
|
||||
// let request = new Request(prepareURL(), {
|
||||
// body: prepareRequestBody(type),
|
||||
// method: "POST"
|
||||
// });
|
||||
// return request
|
||||
// }
|
||||
//
|
||||
// function prepareURL(): string {
|
||||
// //const engineEndpoint = engine.value == "libxml" ? "libxml" : "java";
|
||||
// return document.location.protocol + "//" + document.location.hostname + "/" + "java" + "/xslt/param";
|
||||
// //return "http://localhost:8081/xslt/param";
|
||||
// }
|
||||
//
|
||||
// function prepareRequestBody(type: string): string {
|
||||
// let requestBody = JSON.stringify({
|
||||
// "paramName": nameInput.value,
|
||||
// "paramValue": valueInput.value,
|
||||
// "type": type
|
||||
// });
|
||||
// console.log(requestBody);
|
||||
// return requestBody;
|
||||
// }
|
||||
//
|
||||
// async function fetchRequest(request: Request): Promise<JSON> {
|
||||
// console.log(request)
|
||||
// let responseBody = await fetch(request)
|
||||
// return await responseBody.json()
|
||||
// }
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
@@ -15,6 +15,8 @@ const emit = defineEmits(["update"]);
|
||||
const result = ref('');
|
||||
|
||||
let enginesForCurrentTool = ref(["saxon", "xalan", "libxml"]);
|
||||
const formattedParams = ref();
|
||||
|
||||
|
||||
const allVersions = ["1.0", "2.0", "3.0", "3.1"];
|
||||
let versionsForCurrentEngine = ref([""]);
|
||||
@@ -100,6 +102,7 @@ function updateOutputField(data: any) {
|
||||
}
|
||||
|
||||
function prepareRequest():Request {
|
||||
formattedParams.value = formatParams()
|
||||
let request = new Request(prepareURL(), {
|
||||
body: selectRequestBodyType(),
|
||||
method: "POST"
|
||||
@@ -135,10 +138,8 @@ function formatParams() {
|
||||
|
||||
function prepareRequestBodySingleXml(data: string):string {
|
||||
|
||||
const formattedParams = formatParams();
|
||||
|
||||
let requestBody = JSON.stringify({
|
||||
"params": formattedParams,
|
||||
"params": formattedParams.value,
|
||||
"data": data,
|
||||
"processorData": props.query,
|
||||
"processor": engine.value,
|
||||
@@ -149,7 +150,6 @@ function prepareRequestBodySingleXml(data: string):string {
|
||||
}
|
||||
|
||||
function prepareRequestBodyMultiXml():string {
|
||||
const formattedParams = formatParams();
|
||||
|
||||
if (!Array.isArray(props.xml))
|
||||
return "";
|
||||
@@ -157,7 +157,7 @@ function prepareRequestBodyMultiXml():string {
|
||||
let xmlFilesArray = convertDataArray(props.xml);
|
||||
|
||||
let requestBody = JSON.stringify({
|
||||
"params": formattedParams,
|
||||
"params": formattedParams.value,
|
||||
"data": xmlFilesArray,
|
||||
"processorData": props.query,
|
||||
"processor": engine.value,
|
||||
|
||||
Reference in New Issue
Block a user