--wip-- [skip ci]

This commit is contained in:
philipp lang 2024-09-21 15:22:26 +02:00
parent 78920e8aef
commit 11530c575b
7 changed files with 195 additions and 170 deletions

View File

@ -155,6 +155,7 @@ class MemberResource extends JsonResource
'members' => Member::ordered()->get()->map(fn ($member) => ['id' => $member->id, 'name' => $member->fullname]), 'members' => Member::ordered()->get()->map(fn ($member) => ['id' => $member->id, 'name' => $member->fullname]),
'links' => [ 'links' => [
'index' => route('member.index'), 'index' => route('member.index'),
'store' => route('member.store'),
], ],
'default_membership_filter' => [ 'default_membership_filter' => [
'group_ids' => [], 'group_ids' => [],

View File

@ -92,6 +92,8 @@ services:
socketi: socketi:
image: quay.io/soketi/soketi:89604f268623cf799573178a7ba56b7491416bde-16-debian image: quay.io/soketi/soketi:89604f268623cf799573178a7ba56b7491416bde-16-debian
ports:
- '6001:6001'
environment: environment:
SOKETI_DEFAULT_APP_ID: adremaid SOKETI_DEFAULT_APP_ID: adremaid
SOKETI_DEFAULT_APP_KEY: adremakey SOKETI_DEFAULT_APP_KEY: adremakey
@ -104,6 +106,8 @@ services:
meilisearch: meilisearch:
image: getmeili/meilisearch:v1.6 image: getmeili/meilisearch:v1.6
ports:
- '7700:7700'
volumes: volumes:
- ./data/meilisearch:/meili_data - ./data/meilisearch:/meili_data
env_file: env_file:

View File

@ -4,7 +4,7 @@
class="relative rounded-lg p-8 bg-zinc-800 shadow-2xl shadow-black border border-zinc-700 border-solid w-full max-h-full flex flex-col overflow-auto" class="relative rounded-lg p-8 bg-zinc-800 shadow-2xl shadow-black border border-zinc-700 border-solid w-full max-h-full flex flex-col overflow-auto"
:class="full ? 'h-full' : innerWidth" :class="full ? 'h-full' : innerWidth"
> >
<div class="absolute top-0 right-0 mt-6 mr-6 flex space-x-6"> <div class="absolute top-0 right-0 mt-6 mr-6 flex space-x-6 group is-toolbar">
<slot name="actions"></slot> <slot name="actions"></slot>
<a href="#" @click.prevent="$emit('close')"> <a href="#" @click.prevent="$emit('close')">
<ui-sprite src="close" class="text-zinc-400 w-6 h-6"></ui-sprite> <ui-sprite src="close" class="text-zinc-400 w-6 h-6"></ui-sprite>

View File

@ -58,7 +58,11 @@ export function useIndex(props, siteName) {
single.value = JSON.parse(JSON.stringify(model)); single.value = JSON.parse(JSON.stringify(model));
} }
async function submit() { async function submit(data = null) {
if (data !== null) {
single.value = data;
}
single.value.id ? await axios.patch(single.value.links.update, single.value) : await axios.post(inner.meta.value.links.store, single.value); single.value.id ? await axios.patch(single.value.links.update, single.value) : await axios.post(inner.meta.value.links.store, single.value);
reload(); reload();
single.value = null; single.value = null;
@ -105,6 +109,7 @@ export function useIndex(props, siteName) {
axios, axios,
setFilter, setFilter,
getFilter, getFilter,
filterString,
}; };
} }

View File

@ -1,5 +1,5 @@
<template> <template>
<page-layout> <!--
<template #toolbar> <template #toolbar>
<page-toolbar-button :href="meta.links.index" color="primary" icon="undo">zurück</page-toolbar-button> <page-toolbar-button :href="meta.links.index" color="primary" icon="undo">zurück</page-toolbar-button>
<page-toolbar-button v-if="mode === 'edit'" :href="data.links.show" color="primary" icon="eye">anschauen</page-toolbar-button> <page-toolbar-button v-if="mode === 'edit'" :href="data.links.show" color="primary" icon="eye">anschauen</page-toolbar-button>
@ -7,20 +7,21 @@
<template #right> <template #right>
<f-save-button form="memberedit"></f-save-button> <f-save-button form="memberedit"></f-save-button>
</template> </template>
-->
<form id="memberedit" class="flex grow relative" @submit.prevent="submit"> <form id="memberedit" class="flex grow relative" @submit.prevent="submit">
<ui-popup v-if="conflict === true" heading="Ein Konflikt ist aufgetreten"> <ui-popup v-if="conflict === true" heading="Ein Konflikt ist aufgetreten">
<div> <div>
<p class="mt-4">Dieses Mitglied wurde vorher bereits aktualisiert. Daher könnte ein Update zu Datenverlust führen.</p> <p>Dieses Mitglied wurde vorher bereits aktualisiert. Daher könnte ein Update zu Datenverlust führen.</p>
<p class="mt-2">Wir empfehlen, die Daten aus NaMi zunächst neu zu synchronisieren und dann die Änderungen hier in der Adrema erneut vorzunehmen.</p> <p class="mt-2">Wir empfehlen, die Daten aus NaMi zunächst neu zu synchronisieren und dann die Änderungen hier in der Adrema erneut vorzunehmen.</p>
<div class="grid grid-cols-2 gap-3 mt-6"> <div class="grid grid-cols-2 gap-3 mt-6">
<a href="#" class="text-center btn btn-primary" @click.prevent="resync">Neu synchronisieren</a> <a href="#" class="text-center btn btn-primary" @click.prevent="load">Neu synchronisieren</a>
<a href="#" class="text-center btn btn-danger" @click.prevent="forceWrite">Änderungen schreiben</a> <a href="#" class="text-center btn btn-danger" @click.prevent="forceWrite">Änderungen schreiben</a>
</div> </div>
</div> </div>
</ui-popup> </ui-popup>
<!-- ***************************** Hauptbereich ****************************** --> <!-- ***************************** Hauptbereich ****************************** -->
<div class="grow grid md:grid-cols-2 gap-3 p-3"> <div class="grow grid md:grid-cols-2 gap-3">
<ui-box heading="Stammdaten"> <ui-box heading="Stammdaten">
<div class="grid sm:grid-cols-2 gap-3"> <div class="grid sm:grid-cols-2 gap-3">
<div class="grid grid-cols-2 gap-3"> <div class="grid grid-cols-2 gap-3">
@ -60,7 +61,7 @@
<f-switch id="send_newspaper" v-model="inner.send_newspaper" name="send_newspaper" label="Mittendrin versenden" size="sm"></f-switch> <f-switch id="send_newspaper" v-model="inner.send_newspaper" name="send_newspaper" label="Mittendrin versenden" size="sm"></f-switch>
<f-text id="joined_at" v-model="inner.joined_at" class="sm:col-span-2" type="date" label="Eintrittsdatum" size="sm" required></f-text> <f-text id="joined_at" v-model="inner.joined_at" class="sm:col-span-2" type="date" label="Eintrittsdatum" size="sm" required></f-text>
<f-textarea id="comment" v-model="inner.comment" :rows="3" class="col-span-2" label="Kommentar" size="sm"></f-textarea> <f-textarea id="comment" v-model="inner.comment" :rows="3" class="col-span-2" label="Kommentar" size="sm"></f-textarea>
<div v-if="mode === 'create' || (original.has_nami === false && inner.has_nami === true)" class="contents"> <div v-if="!inner.id || (original.has_nami === false && inner.has_nami === true)" class="contents">
<f-select <f-select
id="first_activity_id" id="first_activity_id"
v-model="inner.first_activity_id" v-model="inner.first_activity_id"
@ -129,53 +130,56 @@
</ui-box> </ui-box>
</div> </div>
</form> </form>
</page-layout>
</template> </template>
<script> <script setup>
import {ref, computed, inject} from 'vue';
const axios = inject('axios');
const emit = defineEmits(['submit']);
function issetComputed(val) { function issetComputed(val) {
return { return {
set(v) { set(v) {
this.inner[val] = v ? '' : null; inner.value[val] = v ? '' : null;
}, },
get() { get() {
return this.inner[val] !== null; return inner.value[val] !== null;
}, },
}; };
} }
export default { const props = defineProps({
props: {
mode: {},
data: {}, data: {},
conflict: {}, conflict: {},
model: {},
meta: {}, meta: {},
}, });
data: function () {
return {
original: this.mode === 'create' ? {...this.meta.default} : {...this.data},
inner: this.mode === 'create' ? {...this.meta.default} : {...this.data},
active: 0,
};
},
methods: { const inner = ref({});
submit() { const original = ref({});
this.mode === 'create' ? this.$inertia.post(`/member`, this.inner) : this.$inertia.patch(`/member/${this.inner.id}`, this.inner); const activeTab = ref(0);
}, const tabs = ref([{title: 'Kontakt'}, {title: 'System'}, {title: 'Prävention'}]);
resync() {
this.$inertia.get(`/member/${this.inner.id}/resync`);
},
forceWrite() {},
},
computed: { async function load() {
hasEfz: issetComputed('efz'), if (props.model.id) {
hasPs: issetComputed('ps_at'), const response = await axios.get(props.model.links.show);
hasMorePs: issetComputed('more_ps_at'), inner.value = response.data.data;
isRecertified: issetComputed('recertified_at'), } else {
hasWithoutEfz: issetComputed('without_efz_at'), inner.value = props.model;
hasWithoutEducation: issetComputed('without_education_at'), original.value = props.model;
}, }
}; }
await load();
async function submit() {
emit('submit', inner.value);
}
const hasEfz = computed(issetComputed('efz'));
const hasPs = computed(issetComputed('ps_at'));
const hasMorePs = computed(issetComputed('more_ps_at'));
const isRecertified = computed(issetComputed('recertified_at'));
const hasWithoutEfz = computed(issetComputed('without_efz_at'));
const hasWithoutEducation = computed(issetComputed('without_education_at'));
</script> </script>

View File

@ -1,11 +1,17 @@
<template> <template>
<page-layout page-class="pb-6"> <page-layout page-class="pb-6">
<template #toolbar> <template #toolbar>
<page-toolbar-button :href="meta.links.create" color="primary" icon="plus">Mitglied anlegen</page-toolbar-button> <page-toolbar-button color="primary" icon="plus" @click="create">Mitglied anlegen</page-toolbar-button>
</template> </template>
<ui-popup v-if="single !== null" :heading="single.id ? 'Mitglied bearbeiten' : 'Mitglied erstellen'" full @close="cancel">
<v-form :meta="meta" :model="single" @submit="submit"></v-form>
<template #actions>
<f-save-button form="memberedit"></f-save-button>
</template>
</ui-popup>
<ui-popup v-if="deleting !== null" heading="Mitglied löschen?" @close="deleting.reject()"> <ui-popup v-if="deleting !== null" heading="Mitglied löschen?" @close="deleting.reject()">
<div> <div>
<p class="mt-4">Das Mitglied "{{ deleting.member.fullname }}" löschen?</p> <p>Das Mitglied "{{ deleting.member.fullname }}" löschen?</p>
<p class="mt-2">Alle Zuordnungen (Ausbildungen, Rechnungen, Zahlungen, Tätigkeiten) werden ebenfalls entfernt.</p> <p class="mt-2">Alle Zuordnungen (Ausbildungen, Rechnungen, Zahlungen, Tätigkeiten) werden ebenfalls entfernt.</p>
<ui-note v-if="!deleting.member.has_nami" class="mt-5" type="warning"> Dieses Mitglied ist nicht in NaMi vorhanden und wird daher nur in der AdReMa gelöscht werden. </ui-note> <ui-note v-if="!deleting.member.has_nami" class="mt-5" type="warning"> Dieses Mitglied ist nicht in NaMi vorhanden und wird daher nur in der AdReMa gelöscht werden. </ui-note>
<ui-note v-if="deleting.member.has_nami" class="mt-5" type="danger"> <ui-note v-if="deleting.member.has_nami" class="mt-5" type="danger">
@ -18,7 +24,7 @@
</div> </div>
</ui-popup> </ui-popup>
<ui-popup v-if="membershipFilters !== null" heading="Nach Mitgliedschaften filtern" full @close="membershipFilters = null"> <ui-popup v-if="membershipFilters !== null" heading="Nach Mitgliedschaften filtern" full @close="membershipFilters = null">
<button class="btn btn-primary label mt-2" @click.prevent="membershipFilters.push({...meta.default_membership_filter})"> <button class="btn btn-primary label" @click.prevent="membershipFilters.push({...meta.default_membership_filter})">
<ui-sprite class="w-3 h-3 xl:mr-2" src="plus"></ui-sprite> <ui-sprite class="w-3 h-3 xl:mr-2" src="plus"></ui-sprite>
<span class="hidden xl:inline">Hinzufügen</span> <span class="hidden xl:inline">Hinzufügen</span>
</button> </button>
@ -109,7 +115,7 @@
<ui-label :value="member.pending_payment" fallback="---"></ui-label> <ui-label :value="member.pending_payment" fallback="---"></ui-label>
</td> </td>
<td> <td>
<actions :member="member" @sidebar="openSidebar($event, member)" @remove="remove(member)"></actions> <actions :member="member" @sidebar="openSidebar($event, member)" @edit="edit(member)" @show="show(member)" @remove="remove(member)"></actions>
</td> </td>
</tr> </tr>
</table> </table>
@ -124,7 +130,7 @@
<tags :member="member"></tags> <tags :member="member"></tags>
<ui-label v-show="hasModule('bill')" class="text-gray-100 block" :value="member.pending_payment" fallback=""></ui-label> <ui-label v-show="hasModule('bill')" class="text-gray-100 block" :value="member.pending_payment" fallback=""></ui-label>
</div> </div>
<actions class="mt-2" :member="member" @sidebar="openSidebar($event, member)" @remove="remove(member)"> </actions> <actions class="mt-2" :member="member" @sidebar="openSidebar($event, member)" @edit="edit(member)" @remove="remove(member)"> </actions>
<div class="absolute right-0 top-0 h-full flex items-center mr-2"> <div class="absolute right-0 top-0 h-full flex items-center mr-2">
<i-link v-tooltip="`Details`" :href="member.links.show"><ui-sprite src="chevron" class="w-6 h-6 text-teal-100 -rotate-90"></ui-sprite></i-link> <i-link v-tooltip="`Details`" :href="member.links.show"><ui-sprite src="chevron" class="w-6 h-6 text-teal-100 -rotate-90"></ui-sprite></i-link>
</div> </div>
@ -135,10 +141,10 @@
<ui-pagination class="mt-4" :value="meta" @reload="reloadPage"></ui-pagination> <ui-pagination class="mt-4" :value="meta" @reload="reloadPage"></ui-pagination>
</div> </div>
<ui-sidebar v-if="single !== null" @close="closeSidebar"> <ui-sidebar v-if="sidebar !== null" @close="closeSidebar">
<member-invoice-positions v-if="single.type === 'invoicePosition'" :url="single.model.links.invoiceposition_index" @close="closeSidebar"></member-invoice-positions> <member-invoice-positions v-if="sidebar.type === 'invoicePosition'" :url="sidebar.model.links.invoiceposition_index" @close="closeSidebar"></member-invoice-positions>
<member-memberships v-if="single.type === 'membership'" :url="single.model.links.membership_index" @close="closeSidebar"></member-memberships> <member-memberships v-if="sidebar.type === 'membership'" :url="sidebar.model.links.membership_index" @close="closeSidebar"></member-memberships>
<member-courses v-if="single.type === 'courses'" :url="single.model.links.course_index" @close="closeSidebar"></member-courses> <member-courses v-if="sidebar.type === 'courses'" :url="sidebar.model.links.course_index" @close="closeSidebar"></member-courses>
</ui-sidebar> </ui-sidebar>
</page-layout> </page-layout>
</template> </template>
@ -149,20 +155,25 @@ import MemberMemberships from './MemberMemberships.vue';
import MemberCourses from './MemberCourses.vue'; import MemberCourses from './MemberCourses.vue';
import Tags from './Tags.vue'; import Tags from './Tags.vue';
import Actions from './index/Actions.vue'; import Actions from './index/Actions.vue';
import { indexProps, useIndex } from '../../composables/useIndex.js'; import VForm from './VForm.vue';
import { indexProps, useIndex } from '../../composables/useInertiaApiIndex.js';
import { ref, defineProps } from 'vue'; import { ref, defineProps } from 'vue';
const single = ref(null); const sidebar = ref(null);
const deleting = ref(null); const deleting = ref(null);
const membershipFilters = ref(null); const membershipFilters = ref(null);
const props = defineProps(indexProps); const props = defineProps(indexProps);
var { router, data, meta, getFilter, setFilter, filterString, reloadPage } = useIndex(props.data, 'member'); var { router, data, meta, getFilter, setFilter, reloadPage, edit, create, single, cancel, submit, filterString } = useIndex(props.data, 'member');
function exportMembers() { function exportMembers() {
window.open(`/member-export?filter=${filterString.value}`); window.open(`/member-export?filter=${filterString.value}`);
} }
function show(member) {
console.log(member);
}
async function remove(member) { async function remove(member) {
new Promise((resolve, reject) => { new Promise((resolve, reject) => {
deleting.value = { resolve, reject, member }; deleting.value = { resolve, reject, member };
@ -175,12 +186,12 @@ async function remove(member) {
} }
function openSidebar(type, model) { function openSidebar(type, model) {
single.value = { sidebar.value = {
type: type, type: type,
model: model, model: model,
}; };
} }
function closeSidebar() { function closeSidebar() {
single.value = null; sidebar.value = null;
} }
</script> </script>

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="flex space-x-1"> <div class="flex space-x-1">
<i-link v-tooltip="`Details`" :href="member.links.show" class="inline-flex btn btn-primary btn-sm"><ui-sprite src="eye"></ui-sprite></i-link> <a v-tooltip="`Details`" href="#" class="inline-flex btn btn-primary btn-sm" @click.prevent="$emit('show')"><ui-sprite src="eye"></ui-sprite></a>
<i-link v-tooltip="`Bearbeiten`" :href="member.links.edit" class="inline-flex btn btn-warning btn-sm"><ui-sprite src="pencil"></ui-sprite></i-link> <a v-tooltip="`Bearbeiten`" href="#" class="inline-flex btn btn-warning btn-sm" @click.prevent="$emit('edit')"><ui-sprite src="pencil"></ui-sprite></a>
<a v-show="hasModule('bill')" v-tooltip="`Zahlungen`" href="#" class="inline-flex btn btn-info btn-sm" @click.prevent="$emit('sidebar', 'invoicePosition')" <a v-show="hasModule('bill')" v-tooltip="`Zahlungen`" href="#" class="inline-flex btn btn-info btn-sm" @click.prevent="$emit('sidebar', 'invoicePosition')"
><ui-sprite src="money"></ui-sprite ><ui-sprite src="money"></ui-sprite
></a> ></a>