From b106ea63964dd9ce073ded90ff2f723d987d4745 Mon Sep 17 00:00:00 2001
From: Julian Krauser
Date: Sun, 5 Jan 2025 12:12:21 +0100
Subject: [PATCH] enhancement syncing & protocol presence absence
---
.../admin/club/newsletter/newsletterDates.ts | 9 +++-
.../club/newsletter/newsletterRecipients.ts | 5 ++
.../admin/club/protocol/protocolAgenda.ts | 9 +++-
.../admin/club/protocol/protocolDecision.ts | 5 ++
.../admin/club/protocol/protocolPresence.ts | 18 +++++--
.../admin/club/protocol/protocolPrintout.ts | 2 +-
.../admin/club/protocol/protocolVoting.ts | 9 +++-
.../club/protocol/protocolPresence.models.ts | 4 +-
.../admin/club/newsletter/NewsletterDates.vue | 2 +-
.../club/newsletter/NewsletterOverview.vue | 2 +-
.../club/newsletter/NewsletterRecipients.vue | 4 +-
.../admin/club/protocol/ProtocolAgenda.vue | 2 +-
.../admin/club/protocol/ProtocolDecisions.vue | 2 +-
.../admin/club/protocol/ProtocolOverview.vue | 2 +-
.../admin/club/protocol/ProtocolPresence.vue | 53 +++++++++----------
.../admin/club/protocol/ProtocolRouting.vue | 12 +++++
.../admin/club/protocol/ProtocolVoting.vue | 2 +-
17 files changed, 95 insertions(+), 47 deletions(-)
diff --git a/src/stores/admin/club/newsletter/newsletterDates.ts b/src/stores/admin/club/newsletter/newsletterDates.ts
index 82d6e77..89d690d 100644
--- a/src/stores/admin/club/newsletter/newsletterDates.ts
+++ b/src/stores/admin/club/newsletter/newsletterDates.ts
@@ -1,6 +1,9 @@
import { defineStore } from "pinia";
import { http } from "@/serverCom";
-import type { NewsletterDatesViewModel, SyncNewsletterDatesViewModel } from "@/viewmodels/admin/club/newsletter/newsletterDates.models";
+import type {
+ NewsletterDatesViewModel,
+ SyncNewsletterDatesViewModel,
+} from "@/viewmodels/admin/club/newsletter/newsletterDates.models";
import { useNewsletterStore } from "./newsletter";
import cloneDeep from "lodash.clonedeep";
import isEqual from "lodash.isequal";
@@ -9,6 +12,7 @@ import differenceWith from "lodash.differencewith";
export const useNewsletterDatesStore = defineStore("newsletterDates", {
state: () => {
return {
+ initialized: false as boolean,
dates: [] as Array,
origin: [] as Array,
loading: "loading" as "loading" | "fetched" | "failed",
@@ -38,6 +42,7 @@ export const useNewsletterDatesStore = defineStore("newsletterDates", {
.then((result) => {
this.origin = result.data;
this.dates = cloneDeep(this.origin);
+ this.initialized = true;
this.loading = "fetched";
})
.catch((err) => {
@@ -49,6 +54,8 @@ export const useNewsletterDatesStore = defineStore("newsletterDates", {
return http.get(`/admin/newsletter/${newsletterId}/dates`);
},
async synchronizeActiveNewsletterDates() {
+ if (!this.initialized) return;
+
this.syncingNewsletterDates = "syncing";
const newsletterId = useNewsletterStore().activeNewsletter;
diff --git a/src/stores/admin/club/newsletter/newsletterRecipients.ts b/src/stores/admin/club/newsletter/newsletterRecipients.ts
index cb45a76..594ac7f 100644
--- a/src/stores/admin/club/newsletter/newsletterRecipients.ts
+++ b/src/stores/admin/club/newsletter/newsletterRecipients.ts
@@ -11,6 +11,7 @@ import isEqual from "lodash.isequal";
export const useNewsletterRecipientsStore = defineStore("newsletterRecipients", {
state: () => {
return {
+ initialized: false as boolean,
recipients: [] as Array,
origin: [] as Array,
loading: "loading" as "loading" | "fetched" | "failed",
@@ -31,6 +32,7 @@ export const useNewsletterRecipientsStore = defineStore("newsletterRecipients",
.then((result) => {
this.origin = result.data.map((d: NewsletterRecipientsViewModel) => d.memberId);
this.recipients = cloneDeep(this.origin);
+ this.initialized = true;
this.loading = "fetched";
})
.catch((err) => {
@@ -42,8 +44,11 @@ export const useNewsletterRecipientsStore = defineStore("newsletterRecipients",
return http.get(`/admin/newsletter/${newsletterId}/recipients`);
},
async synchronizeActiveNewsletterRecipients() {
+ if (!this.initialized) return;
+
this.syncingNewsletterRecipients = "syncing";
const newsletterId = useNewsletterStore().activeNewsletter;
+
await http
.patch(`/admin/newsletter/${newsletterId}/synchronize/recipients`, {
recipients: this.recipients,
diff --git a/src/stores/admin/club/protocol/protocolAgenda.ts b/src/stores/admin/club/protocol/protocolAgenda.ts
index 5cf6b0d..68e48a8 100644
--- a/src/stores/admin/club/protocol/protocolAgenda.ts
+++ b/src/stores/admin/club/protocol/protocolAgenda.ts
@@ -1,6 +1,9 @@
import { defineStore } from "pinia";
import { http } from "@/serverCom";
-import type { ProtocolAgendaViewModel, SyncProtocolAgendaViewModel } from "@/viewmodels/admin/club/protocol/protocolAgenda.models";
+import type {
+ ProtocolAgendaViewModel,
+ SyncProtocolAgendaViewModel,
+} from "@/viewmodels/admin/club/protocol/protocolAgenda.models";
import { useProtocolStore } from "./protocol";
import cloneDeep from "lodash.clonedeep";
import isEqual from "lodash.isequal";
@@ -9,6 +12,7 @@ import differenceWith from "lodash.differencewith";
export const useProtocolAgendaStore = defineStore("protocolAgenda", {
state: () => {
return {
+ initialized: false as boolean,
agenda: [] as Array,
origin: [] as Array,
loading: "loading" as "loading" | "fetched" | "failed",
@@ -29,6 +33,7 @@ export const useProtocolAgendaStore = defineStore("protocolAgenda", {
.then((result) => {
this.origin = result.data;
this.agenda = cloneDeep(this.origin);
+ this.initialized = true;
this.loading = "fetched";
})
.catch((err) => {
@@ -55,6 +60,8 @@ export const useProtocolAgendaStore = defineStore("protocolAgenda", {
.catch((err) => {});
},
async synchronizeActiveProtocolAgenda() {
+ if (!this.initialized) return;
+
this.syncingProtocolAgenda = "syncing";
const protocolId = useProtocolStore().activeProtocol;
diff --git a/src/stores/admin/club/protocol/protocolDecision.ts b/src/stores/admin/club/protocol/protocolDecision.ts
index 632b080..8ff0fcb 100644
--- a/src/stores/admin/club/protocol/protocolDecision.ts
+++ b/src/stores/admin/club/protocol/protocolDecision.ts
@@ -13,6 +13,7 @@ import differenceWith from "lodash.differencewith";
export const useProtocolDecisionStore = defineStore("protocolDecision", {
state: () => {
return {
+ initialized: false as boolean,
decision: [] as Array,
origin: [] as Array,
loading: "loading" as "loading" | "fetched" | "failed",
@@ -33,9 +34,11 @@ export const useProtocolDecisionStore = defineStore("protocolDecision", {
.then((result) => {
this.origin = result.data;
this.decision = cloneDeep(this.origin);
+ this.initialized = true;
this.loading = "fetched";
})
.catch((err) => {
+ console.log(err);
this.loading = "failed";
});
},
@@ -59,6 +62,8 @@ export const useProtocolDecisionStore = defineStore("protocolDecision", {
.catch((err) => {});
},
async synchronizeActiveProtocolDecision() {
+ if (!this.initialized) return;
+
this.syncingProtocolDecision = "syncing";
const protocolId = useProtocolStore().activeProtocol;
diff --git a/src/stores/admin/club/protocol/protocolPresence.ts b/src/stores/admin/club/protocol/protocolPresence.ts
index ac7a94e..de641d2 100644
--- a/src/stores/admin/club/protocol/protocolPresence.ts
+++ b/src/stores/admin/club/protocol/protocolPresence.ts
@@ -12,15 +12,19 @@ import isEqual from "lodash.isequal";
export const useProtocolPresenceStore = defineStore("protocolPresence", {
state: () => {
return {
- presence: [] as Array,
- origin: [] as Array,
+ initialized: false as boolean,
+ presence: [] as Array,
+ origin: [] as Array,
loading: "loading" as "loading" | "fetched" | "failed",
syncingProtocolPresence: "synced" as "synced" | "syncing" | "detectedChanges" | "failed",
};
},
getters: {
detectedChangeProtocolPresence: (state) =>
- !isEqual(state.origin, state.presence) && state.syncingProtocolPresence != "syncing",
+ !isEqual(
+ state.origin.sort((a: ProtocolPresenceViewModel, b: ProtocolPresenceViewModel) => a.memberId - b.memberId),
+ state.presence.sort((a: ProtocolPresenceViewModel, b: ProtocolPresenceViewModel) => a.memberId - b.memberId)
+ ) && state.syncingProtocolPresence != "syncing",
},
actions: {
setProtocolPresenceSyncingState(state: "synced" | "syncing" | "detectedChanges" | "failed") {
@@ -30,8 +34,9 @@ export const useProtocolPresenceStore = defineStore("protocolPresence", {
this.loading = "loading";
this.fetchProtocolPresencePromise()
.then((result) => {
- this.origin = result.data.map((d: ProtocolPresenceViewModel) => d.memberId);
+ this.origin = result.data;
this.presence = cloneDeep(this.origin);
+ this.initialized = true;
this.loading = "fetched";
})
.catch((err) => {
@@ -43,8 +48,11 @@ export const useProtocolPresenceStore = defineStore("protocolPresence", {
return http.get(`/admin/protocol/${protocolId}/presence`);
},
async synchronizeActiveProtocolPresence() {
+ if (!this.initialized) return;
+
this.syncingProtocolPresence = "syncing";
const protocolId = useProtocolStore().activeProtocol;
+
await http
.put(`/admin/protocol/${protocolId}/synchronize/presence`, {
presence: this.presence,
@@ -57,7 +65,7 @@ export const useProtocolPresenceStore = defineStore("protocolPresence", {
});
this.fetchProtocolPresencePromise()
.then((result) => {
- this.origin = result.data.map((d: ProtocolPresenceViewModel) => d.memberId);
+ this.origin = result.data;
if (this.detectedChangeProtocolPresence) this.syncingProtocolPresence = "detectedChanges";
})
.catch((err) => {});
diff --git a/src/stores/admin/club/protocol/protocolPrintout.ts b/src/stores/admin/club/protocol/protocolPrintout.ts
index 81e5943..ae2059b 100644
--- a/src/stores/admin/club/protocol/protocolPrintout.ts
+++ b/src/stores/admin/club/protocol/protocolPrintout.ts
@@ -19,7 +19,7 @@ export const useProtocolPrintoutStore = defineStore("protocolPrintout", {
http
.get(`/admin/protocol/${protocolId}/printouts`)
.then((result) => {
- this.printout = result.data;
+ this.printout = result.data.reverse();
this.loading = "fetched";
})
.catch((err) => {
diff --git a/src/stores/admin/club/protocol/protocolVoting.ts b/src/stores/admin/club/protocol/protocolVoting.ts
index 2a0b63c..e5e797a 100644
--- a/src/stores/admin/club/protocol/protocolVoting.ts
+++ b/src/stores/admin/club/protocol/protocolVoting.ts
@@ -1,7 +1,10 @@
import { defineStore } from "pinia";
import { http } from "@/serverCom";
import type { AxiosResponse } from "axios";
-import type { ProtocolVotingViewModel, SyncProtocolVotingViewModel } from "@/viewmodels/admin/club/protocol/protocolVoting.models";
+import type {
+ ProtocolVotingViewModel,
+ SyncProtocolVotingViewModel,
+} from "@/viewmodels/admin/club/protocol/protocolVoting.models";
import { useProtocolStore } from "./protocol";
import cloneDeep from "lodash.clonedeep";
import isEqual from "lodash.isequal";
@@ -10,6 +13,7 @@ import differenceWith from "lodash.differencewith";
export const useProtocolVotingStore = defineStore("protocolVoting", {
state: () => {
return {
+ initialized: false as boolean,
voting: [] as Array,
origin: [] as Array,
loading: "loading" as "loading" | "fetched" | "failed",
@@ -30,6 +34,7 @@ export const useProtocolVotingStore = defineStore("protocolVoting", {
.then((result) => {
this.origin = result.data;
this.voting = cloneDeep(this.origin);
+ this.initialized = true;
this.loading = "fetched";
})
.catch((err) => {
@@ -59,6 +64,8 @@ export const useProtocolVotingStore = defineStore("protocolVoting", {
.catch((err) => {});
},
async synchronizeActiveProtocolVoting() {
+ if (!this.initialized) return;
+
this.syncingProtocolVoting = "syncing";
const protocolId = useProtocolStore().activeProtocol;
diff --git a/src/viewmodels/admin/club/protocol/protocolPresence.models.ts b/src/viewmodels/admin/club/protocol/protocolPresence.models.ts
index a395172..41fb03c 100644
--- a/src/viewmodels/admin/club/protocol/protocolPresence.models.ts
+++ b/src/viewmodels/admin/club/protocol/protocolPresence.models.ts
@@ -1,8 +1,6 @@
-import type { MemberViewModel } from "../member/member.models";
-
export interface ProtocolPresenceViewModel {
memberId: number;
- member: MemberViewModel;
+ absent: boolean;
protocolId: number;
}
diff --git a/src/views/admin/club/newsletter/NewsletterDates.vue b/src/views/admin/club/newsletter/NewsletterDates.vue
index 152a63f..ddf188a 100644
--- a/src/views/admin/club/newsletter/NewsletterDates.vue
+++ b/src/views/admin/club/newsletter/NewsletterDates.vue
@@ -140,7 +140,7 @@ export default defineComponent({
},
},
mounted() {
- this.fetchNewsletterDates();
+ // this.fetchNewsletterDates();
this.fetchCalendars();
},
methods: {
diff --git a/src/views/admin/club/newsletter/NewsletterOverview.vue b/src/views/admin/club/newsletter/NewsletterOverview.vue
index 1097bc8..5283ac0 100644
--- a/src/views/admin/club/newsletter/NewsletterOverview.vue
+++ b/src/views/admin/club/newsletter/NewsletterOverview.vue
@@ -58,7 +58,7 @@ export default defineComponent({
...mapState(useAbilityStore, ["can"]),
},
mounted() {
- this.fetchNewsletterByActiveId();
+ // this.fetchNewsletterByActiveId();
},
methods: {
...mapActions(useNewsletterStore, ["fetchNewsletterByActiveId"]),
diff --git a/src/views/admin/club/newsletter/NewsletterRecipients.vue b/src/views/admin/club/newsletter/NewsletterRecipients.vue
index d39c105..4e55526 100644
--- a/src/views/admin/club/newsletter/NewsletterRecipients.vue
+++ b/src/views/admin/club/newsletter/NewsletterRecipients.vue
@@ -205,8 +205,8 @@ export default defineComponent({
},
},
mounted() {
- this.fetchMembers(0, 1000, true);
- this.fetchNewsletterRecipients();
+ this.fetchMembers(0, 1000, "", true);
+ // this.fetchNewsletterRecipients();
this.fetchQueries();
this.loadQuery();
},
diff --git a/src/views/admin/club/protocol/ProtocolAgenda.vue b/src/views/admin/club/protocol/ProtocolAgenda.vue
index 767d723..b0d6eed 100644
--- a/src/views/admin/club/protocol/ProtocolAgenda.vue
+++ b/src/views/admin/club/protocol/ProtocolAgenda.vue
@@ -73,7 +73,7 @@ export default defineComponent({
...mapState(useAbilityStore, ["can"]),
},
mounted() {
- this.fetchProtocolAgenda();
+ // this.fetchProtocolAgenda();
},
methods: {
...mapActions(useProtocolAgendaStore, ["fetchProtocolAgenda", "createProtocolAgenda"]),
diff --git a/src/views/admin/club/protocol/ProtocolDecisions.vue b/src/views/admin/club/protocol/ProtocolDecisions.vue
index 9f72172..7fbe8af 100644
--- a/src/views/admin/club/protocol/ProtocolDecisions.vue
+++ b/src/views/admin/club/protocol/ProtocolDecisions.vue
@@ -73,7 +73,7 @@ export default defineComponent({
...mapState(useAbilityStore, ["can"]),
},
mounted() {
- this.fetchProtocolDecision();
+ // this.fetchProtocolDecision();
},
methods: {
...mapActions(useProtocolDecisionStore, ["fetchProtocolDecision", "createProtocolDecision"]),
diff --git a/src/views/admin/club/protocol/ProtocolOverview.vue b/src/views/admin/club/protocol/ProtocolOverview.vue
index 4a14774..d5f984a 100644
--- a/src/views/admin/club/protocol/ProtocolOverview.vue
+++ b/src/views/admin/club/protocol/ProtocolOverview.vue
@@ -80,7 +80,7 @@ export default defineComponent({
...mapState(useAbilityStore, ["can"]),
},
mounted() {
- this.fetchProtocolByActiveId();
+ // this.fetchProtocolByActiveId();
},
methods: {
...mapActions(useProtocolStore, ["fetchProtocolByActiveId"]),
diff --git a/src/views/admin/club/protocol/ProtocolPresence.vue b/src/views/admin/club/protocol/ProtocolPresence.vue
index 8696512..1e1c38c 100644
--- a/src/views/admin/club/protocol/ProtocolPresence.vue
+++ b/src/views/admin/club/protocol/ProtocolPresence.vue
@@ -6,7 +6,7 @@
-
+
Anwesende suchen
- {{ member.firstname }} {{ member.lastname }} {{ member.nameaffix }}
+ {{ getMember(member.memberId)?.firstname }} {{ getMember(member.memberId)?.lastname }} {{ getMember(member.memberId)?.nameaffix }}
- Ausgewählte Anwesende
+ Anwesenheit
-
{{ member.lastname }}, {{ member.firstname }} {{ member.nameaffix ? `- ${member.nameaffix}` : "" }}
+
+
{{ getMember(member.memberId)?.lastname }}, {{ getMember(member.memberId)?.firstname }} {{ getMember(member.memberId)?.nameaffix ? `- ${getMember(member.memberId)?.nameaffix}` : "" }}
+
+
@@ -117,38 +123,31 @@ export default defineComponent({
...mapWritableState(useProtocolPresenceStore, ["presence", "loading"]),
...mapState(useMemberStore, ["members"]),
...mapState(useAbilityStore, ["can"]),
- filtered(): Array {
- return this.query === ""
+ filtered(): Array<{memberId:number, absent:boolean; protocolId:number}> {
+ return (this.query === ""
? this.members
: this.members.filter((member) =>
(member.firstname + " " + member.lastname)
.toLowerCase()
.replace(/\s+/g, "")
.includes(this.query.toLowerCase().replace(/\s+/g, ""))
- );
- },
- sorted(): Array {
- return this.selected.sort((a, b) => {
- if (a.lastname < b.lastname) return -1;
- if (a.lastname > b.lastname) return 1;
- if (a.firstname < b.firstname) return -1;
- if (a.firstname > b.firstname) return 1;
- return 0;
- });
- },
- selected(): Array {
- return this.members.filter((m) => this.presence.includes(m.id));
+ )).map(m =>({memberId: m.id, absent:false, protocolId:parseInt(this.protocolId ?? "")}));
},
+ getMember(){
+ return (memberId:number) => {
+ return this.members.find(m => memberId == m.id)
+ }
+ }
},
mounted() {
- this.fetchMembers(0, 1000, true);
- this.fetchProtocolPresence();
+ this.fetchMembers(0, 1000, "", true);
+ // this.fetchProtocolPresence();
},
methods: {
...mapActions(useMemberStore, ["fetchMembers"]),
...mapActions(useProtocolPresenceStore, ["fetchProtocolPresence"]),
removeSelected(id: number) {
- let index = this.presence.findIndex((s) => s == id);
+ let index = this.presence.findIndex((s) => s.memberId == id);
if (index != -1) {
this.presence.splice(index, 1);
}
diff --git a/src/views/admin/club/protocol/ProtocolRouting.vue b/src/views/admin/club/protocol/ProtocolRouting.vue
index b730fed..1fc997f 100644
--- a/src/views/admin/club/protocol/ProtocolRouting.vue
+++ b/src/views/admin/club/protocol/ProtocolRouting.vue
@@ -53,6 +53,10 @@ import { useProtocolStore } from "@/stores/admin/club/protocol/protocol";
import { useModalStore } from "@/stores/modal";
import ProtocolSyncing from "@/components/admin/club/protocol/ProtocolSyncing.vue";
import { PrinterIcon } from "@heroicons/vue/24/outline";
+import { useProtocolAgendaStore } from "@/stores/admin/club/protocol/protocolAgenda";
+import { useProtocolDecisionStore } from "@/stores/admin/club/protocol/protocolDecision";
+import { useProtocolPresenceStore } from "@/stores/admin/club/protocol/protocolPresence";
+import { useProtocolVotingStore } from "@/stores/admin/club/protocol/protocolVoting";