Loheide-eu-mitarbeiterplatt.../resources/js/components/AudienceEditor.vue
Friederich Loheide d7d09d6b9a
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 3m53s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 3m42s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 4m13s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 4m10s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 5m46s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 5m35s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 4m54s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 4m53s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m10s
Termine im Portal bearbeiten (0.23.0)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-27 07:56:48 +00:00

45 lines
2.3 KiB
Vue
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<script setup>
import { computed } from 'vue';
/**
* Zielgruppe bearbeiten: Rollen, Abteilungen, Standorte und ausgeschlossene Rollen.
* v-model: { role: [], department: [], location: [], exclude_role: [] } – leer = alle.
*/
const props = defineProps({
options: { type: Object, required: true }, // App\Support\Permissions\Audiences::options()
excludeHint: { type: String, default: 'Sehen es nie – auch wenn oben etwas passt.' },
});
const model = defineModel({ type: Object, default: () => ({}) });
function toggle(rule, value) {
const current = new Set(model.value?.[rule] ?? []);
current.has(value) ? current.delete(value) : current.add(value);
model.value = { ...model.value, [rule]: [...current] };
}
const groups = computed(() => [
{ key: 'role', label: 'Rollen', options: props.options.role ?? [] },
{ key: 'department', label: 'Abteilungen', options: (props.options.department ?? []).map((value) => ({ value, label: value })) },
{ key: 'location', label: 'Standorte', options: (props.options.location ?? []).map((value) => ({ value, label: value })) },
{ key: 'exclude_role', label: 'Ausgeschlossene Rollen', hint: props.excludeHint, options: props.options.role ?? [] },
].filter((group) => group.options.length));
</script>
<template>
<div class="grid gap-3">
<fieldset v-for="group in groups" :key="group.key" class="grid gap-1">
<legend class="mb-1 text-xs font-semibold text-muted-foreground">
{{ group.label }}
<span v-if="model?.[group.key]?.length" class="ml-1 rounded-pill bg-brand-soft px-1.5 text-[11px] text-brand-soft-foreground">{{ model[group.key].length }}</span>
</legend>
<p v-if="group.hint" class="-mt-1 mb-1 text-[11px] text-muted-foreground">{{ group.hint }}</p>
<div class="grid max-h-36 gap-0.5 overflow-y-auto rounded-md border p-1">
<label v-for="option in group.options" :key="option.value" class="flex items-center gap-2 rounded px-1.5 py-0.5 text-[13px] hover:bg-accent">
<input type="checkbox" class="size-4 accent-[var(--brand)]" :checked="(model?.[group.key] ?? []).includes(option.value)" @change="toggle(group.key, option.value)" />
{{ option.label }}
</label>
</div>
</fieldset>
</div>
</template>