#23-cleanup-&-enhancements #28

Merged
jkeffects merged 3 commits from #23-cleanup-&-enhancements into main 2025-01-05 15:12:32 +00:00
17 changed files with 95 additions and 47 deletions
Showing only changes of commit b106ea6396 - Show all commits

View file

@ -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<NewsletterDatesViewModel>,
origin: [] as Array<NewsletterDatesViewModel>,
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;

View file

@ -11,6 +11,7 @@ import isEqual from "lodash.isequal";
export const useNewsletterRecipientsStore = defineStore("newsletterRecipients", {
state: () => {
return {
initialized: false as boolean,
recipients: [] as Array<number>,
origin: [] as Array<number>,
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,

View file

@ -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<ProtocolAgendaViewModel>,
origin: [] as Array<ProtocolAgendaViewModel>,
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;

View file

@ -13,6 +13,7 @@ import differenceWith from "lodash.differencewith";
export const useProtocolDecisionStore = defineStore("protocolDecision", {
state: () => {
return {
initialized: false as boolean,
decision: [] as Array<ProtocolDecisionViewModel>,
origin: [] as Array<ProtocolDecisionViewModel>,
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;

View file

@ -12,15 +12,19 @@ import isEqual from "lodash.isequal";
export const useProtocolPresenceStore = defineStore("protocolPresence", {
state: () => {
return {
presence: [] as Array<number>,
origin: [] as Array<number>,
initialized: false as boolean,
presence: [] as Array<ProtocolPresenceViewModel>,
origin: [] as Array<ProtocolPresenceViewModel>,
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) => {});

View file

@ -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) => {

View file

@ -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<ProtocolVotingViewModel>,
origin: [] as Array<ProtocolVotingViewModel>,
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;

View file

@ -1,8 +1,6 @@
import type { MemberViewModel } from "../member/member.models";
export interface ProtocolPresenceViewModel {
memberId: number;
member: MemberViewModel;
absent: boolean;
protocolId: number;
}

View file

@ -140,7 +140,7 @@ export default defineComponent({
},
},
mounted() {
this.fetchNewsletterDates();
// this.fetchNewsletterDates();
this.fetchCalendars();
},
methods: {

View file

@ -58,7 +58,7 @@ export default defineComponent({
...mapState(useAbilityStore, ["can"]),
},
mounted() {
this.fetchNewsletterByActiveId();
// this.fetchNewsletterByActiveId();
},
methods: {
...mapActions(useNewsletterStore, ["fetchNewsletterByActiveId"]),

View file

@ -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();
},

View file

@ -73,7 +73,7 @@ export default defineComponent({
...mapState(useAbilityStore, ["can"]),
},
mounted() {
this.fetchProtocolAgenda();
// this.fetchProtocolAgenda();
},
methods: {
...mapActions(useProtocolAgendaStore, ["fetchProtocolAgenda", "createProtocolAgenda"]),

View file

@ -73,7 +73,7 @@ export default defineComponent({
...mapState(useAbilityStore, ["can"]),
},
mounted() {
this.fetchProtocolDecision();
// this.fetchProtocolDecision();
},
methods: {
...mapActions(useProtocolDecisionStore, ["fetchProtocolDecision", "createProtocolDecision"]),

View file

@ -80,7 +80,7 @@ export default defineComponent({
...mapState(useAbilityStore, ["can"]),
},
mounted() {
this.fetchProtocolByActiveId();
// this.fetchProtocolByActiveId();
},
methods: {
...mapActions(useProtocolStore, ["fetchProtocolByActiveId"]),

View file

@ -6,7 +6,7 @@
</p>
<div class="w-full">
<Combobox v-model="presence" :disabled="!can('create', 'club', 'protocol')" multiple>
<Combobox v-model="presence" :disabled="!can('create', 'club', 'protocol')" multiple by="memberId">
<ComboboxLabel>Anwesende suchen</ComboboxLabel>
<div class="relative mt-1">
<ComboboxInput
@ -34,8 +34,8 @@
<ComboboxOption
v-for="member in filtered"
as="template"
:key="member.id"
:value="member.id"
:key="member.memberId"
:value="member"
v-slot="{ selected, active }"
>
<li
@ -46,7 +46,7 @@
}"
>
<span class="block truncate" :class="{ 'font-medium': selected, 'font-normal': !selected }">
{{ member.firstname }} {{ member.lastname }} {{ member.nameaffix }}
{{ getMember(member.memberId)?.firstname }} {{ getMember(member.memberId)?.lastname }} {{ getMember(member.memberId)?.nameaffix }}
</span>
<span
v-if="selected"
@ -63,18 +63,24 @@
</Combobox>
</div>
<br />
<p>Ausgewählte Anwesende</p>
<p>Anwesenheit</p>
<div class="flex flex-col gap-2 grow overflow-y-auto">
<div
v-for="member in selected"
:key="member.id"
v-for="member in presence"
:key="member.memberId"
class="flex flex-row h-fit w-full border border-primary rounded-md bg-primary p-2 text-white justify-between items-center"
>
<p>{{ member.lastname }}, {{ member.firstname }} {{ member.nameaffix ? `- ${member.nameaffix}` : "" }}</p>
<div class="flex flex-col items-start">
<p>{{ getMember(member.memberId)?.lastname }}, {{ getMember(member.memberId)?.firstname }} {{ getMember(member.memberId)?.nameaffix ? `- ${getMember(member.memberId)?.nameaffix}` : "" }}</p>
<label class="flex flex-row gap-2 items-center">
<input type="checkbox" v-model="member.absent" />
war abwesend
</label>
</div>
<TrashIcon
v-if="can('create', 'club', 'protocol')"
class="w-5 h-5 p-1 box-content cursor-pointer"
@click="removeSelected(member.id)"
@click="removeSelected(member.memberId)"
/>
</div>
</div>
@ -117,38 +123,31 @@ export default defineComponent({
...mapWritableState(useProtocolPresenceStore, ["presence", "loading"]),
...mapState(useMemberStore, ["members"]),
...mapState(useAbilityStore, ["can"]),
filtered(): Array<MemberViewModel> {
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<MemberViewModel> {
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<MemberViewModel> {
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);
}

View file

@ -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";
</script>
<script lang="ts">
@ -88,6 +92,10 @@ export default defineComponent({
},
mounted() {
this.fetchProtocolByActiveId();
this.fetchProtocolAgenda()
this.fetchProtocolDecision()
this.fetchProtocolPresence()
this.fetchProtocolVoting()
},
// this.syncState is undefined, so it will never work
// beforeRouteLeave(to, from, next) {
@ -108,6 +116,10 @@ export default defineComponent({
// },
methods: {
...mapActions(useProtocolStore, ["fetchProtocolByActiveId"]),
...mapActions(useProtocolAgendaStore, ["fetchProtocolAgenda"]),
...mapActions(useProtocolDecisionStore, ["fetchProtocolDecision"]),
...mapActions(useProtocolPresenceStore,["fetchProtocolPresence"]),
...mapActions(useProtocolVotingStore,["fetchProtocolVoting"]),
...mapActions(useModalStore, ["openModal"]),
openInfoModal() {
this.openModal(

View file

@ -90,7 +90,7 @@ export default defineComponent({
...mapState(useAbilityStore, ["can"]),
},
mounted() {
this.fetchProtocolVoting();
// this.fetchProtocolVoting();
},
methods: {
...mapActions(useProtocolVotingStore, ["fetchProtocolVoting", "createProtocolVoting"]),