Merge pull request '#18-public-calendar' (#19) from #18-public-calendar into main

Reviewed-on: Ehrenamt/member-administration-ui#19
This commit is contained in:
Julian Krauser 2024-12-12 14:04:28 +00:00
commit 94b9e7daff
19 changed files with 428 additions and 9 deletions

View file

@ -5,13 +5,17 @@
>
<div class="w-full flex flex-row gap-2 h-full align-middle">
<TopLevelLink
v-if="routeName.includes('admin-')"
v-if="routeName == 'admin' || routeName.includes('admin-')"
v-for="item in topLevel"
:key="item.key"
:link="item"
:disableSubLink="true"
/>
<TopLevelLink v-else :link="{ key: 'club', title: 'Zur Verwaltung', levelDefault: '' }" :disableSubLink="true" />
<TopLevelLink
v-else-if="routeName == 'account' || routeName.includes('account-')"
:link="{ key: 'club', title: 'Zur Verwaltung', levelDefault: '' }"
:disableSubLink="true"
/>
</div>
</footer>
</template>

View file

@ -6,9 +6,14 @@
</RouterLink>
<div class="flex flex-row gap-2 items-center">
<div v-if="authCheck" class="hidden md:flex flex-row gap-2 h-full align-middle">
<TopLevelLink v-if="routeName.includes('admin-')" v-for="item in topLevel" :key="item.key" :link="item" />
<TopLevelLink
v-else-if="routeName.includes('account-')"
v-if="routeName == 'admin' || routeName.includes('admin-')"
v-for="item in topLevel"
:key="item.key"
:link="item"
/>
<TopLevelLink
v-else-if="routeName == 'account' || routeName.includes('account-')"
:link="{ key: 'club', title: 'Zur Verwaltung', levelDefault: '' }"
:disable-sub-link="true"
/>

View file

@ -0,0 +1,138 @@
<template>
<div class="relative w-full md:max-w-md">
<div class="flex flex-col items-center">
<p class="text-xl font-medium">Kalenderlink</p>
</div>
<br />
<div class="flex flex-col gap-2">
<div>
<Listbox v-model="selectedTypes" name="type" multiple>
<ListboxLabel>Typen zur Anzeige auswählen</ListboxLabel>
<div class="relative mt-1">
<ListboxButton
class="rounded-md shadow-sm relative block w-full px-3 py-2 border border-gray-300 focus:border-primary placeholder-gray-500 text-gray-900 rounded-b-md focus:outline-none focus:ring-0 focus:z-10 sm:text-sm resize-none"
>
<span class="block truncate w-full text-start">
{{
selectedTypes.length != 0
? selectedTypes?.map((t) => t.type).join(", ")
: "Standard-Typen werden ausgeliefert"
}}
</span>
<span class="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-2">
<ChevronUpDownIcon class="h-5 w-5 text-gray-400" aria-hidden="true" />
</span>
</ListboxButton>
<transition
leave-active-class="transition duration-100 ease-in"
leave-from-class="opacity-100"
leave-to-class="opacity-0"
>
<ListboxOptions
class="absolute mt-1 max-h-60 z-20 w-full overflow-auto rounded-md bg-white py-1 text-base shadow-lg ring-1 ring-black/5 focus:outline-none sm:text-sm h-32 overflow-y-auto"
>
<ListboxOption v-if="calendarTypes.length == 0" disabled as="template">
<li :class="['relative cursor-default select-none py-2 pl-10 pr-4']">
<span :class="['font-normal', 'block truncate']">keine Auswahl vorhanden</span>
</li>
</ListboxOption>
<ListboxOption
v-slot="{ active, selected }"
v-for="type in calendarTypes"
:key="type.id"
:value="type"
as="template"
>
<li
:class="[
active ? 'bg-red-200 text-amber-900' : 'text-gray-900',
'relative cursor-default select-none py-2 pl-10 pr-4',
]"
>
<span :class="[selected ? 'font-medium' : 'font-normal', 'block truncate']">
{{ type.type }}
<small v-if="type.passphrase">(passwortgeschützt)</small>
<small v-if="type.nscdr">(standard-Auslieferung)</small>
</span>
<span v-if="selected" class="absolute inset-y-0 left-0 flex items-center pl-3 text-primary">
<CheckIcon class="h-5 w-5" aria-hidden="true" />
</span>
</li>
</ListboxOption>
</ListboxOptions>
</transition>
</div>
</Listbox>
</div>
<p class="flex flex-row text-sm">
<InformationCircleIcon class="text-gray-500 h-5 w-5" /> Wenn kein Typ ausgewählt ist, werden die Standard-Typen
zur Verfügung gestellt: <br />
-> {{ defaultTypes }}
</p>
<br />
<TextCopy :copyText="generatedLink" />
<br />
</div>
<RouterLink
:to="{ name: 'public-calendar' }"
title="Zur öffentlichen Kalender Anzeige"
class="absolute top-3 right-3"
target="_blank"
>
<CalendarDaysIcon class="text-gray-500 h-5 w-5" />
</RouterLink>
<div class="flex flex-row justify-end">
<div class="flex flex-row gap-4 py-2">
<button primary-outline @click="closeModal">schließen</button>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { defineComponent } from "vue";
import { mapState, mapActions } from "pinia";
import { RouterLink } from "vue-router";
import { useModalStore } from "@/stores/modal";
import { useCalendarTypeStore } from "@/stores/admin/calendarType";
import type { CalendarTypeViewModel } from "@/viewmodels/admin/calendarType.models";
import { Listbox, ListboxButton, ListboxOptions, ListboxOption, ListboxLabel } from "@headlessui/vue";
import { CheckIcon, ChevronUpDownIcon } from "@heroicons/vue/20/solid";
import TextCopy from "@/components/TextCopy.vue";
import { CalendarDaysIcon, InformationCircleIcon } from "@heroicons/vue/24/outline";
import { host } from "@/serverCom";
</script>
<script lang="ts">
export default defineComponent({
data() {
return {
selectedTypes: [] as Array<CalendarTypeViewModel>,
};
},
computed: {
...mapState(useModalStore, ["data"]),
...mapState(useCalendarTypeStore, ["calendarTypes"]),
defaultTypes() {
return this.calendarTypes
.filter((t) => t.nscdr)
.map((t) => t.type)
.join(", ");
},
generatedLink() {
let extend = this.selectedTypes.map((t) => [t.type, t.passphrase].filter((at) => at).join(":"));
return `webcal://${host || window.location.host}/api/public/calendar${extend.length == 0 ? "" : "?types=" + extend.join("&types=")}`;
},
},
mounted() {
this.fetchCalendarTypes();
},
methods: {
...mapActions(useModalStore, ["closeModal"]),
...mapActions(useCalendarTypeStore, ["fetchCalendarTypes"]),
},
});
</script>

View file

@ -6,6 +6,8 @@
<EyeIcon v-if="calendarType.nscdr" class="w-5 h-5" />
</div>
<p>{{ calendarType.type }}</p>
<small v-if="calendarType.passphrase">(passwortgeschützt)</small>
<small v-if="calendarType.nscdr">(standard-Auslieferung)</small>
</div>
<div class="flex flex-row">
<RouterLink

View file

@ -14,9 +14,13 @@
<label for="color">Farbe</label>
</div>
<div class="flex flex-row items-center gap-2">
<input type="checkbox" id="nscdr" />
<input type="checkbox" id="nscdr" v-model="nscdr" />
<label for="nscdr">Standard Kalender Auslieferung (optional)</label>
</div>
<div v-if="!nscdr">
<label for="passphrase">Passphrase (optional)</label>
<input type="text" id="passphrase" />
</div>
<div class="flex flex-row gap-2">
<button primary type="submit" :disabled="status == 'loading' || status?.status == 'success'">erstellen</button>
@ -59,6 +63,7 @@ export default defineComponent({
return {
status: null as null | "loading" | { status: "success" | "failed"; reason?: string },
timeout: undefined as any,
nscdr: false as boolean,
};
},
beforeUnmount() {
@ -75,6 +80,7 @@ export default defineComponent({
type: formData.type.value,
color: formData.color.value,
nscdr: formData.nscdr.checked,
passphrase: formData.passphrase.value,
};
this.createCalendarType(createCalendarType)
.then(() => {

View file

@ -0,0 +1,36 @@
<template>
<div class="w-full md:max-w-md">
<div class="flex flex-col items-center">
<p class="text-xl font-medium">Kalenderlink</p>
</div>
<br />
<TextCopy :copyText="generatedLink" />
<div class="flex flex-row justify-end">
<div class="flex flex-row gap-4 py-2">
<button primary-outline @click="closeModal">schließen</button>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { defineComponent } from "vue";
import { mapState, mapActions } from "pinia";
import { useModalStore } from "@/stores/modal";
import TextCopy from "@/components/TextCopy.vue";
import { host } from "@/serverCom";
</script>
<script lang="ts">
export default defineComponent({
computed: {
generatedLink() {
return `webcal://${host || window.location.host}/api/public/calendar`;
},
},
methods: {
...mapActions(useModalStore, ["closeModal"]),
},
});
</script>