Education views in member and config
This commit is contained in:
parent
3b89262ce9
commit
05ec4afadb
20 changed files with 1139 additions and 4 deletions
51
src/views/admin/club/members/MemberEducations.vue
Normal file
51
src/views/admin/club/members/MemberEducations.vue
Normal file
|
@ -0,0 +1,51 @@
|
|||
<template>
|
||||
<div class="flex flex-col gap-2 h-full w-full overflow-y-auto">
|
||||
<div v-if="memberEducations != null" class="flex flex-col gap-2 w-full">
|
||||
<MemberEducationListItem v-for="education in memberEducations" :key="education.id" :education="education" />
|
||||
</div>
|
||||
<Spinner v-if="loading == 'loading'" class="mx-auto" />
|
||||
<p v-else-if="loading == 'failed'" @click="fetchItem" class="cursor-pointer">↺ laden fehlgeschlagen</p>
|
||||
</div>
|
||||
<div class="flex flex-row gap-4">
|
||||
<button v-if="can('create', 'club', 'member')" primary class="w-fit!" @click="openCreateModal">
|
||||
Aus-/Fortbildung hinzufügen
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { defineAsyncComponent, defineComponent, markRaw } from "vue";
|
||||
import { mapActions, mapState } from "pinia";
|
||||
import Spinner from "@/components/Spinner.vue";
|
||||
import { useMemberEducationStore } from "@/stores/admin/club/member/memberEducation";
|
||||
import MemberEducationListItem from "@/components/admin/club/member/MemberEducationListItem.vue";
|
||||
import { useModalStore } from "@/stores/modal";
|
||||
import { useAbilityStore } from "@/stores/ability";
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default defineComponent({
|
||||
props: {
|
||||
memberId: String,
|
||||
},
|
||||
computed: {
|
||||
...mapState(useMemberEducationStore, ["memberEducations", "loading"]),
|
||||
...mapState(useAbilityStore, ["can"]),
|
||||
},
|
||||
mounted() {
|
||||
this.fetchItem();
|
||||
},
|
||||
methods: {
|
||||
...mapActions(useMemberEducationStore, ["fetchMemberEducationsForMember"]),
|
||||
...mapActions(useModalStore, ["openModal"]),
|
||||
fetchItem() {
|
||||
this.fetchMemberEducationsForMember();
|
||||
},
|
||||
openCreateModal() {
|
||||
this.openModal(
|
||||
markRaw(defineAsyncComponent(() => import("@/components/admin/club/member/MemberEducationCreateModal.vue")))
|
||||
);
|
||||
},
|
||||
},
|
||||
});
|
||||
</script>
|
|
@ -21,7 +21,7 @@
|
|||
<template #diffMain>
|
||||
<div class="flex flex-col gap-2 grow px-7 overflow-hidden">
|
||||
<div class="flex flex-col grow gap-2 overflow-hidden">
|
||||
<div class="w-full flex flex-row max-lg:flex-wrap justify-center">
|
||||
<div class="w-full flex flex-row max-lg:flex-wrap justify-center items-stretch">
|
||||
<RouterLink
|
||||
v-for="tab in tabs"
|
||||
:key="tab.route"
|
||||
|
@ -31,7 +31,7 @@
|
|||
>
|
||||
<p
|
||||
:class="[
|
||||
'w-full rounded-lg py-2.5 text-sm text-center font-medium leading-5 focus:ring-0 outline-hidden',
|
||||
'flex w-full h-full items-center justify-center rounded-lg py-2.5 text-sm text-center font-medium leading-5 focus:ring-0 outline-hidden',
|
||||
isActive ? 'bg-red-200 shadow-sm border-b-2 border-primary rounded-b-none' : ' hover:bg-red-200',
|
||||
]"
|
||||
>
|
||||
|
@ -68,8 +68,9 @@ export default defineComponent({
|
|||
{ route: "admin-club-member-overview", title: "Übersicht" },
|
||||
{ route: "admin-club-member-membership", title: "Mitgliedschaft" },
|
||||
{ route: "admin-club-member-communication", title: "Kommunikation" },
|
||||
{ route: "admin-club-member-awards", title: "Auszeichnungen" },
|
||||
{ route: "admin-club-member-qualifications", title: "Qualifikationen" },
|
||||
{ route: "admin-club-member-awards", title: "Auszeichnungen / Ehrungen" },
|
||||
{ route: "admin-club-member-educations", title: "Aus- / Fortbildungen" },
|
||||
{ route: "admin-club-member-qualifications", title: "Qualifikationen / Funktionen" },
|
||||
{ route: "admin-club-member-positions", title: "Vereinsämter" },
|
||||
],
|
||||
};
|
||||
|
|
49
src/views/admin/configuration/education/Education.vue
Normal file
49
src/views/admin/configuration/education/Education.vue
Normal file
|
@ -0,0 +1,49 @@
|
|||
<template>
|
||||
<MainTemplate title="Aus-/Fortbildungen">
|
||||
<template #diffMain>
|
||||
<div class="flex flex-col gap-4 h-full pl-7">
|
||||
<div class="flex flex-col gap-2 grow overflow-y-scroll pr-7">
|
||||
<EducationListItem v-for="education in educations" :key="education.id" :education="education" />
|
||||
</div>
|
||||
<div class="flex flex-row gap-4">
|
||||
<button v-if="can('create', 'configuration', 'education')" primary class="w-fit!" @click="openCreateModal">
|
||||
Aus-/Fortbildung erstellen
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</MainTemplate>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { defineComponent, defineAsyncComponent, markRaw } from "vue";
|
||||
import { mapState, mapActions } from "pinia";
|
||||
import MainTemplate from "@/templates/Main.vue";
|
||||
import { useEducationStore } from "@/stores/admin/configuration/education";
|
||||
import EducationListItem from "@/components/admin/configuration/education/EducationListItem.vue";
|
||||
import { useModalStore } from "@/stores/modal";
|
||||
import { useAbilityStore } from "@/stores/ability";
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default defineComponent({
|
||||
computed: {
|
||||
...mapState(useEducationStore, ["educations"]),
|
||||
...mapState(useAbilityStore, ["can"]),
|
||||
},
|
||||
mounted() {
|
||||
this.fetchEducations();
|
||||
},
|
||||
methods: {
|
||||
...mapActions(useEducationStore, ["fetchEducations"]),
|
||||
...mapActions(useModalStore, ["openModal"]),
|
||||
openCreateModal() {
|
||||
this.openModal(
|
||||
markRaw(
|
||||
defineAsyncComponent(() => import("@/components/admin/configuration/education/CreateEducationModal.vue"))
|
||||
)
|
||||
);
|
||||
},
|
||||
},
|
||||
});
|
||||
</script>
|
120
src/views/admin/configuration/education/EducationEdit.vue
Normal file
120
src/views/admin/configuration/education/EducationEdit.vue
Normal file
|
@ -0,0 +1,120 @@
|
|||
<template>
|
||||
<MainTemplate :title="`Aus-/Fortbildung ${origin?.education} - Daten bearbeiten`">
|
||||
<template #headerInsert>
|
||||
<RouterLink to="../" class="text-primary">zurück zur Liste (abbrechen)</RouterLink>
|
||||
</template>
|
||||
<template #main>
|
||||
<Spinner v-if="loading == 'loading'" class="mx-auto" />
|
||||
<p v-else-if="loading == 'failed'">laden fehlgeschlagen</p>
|
||||
<form
|
||||
v-else-if="education != null"
|
||||
class="flex flex-col gap-4 py-2 w-full max-w-xl mx-auto"
|
||||
@submit.prevent="triggerUpdate"
|
||||
>
|
||||
<div>
|
||||
<label for="education">Bezeichnung</label>
|
||||
<input type="text" id="education" required v-model="education.education" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="description">Beschreibung (optional)</label>
|
||||
<input type="text" id="description" v-model="education.description" />
|
||||
</div>
|
||||
<div class="flex flex-row justify-end gap-2">
|
||||
<button primary-outline type="reset" class="w-fit!" :disabled="canSaveOrReset" @click="resetForm">
|
||||
verwerfen
|
||||
</button>
|
||||
<button primary type="submit" class="w-fit!" :disabled="status == 'loading' || canSaveOrReset">
|
||||
speichern
|
||||
</button>
|
||||
<Spinner v-if="status == 'loading'" class="my-auto" />
|
||||
<SuccessCheckmark v-else-if="status?.status == 'success'" />
|
||||
<FailureXMark v-else-if="status?.status == 'failed'" />
|
||||
</div>
|
||||
</form>
|
||||
</template>
|
||||
</MainTemplate>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { defineComponent } from "vue";
|
||||
import { mapState, mapActions } from "pinia";
|
||||
import MainTemplate from "@/templates/Main.vue";
|
||||
import { useEducationStore } from "@/stores/admin/configuration/education";
|
||||
import Spinner from "@/components/Spinner.vue";
|
||||
import SuccessCheckmark from "@/components/SuccessCheckmark.vue";
|
||||
import FailureXMark from "@/components/FailureXMark.vue";
|
||||
import { RouterLink } from "vue-router";
|
||||
import type { UpdateEducationViewModel, EducationViewModel } from "@/viewmodels/admin/configuration/education.models";
|
||||
import cloneDeep from "lodash.clonedeep";
|
||||
import isEqual from "lodash.isequal";
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default defineComponent({
|
||||
props: {
|
||||
id: String,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
loading: "loading" as "loading" | "fetched" | "failed",
|
||||
status: null as null | "loading" | { status: "success" | "failed"; reason?: string },
|
||||
origin: null as null | EducationViewModel,
|
||||
education: null as null | EducationViewModel,
|
||||
timeout: null as any,
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
canSaveOrReset(): boolean {
|
||||
return isEqual(this.origin, this.education);
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.fetchItem();
|
||||
},
|
||||
beforeUnmount() {
|
||||
try {
|
||||
clearTimeout(this.timeout);
|
||||
} catch (error) {}
|
||||
},
|
||||
methods: {
|
||||
...mapActions(useEducationStore, ["fetchEducationById", "updateActiveEducation"]),
|
||||
resetForm() {
|
||||
this.education = cloneDeep(this.origin);
|
||||
},
|
||||
fetchItem() {
|
||||
this.fetchEducationById(parseInt(this.id ?? ""))
|
||||
.then((result) => {
|
||||
this.education = result.data;
|
||||
this.origin = cloneDeep(result.data);
|
||||
this.loading = "fetched";
|
||||
})
|
||||
.catch((err) => {
|
||||
this.loading = "failed";
|
||||
});
|
||||
},
|
||||
triggerUpdate(e: any) {
|
||||
if (this.education == null) return;
|
||||
let formData = e.target.elements;
|
||||
let updateEducation: UpdateEducationViewModel = {
|
||||
id: this.education.id,
|
||||
education: formData.education.value,
|
||||
description: formData.description.value,
|
||||
};
|
||||
this.status = "loading";
|
||||
this.updateActiveEducation(updateEducation)
|
||||
.then(() => {
|
||||
this.fetchItem();
|
||||
this.status = { status: "success" };
|
||||
})
|
||||
.catch((err) => {
|
||||
this.status = { status: "failed" };
|
||||
})
|
||||
.finally(() => {
|
||||
this.timeout = setTimeout(() => {
|
||||
this.status = null;
|
||||
}, 2000);
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue