fix: query builder query select
This commit is contained in:
parent
8ec3b04824
commit
d04dde688f
1 changed files with 21 additions and 17 deletions
|
@ -32,7 +32,7 @@
|
||||||
>
|
>
|
||||||
<select v-model="activeQueryId" class="max-h-[34px] !py-0">
|
<select v-model="activeQueryId" class="max-h-[34px] !py-0">
|
||||||
<option :value="undefined" disabled>gepeicherte Anfrage auswählen</option>
|
<option :value="undefined" disabled>gepeicherte Anfrage auswählen</option>
|
||||||
<option v-for="query in queries" :key="query.id" :value="query.id" @click="value = query.query">
|
<option v-for="query in queries" :key="query.id" :value="query.id">
|
||||||
{{ query.title }}
|
{{ query.title }}
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
|
@ -54,7 +54,7 @@
|
||||||
class="p-1"
|
class="p-1"
|
||||||
:class="typeof value == 'object' ? 'bg-gray-200' : ''"
|
:class="typeof value == 'object' ? 'bg-gray-200' : ''"
|
||||||
title="Visual Builder"
|
title="Visual Builder"
|
||||||
@click="queryMode = 'builder'"
|
@click="changeMode('builder')"
|
||||||
>
|
>
|
||||||
<RectangleGroupIcon class="text-gray-500 h-6 w-6 cursor-pointer" />
|
<RectangleGroupIcon class="text-gray-500 h-6 w-6 cursor-pointer" />
|
||||||
</div>
|
</div>
|
||||||
|
@ -62,7 +62,7 @@
|
||||||
class="p-1"
|
class="p-1"
|
||||||
:class="typeof value == 'string' ? 'bg-gray-200' : ''"
|
:class="typeof value == 'string' ? 'bg-gray-200' : ''"
|
||||||
title="SQL Editor"
|
title="SQL Editor"
|
||||||
@click="queryMode = 'editor'"
|
@click="changeMode('editor')"
|
||||||
>
|
>
|
||||||
<CommandLineIcon class="text-gray-500 h-6 w-6 cursor-pointer" />
|
<CommandLineIcon class="text-gray-500 h-6 w-6 cursor-pointer" />
|
||||||
</div>
|
</div>
|
||||||
|
@ -116,21 +116,9 @@ export default defineComponent({
|
||||||
},
|
},
|
||||||
emits: ["update:model-value", "query:run", "query:save", "results:export", "results:clear"],
|
emits: ["update:model-value", "query:run", "query:save", "results:export", "results:clear"],
|
||||||
watch: {
|
watch: {
|
||||||
queryMode() {
|
|
||||||
if (this.queryMode == "builder") {
|
|
||||||
this.value = {
|
|
||||||
select: "*",
|
|
||||||
table: "",
|
|
||||||
where: [],
|
|
||||||
join: [],
|
|
||||||
orderBy: [],
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
this.value = "";
|
|
||||||
}
|
|
||||||
this.activeQueryId = undefined;
|
|
||||||
},
|
|
||||||
activeQueryId() {
|
activeQueryId() {
|
||||||
|
if (this.activeQueryId == undefined) return;
|
||||||
|
|
||||||
let query = this.queries.find((t) => t.id == this.activeQueryId)?.query;
|
let query = this.queries.find((t) => t.id == this.activeQueryId)?.query;
|
||||||
if (query != undefined) {
|
if (query != undefined) {
|
||||||
if (typeof query == "string") {
|
if (typeof query == "string") {
|
||||||
|
@ -188,6 +176,22 @@ export default defineComponent({
|
||||||
showStructure() {
|
showStructure() {
|
||||||
this.openModal(markRaw(defineAsyncComponent(() => import("@/components/queryBuilder/StructureModal.vue"))));
|
this.openModal(markRaw(defineAsyncComponent(() => import("@/components/queryBuilder/StructureModal.vue"))));
|
||||||
},
|
},
|
||||||
|
changeMode(mode: "editor" | "builder") {
|
||||||
|
this.queryMode = mode;
|
||||||
|
|
||||||
|
this.activeQueryId = undefined;
|
||||||
|
if (this.queryMode == "builder") {
|
||||||
|
this.value = {
|
||||||
|
select: "*",
|
||||||
|
table: "",
|
||||||
|
where: [],
|
||||||
|
join: [],
|
||||||
|
orderBy: [],
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
this.value = "";
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Add table
Reference in a new issue