syncing agenda
This commit is contained in:
parent
52deb253c1
commit
c0bfc00862
12 changed files with 221 additions and 62 deletions
|
@ -21,7 +21,8 @@ export const useProtocolStore = defineStore("protocol", {
|
|||
};
|
||||
},
|
||||
getters: {
|
||||
detectedChangeProtocol: (state) => !isEqual(state.origin, state.activeProtocolObj),
|
||||
detectedChangeProtocol: (state) =>
|
||||
!isEqual(state.origin, state.activeProtocolObj) && state.syncingProtocol != "syncing",
|
||||
},
|
||||
actions: {
|
||||
setProtocolSyncingState(state: "synced" | "syncing" | "detectedChanges" | "failed") {
|
||||
|
@ -80,7 +81,7 @@ export const useProtocolStore = defineStore("protocol", {
|
|||
|
||||
this.syncingProtocol = "syncing";
|
||||
await http
|
||||
.put(`/admin/protocol/${this.origin.id}/synchronize`, {
|
||||
.patch(`/admin/protocol/${this.origin.id}/synchronize`, {
|
||||
title: this.activeProtocolObj.title,
|
||||
date: this.activeProtocolObj.date,
|
||||
starttime: this.activeProtocolObj.starttime,
|
||||
|
@ -96,7 +97,6 @@ export const useProtocolStore = defineStore("protocol", {
|
|||
this.fetchProtocolById(this.origin.id)
|
||||
.then((res) => {
|
||||
this.origin = res.data;
|
||||
this.activeProtocolObj = cloneDeep(this.origin);
|
||||
})
|
||||
.catch((err) => {});
|
||||
},
|
||||
|
|
|
@ -1,42 +1,82 @@
|
|||
import { defineStore } from "pinia";
|
||||
import { http } from "@/serverCom";
|
||||
import type { AxiosResponse } from "axios";
|
||||
import type {
|
||||
ProtocolAgendaViewModel,
|
||||
SyncProtocolAgendaViewModel,
|
||||
} from "../../viewmodels/admin/protocolAgenda.models";
|
||||
import { useProtocolStore } from "./protocol";
|
||||
import cloneDeep from "lodash.clonedeep";
|
||||
import isEqual from "lodash.isEqual";
|
||||
import differenceWith from "lodash.differencewith";
|
||||
|
||||
export const useProtocolAgendaStore = defineStore("protocolAgenda", {
|
||||
state: () => {
|
||||
return {
|
||||
agenda: [] as Array<ProtocolAgendaViewModel>,
|
||||
origin: [] as Array<ProtocolAgendaViewModel>,
|
||||
loading: "loading" as "loading" | "fetched" | "failed",
|
||||
syncingProtocolAgenda: "synced" as "synced" | "syncing" | "detectedChanges" | "failed",
|
||||
};
|
||||
},
|
||||
getters: {
|
||||
detectedChangeProtocolAgenda: (state) =>
|
||||
!isEqual(state.origin, state.agenda) && state.syncingProtocolAgenda != "syncing",
|
||||
},
|
||||
actions: {
|
||||
setProtocolAgendaSyncingState(state: "synced" | "syncing" | "detectedChanges" | "failed") {
|
||||
this.syncingProtocolAgenda = state;
|
||||
},
|
||||
fetchProtocolAgenda() {
|
||||
const protocolId = useProtocolStore().activeProtocol;
|
||||
this.loading = "loading";
|
||||
http
|
||||
.get(`/admin/protocol/${protocolId}/agenda`)
|
||||
this.fetchProtocolAgendaPromise()
|
||||
.then((result) => {
|
||||
this.agenda = result.data;
|
||||
this.origin = result.data;
|
||||
this.agenda = cloneDeep(this.origin);
|
||||
this.loading = "fetched";
|
||||
})
|
||||
.catch((err) => {
|
||||
this.loading = "failed";
|
||||
});
|
||||
},
|
||||
async synchronizeActiveProtocolAgenda(
|
||||
agenda: Array<SyncProtocolAgendaViewModel>
|
||||
): Promise<AxiosResponse<any, any>> {
|
||||
fetchProtocolAgendaPromise() {
|
||||
const protocolId = useProtocolStore().activeProtocol;
|
||||
const result = await http.patch(`/admin/protocol/${protocolId}/synchronize/agenda`, {
|
||||
agenda: agenda,
|
||||
});
|
||||
this.fetchProtocolAgenda();
|
||||
return result;
|
||||
return http.get(`/admin/protocol/${protocolId}/agenda`);
|
||||
},
|
||||
createProtocolAgenda() {
|
||||
const protocolId = useProtocolStore().activeProtocol;
|
||||
if (protocolId == null) return;
|
||||
return http
|
||||
.post(`/admin/protocol/${protocolId}/agenda`)
|
||||
.then((res) => {
|
||||
this.agenda.push({
|
||||
id: res.data,
|
||||
topic: "",
|
||||
context: "",
|
||||
protocolId,
|
||||
});
|
||||
})
|
||||
.catch((err) => {});
|
||||
},
|
||||
async synchronizeActiveProtocolAgenda() {
|
||||
this.syncingProtocolAgenda = "syncing";
|
||||
const protocolId = useProtocolStore().activeProtocol;
|
||||
console.log(this.agenda, this.origin, differenceWith(this.agenda, this.origin, isEqual));
|
||||
|
||||
await http
|
||||
.patch(`/admin/protocol/${protocolId}/synchronize/agenda`, {
|
||||
agenda: differenceWith(this.agenda, this.origin, isEqual),
|
||||
})
|
||||
.then((res) => {
|
||||
this.syncingProtocolAgenda = "synced";
|
||||
})
|
||||
.catch((err) => {
|
||||
this.syncingProtocolAgenda = "failed";
|
||||
});
|
||||
this.fetchProtocolAgendaPromise()
|
||||
.then((res) => {
|
||||
this.origin = res.data;
|
||||
})
|
||||
.catch((err) => {});
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
@ -6,6 +6,9 @@ import type {
|
|||
SyncProtocolDecisionViewModel,
|
||||
} from "../../viewmodels/admin/protocolDecision.models";
|
||||
import { useProtocolStore } from "./protocol";
|
||||
import cloneDeep from "lodash.clonedeep";
|
||||
import isEqual from "lodash.isEqual";
|
||||
import difference from "lodash.difference";
|
||||
|
||||
export const useProtocolDecisionStore = defineStore("protocolDecision", {
|
||||
state: () => {
|
||||
|
|
|
@ -6,37 +6,60 @@ import type {
|
|||
SyncProtocolPresenceViewModel,
|
||||
} from "../../viewmodels/admin/protocolPresence.models";
|
||||
import { useProtocolStore } from "./protocol";
|
||||
import cloneDeep from "lodash.clonedeep";
|
||||
import isEqual from "lodash.isEqual";
|
||||
|
||||
export const useProtocolPresenceStore = defineStore("protocolPresence", {
|
||||
state: () => {
|
||||
return {
|
||||
presence: [] as Array<ProtocolPresenceViewModel>,
|
||||
presence: [] as Array<number>,
|
||||
origin: [] as Array<number>,
|
||||
loading: "loading" as "loading" | "fetched" | "failed",
|
||||
syncingProtocolPresence: "synced" as "synced" | "syncing" | "detectedChanges" | "failed",
|
||||
};
|
||||
},
|
||||
getters: {
|
||||
detectedChangeProtocolPresence: (state) =>
|
||||
!isEqual(state.origin, state.presence) && state.syncingProtocolPresence != "syncing",
|
||||
},
|
||||
actions: {
|
||||
setProtocolPresenceSyncingState(state: "synced" | "syncing" | "detectedChanges" | "failed") {
|
||||
this.syncingProtocolPresence = state;
|
||||
},
|
||||
fetchProtocolPresence() {
|
||||
const protocolId = useProtocolStore().activeProtocol;
|
||||
this.loading = "loading";
|
||||
http
|
||||
.get(`/admin/protocol/${protocolId}/presence`)
|
||||
this.fetchProtocolPresencePromise()
|
||||
.then((result) => {
|
||||
this.presence = result.data;
|
||||
this.origin = result.data.map((d: ProtocolPresenceViewModel) => d.memberId);
|
||||
this.presence = cloneDeep(this.origin);
|
||||
this.loading = "fetched";
|
||||
})
|
||||
.catch((err) => {
|
||||
this.loading = "failed";
|
||||
});
|
||||
},
|
||||
async synchronizeActiveProtocolPresence(
|
||||
presence: Array<SyncProtocolPresenceViewModel>
|
||||
): Promise<AxiosResponse<any, any>> {
|
||||
fetchProtocolPresencePromise() {
|
||||
const protocolId = useProtocolStore().activeProtocol;
|
||||
const result = await http.patch(`/admin/protocol/${protocolId}/synchronize/presence`, {
|
||||
presence: presence,
|
||||
});
|
||||
this.fetchProtocolPresence();
|
||||
return result;
|
||||
return http.get(`/admin/protocol/${protocolId}/presence`);
|
||||
},
|
||||
async synchronizeActiveProtocolPresence() {
|
||||
this.syncingProtocolPresence = "syncing";
|
||||
const protocolId = useProtocolStore().activeProtocol;
|
||||
await http
|
||||
.put(`/admin/protocol/${protocolId}/synchronize/presence`, {
|
||||
presence: this.presence,
|
||||
})
|
||||
.then((res) => {
|
||||
this.syncingProtocolPresence = "synced";
|
||||
})
|
||||
.catch((err) => {
|
||||
this.syncingProtocolPresence = "failed";
|
||||
});
|
||||
this.fetchProtocolPresencePromise()
|
||||
.then((result) => {
|
||||
this.origin = result.data.map((d: ProtocolPresenceViewModel) => d.memberId);
|
||||
})
|
||||
.catch((err) => {});
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
@ -6,6 +6,9 @@ import type {
|
|||
SyncProtocolVotingViewModel,
|
||||
} from "../../viewmodels/admin/protocolVoting.models";
|
||||
import { useProtocolStore } from "./protocol";
|
||||
import cloneDeep from "lodash.clonedeep";
|
||||
import isEqual from "lodash.isEqual";
|
||||
import difference from "lodash.difference";
|
||||
|
||||
export const useProtocolVotingStore = defineStore("protocolVoting", {
|
||||
state: () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue