Implemented error signal in XML formatter
This commit is contained in:
@@ -6,6 +6,9 @@ import { ref } from 'vue';
|
||||
|
||||
|
||||
const xml = ref('');
|
||||
const inputFile = ref()
|
||||
|
||||
const errorOccurred = ref(false);
|
||||
|
||||
function setTextFieldValue(data: string) {
|
||||
xml.value = data
|
||||
@@ -15,8 +18,19 @@ function format(formattedXml: any) {
|
||||
xml.value = formattedXml.result;
|
||||
}
|
||||
|
||||
function setErrorOccurred(occurred: boolean) {
|
||||
errorOccurred.value = occurred
|
||||
}
|
||||
|
||||
function setExample(data: string) {
|
||||
inputFile.value.value = ''
|
||||
setTextFieldValue(data)
|
||||
}
|
||||
|
||||
function clear() {
|
||||
xml.value = '';
|
||||
errorOccurred.value = false
|
||||
inputFile.value.value = ''
|
||||
}
|
||||
|
||||
function readFile(file : any) {
|
||||
@@ -41,12 +55,12 @@ function readFile(file : any) {
|
||||
<div class="flex items-stretch w-64">
|
||||
<input id="fileLoader" ref="inputFile" class="file-selector" type="file" accept=".xml,.xql,.xquery,.xslt,text/xml,text/plain" @change="readFile" />
|
||||
</div>
|
||||
<InsertTemplateComponent stylized-name="XML" @update:defaultData="(data: string) => setTextFieldValue(data)"></InsertTemplateComponent>
|
||||
<InsertTemplateComponent stylized-name="XML" @update:defaultData="(data: string) => setExample(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>
|
||||
<XMLButtonFormatterComponent @update:error="setErrorOccurred" is-minimizer :xml="xml" @update:result="(data: any) => format(data)"></XMLButtonFormatterComponent>
|
||||
<XMLButtonFormatterComponent @update:error="setErrorOccurred" :xml="xml" @update:result="(data: any) => format(data)"></XMLButtonFormatterComponent>
|
||||
</div>
|
||||
</div>
|
||||
<CodeEditorComponent @update:updated-code="setTextFieldValue" :code="xml" :config="{disabled:false,language:'xml'}" />
|
||||
<CodeEditorComponent :class="{'text-field-error' : errorOccurred}" @update:updated-code="setTextFieldValue" :code="xml" :config="{disabled:false,language:'xml'}" />
|
||||
</div>
|
||||
</template>
|
||||
Reference in New Issue
Block a user