enhancement syncing & protocol presence absence
This commit is contained in:
parent
5050011f29
commit
b106ea6396
17 changed files with 95 additions and 47 deletions
|
@ -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;
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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) => {});
|
||||
|
|
|
@ -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) => {
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue