Implemented XML Formatter and simplified structure of XML tools #229

Merged
bema merged 33 commits from ref/simplify_xml_tools into master 2023-06-21 14:32:02 +02:00
3 changed files with 9 additions and 4 deletions
Showing only changes of commit b33d20fc91 - Show all commits

View File

@@ -48,7 +48,7 @@ function sendProcessedData(data: JSON) {
</script>
<template>
<button class="tool-button" @click="process()">{{ props.isMinimizer ? "Minimize" : "Format"}}</button>
<button class="tool-button" @click="process()">{{ props.isMinimizer ? "Minimize" : "Format" }}</button>
</template>
<style scoped></style>

View File

@@ -1,7 +1,8 @@
<script setup lang="ts">
const props = defineProps({
xml: {type: String, required: true}
xml: {type: String, required: true},
isMinimizer: {type: Boolean}
Review

isMinimizer boolean it's good option, when we have only two options, but in future when we'll need to add another option like for example "removeNamespaces" we need refactor larger piece of code. I suggest to make prop "formatType", with type String.

isMinimizer boolean it's good option, when we have only two options, but in future when we'll need to add another option like for example "removeNamespaces" we need refactor larger piece of code. I suggest to make prop "formatType", with type String.
})
const emit = defineEmits(["update:result"])
@@ -22,7 +23,10 @@ function prepareRequest():Request {
}
function prepareURL(): string {
return document.location.protocol + "//" + document.location.hostname + "/libxml/prettify";
var mode = "prettify";
if (props.isMinimizer)
mode = "minimize";
return document.location.protocol + "//" + document.location.hostname + "/libxml/" + mode;
}
function prepareRequestBody():string {
@@ -48,7 +52,7 @@ function sendProcessedData(data: JSON) {
</script>
<template>
<button class="tool-button" @click="process()">Format</button>
<button class="tool-button" @click="process()">{{ props.isMinimizer ? "Minimize" : "Format" }}</button>
</template>
<style scoped></style>

View File

@@ -27,6 +27,7 @@ function clear() {
<div class="space-x-2">
<InsertTemplateComponent pretty-name="XML" @update:defaultData="(data: string) => setTextFieldValue(data)"></InsertTemplateComponent>
<button class="tool-button" @click="clear()">Clear</button>
<XMLButtonFormatterComponent is-minimizer :xml="xml" @update:result="(data: any) => format(data)"></XMLButtonFormatterComponent>
<XMLButtonFormatterComponent :xml="xml" @update:result="(data: any) => format(data)"></XMLButtonFormatterComponent>
</div>
</div>