Nachrichten-Plugin 1.0.0: Direktnachrichten, Gruppen, Anhänge, GIFs, Emojis
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
commit
2844452002
55 changed files with 5448 additions and 0 deletions
84
resources/js/components/NewChatDialog.vue
Normal file
84
resources/js/components/NewChatDialog.vue
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
<script setup>
|
||||
import { ref, watch } from 'vue';
|
||||
import { LoaderCircle } from '@lucide/vue';
|
||||
import { Button, Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, Input, Label, toast } from '@inhaus/ui';
|
||||
import PeopleSelect from './PeopleSelect.vue';
|
||||
import { api } from '../lib/api';
|
||||
|
||||
/** Neue Direktnachricht bzw. neue Gruppe */
|
||||
const props = defineProps({
|
||||
group: { type: Boolean, default: false },
|
||||
me: { type: Object, required: true },
|
||||
});
|
||||
const open = defineModel('open', { type: Boolean, default: false });
|
||||
const emit = defineEmits(['created']);
|
||||
|
||||
const name = ref('');
|
||||
const people = ref([]);
|
||||
const busy = ref(false);
|
||||
|
||||
watch(open, (value) => {
|
||||
if (value) {
|
||||
name.value = '';
|
||||
people.value = [];
|
||||
}
|
||||
});
|
||||
|
||||
async function start(person) {
|
||||
if (props.group) return;
|
||||
|
||||
busy.value = true;
|
||||
|
||||
try {
|
||||
const data = await api.direct(person.id);
|
||||
open.value = false;
|
||||
emit('created', data);
|
||||
} catch (error) {
|
||||
toast.error(error.message);
|
||||
} finally {
|
||||
busy.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function createGroup() {
|
||||
busy.value = true;
|
||||
|
||||
try {
|
||||
const data = await api.createGroup(name.value.trim(), people.value.map((p) => p.id));
|
||||
open.value = false;
|
||||
emit('created', data);
|
||||
} catch (error) {
|
||||
toast.error(error.message);
|
||||
} finally {
|
||||
busy.value = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Dialog v-model:open="open">
|
||||
<DialogContent class="ih:sm:max-w-md">
|
||||
<DialogHeader>
|
||||
<DialogTitle>{{ group ? 'Neue Gruppe' : 'Neue Nachricht' }}</DialogTitle>
|
||||
<DialogDescription>{{ group ? 'Name und Mitglieder wählen – Sie verwalten die Gruppe.' : 'An wen möchten Sie schreiben?' }}</DialogDescription>
|
||||
</DialogHeader>
|
||||
<div class="ih:grid ih:gap-4">
|
||||
<div v-if="group" class="ih:grid ih:gap-1.5">
|
||||
<Label for="chat-group-name">Name der Gruppe</Label>
|
||||
<Input id="chat-group-name" v-model="name" maxlength="100" placeholder="z. B. Station 3 – Frühdienst" />
|
||||
</div>
|
||||
<div class="ih:grid ih:gap-1.5">
|
||||
<Label v-if="group">Mitglieder</Label>
|
||||
<PeopleSelect v-model="people" :multiple="group" :exclude="[me.id]" autofocus @pick="start" />
|
||||
</div>
|
||||
<p v-if="busy && !group" class="ih:flex ih:items-center ih:gap-2 ih:text-sm ih:text-muted-foreground"><LoaderCircle class="ih:size-4 ih:animate-spin" /> Gespräch wird geöffnet …</p>
|
||||
</div>
|
||||
<DialogFooter v-if="group">
|
||||
<Button variant="ghost" @click="open = false">Abbrechen</Button>
|
||||
<Button :disabled="busy || !name.trim() || !people.length" @click="createGroup">
|
||||
<LoaderCircle v-if="busy" class="ih:animate-spin" /> Gruppe erstellen
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</template>
|
||||
Loading…
Add table
Add a link
Reference in a new issue