2021-08-22 22:23:17 +02:00
|
|
|
<template>
|
2023-10-13 13:07:16 +02:00
|
|
|
<page-header title="Mitgliedschaften" @close="$emit('close')">
|
|
|
|
<template #toolbar>
|
2023-12-20 22:58:26 +01:00
|
|
|
<page-toolbar-button v-if="single === null" color="primary" icon="plus" @click.prevent="create">Neue
|
|
|
|
Mitgliedschaft</page-toolbar-button>
|
|
|
|
<page-toolbar-button v-if="single !== null" color="primary" icon="undo"
|
|
|
|
@click.prevent="single = null">Zurück</page-toolbar-button>
|
2023-10-13 13:07:16 +02:00
|
|
|
</template>
|
|
|
|
</page-header>
|
|
|
|
|
|
|
|
<form v-if="single" class="p-6 grid gap-4 justify-start" @submit.prevent="submit">
|
2023-12-20 22:58:26 +01:00
|
|
|
<f-select id="group_id" v-model="single.group_id" name="group_id" :options="meta.groups" label="Gruppierung"
|
|
|
|
required></f-select>
|
|
|
|
<f-select id="activity_id" v-model="single.activity_id" name="activity_id" :options="meta.activities"
|
|
|
|
label="Tätigkeit" required></f-select>
|
|
|
|
<f-select v-if="single.activity_id" id="subactivity_id" :model-value="single.subactivity_id" name="subactivity_id"
|
|
|
|
:options="meta.subactivities[single.activity_id]" label="Untertätigkeit"
|
|
|
|
@update:modelValue="setSubactivityId(single, $event)"></f-select>
|
|
|
|
<f-switch v-if="displayPromisedAt" id="has_promise" :model-value="single.promised_at !== null"
|
|
|
|
label="Hat Versprechen" @update:modelValue="setPromisedAtSwitch(single, $event)"></f-switch>
|
|
|
|
<f-text v-show="displayPromisedAt && single.promised_at !== null" id="promised_at" v-model="single.promised_at"
|
|
|
|
type="date" label="Versprechensdatum" size="sm"></f-text>
|
2023-10-13 13:07:16 +02:00
|
|
|
<button type="submit" class="btn btn-primary">Absenden</button>
|
|
|
|
</form>
|
|
|
|
|
|
|
|
<div v-else class="grow">
|
|
|
|
<table class="custom-table custom-table-light custom-table-sm text-sm">
|
|
|
|
<thead>
|
|
|
|
<th>Tätigkeit</th>
|
|
|
|
<th>Untertätigkeit</th>
|
|
|
|
<th>Datum</th>
|
|
|
|
<th>Aktiv</th>
|
|
|
|
<th></th>
|
|
|
|
</thead>
|
|
|
|
|
|
|
|
<tr v-for="(membership, index) in data" :key="index">
|
|
|
|
<td v-text="membership.activity_name"></td>
|
|
|
|
<td v-text="membership.subactivity_name"></td>
|
|
|
|
<td v-text="membership.human_date"></td>
|
|
|
|
<td><ui-boolean-display :value="membership.is_active" dark></ui-boolean-display></td>
|
|
|
|
<td class="flex space-x-1">
|
2023-12-20 22:58:26 +01:00
|
|
|
<a href="#" class="inline-flex btn btn-warning btn-sm" @click.prevent="edit(membership)"><ui-sprite
|
|
|
|
src="pencil"></ui-sprite></a>
|
|
|
|
<a href="#" class="inline-flex btn btn-danger btn-sm" @click.prevent="remove(membership)"><ui-sprite
|
|
|
|
src="trash"></ui-sprite></a>
|
2023-10-13 13:07:16 +02:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
2021-08-22 22:23:17 +02:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2023-09-12 16:54:13 +02:00
|
|
|
<script setup>
|
2023-12-20 22:58:26 +01:00
|
|
|
import { computed } from 'vue';
|
|
|
|
import dayjs from 'dayjs';
|
|
|
|
|
2023-10-13 13:07:16 +02:00
|
|
|
defineEmits(['close']);
|
2023-12-20 22:58:26 +01:00
|
|
|
import { useApiIndex } from '../../composables/useApiIndex.js';
|
2021-08-22 22:23:17 +02:00
|
|
|
|
2023-09-12 16:54:13 +02:00
|
|
|
const props = defineProps({
|
2023-10-13 13:07:16 +02:00
|
|
|
url: {
|
|
|
|
type: String,
|
2023-09-12 16:54:13 +02:00
|
|
|
required: true,
|
2023-02-25 19:49:53 +01:00
|
|
|
},
|
2023-09-12 16:54:13 +02:00
|
|
|
});
|
2023-12-20 22:58:26 +01:00
|
|
|
const { data, meta, reload, single, create, edit, submit, remove } = useApiIndex(props.url, 'membership');
|
|
|
|
|
|
|
|
function setPromisedAtSwitch(single, value) {
|
|
|
|
single.promised_at = value ? dayjs().format('YYYY-MM-DD') : null;
|
|
|
|
}
|
|
|
|
|
|
|
|
const displayPromisedAt = computed(function () {
|
|
|
|
if (!single.value || !single.value.activity_id || !single.value.subactivity_id) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return meta.value.subactivities[single.value.activity_id].find((s) => s.id === single.value.subactivity_id).is_age_group;
|
|
|
|
});
|
|
|
|
|
|
|
|
function setSubactivityId(single, value) {
|
|
|
|
single.subactivity_id = value;
|
|
|
|
|
|
|
|
return displayPromisedAt;
|
|
|
|
}
|
2023-02-25 19:49:53 +01:00
|
|
|
|
2023-10-13 13:07:16 +02:00
|
|
|
await reload();
|
2021-08-22 22:23:17 +02:00
|
|
|
</script>
|