adrema/resources/js/views/form/Index.vue

205 lines
10 KiB
Vue
Raw Normal View History

2024-01-01 18:29:33 +01:00
<template>
<page-layout>
<template #toolbar>
2024-02-02 01:05:45 +01:00
<page-toolbar-button :href="meta.links.formtemplate_index" color="primary" icon="event">Vorlagen</page-toolbar-button>
<page-toolbar-button color="primary" icon="plus" @click.prevent="create">Veranstaltung erstellen</page-toolbar-button>
2024-01-01 18:29:33 +01:00
</template>
<ui-popup v-if="deleting !== null" :heading="`Veranstaltung ${deleting.name} löschen?`" @close="deleting = null">
<div>
<p class="mt-4">Diese Veranstaltung löschen?</p>
<div class="grid grid-cols-2 gap-3 mt-6">
2024-02-02 01:05:45 +01:00
<a
href="#"
class="text-center btn btn-danger"
@click.prevent="
remove(deleting);
deleting = null;
"
>Veranstaltung löschen</a
>
2024-01-01 18:29:33 +01:00
<a href="#" class="text-center btn btn-primary" @click.prevent="deleting = null">Abbrechen</a>
</div>
</div>
</ui-popup>
<ui-popup v-if="single !== null && single.config === null" heading="Vorlage auswählen" @close="cancel">
<div class="mt-3 grid gap-3 grid-cols-2">
2024-02-02 01:05:45 +01:00
<a v-for="(template, index) in meta.templates" :key="index" class="py-2 px-3 border rounded bg-zinc-800 hover:bg-zinc-700 transition" href="#" @click.prevent="setTemplate(template)">
2024-01-01 18:29:33 +01:00
<span v-text="template.name"></span>
</a>
</div>
</ui-popup>
2024-02-08 23:09:51 +01:00
<ui-popup v-if="showing !== null" :heading="`Teilnehmende für ${showing.name}`" full @close="showing = null">
<participants :url="showing.links.participant_index"></participants>
</ui-popup>
2024-02-02 01:05:45 +01:00
<ui-popup v-if="single !== null && single.config !== null" :heading="`Veranstaltung ${single.id ? 'bearbeiten' : 'erstellen'}`" full @close="cancel">
2024-01-01 18:29:33 +01:00
<div class="flex flex-col mt-3">
<ui-tabs v-model="active" :entries="tabs"></ui-tabs>
<div v-show="active === 0" class="grid grid-cols-2 gap-3">
2024-01-13 21:53:39 +01:00
<f-text id="name" v-model="single.name" name="name" label="Name" required></f-text>
2024-02-02 01:05:45 +01:00
<f-singlefile
id="header_image"
v-model="single.header_image"
label="Bild"
name="header_image"
parent-name="form"
:parent-id="single.id"
collection="headerImage"
required
></f-singlefile>
2024-01-01 18:29:33 +01:00
<f-text id="from" v-model="single.from" type="date" name="from" label="Von" required></f-text>
<f-text id="to" v-model="single.to" type="date" name="to" label="Bis" required></f-text>
2024-02-02 01:05:45 +01:00
<f-textarea
id="excerpt"
v-model="single.excerpt"
2024-01-01 18:29:33 +01:00
hint="Gebe hier eine kurze Beschreibung für die Veranstaltungs-Übersicht ein (Maximal 130 Zeichen)."
2024-02-02 01:05:45 +01:00
name="excerpt"
label="Auszug"
rows="5"
required
></f-textarea>
<f-editor id="description" v-model="single.description" name="description" label="Beschreibung" rows="10" required></f-editor>
2024-01-01 18:29:33 +01:00
</div>
2024-04-19 14:58:49 +02:00
<div v-if="active === 1">
2024-02-02 01:05:45 +01:00
<ui-note class="mt-2"> Sobald sich der erste Teilnehmer für die Veranstaltung angemeldet hat, kann dieses Formular nicht mehr geändert werden. </ui-note>
2024-01-01 18:29:33 +01:00
<form-builder v-model="single.config" :meta="meta"></form-builder>
</div>
<div v-show="active === 2" class="grid grid-cols-[1fr_300px] gap-3">
<ui-note class="mt-2 col-span-full">
2024-01-01 18:29:33 +01:00
Hier kannst du die E-Mail anpassen, die nach der Anmeldung an den Teilnehmer verschickt wird.<br />
2024-02-02 01:05:45 +01:00
Es gibt dafür einen ersten E-Mail-Teil und einen zweiten E-Mail-Teil. Dazwischen werden die Daten des Teilnehmers aufgelistet.<br />
Die Anrede ("Hallo Max Mustermann") wird automatisch an den Anfang gesetzt.<br />
Außerdem kannst du Dateien hochladen, die automatisch mit angehangen werden.
</ui-note>
2024-04-19 13:49:47 +02:00
<div>
<ui-tabs v-model="activeMailTab" :entries="mailTabs"></ui-tabs>
<f-editor v-if="activeMailTab === 0" id="mail_top" v-model="single.mail_top" name="mail_top" label="E-Mail-Teil 1" rows="8" conditions required>
<template #conditions="{data, resolve}">
<conditions :single="single" :value="data" @save="resolve"> </conditions>
</template>
</f-editor>
<f-editor v-if="activeMailTab === 1" id="mail_bottom" v-model="single.mail_bottom" name="mail_bottom" label="E-Mail-Teil 2" rows="8" conditions required>
<template #conditions="{data, resolve}">
<conditions :single="single" :value="data" @save="resolve"> </conditions>
</template>
</f-editor>
</div>
<f-multiplefiles
id="mailattachments"
v-model="single.mailattachments"
label="Anhänge"
name="mailattachments"
parent-name="form"
:parent-id="single.id"
collection="mailattachments"
class="row-span-2"
2024-04-18 22:15:28 +02:00
>
<template #buttons="{file, buttonClass, iconClass}">
<a v-tooltip="`Bedingungen`" href="#" :class="[buttonClass, 'bg-blue-200', 'relative']" @click.prevent="fileSettingPopup = file">
<div v-if="file.properties.conditions.length" class="absolute w-2 h-2 -mt-[0.05rem] -ml-[0.05rem] flex-none bg-red-900 rounded-full top-0 left-0"></div>
<ui-sprite src="setting" :class="[iconClass, 'text-blue-800']"></ui-sprite>
</a>
</template>
</f-multiplefiles>
2024-01-01 18:29:33 +01:00
</div>
</div>
<template #actions>
<a href="#" @click.prevent="submit">
<ui-sprite src="save" class="text-zinc-400 w-6 h-6"></ui-sprite>
</a>
</template>
</ui-popup>
2024-04-19 13:49:47 +02:00
<ui-popup v-if="fileSettingPopup !== null" :heading="`Bedingungen für Datei ${fileSettingPopup.name}`" @close="fileSettingPopup = null">
<conditions :single="single" :value="fileSettingPopup.properties.conditions" @save="saveFileConditions"> </conditions>
2024-04-18 22:15:28 +02:00
</ui-popup>
2024-01-29 22:07:33 +01:00
<page-filter breakpoint="xl">
2024-02-02 01:05:45 +01:00
<f-text id="search" :model-value="getFilter('search')" name="search" label="Suchen …" size="sm" @update:model-value="setFilter('search', $event)"></f-text>
<f-switch id="past" :model-value="getFilter('past')" label="vergangene zeigen" size="sm" @update:model-value="setFilter('past', $event)"></f-switch>
2024-01-29 22:07:33 +01:00
</page-filter>
2024-01-01 18:29:33 +01:00
<table cellspacing="0" cellpadding="0" border="0" class="custom-table custom-table-sm">
<thead>
<th>Name</th>
2024-01-29 21:56:01 +01:00
<th>Von</th>
<th>Bis</th>
2024-02-08 20:29:46 +01:00
<th>Anzahl TN</th>
2024-01-01 18:29:33 +01:00
<th></th>
</thead>
<tr v-for="(form, index) in data" :key="index">
<td>
<div v-text="form.name"></div>
</td>
2024-01-29 21:56:01 +01:00
<td>
<div v-text="form.from_human"></div>
</td>
<td>
<div v-text="form.to_human"></div>
</td>
2024-02-08 20:29:46 +01:00
<td>
<div v-text="form.participants_count"></div>
</td>
2024-01-01 18:29:33 +01:00
<td>
2024-04-11 22:53:26 +02:00
<div class="flex space-x-2">
<ui-action-button tooltip="Bearbeiten" class="btn-warning" icon="pencil" @click.prevent="edit(form)"></ui-action-button>
<ui-action-button tooltip="Teilnehmende anzeigen" class="btn-info" icon="user" @click.prevent="showParticipants(form)"></ui-action-button>
<ui-action-button tooltip="Löschen" class="btn-danger" icon="trash" @click.prevent="deleting = form"></ui-action-button>
</div>
2024-01-01 18:29:33 +01:00
</td>
</tr>
</table>
<div class="px-6">
<ui-pagination class="mt-4" :value="meta" @reload="reloadPage"></ui-pagination>
</div>
</page-layout>
</template>
<script setup>
2024-04-19 13:49:47 +02:00
import {ref, inject} from 'vue';
2024-02-02 01:05:45 +01:00
import {indexProps, useIndex} from '../../composables/useInertiaApiIndex.js';
2024-01-01 18:29:33 +01:00
import FormBuilder from '../formtemplate/FormBuilder.vue';
2024-02-08 23:09:51 +01:00
import Participants from './Participants.vue';
2024-04-19 13:49:47 +02:00
import Conditions from './Conditions.vue';
import {useToast} from 'vue-toastification';
2024-01-01 18:29:33 +01:00
const props = defineProps(indexProps);
2024-02-02 01:05:45 +01:00
var {meta, data, reloadPage, create, single, edit, cancel, submit, remove, getFilter, setFilter} = useIndex(props.data, 'form');
2024-04-19 13:49:47 +02:00
const axios = inject('axios');
const toast = useToast();
2024-01-01 18:29:33 +01:00
const active = ref(0);
2024-04-19 13:49:47 +02:00
const activeMailTab = ref(0);
2024-01-01 18:29:33 +01:00
const deleting = ref(null);
2024-02-08 23:09:51 +01:00
const showing = ref(null);
2024-04-18 22:15:28 +02:00
const fileSettingPopup = ref(null);
2024-01-01 18:29:33 +01:00
2024-02-02 01:05:45 +01:00
const tabs = [{title: 'Allgemeines'}, {title: 'Formular'}, {title: 'E-Mail'}, {title: 'Export'}];
2024-04-19 13:49:47 +02:00
const mailTabs = [{title: 'vor Daten'}, {title: 'nach Daten'}];
2024-01-01 18:29:33 +01:00
function setTemplate(template) {
active.value = 0;
single.value.config = template.config;
}
2024-02-08 23:09:51 +01:00
2024-04-19 13:49:47 +02:00
async function saveFileConditions(conditions) {
await axios.patch(`/mediaupload/${fileSettingPopup.value.id}`, {
properties: {
...fileSettingPopup.value.properties,
conditions: conditions,
},
});
fileSettingPopup.value = null;
toast.success('Datei aktualisiert');
}
2024-02-08 23:09:51 +01:00
function showParticipants(form) {
showing.value = form;
}
2024-01-01 18:29:33 +01:00
</script>