Compare commits
No commits in common. "d5193842d2546b5d1f838987d82326ceafa11f06" and "eb622658d94491c82ed8c6b067fe28a02ec7c652" have entirely different histories.
d5193842d2
...
eb622658d9
6 changed files with 23 additions and 47 deletions
|
@ -69,15 +69,7 @@
|
||||||
<input type="date" id="birthdate" required />
|
<input type="date" id="birthdate" required />
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div class="flex flex-row">
|
<label for="internalId">Interne ID (optional)</label>
|
||||||
<label for="internalId" class="grow">
|
|
||||||
Interne ID (optional{{ lastId ? ` - zuletzte verwendet: ${lastId}` : "" }})
|
|
||||||
</label>
|
|
||||||
<div title="Es empfiehlt sich, die Interne Id mit Platzhaltern wie '0' vorne aufzufüllen.">
|
|
||||||
<InformationCircleIcon class="h-5 w-5" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<input type="text" id="internalId" />
|
<input type="text" id="internalId" />
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-row gap-2">
|
<div class="flex flex-row gap-2">
|
||||||
|
@ -111,7 +103,6 @@ import { useMemberStore } from "@/stores/admin/club/member/member";
|
||||||
import type { CreateMemberViewModel } from "@/viewmodels/admin/club/member/member.models";
|
import type { CreateMemberViewModel } from "@/viewmodels/admin/club/member/member.models";
|
||||||
import { useSalutationStore } from "../../../../stores/admin/configuration/salutation";
|
import { useSalutationStore } from "../../../../stores/admin/configuration/salutation";
|
||||||
import type { SalutationViewModel } from "../../../../viewmodels/admin/configuration/salutation.models";
|
import type { SalutationViewModel } from "../../../../viewmodels/admin/configuration/salutation.models";
|
||||||
import { InformationCircleIcon } from "@heroicons/vue/24/outline";
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
@ -121,7 +112,6 @@ export default defineComponent({
|
||||||
status: null as null | "loading" | { status: "success" | "failed"; reason?: string },
|
status: null as null | "loading" | { status: "success" | "failed"; reason?: string },
|
||||||
timeout: undefined as any,
|
timeout: undefined as any,
|
||||||
selectedSalutation: null as null | SalutationViewModel,
|
selectedSalutation: null as null | SalutationViewModel,
|
||||||
lastId: "" as string,
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -129,11 +119,6 @@ export default defineComponent({
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.fetchSalutations();
|
this.fetchSalutations();
|
||||||
this.fetchLastInternalId()
|
|
||||||
.then((res) => {
|
|
||||||
this.lastId = res.data;
|
|
||||||
})
|
|
||||||
.catch(() => {});
|
|
||||||
},
|
},
|
||||||
beforeUnmount() {
|
beforeUnmount() {
|
||||||
try {
|
try {
|
||||||
|
@ -142,7 +127,7 @@ export default defineComponent({
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions(useModalStore, ["closeModal"]),
|
...mapActions(useModalStore, ["closeModal"]),
|
||||||
...mapActions(useMemberStore, ["createMember", "fetchLastInternalId"]),
|
...mapActions(useMemberStore, ["createMember"]),
|
||||||
...mapActions(useSalutationStore, ["fetchSalutations"]),
|
...mapActions(useSalutationStore, ["fetchSalutations"]),
|
||||||
triggerCreate(e: any) {
|
triggerCreate(e: any) {
|
||||||
if (!this.selectedSalutation) return;
|
if (!this.selectedSalutation) return;
|
||||||
|
|
|
@ -55,7 +55,6 @@ export async function isAuthenticatedPromise(forceRefresh: boolean = false): Pro
|
||||||
// check jwt expiry
|
// check jwt expiry
|
||||||
const exp = decoded.exp ?? 0;
|
const exp = decoded.exp ?? 0;
|
||||||
const correctedLocalTime = new Date().getTime();
|
const correctedLocalTime = new Date().getTime();
|
||||||
let failedRefresh = false;
|
|
||||||
if (exp < Math.floor(correctedLocalTime / 1000) || forceRefresh) {
|
if (exp < Math.floor(correctedLocalTime / 1000) || forceRefresh) {
|
||||||
await refreshToken()
|
await refreshToken()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
@ -64,13 +63,10 @@ export async function isAuthenticatedPromise(forceRefresh: boolean = false): Pro
|
||||||
.catch((err: string) => {
|
.catch((err: string) => {
|
||||||
console.log("expired");
|
console.log("expired");
|
||||||
auth.setFailed();
|
auth.setFailed();
|
||||||
failedRefresh = true;
|
|
||||||
reject(err);
|
reject(err);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (failedRefresh) return;
|
|
||||||
|
|
||||||
var { userId, firstname, lastname, mail, username, permissions, isOwner } = decoded;
|
var { userId, firstname, lastname, mail, username, permissions, isOwner } = decoded;
|
||||||
|
|
||||||
if (Object.keys(permissions ?? {}).length === 0 && !isOwner) {
|
if (Object.keys(permissions ?? {}).length === 0 && !isOwner) {
|
||||||
|
|
|
@ -87,9 +87,6 @@ export const useMemberStore = defineStore("member", {
|
||||||
})
|
})
|
||||||
.catch((err) => {});
|
.catch((err) => {});
|
||||||
},
|
},
|
||||||
fetchLastInternalId() {
|
|
||||||
return http.get(`/admin/member/last/internalId`);
|
|
||||||
},
|
|
||||||
async printMemberByActiveId() {
|
async printMemberByActiveId() {
|
||||||
return http.get(`/admin/member/${this.activeMember}/print`, {
|
return http.get(`/admin/member/${this.activeMember}/print`, {
|
||||||
responseType: "blob",
|
responseType: "blob",
|
||||||
|
|
|
@ -2,7 +2,6 @@ import { defineStore } from "pinia";
|
||||||
import { http } from "@/serverCom";
|
import { http } from "@/serverCom";
|
||||||
import type { TableMeta } from "@/viewmodels/admin/configuration/query.models";
|
import type { TableMeta } from "@/viewmodels/admin/configuration/query.models";
|
||||||
import type { DynamicQueryStructure, FieldType } from "@/types/dynamicQueries";
|
import type { DynamicQueryStructure, FieldType } from "@/types/dynamicQueries";
|
||||||
import type { AxiosResponse } from "axios";
|
|
||||||
|
|
||||||
export const useQueryBuilderStore = defineStore("queryBuilder", {
|
export const useQueryBuilderStore = defineStore("queryBuilder", {
|
||||||
state: () => {
|
state: () => {
|
||||||
|
@ -59,16 +58,6 @@ export const useQueryBuilderStore = defineStore("queryBuilder", {
|
||||||
this.loadingData = "failed";
|
this.loadingData = "failed";
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
async sendQueryByStoreId(
|
|
||||||
id: string,
|
|
||||||
offset = 0,
|
|
||||||
count = 25,
|
|
||||||
noLimit: boolean = false
|
|
||||||
): Promise<AxiosResponse<any, any>> {
|
|
||||||
return await http.post(
|
|
||||||
`/admin/querybuilder/query/${id}?` + (noLimit ? `noLimit=true` : `offset=${offset}&count=${count}`)
|
|
||||||
);
|
|
||||||
},
|
|
||||||
clearResults() {
|
clearResults() {
|
||||||
this.data = [];
|
this.data = [];
|
||||||
this.totalLength = 0;
|
this.totalLength = 0;
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import type { QueryViewModel } from "../../configuration/query.models";
|
||||||
|
|
||||||
export interface NewsletterViewModel {
|
export interface NewsletterViewModel {
|
||||||
id: number;
|
id: number;
|
||||||
title: string;
|
title: string;
|
||||||
|
@ -7,6 +9,7 @@ export interface NewsletterViewModel {
|
||||||
newsletterSignatur: string;
|
newsletterSignatur: string;
|
||||||
isSent: boolean;
|
isSent: boolean;
|
||||||
recipientsByQueryId?: string | null;
|
recipientsByQueryId?: string | null;
|
||||||
|
recipientsByQuery?: QueryViewModel | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CreateNewsletterViewModel {
|
export interface CreateNewsletterViewModel {
|
||||||
|
|
|
@ -81,7 +81,6 @@ import { useQueryStoreStore } from "@/stores/admin/configuration/queryStore";
|
||||||
import { useQueryBuilderStore } from "@/stores/admin/club/queryBuilder";
|
import { useQueryBuilderStore } from "@/stores/admin/club/queryBuilder";
|
||||||
import cloneDeep from "lodash.clonedeep";
|
import cloneDeep from "lodash.clonedeep";
|
||||||
import MemberSearchSelect from "@/components/admin/MemberSearchSelect.vue";
|
import MemberSearchSelect from "@/components/admin/MemberSearchSelect.vue";
|
||||||
import type { FieldType } from "@/types/dynamicQueries";
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
@ -89,9 +88,14 @@ export default defineComponent({
|
||||||
props: {
|
props: {
|
||||||
newsletterId: String,
|
newsletterId: String,
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
recipientsByQuery() {
|
||||||
|
this.loadQuery();
|
||||||
|
},
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
queryResult: [] as Array<{ id: FieldType; [key: string]: FieldType }>,
|
query: "" as String,
|
||||||
members: [] as Array<MemberViewModel>,
|
members: [] as Array<MemberViewModel>,
|
||||||
showMemberSelect: false as boolean,
|
showMemberSelect: false as boolean,
|
||||||
};
|
};
|
||||||
|
@ -100,6 +104,7 @@ export default defineComponent({
|
||||||
...mapWritableState(useNewsletterRecipientsStore, ["recipients", "loading"]),
|
...mapWritableState(useNewsletterRecipientsStore, ["recipients", "loading"]),
|
||||||
...mapWritableState(useNewsletterStore, ["activeNewsletterObj"]),
|
...mapWritableState(useNewsletterStore, ["activeNewsletterObj"]),
|
||||||
...mapState(useQueryStoreStore, ["queries"]),
|
...mapState(useQueryStoreStore, ["queries"]),
|
||||||
|
...mapState(useQueryBuilderStore, ["data"]),
|
||||||
...mapState(useAbilityStore, ["can"]),
|
...mapState(useAbilityStore, ["can"]),
|
||||||
selected(): Array<MemberViewModel> {
|
selected(): Array<MemberViewModel> {
|
||||||
return this.members
|
return this.members
|
||||||
|
@ -114,10 +119,10 @@ export default defineComponent({
|
||||||
},
|
},
|
||||||
queried(): Array<MemberViewModel> {
|
queried(): Array<MemberViewModel> {
|
||||||
if (this.recipientsByQueryId == "def") return [];
|
if (this.recipientsByQueryId == "def") return [];
|
||||||
let keys = Object.keys(this.queryResult?.[0] ?? {});
|
let keys = Object.keys(this.data?.[0] ?? {});
|
||||||
let memberKey = keys.find((k) => k.includes("member_id"));
|
let memberKey = keys.find((k) => k.includes("member_id"));
|
||||||
return this.members.filter((m) =>
|
return this.members.filter((m) =>
|
||||||
this.queryResult
|
this.data
|
||||||
.map((t) => ({
|
.map((t) => ({
|
||||||
id: t.id,
|
id: t.id,
|
||||||
...(memberKey ? { memberId: t[memberKey] } : {}),
|
...(memberKey ? { memberId: t[memberKey] } : {}),
|
||||||
|
@ -144,12 +149,17 @@ export default defineComponent({
|
||||||
if (this.activeNewsletterObj == undefined) return;
|
if (this.activeNewsletterObj == undefined) return;
|
||||||
if (val == "def") {
|
if (val == "def") {
|
||||||
this.activeNewsletterObj.recipientsByQueryId = null;
|
this.activeNewsletterObj.recipientsByQueryId = null;
|
||||||
|
this.activeNewsletterObj.recipientsByQuery = null;
|
||||||
} else if (this.queries.find((q) => q.id == val)) {
|
} else if (this.queries.find((q) => q.id == val)) {
|
||||||
this.activeNewsletterObj.recipientsByQueryId = val;
|
this.activeNewsletterObj.recipientsByQueryId = val;
|
||||||
this.loadQuery();
|
this.activeNewsletterObj.recipientsByQuery = cloneDeep(this.queries.find((q) => q.id == val));
|
||||||
|
this.sendQuery(0, 0, this.recipientsByQuery?.query, true);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
recipientsByQuery() {
|
||||||
|
return this.activeNewsletterObj?.recipientsByQuery;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
// this.fetchNewsletterRecipients();
|
// this.fetchNewsletterRecipients();
|
||||||
|
@ -161,7 +171,7 @@ export default defineComponent({
|
||||||
...mapActions(useMemberStore, ["getAllMembers"]),
|
...mapActions(useMemberStore, ["getAllMembers"]),
|
||||||
...mapActions(useNewsletterRecipientsStore, ["fetchNewsletterRecipients"]),
|
...mapActions(useNewsletterRecipientsStore, ["fetchNewsletterRecipients"]),
|
||||||
...mapActions(useQueryStoreStore, ["fetchQueries"]),
|
...mapActions(useQueryStoreStore, ["fetchQueries"]),
|
||||||
...mapActions(useQueryBuilderStore, ["sendQueryByStoreId"]),
|
...mapActions(useQueryBuilderStore, ["sendQuery"]),
|
||||||
removeSelected(id: string) {
|
removeSelected(id: string) {
|
||||||
let index = this.recipients.findIndex((s) => s == id);
|
let index = this.recipients.findIndex((s) => s == id);
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
|
@ -176,12 +186,8 @@ export default defineComponent({
|
||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
},
|
},
|
||||||
loadQuery() {
|
loadQuery() {
|
||||||
if (this.recipientsByQueryId != "def") {
|
if (this.recipientsByQuery) {
|
||||||
this.sendQueryByStoreId(this.recipientsByQueryId, 0, 0, true)
|
this.sendQuery(0, 0, this.recipientsByQuery.query, true);
|
||||||
.then((result) => {
|
|
||||||
this.queryResult = result.data.rows;
|
|
||||||
})
|
|
||||||
.catch(() => {});
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Reference in a new issue