diff --git a/src/helpers/queryFormatter.ts b/src/helpers/queryFormatter.ts index 0a8347e..fe8cc6e 100644 --- a/src/helpers/queryFormatter.ts +++ b/src/helpers/queryFormatter.ts @@ -11,7 +11,7 @@ export function flattenQueryResult(result: Array): Array<{ [key: st for (const key in row) { const value = row[key]; - const newKey = prefix ? `${prefix}.${key}` : key; + const newKey = prefix ? `${prefix}_${key}` : key; if (Array.isArray(value) && value.every((item) => typeof item === "object" && item !== null)) { console.log(value, newKey); diff --git a/src/stores/admin/queryBuilder.ts b/src/stores/admin/queryBuilder.ts index 9612025..d65e150 100644 --- a/src/stores/admin/queryBuilder.ts +++ b/src/stores/admin/queryBuilder.ts @@ -2,7 +2,6 @@ import { defineStore } from "pinia"; import { http } from "@/serverCom"; import type { TableMeta } from "@/viewmodels/admin/query.models"; import type { DynamicQueryStructure, FieldType } from "@/types/dynamicQueries"; -import { flattenQueryResult } from "@/helpers/queryFormatter"; export const useQueryBuilderStore = defineStore("queryBuilder", { state: () => { @@ -31,23 +30,21 @@ export const useQueryBuilderStore = defineStore("queryBuilder", { this.loading = "failed"; }); }, - sendQuery(offset = 0, count = 25) { + sendQuery(offset = 0, count = 25, query?: DynamicQueryStructure | string) { this.queryError = ""; this.data = []; this.totalLength = 0; - if (this.query == undefined || this.query == "" || (typeof this.query != "string" && this.query.table == "")) + let queryToSend = query ?? this.query; + if (queryToSend == undefined || queryToSend == "" || (typeof queryToSend != "string" && queryToSend.table == "")) return; this.loadingData = "loading"; http .post(`/admin/querybuilder/query?offset=${offset}&count=${count}`, { - query: this.query, + query: queryToSend, }) .then((result) => { if (result.data.stats == "success") { - this.data = flattenQueryResult(result.data.rows).map((row) => ({ - id: row.id ?? "", // Ensure id is present - ...row, - })); + this.data = result.data.rows; this.totalLength = result.data.total; this.loadingData = "fetched"; } else { diff --git a/src/viewmodels/admin/newsletter.models.ts b/src/viewmodels/admin/newsletter.models.ts index 4a98729..19347b1 100644 --- a/src/viewmodels/admin/newsletter.models.ts +++ b/src/viewmodels/admin/newsletter.models.ts @@ -8,8 +8,8 @@ export interface NewsletterViewModel { newsletterText: string; newsletterSignatur: string; isSent: boolean; - recipientsByQueryId?: number; - recipientsByQuery?: QueryViewModel; + recipientsByQueryId?: number | null; + recipientsByQuery?: QueryViewModel | null; } export interface CreateNewsletterViewModel { diff --git a/src/views/admin/club/newsletter/NewsletterOverview.vue b/src/views/admin/club/newsletter/NewsletterOverview.vue index 0d7b004..58b09a3 100644 --- a/src/views/admin/club/newsletter/NewsletterOverview.vue +++ b/src/views/admin/club/newsletter/NewsletterOverview.vue @@ -15,7 +15,7 @@ - -- select members by query + +

Empfänger durch gespeicherte Abfrage

+
+
+
+

{{ member.lastname }}, {{ member.firstname }} {{ member.nameaffix ? `- ${member.nameaffix}` : "" }}

+

Newsletter senden an Typ: {{ member.sendNewsletter?.type.type }}

+
+
+
- Empfänger suchen + weitere Empfänger suchen
-

Ausgewählte Empfänger

diff --git a/src/views/admin/club/protocol/ProtocolPresence.vue b/src/views/admin/club/protocol/ProtocolPresence.vue index d66e7f1..be6aab5 100644 --- a/src/views/admin/club/protocol/ProtocolPresence.vue +++ b/src/views/admin/club/protocol/ProtocolPresence.vue @@ -141,7 +141,7 @@ export default defineComponent({ }, }, mounted() { - this.fetchMembers(); + this.fetchMembers(0, 1000, true); this.fetchProtocolPresence(); }, methods: {