Einheitliche Listen (0.61.0)
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 9m26s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 9m11s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 9m4s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 9m31s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 13m3s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 13m1s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 10m30s
CI / Bekannte Sicherheitslücken in Paketen (pull_request) Successful in 46s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m10s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 11m28s
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 9m26s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 9m11s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 9m4s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 9m31s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 13m3s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 13m1s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 10m30s
CI / Bekannte Sicherheitslücken in Paketen (pull_request) Successful in 46s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m10s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 11m28s
Gemeinsame Werkzeugleiste ListToolbar (Filter-Chips, Suche, Sortierung, Kacheln/Liste) für Neuigkeiten, Stellen, Ideen und Personen; im SDK für Plugins. Neuigkeiten durchsuchbar. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
8fbe32ed5c
commit
9cb34635bc
167 changed files with 644 additions and 482 deletions
114
resources/js/components/ListToolbar.vue
Normal file
114
resources/js/components/ListToolbar.vue
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
<script setup>
|
||||
import { onBeforeUnmount, ref, watch } from 'vue';
|
||||
import { LayoutGrid, List, Search, X } from '@lucide/vue';
|
||||
|
||||
/**
|
||||
* Einheitliche Leiste über Listen (auch für Plugins, @inhaus/ui):
|
||||
*
|
||||
* <ListToolbar v-model:filter="status" :filters="[{ value: null, label: 'Alle', count: 12 }, …]"
|
||||
* v-model:search="q" search-placeholder="Bilder suchen"
|
||||
* v-model:sort="sort" :sorts="[{ value: 'neu', label: 'Neueste zuerst' }, …]"
|
||||
* v-model:view="view" />
|
||||
*
|
||||
* Alles optional: Ohne `filters` keine Chips, ohne `search` (undefined) kein Suchfeld,
|
||||
* ohne `sorts` keine Sortierung, ohne `view` keine Umschaltung Kacheln/Liste.
|
||||
* Die Suche meldet sich mit kurzer Verzögerung (300 ms). Weitere Schalter im Slot.
|
||||
*/
|
||||
const props = defineProps({
|
||||
filters: { type: Array, default: () => [] },
|
||||
filter: { type: [String, Number, Boolean], default: null },
|
||||
filterLabel: { type: String, default: 'Filter' },
|
||||
search: { type: String, default: undefined },
|
||||
searchPlaceholder: { type: String, default: 'Suchen' },
|
||||
sorts: { type: Array, default: () => [] },
|
||||
sort: { type: String, default: null },
|
||||
view: { type: String, default: undefined }, // 'grid' | 'list'
|
||||
});
|
||||
|
||||
const emit = defineEmits(['update:filter', 'update:search', 'update:sort', 'update:view']);
|
||||
|
||||
const query = ref(props.search ?? '');
|
||||
watch(() => props.search, (value) => {
|
||||
if (value !== undefined && value !== query.value) query.value = value;
|
||||
});
|
||||
|
||||
let timer = null;
|
||||
watch(query, (value) => {
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(() => emit('update:search', value), 300);
|
||||
});
|
||||
onBeforeUnmount(() => clearTimeout(timer));
|
||||
|
||||
const active = (value) => (value ?? null) === (props.filter ?? null);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="mb-5 flex flex-wrap items-center gap-x-3 gap-y-3">
|
||||
<nav v-if="filters.length" class="-mx-1 flex max-w-full gap-1.5 overflow-x-auto px-1 pb-0.5 [scrollbar-width:none]" :aria-label="filterLabel">
|
||||
<button
|
||||
v-for="item in filters"
|
||||
:key="String(item.value)"
|
||||
type="button"
|
||||
class="inline-flex shrink-0 items-center gap-1.5 rounded-pill border px-3.5 py-1.5 text-[13px] font-medium whitespace-nowrap transition-colors"
|
||||
:class="active(item.value) ? 'border-brand bg-brand text-brand-foreground' : 'bg-card hover:bg-accent'"
|
||||
:aria-pressed="active(item.value)"
|
||||
@click="emit('update:filter', item.value ?? null)"
|
||||
>
|
||||
{{ item.label }}
|
||||
<span v-if="item.count != null" class="text-xs tabular-nums" :class="active(item.value) ? 'opacity-80' : 'text-muted-foreground'">{{ item.count }}</span>
|
||||
</button>
|
||||
</nav>
|
||||
|
||||
<div class="ml-auto flex w-full flex-wrap items-center gap-2 sm:w-auto">
|
||||
<slot />
|
||||
|
||||
<label v-if="search !== undefined" class="relative order-first flex h-9 min-w-0 basis-full items-center sm:order-none sm:w-64 sm:basis-auto">
|
||||
<span class="sr-only">{{ searchPlaceholder }}</span>
|
||||
<Search class="pointer-events-none absolute left-3 size-4 text-muted-foreground" />
|
||||
<input
|
||||
v-model="query"
|
||||
type="search"
|
||||
:placeholder="searchPlaceholder"
|
||||
class="h-9 w-full rounded-pill border border-input bg-card pr-8 pl-9 text-sm placeholder:text-muted-foreground focus-visible:border-brand-400 focus-visible:ring-3 focus-visible:ring-ring/30 focus-visible:outline-none [&::-webkit-search-cancel-button]:hidden"
|
||||
/>
|
||||
<button v-if="query" type="button" class="absolute right-2 grid size-5 place-items-center rounded-full text-muted-foreground hover:bg-accent" aria-label="Suche leeren" @click="query = ''">
|
||||
<X class="size-3.5" />
|
||||
</button>
|
||||
</label>
|
||||
|
||||
<label v-if="sorts.length" class="relative min-w-0 flex-1 sm:flex-none">
|
||||
<span class="sr-only">Sortierung</span>
|
||||
<select
|
||||
:value="sort ?? sorts[0].value"
|
||||
class="h-9 w-full rounded-pill border border-input bg-card px-3 pr-8 text-sm focus-visible:ring-3 focus-visible:ring-ring/30 focus-visible:outline-none"
|
||||
@change="emit('update:sort', $event.target.value)"
|
||||
>
|
||||
<option v-for="item in sorts" :key="item.value" :value="item.value">{{ item.label }}</option>
|
||||
</select>
|
||||
</label>
|
||||
|
||||
<div v-if="view !== undefined" class="ml-auto flex rounded-pill sm:ml-0 border bg-card p-0.5" role="group" aria-label="Ansicht">
|
||||
<button
|
||||
type="button"
|
||||
class="grid size-8 place-items-center rounded-pill"
|
||||
:class="view === 'grid' ? 'bg-brand-soft text-brand-text' : 'text-muted-foreground hover:text-foreground'"
|
||||
:aria-pressed="view === 'grid'"
|
||||
aria-label="Als Kacheln"
|
||||
@click="emit('update:view', 'grid')"
|
||||
>
|
||||
<LayoutGrid class="size-4" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="grid size-8 place-items-center rounded-pill"
|
||||
:class="view === 'list' ? 'bg-brand-soft text-brand-text' : 'text-muted-foreground hover:text-foreground'"
|
||||
:aria-pressed="view === 'list'"
|
||||
aria-label="Als Liste"
|
||||
@click="emit('update:view', 'list')"
|
||||
>
|
||||
<List class="size-4" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
29
resources/js/lib/listView.js
Normal file
29
resources/js/lib/listView.js
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import { ref, watch } from 'vue';
|
||||
|
||||
/**
|
||||
* Kacheln oder Liste – je Seite im Browser gemerkt (@inhaus/ui: useListView).
|
||||
*
|
||||
* const view = useListView('verleih', 'grid');
|
||||
*/
|
||||
export function useListView(key, fallback = 'grid') {
|
||||
const storageKey = `inhaus:ansicht:${key}`;
|
||||
let initial = fallback;
|
||||
|
||||
try {
|
||||
const stored = localStorage.getItem(storageKey);
|
||||
if (stored === 'grid' || stored === 'list') initial = stored;
|
||||
} catch {
|
||||
// ohne Speicher: Standard
|
||||
}
|
||||
|
||||
const view = ref(initial);
|
||||
watch(view, (value) => {
|
||||
try {
|
||||
localStorage.setItem(storageKey, value);
|
||||
} catch {
|
||||
// egal
|
||||
}
|
||||
});
|
||||
|
||||
return view;
|
||||
}
|
||||
|
|
@ -1,10 +1,11 @@
|
|||
<script setup>
|
||||
import { ref, watch } from 'vue';
|
||||
import { Link, router } from '@inertiajs/vue3';
|
||||
import { useDebounceFn } from '@vueuse/core';
|
||||
import { ChevronLeft, ChevronRight, Mail, Phone, Search, SearchX } from '@lucide/vue';
|
||||
import { ChevronLeft, ChevronRight, Mail, Phone, SearchX } from '@lucide/vue';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import ListToolbar from '@/components/ListToolbar.vue';
|
||||
import PersonAvatar from '@/components/PersonAvatar.vue';
|
||||
import { useListView } from '@/lib/listView';
|
||||
import PageHeader from '@/components/PageHeader.vue';
|
||||
import AppLayout from '@/layouts/AppLayout.vue';
|
||||
|
||||
|
|
@ -14,6 +15,7 @@ const props = defineProps({
|
|||
departments: { type: Array, required: true },
|
||||
});
|
||||
|
||||
const view = useListView('personen', 'grid');
|
||||
const search = ref(props.filters.q ?? '');
|
||||
const department = ref(props.filters.abteilung ?? '');
|
||||
|
||||
|
|
@ -26,7 +28,7 @@ function apply() {
|
|||
router.get('/personen', query, { preserveState: true, preserveScroll: true, replace: true });
|
||||
}
|
||||
|
||||
watch(search, useDebounceFn(apply, 300));
|
||||
watch(search, apply);
|
||||
watch(department, apply);
|
||||
</script>
|
||||
|
||||
|
|
@ -38,31 +40,34 @@ watch(department, apply);
|
|||
{{ people.meta.total === 1 ? 'Person' : 'Personen' }}{{ filters.q || filters.abteilung ? ' gefunden' : ' im Verzeichnis' }}
|
||||
· <Link href="/personen/organigramm" class="font-medium text-brand-text hover:underline">Organigramm</Link>
|
||||
</template>
|
||||
<template #actions>
|
||||
<div class="flex w-full flex-col gap-3 sm:w-auto sm:flex-row">
|
||||
<label class="relative block sm:w-80">
|
||||
<span class="sr-only">Suchen</span>
|
||||
<Search class="pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground" />
|
||||
<input
|
||||
v-model="search"
|
||||
type="search"
|
||||
placeholder="Name, Funktion, Standort …"
|
||||
class="h-10 w-full rounded-md border border-input bg-card pr-3 pl-9 text-sm placeholder:text-muted-foreground focus-visible:border-brand-400 focus-visible:ring-3 focus-visible:ring-ring/30 focus-visible:outline-none"
|
||||
/>
|
||||
</label>
|
||||
<select
|
||||
v-model="department"
|
||||
class="h-10 rounded-md border border-input bg-card px-3 text-sm focus-visible:border-brand-400 focus-visible:ring-3 focus-visible:ring-ring/30 focus-visible:outline-none sm:w-56"
|
||||
aria-label="Abteilung"
|
||||
>
|
||||
<option value="">Alle Abteilungen</option>
|
||||
<option v-for="item in departments" :key="item" :value="item">{{ item }}</option>
|
||||
</select>
|
||||
</div>
|
||||
</template>
|
||||
</PageHeader>
|
||||
|
||||
<ul v-if="people.data.length" class="grid gap-4 sm:grid-cols-2 lg:grid-cols-3 2xl:grid-cols-4">
|
||||
<ListToolbar v-model:search="search" search-placeholder="Name, Funktion, Standort …" v-model:view="view">
|
||||
<select
|
||||
v-model="department"
|
||||
class="h-9 rounded-pill border border-input bg-card px-3 text-sm focus-visible:ring-3 focus-visible:ring-ring/30 focus-visible:outline-none sm:w-56"
|
||||
aria-label="Abteilung"
|
||||
>
|
||||
<option value="">Alle Abteilungen</option>
|
||||
<option v-for="item in departments" :key="item" :value="item">{{ item }}</option>
|
||||
</select>
|
||||
</ListToolbar>
|
||||
|
||||
<ul v-if="people.data.length && view === 'list'" class="divide-y rounded-lg border bg-card">
|
||||
<li v-for="person in people.data" :key="person.id" class="flex items-center gap-3 px-4 py-2.5">
|
||||
<Link :href="`/personen/${person.id}`" class="flex min-w-0 flex-1 items-center gap-3">
|
||||
<PersonAvatar :person="person" class="size-9" />
|
||||
<span class="grid min-w-0">
|
||||
<span class="truncate text-sm font-semibold hover:underline">{{ person.name }}</span>
|
||||
<span class="truncate text-xs text-muted-foreground">{{ [person.job_title, person.department, person.location].filter(Boolean).join(' · ') }}</span>
|
||||
</span>
|
||||
</Link>
|
||||
<a v-if="person.phone" :href="`tel:${person.phone}`" class="hidden shrink-0 items-center gap-1.5 text-[13px] text-muted-foreground hover:text-foreground sm:inline-flex"><Phone class="size-3.5" /> {{ person.phone }}</a>
|
||||
<a :href="`mailto:${person.email}`" class="grid size-8 shrink-0 place-items-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground" :aria-label="`E-Mail an ${person.name}`"><Mail class="size-4" /></a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ul v-else-if="people.data.length" class="grid gap-4 sm:grid-cols-2 lg:grid-cols-3 2xl:grid-cols-4">
|
||||
<li v-for="person in people.data" :key="person.id" class="flex flex-col rounded-lg border bg-card">
|
||||
<Link :href="`/personen/${person.id}`" class="flex items-center gap-3 p-4 pb-3">
|
||||
<PersonAvatar :person="person" class="size-12" />
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ export { default as EasyLanguageBar } from '@/components/EasyLanguageBar.vue';
|
|||
export { default as TreeSelect } from '@/components/TreeSelect.vue';
|
||||
export { default as PersonPicker } from '@/components/PersonPicker.vue';
|
||||
export { default as AudienceEditor } from '@/components/AudienceEditor.vue';
|
||||
export { default as ListToolbar } from '@/components/ListToolbar.vue';
|
||||
|
||||
// UI-Kit (shadcn-vue)
|
||||
export { Button } from '@/components/ui/button';
|
||||
|
|
@ -48,4 +49,5 @@ export { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@/
|
|||
export { http, HttpError } from '@/lib/http';
|
||||
export { formatDate, formatShortDate, formatTime, formatRelative, formatMonthYear } from '@/lib/format';
|
||||
export { colorFor } from '@/lib/colors';
|
||||
export { useListView } from '@/lib/listView';
|
||||
export { toast } from 'vue-sonner';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue