From ff253c73f049ccf558b2b15e1b7afc3f219f7730 Mon Sep 17 00:00:00 2001 From: Julian Krauser Date: Mon, 16 Dec 2024 17:49:18 +0100 Subject: [PATCH] condition building --- src/components/queryBuilder/BuilderHost.vue | 15 ++++++++- src/components/queryBuilder/Condition.vue | 31 +++++++++++++++++-- .../queryBuilder/NestedCondition.vue | 2 +- src/components/queryBuilder/NestedWhere.vue | 3 +- src/components/queryBuilder/Table.vue | 8 ++--- src/components/queryBuilder/Where.vue | 2 +- src/stores/admin/queryBuilder.ts | 19 ++++++++---- src/types/dynamicQueries.ts | 22 ++++++++++++- src/views/admin/club/query/Builder.vue | 29 +++++++++++++++-- 9 files changed, 112 insertions(+), 19 deletions(-) diff --git a/src/components/queryBuilder/BuilderHost.vue b/src/components/queryBuilder/BuilderHost.vue index 4d1c0a4..f2cb3e3 100644 --- a/src/components/queryBuilder/BuilderHost.vue +++ b/src/components/queryBuilder/BuilderHost.vue @@ -29,6 +29,13 @@ > +
+ +
@@ -40,7 +47,13 @@ import { defineComponent, type PropType } from "vue"; import { mapActions, mapState } from "pinia"; import type { DynamicQueryStructure } from "../../types/dynamicQueries"; -import { ArchiveBoxArrowDownIcon, InboxArrowDownIcon, NoSymbolIcon, PlayIcon } from "@heroicons/vue/24/outline"; +import { + ArchiveBoxArrowDownIcon, + InboxArrowDownIcon, + NoSymbolIcon, + PlayIcon, + TrashIcon, +} from "@heroicons/vue/24/outline"; import { useQueryBuilderStore } from "../../stores/admin/queryBuilder"; import Table from "./Table.vue"; diff --git a/src/components/queryBuilder/Condition.vue b/src/components/queryBuilder/Condition.vue index f686a9b..66c62d9 100644 --- a/src/components/queryBuilder/Condition.vue +++ b/src/components/queryBuilder/Condition.vue @@ -8,10 +8,17 @@ + +
@@ -21,7 +28,13 @@ @@ -50,6 +63,20 @@ export default defineComponent({ foreignColumns() { return this.activeTable?.relations.map((r) => r.column); }, + inputType() { + let type = this.activeTable?.columns.find((c) => c.column == this.column)?.type; + if (this.operation.includes("timespan")) return "number"; + switch (type) { + case "int": + return "number"; + case "varchar": + return "text"; + case "date": + return "date"; + default: + return "text"; + } + }, concat: { get() { return this.modelValue.concat; diff --git a/src/components/queryBuilder/NestedCondition.vue b/src/components/queryBuilder/NestedCondition.vue index 44cbb26..dde4d9c 100644 --- a/src/components/queryBuilder/NestedCondition.vue +++ b/src/components/queryBuilder/NestedCondition.vue @@ -1,6 +1,6 @@