CRUD base types
This commit is contained in:
parent
3cdc64674b
commit
0dd5ad09a8
43 changed files with 2457 additions and 26 deletions
90
src/stores/admin/award.ts
Normal file
90
src/stores/admin/award.ts
Normal file
|
@ -0,0 +1,90 @@
|
|||
import { defineStore } from "pinia";
|
||||
import type { CreateOrUpdateAwardViewModel, AwardViewModel } from "../../viewmodels/admin/award.models";
|
||||
import { http } from "../../serverCom";
|
||||
|
||||
export const useAwardStore = defineStore("award", {
|
||||
state: () => {
|
||||
return {
|
||||
awards: [] as Array<AwardViewModel>,
|
||||
award: null as null | AwardViewModel,
|
||||
loadingAll: "loading" as "loading" | "fetched" | "failed",
|
||||
loadingSingle: "loading" as "loading" | "fetched" | "failed",
|
||||
createStatus: null as null | "loading" | { status: "success" | "failed"; reason?: string },
|
||||
updateStatus: null as null | "loading" | { status: "success" | "failed"; reason?: string },
|
||||
deleteStatus: null as null | "loading" | { status: "success" | "failed"; reason?: string },
|
||||
};
|
||||
},
|
||||
actions: {
|
||||
resetStatus() {
|
||||
this.createStatus = null;
|
||||
this.updateStatus = null;
|
||||
this.deleteStatus = null;
|
||||
},
|
||||
fetchAwards() {
|
||||
this.loadingAll = "loading";
|
||||
http
|
||||
.get("/admin/award")
|
||||
.then((result) => {
|
||||
this.awards = result.data;
|
||||
this.loadingAll = "fetched";
|
||||
})
|
||||
.catch((err) => {
|
||||
this.loadingAll = "failed";
|
||||
});
|
||||
},
|
||||
fetchAwardById(id: number) {
|
||||
this.award = null;
|
||||
this.loadingSingle = "loading";
|
||||
http
|
||||
.get(`/admin/award/${id}`)
|
||||
.then((result) => {
|
||||
this.award = result.data;
|
||||
this.loadingSingle = "fetched";
|
||||
})
|
||||
.catch((err) => {
|
||||
this.loadingSingle = "failed";
|
||||
});
|
||||
},
|
||||
createAward(award: CreateOrUpdateAwardViewModel) {
|
||||
this.createStatus = "loading";
|
||||
http
|
||||
.post(`/admin/award`, {
|
||||
award: award.award,
|
||||
})
|
||||
.then((result) => {
|
||||
this.createStatus = { status: "success" };
|
||||
this.fetchAwards();
|
||||
})
|
||||
.catch((err) => {
|
||||
this.createStatus = { status: "failed" };
|
||||
});
|
||||
},
|
||||
updateActiveAward(award: CreateOrUpdateAwardViewModel) {
|
||||
if (this.award == null) return;
|
||||
this.updateStatus = "loading";
|
||||
http
|
||||
.patch(`/admin/award/${this.award.id}`, {
|
||||
award: award.award,
|
||||
})
|
||||
.then((result) => {
|
||||
this.updateStatus = { status: "success" };
|
||||
this.fetchAwards();
|
||||
})
|
||||
.catch((err) => {
|
||||
this.updateStatus = { status: "failed" };
|
||||
});
|
||||
},
|
||||
deleteAward(award: number) {
|
||||
this.deleteStatus = "loading";
|
||||
http
|
||||
.delete(`/admin/award/${award}`)
|
||||
.then((res) => {
|
||||
this.deleteStatus = { status: "success" };
|
||||
this.fetchAwards();
|
||||
})
|
||||
.catch((err) => {
|
||||
this.deleteStatus = { status: "failed", reason: err.data };
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
109
src/stores/admin/communicationType.ts
Normal file
109
src/stores/admin/communicationType.ts
Normal file
|
@ -0,0 +1,109 @@
|
|||
import { defineStore } from "pinia";
|
||||
import type {
|
||||
CreateOrUpdateCommunicationTypeViewModel,
|
||||
CommunicationTypeViewModel,
|
||||
} from "../../viewmodels/admin/communicationType.models";
|
||||
import { http } from "../../serverCom";
|
||||
|
||||
export const useCommunicationTypeStore = defineStore("communicationType", {
|
||||
state: () => {
|
||||
return {
|
||||
communicationTypes: [] as Array<CommunicationTypeViewModel>,
|
||||
communicationType: null as null | CommunicationTypeViewModel,
|
||||
availableFields: [] as Array<string>,
|
||||
loadingAll: "loading" as "loading" | "fetched" | "failed",
|
||||
loadingSingle: "loading" as "loading" | "fetched" | "failed",
|
||||
loadingFields: "loading" as "loading" | "fetched" | "failed",
|
||||
createStatus: null as null | "loading" | { status: "success" | "failed"; reason?: string },
|
||||
updateStatus: null as null | "loading" | { status: "success" | "failed"; reason?: string },
|
||||
deleteStatus: null as null | "loading" | { status: "success" | "failed"; reason?: string },
|
||||
};
|
||||
},
|
||||
actions: {
|
||||
resetStatus() {
|
||||
this.createStatus = null;
|
||||
this.updateStatus = null;
|
||||
this.deleteStatus = null;
|
||||
},
|
||||
fetchCommunicationTypes() {
|
||||
this.loadingAll = "loading";
|
||||
http
|
||||
.get("/admin/communicationType")
|
||||
.then((result) => {
|
||||
this.communicationTypes = result.data;
|
||||
this.loadingAll = "fetched";
|
||||
})
|
||||
.catch((err) => {
|
||||
this.loadingAll = "failed";
|
||||
});
|
||||
},
|
||||
fetchCommunicationTypeById(id: number) {
|
||||
this.communicationType = null;
|
||||
this.loadingSingle = "loading";
|
||||
http
|
||||
.get(`/admin/communicationType/${id}`)
|
||||
.then((result) => {
|
||||
this.communicationType = result.data;
|
||||
this.loadingSingle = "fetched";
|
||||
})
|
||||
.catch((err) => {
|
||||
this.loadingSingle = "failed";
|
||||
});
|
||||
},
|
||||
fetchAvailableFields() {
|
||||
this.loadingFields = "loading";
|
||||
http
|
||||
.get("/admin/communicationType/fields")
|
||||
.then((result) => {
|
||||
this.availableFields = result.data;
|
||||
this.loadingFields = "fetched";
|
||||
})
|
||||
.catch((err) => {
|
||||
this.loadingFields = "failed";
|
||||
});
|
||||
},
|
||||
createCommunicationType(communicationType: CreateOrUpdateCommunicationTypeViewModel) {
|
||||
this.createStatus = "loading";
|
||||
http
|
||||
.post(`/admin/communicationType`, {
|
||||
communicationType: communicationType.type,
|
||||
fields: communicationType.fields,
|
||||
})
|
||||
.then((result) => {
|
||||
this.createStatus = { status: "success" };
|
||||
this.fetchCommunicationTypes();
|
||||
})
|
||||
.catch((err) => {
|
||||
this.createStatus = { status: "failed" };
|
||||
});
|
||||
},
|
||||
updateActiveCommunicationType(communicationType: CreateOrUpdateCommunicationTypeViewModel) {
|
||||
if (this.communicationType == null) return;
|
||||
this.updateStatus = "loading";
|
||||
http
|
||||
.patch(`/admin/communicationType/${this.communicationType.id}`, {
|
||||
communicationType: communicationType.type,
|
||||
fields: communicationType.fields,
|
||||
})
|
||||
.then((result) => {
|
||||
this.updateStatus = { status: "success" };
|
||||
this.fetchCommunicationTypes();
|
||||
})
|
||||
.catch((err) => {
|
||||
this.updateStatus = { status: "failed" };
|
||||
});
|
||||
},
|
||||
deleteCommunicationType(communicationType: number) {
|
||||
this.deleteStatus = "loading";
|
||||
http
|
||||
.delete(`/admin/communicationType/${communicationType}`)
|
||||
.then((res) => {
|
||||
this.deleteStatus = { status: "success" };
|
||||
this.fetchCommunicationTypes();
|
||||
})
|
||||
.catch((err) => {
|
||||
this.deleteStatus = { status: "failed", reason: err.data };
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
93
src/stores/admin/executivePosition.ts
Normal file
93
src/stores/admin/executivePosition.ts
Normal file
|
@ -0,0 +1,93 @@
|
|||
import { defineStore } from "pinia";
|
||||
import type {
|
||||
CreateOrUpdateExecutivePositionViewModel,
|
||||
ExecutivePositionViewModel,
|
||||
} from "../../viewmodels/admin/executivePosition.models";
|
||||
import { http } from "../../serverCom";
|
||||
|
||||
export const useExecutivePositionStore = defineStore("executivePosition", {
|
||||
state: () => {
|
||||
return {
|
||||
executivePositions: [] as Array<ExecutivePositionViewModel>,
|
||||
executivePosition: null as null | ExecutivePositionViewModel,
|
||||
loadingAll: "loading" as "loading" | "fetched" | "failed",
|
||||
loadingSingle: "loading" as "loading" | "fetched" | "failed",
|
||||
createStatus: null as null | "loading" | { status: "success" | "failed"; reason?: string },
|
||||
updateStatus: null as null | "loading" | { status: "success" | "failed"; reason?: string },
|
||||
deleteStatus: null as null | "loading" | { status: "success" | "failed"; reason?: string },
|
||||
};
|
||||
},
|
||||
actions: {
|
||||
resetStatus() {
|
||||
this.createStatus = null;
|
||||
this.updateStatus = null;
|
||||
this.deleteStatus = null;
|
||||
},
|
||||
fetchExecutivePositions() {
|
||||
this.loadingAll = "loading";
|
||||
http
|
||||
.get("/admin/executivePosition")
|
||||
.then((result) => {
|
||||
this.executivePositions = result.data;
|
||||
this.loadingAll = "fetched";
|
||||
})
|
||||
.catch((err) => {
|
||||
this.loadingAll = "failed";
|
||||
});
|
||||
},
|
||||
fetchExecutivePositionById(id: number) {
|
||||
this.executivePosition = null;
|
||||
this.loadingSingle = "loading";
|
||||
http
|
||||
.get(`/admin/executivePosition/${id}`)
|
||||
.then((result) => {
|
||||
this.executivePosition = result.data;
|
||||
this.loadingSingle = "fetched";
|
||||
})
|
||||
.catch((err) => {
|
||||
this.loadingSingle = "failed";
|
||||
});
|
||||
},
|
||||
createExecutivePosition(executivePosition: CreateOrUpdateExecutivePositionViewModel) {
|
||||
this.createStatus = "loading";
|
||||
http
|
||||
.post(`/admin/executivePosition`, {
|
||||
executivePosition: executivePosition.position,
|
||||
})
|
||||
.then((result) => {
|
||||
this.createStatus = { status: "success" };
|
||||
this.fetchExecutivePositions();
|
||||
})
|
||||
.catch((err) => {
|
||||
this.createStatus = { status: "failed" };
|
||||
});
|
||||
},
|
||||
updateActiveExecutivePosition(executivePosition: CreateOrUpdateExecutivePositionViewModel) {
|
||||
if (this.executivePosition == null) return;
|
||||
this.updateStatus = "loading";
|
||||
http
|
||||
.patch(`/admin/executivePosition/${this.executivePosition.id}`, {
|
||||
executivePosition: executivePosition.position,
|
||||
})
|
||||
.then((result) => {
|
||||
this.updateStatus = { status: "success" };
|
||||
this.fetchExecutivePositions();
|
||||
})
|
||||
.catch((err) => {
|
||||
this.updateStatus = { status: "failed" };
|
||||
});
|
||||
},
|
||||
deleteExecutivePosition(executivePosition: number) {
|
||||
this.deleteStatus = "loading";
|
||||
http
|
||||
.delete(`/admin/executivePosition/${executivePosition}`)
|
||||
.then((res) => {
|
||||
this.deleteStatus = { status: "success" };
|
||||
this.fetchExecutivePositions();
|
||||
})
|
||||
.catch((err) => {
|
||||
this.deleteStatus = { status: "failed", reason: err.data };
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
93
src/stores/admin/membershipStatus.ts
Normal file
93
src/stores/admin/membershipStatus.ts
Normal file
|
@ -0,0 +1,93 @@
|
|||
import { defineStore } from "pinia";
|
||||
import type {
|
||||
CreateOrUpdateMembershipStatusViewModel,
|
||||
MembershipStatusViewModel,
|
||||
} from "../../viewmodels/admin/membershipStatus.models";
|
||||
import { http } from "../../serverCom";
|
||||
|
||||
export const useMembershipStatusStore = defineStore("membershipStatus", {
|
||||
state: () => {
|
||||
return {
|
||||
membershipStatuss: [] as Array<MembershipStatusViewModel>,
|
||||
membershipStatus: null as null | MembershipStatusViewModel,
|
||||
loadingAll: "loading" as "loading" | "fetched" | "failed",
|
||||
loadingSingle: "loading" as "loading" | "fetched" | "failed",
|
||||
createStatus: null as null | "loading" | { status: "success" | "failed"; reason?: string },
|
||||
updateStatus: null as null | "loading" | { status: "success" | "failed"; reason?: string },
|
||||
deleteStatus: null as null | "loading" | { status: "success" | "failed"; reason?: string },
|
||||
};
|
||||
},
|
||||
actions: {
|
||||
resetStatus() {
|
||||
this.createStatus = null;
|
||||
this.updateStatus = null;
|
||||
this.deleteStatus = null;
|
||||
},
|
||||
fetchMembershipStatuss() {
|
||||
this.loadingAll = "loading";
|
||||
http
|
||||
.get("/admin/membershipStatus")
|
||||
.then((result) => {
|
||||
this.membershipStatuss = result.data;
|
||||
this.loadingAll = "fetched";
|
||||
})
|
||||
.catch((err) => {
|
||||
this.loadingAll = "failed";
|
||||
});
|
||||
},
|
||||
fetchMembershipStatusById(id: number) {
|
||||
this.membershipStatus = null;
|
||||
this.loadingSingle = "loading";
|
||||
http
|
||||
.get(`/admin/membershipStatus/${id}`)
|
||||
.then((result) => {
|
||||
this.membershipStatus = result.data;
|
||||
this.loadingSingle = "fetched";
|
||||
})
|
||||
.catch((err) => {
|
||||
this.loadingSingle = "failed";
|
||||
});
|
||||
},
|
||||
createMembershipStatus(membershipStatus: CreateOrUpdateMembershipStatusViewModel) {
|
||||
this.createStatus = "loading";
|
||||
http
|
||||
.post(`/admin/membershipStatus`, {
|
||||
membershipStatus: membershipStatus.status,
|
||||
})
|
||||
.then((result) => {
|
||||
this.createStatus = { status: "success" };
|
||||
this.fetchMembershipStatuss();
|
||||
})
|
||||
.catch((err) => {
|
||||
this.createStatus = { status: "failed" };
|
||||
});
|
||||
},
|
||||
updateActiveMembershipStatus(membershipStatus: CreateOrUpdateMembershipStatusViewModel) {
|
||||
if (this.membershipStatus == null) return;
|
||||
this.updateStatus = "loading";
|
||||
http
|
||||
.patch(`/admin/membershipStatus/${this.membershipStatus.id}`, {
|
||||
membershipStatus: membershipStatus.status,
|
||||
})
|
||||
.then((result) => {
|
||||
this.updateStatus = { status: "success" };
|
||||
this.fetchMembershipStatuss();
|
||||
})
|
||||
.catch((err) => {
|
||||
this.updateStatus = { status: "failed" };
|
||||
});
|
||||
},
|
||||
deleteMembershipStatus(membershipStatus: number) {
|
||||
this.deleteStatus = "loading";
|
||||
http
|
||||
.delete(`/admin/membershipStatus/${membershipStatus}`)
|
||||
.then((res) => {
|
||||
this.deleteStatus = { status: "success" };
|
||||
this.fetchMembershipStatuss();
|
||||
})
|
||||
.catch((err) => {
|
||||
this.deleteStatus = { status: "failed", reason: err.data };
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
|
@ -103,7 +103,10 @@ export const useNavigationStore = defineStore("navigation", {
|
|||
? [{ key: "executive_position", title: "Vereinsämter" }]
|
||||
: []),
|
||||
...(abilityStore.can("read", "settings", "communication")
|
||||
? [{ key: "communication", title: "Mitgliederdaten" }]
|
||||
? [{ key: "communication", title: "Kommunikationsarten" }]
|
||||
: []),
|
||||
...(abilityStore.can("read", "settings", "membership_status")
|
||||
? [{ key: "membership_status", title: "Mitgliedsstatus" }]
|
||||
: []),
|
||||
],
|
||||
},
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
import { defineStore } from "pinia";
|
||||
|
||||
export const usePermissionStore = defineStore("permission", {
|
||||
state: () => {
|
||||
return {
|
||||
sections: [],
|
||||
};
|
||||
},
|
||||
actions: {
|
||||
logoutAccount() {},
|
||||
},
|
||||
});
|
95
src/stores/admin/qualification.ts
Normal file
95
src/stores/admin/qualification.ts
Normal file
|
@ -0,0 +1,95 @@
|
|||
import { defineStore } from "pinia";
|
||||
import type {
|
||||
CreateOrUpdateQualificationViewModel,
|
||||
QualificationViewModel,
|
||||
} from "../../viewmodels/admin/qualification.models";
|
||||
import { http } from "../../serverCom";
|
||||
|
||||
export const useQualificationStore = defineStore("qualification", {
|
||||
state: () => {
|
||||
return {
|
||||
qualifications: [] as Array<QualificationViewModel>,
|
||||
qualification: null as null | QualificationViewModel,
|
||||
loadingAll: "loading" as "loading" | "fetched" | "failed",
|
||||
loadingSingle: "loading" as "loading" | "fetched" | "failed",
|
||||
createStatus: null as null | "loading" | { status: "success" | "failed"; reason?: string },
|
||||
updateStatus: null as null | "loading" | { status: "success" | "failed"; reason?: string },
|
||||
deleteStatus: null as null | "loading" | { status: "success" | "failed"; reason?: string },
|
||||
};
|
||||
},
|
||||
actions: {
|
||||
resetStatus() {
|
||||
this.createStatus = null;
|
||||
this.updateStatus = null;
|
||||
this.deleteStatus = null;
|
||||
},
|
||||
fetchQualifications() {
|
||||
this.loadingAll = "loading";
|
||||
http
|
||||
.get("/admin/qualification")
|
||||
.then((result) => {
|
||||
this.qualifications = result.data;
|
||||
this.loadingAll = "fetched";
|
||||
})
|
||||
.catch((err) => {
|
||||
this.loadingAll = "failed";
|
||||
});
|
||||
},
|
||||
fetchQualificationById(id: number) {
|
||||
this.qualification = null;
|
||||
this.loadingSingle = "loading";
|
||||
http
|
||||
.get(`/admin/qualification/${id}`)
|
||||
.then((result) => {
|
||||
this.qualification = result.data;
|
||||
this.loadingSingle = "fetched";
|
||||
})
|
||||
.catch((err) => {
|
||||
this.loadingSingle = "failed";
|
||||
});
|
||||
},
|
||||
createQualification(qualification: CreateOrUpdateQualificationViewModel) {
|
||||
this.createStatus = "loading";
|
||||
http
|
||||
.post(`/admin/qualification`, {
|
||||
qualification: qualification.qualification,
|
||||
description: qualification.description,
|
||||
})
|
||||
.then((result) => {
|
||||
this.createStatus = { status: "success" };
|
||||
this.fetchQualifications();
|
||||
})
|
||||
.catch((err) => {
|
||||
this.createStatus = { status: "failed" };
|
||||
});
|
||||
},
|
||||
updateActiveQualification(qualification: CreateOrUpdateQualificationViewModel) {
|
||||
if (this.qualification == null) return;
|
||||
this.updateStatus = "loading";
|
||||
http
|
||||
.patch(`/admin/qualification/${this.qualification.id}`, {
|
||||
qualification: qualification.qualification,
|
||||
description: qualification.description,
|
||||
})
|
||||
.then((result) => {
|
||||
this.updateStatus = { status: "success" };
|
||||
this.fetchQualifications();
|
||||
})
|
||||
.catch((err) => {
|
||||
this.updateStatus = { status: "failed" };
|
||||
});
|
||||
},
|
||||
deleteQualification(qualification: number) {
|
||||
this.deleteStatus = "loading";
|
||||
http
|
||||
.delete(`/admin/qualification/${qualification}`)
|
||||
.then((res) => {
|
||||
this.deleteStatus = { status: "success" };
|
||||
this.fetchQualifications();
|
||||
})
|
||||
.catch((err) => {
|
||||
this.deleteStatus = { status: "failed", reason: err.data };
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue