From c1a6c0040de957631234a3a8f89cc402cdc6224c Mon Sep 17 00:00:00 2001 From: Julian Krauser Date: Mon, 16 Sep 2024 19:03:52 +0200 Subject: [PATCH] basic member pagination --- .../admin/club/member/MemberListItem.vue | 51 +++++++ src/enums/salutation.ts | 6 + src/router/index.ts | 6 +- src/stores/admin/member.ts | 43 ++++++ src/stores/admin/navigation.ts | 4 +- src/viewmodels/admin/communication.models.ts | 14 ++ src/viewmodels/admin/member.models.ts | 13 ++ src/viewmodels/admin/memberAward.models.ts | 7 + .../admin/memberExecutivePosition.models.ts | 7 + .../admin/memberQualification.models.ts | 8 + src/viewmodels/admin/membership.models.ts | 8 + src/views/admin/members/Member.vue | 140 ++++++++++++++++++ 12 files changed, 302 insertions(+), 5 deletions(-) create mode 100644 src/components/admin/club/member/MemberListItem.vue create mode 100644 src/enums/salutation.ts create mode 100644 src/stores/admin/member.ts create mode 100644 src/viewmodels/admin/communication.models.ts create mode 100644 src/viewmodels/admin/member.models.ts create mode 100644 src/viewmodels/admin/memberAward.models.ts create mode 100644 src/viewmodels/admin/memberExecutivePosition.models.ts create mode 100644 src/viewmodels/admin/memberQualification.models.ts create mode 100644 src/viewmodels/admin/membership.models.ts create mode 100644 src/views/admin/members/Member.vue diff --git a/src/components/admin/club/member/MemberListItem.vue b/src/components/admin/club/member/MemberListItem.vue new file mode 100644 index 0000000..65e2fb7 --- /dev/null +++ b/src/components/admin/club/member/MemberListItem.vue @@ -0,0 +1,51 @@ + + + + + diff --git a/src/enums/salutation.ts b/src/enums/salutation.ts new file mode 100644 index 0000000..214bb85 --- /dev/null +++ b/src/enums/salutation.ts @@ -0,0 +1,6 @@ +export enum Salutation { + Sir = "sir", + Madam = "madam", + other = "other", + none = "none", +} diff --git a/src/router/index.ts b/src/router/index.ts index 733fc10..07341d5 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -65,9 +65,9 @@ const router = createRouter({ }, { path: "members", - name: "admin-club-members", - component: () => import("../views/admin/members/Overview.vue"), - meta: { type: "read", section: "club", module: "members" }, + name: "admin-club-member", + component: () => import("../views/admin/members/Member.vue"), + meta: { type: "read", section: "club", module: "member" }, beforeEnter: [abilityAndNavUpdate], }, { diff --git a/src/stores/admin/member.ts b/src/stores/admin/member.ts new file mode 100644 index 0000000..a741484 --- /dev/null +++ b/src/stores/admin/member.ts @@ -0,0 +1,43 @@ +import { defineStore } from "pinia"; +import type { CreateAwardViewModel, UpdateAwardViewModel, AwardViewModel } from "../../viewmodels/admin/award.models"; +import { http } from "../../serverCom"; +import type { AxiosResponse } from "axios"; +import type { MemberViewModel } from "../../viewmodels/admin/member.models"; + +export const useMemberStore = defineStore("member", { + state: () => { + return { + members: [] as Array, + totalCount: 0 as number, + loading: "loading" as "loading" | "fetched" | "failed", + activeMember: null as null | MemberViewModel, + }; + }, + actions: { + fetchMembers(offset = 0, count = 25, clear = false) { + if (clear) this.members = []; + this.loading = "loading"; + http + .get(`/admin/member?offset=${offset}&count=${count}`) + .then((result) => { + this.members = result.data.members; + this.totalCount = result.data.total; + result.data.members + .filter((elem: MemberViewModel) => this.members.findIndex((m) => m.id == elem.id) == -1) + .map((elem: MemberViewModel, index: number): MemberViewModel & { tab_pos: number } => { + return { + ...elem, + tab_pos: index + offset, + }; + }) + .forEach((elem: MemberViewModel & { tab_pos: number }) => { + this.members.push(elem); + }); + this.loading = "fetched"; + }) + .catch((err) => { + this.loading = "failed"; + }); + }, + }, +}); diff --git a/src/stores/admin/navigation.ts b/src/stores/admin/navigation.ts index bb3d4f9..0cf9964 100644 --- a/src/stores/admin/navigation.ts +++ b/src/stores/admin/navigation.ts @@ -54,7 +54,7 @@ export const useNavigationStore = defineStore("navigation", { { key: "club", title: "Verein", - levelDefault: "members", + levelDefault: "member", } as topLevelNavigationModel, ] : []), @@ -86,7 +86,7 @@ export const useNavigationStore = defineStore("navigation", { club: { mainTitle: "Verein", main: [ - ...(abilityStore.can("read", "club", "members") ? [{ key: "members", title: "Mitglieder" }] : []), + ...(abilityStore.can("read", "club", "member") ? [{ key: "member", title: "Mitglieder" }] : []), ...(abilityStore.can("read", "club", "calendar") ? [{ key: "calendar", title: "Termine" }] : []), ...(abilityStore.can("read", "club", "newsletter") ? [{ key: "newsletter", title: "Newsletter" }] : []), ...(abilityStore.can("read", "club", "protocoll") ? [{ key: "protocol", title: "Protokolle" }] : []), diff --git a/src/viewmodels/admin/communication.models.ts b/src/viewmodels/admin/communication.models.ts new file mode 100644 index 0000000..794fdcf --- /dev/null +++ b/src/viewmodels/admin/communication.models.ts @@ -0,0 +1,14 @@ +import type { CommunicationTypeViewModel } from "./communicationType.models"; + +export interface CommunicationViewModel { + id: number; + preferred: boolean; + mobile: string; + email: string; + city: string; + street: string; + streetNumber: number; + streetNumberAddition: string; + type: CommunicationTypeViewModel; + isNewsletterMain: boolean; +} diff --git a/src/viewmodels/admin/member.models.ts b/src/viewmodels/admin/member.models.ts new file mode 100644 index 0000000..9920fcb --- /dev/null +++ b/src/viewmodels/admin/member.models.ts @@ -0,0 +1,13 @@ +import { Salutation } from "../../enums/salutation"; +import type { MembershipViewModel } from "./membership.models"; + +export interface MemberViewModel { + id: number; + salutation: Salutation; + firstname: string; + lastname: string; + nameaffix: string; + birthdate: Date; + firstMembershipEntry?: MembershipViewModel; + lastMembershipEntry?: MembershipViewModel; +} diff --git a/src/viewmodels/admin/memberAward.models.ts b/src/viewmodels/admin/memberAward.models.ts new file mode 100644 index 0000000..fc8f447 --- /dev/null +++ b/src/viewmodels/admin/memberAward.models.ts @@ -0,0 +1,7 @@ +export interface MemberAwardViewModel { + id: number; + given: boolean; + note?: string; + date: Date; + award: string; +} diff --git a/src/viewmodels/admin/memberExecutivePosition.models.ts b/src/viewmodels/admin/memberExecutivePosition.models.ts new file mode 100644 index 0000000..6830216 --- /dev/null +++ b/src/viewmodels/admin/memberExecutivePosition.models.ts @@ -0,0 +1,7 @@ +export interface MemberExecutivePositionViewModel { + id: number; + note?: string; + start: Date; + end?: Date; + executivePosition: string; +} diff --git a/src/viewmodels/admin/memberQualification.models.ts b/src/viewmodels/admin/memberQualification.models.ts new file mode 100644 index 0000000..53c7bca --- /dev/null +++ b/src/viewmodels/admin/memberQualification.models.ts @@ -0,0 +1,8 @@ +export interface MemberQualificationViewModel { + id: number; + note?: string; + start: Date; + end?: Date; + terminationReason?: string; + qualification: string; +} diff --git a/src/viewmodels/admin/membership.models.ts b/src/viewmodels/admin/membership.models.ts new file mode 100644 index 0000000..d8a5305 --- /dev/null +++ b/src/viewmodels/admin/membership.models.ts @@ -0,0 +1,8 @@ +export interface MembershipViewModel { + id: number; + internalId?: string; + start: Date; + end?: Date; + terminationReason?: string; + status: string; +} diff --git a/src/views/admin/members/Member.vue b/src/views/admin/members/Member.vue new file mode 100644 index 0000000..1f457e8 --- /dev/null +++ b/src/views/admin/members/Member.vue @@ -0,0 +1,140 @@ + + + + +