Move alertDialog to AppLayout fixes #33
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
import { ref, computed, watch, onMounted, onUpdated, useTemplateRef } from "vue"
|
||||
import { Customer, Invoice, Contact, PaymentTerms, Address } from "@/types"
|
||||
import { newCustomer, newContact, newBillingData } from '@/types/index.d'
|
||||
import { toCurrency, toLocalDate, toShortISOString, cn, calcDueDate, toFixedRounded } from '@/lib/utils';
|
||||
import { toCurrency, toLocalDate, toShortISOString, cn, calcDueDate, toFixedRounded } from '@/lib/utils'
|
||||
import axios from 'axios'
|
||||
import { type DateValue, DateFormatter, getLocalTimeZone, parseDate, fromDate } from "@internationalized/date"
|
||||
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, } from "@/components/ui/dialog"
|
||||
@@ -24,13 +24,13 @@ import { Input } from '@/components/ui/input';
|
||||
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from '@/components/ui/dropdown-menu'
|
||||
import { StatusBadge, statusBadgeLabels, statusBadgeTextColor, StatusBadgeVariants } from '@/components/ui/status-badge'
|
||||
import LineItemTable from '@/components/documents/LineItemTable.vue'
|
||||
import { Eye, FileText, CircleEllipsis, Trash, BookUser, User, CodeXml, CalendarIcon, MessageCircleQuestion, X, CircleX, Logs, ListCheck, ClipboardCheck, ClipboardList } from "lucide-vue-next"
|
||||
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, } from '@/components/ui/alert-dialog'
|
||||
import { Eye, FileText, CircleEllipsis, Trash, Trash2, BookUser, User, CodeXml, CalendarIcon, MessageCircleQuestion, X, CircleX, Logs, ListCheck, ClipboardCheck, ClipboardList } from "lucide-vue-next"
|
||||
import { alertStore } from "@/stores/alertStore"
|
||||
import { Calendar } from "@/components/ui/calendar"
|
||||
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"
|
||||
import { exportPdf, exportXml } from "@/routes/invoice";
|
||||
import { exportPdf, exportXml } from "@/routes/invoice"
|
||||
import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle, SheetTrigger, } from '@/components/ui/sheet'
|
||||
import { GrowingTextarea } from '../ui/growing-textarea';
|
||||
import { GrowingTextarea } from '../ui/growing-textarea'
|
||||
|
||||
const props = defineProps<{
|
||||
invoiceData: Invoice | null,
|
||||
@@ -46,8 +46,7 @@ const isDirty = ref(false);
|
||||
const isLoading = ref(false);
|
||||
const importContact = ref(newContact() as Contact)
|
||||
const importCustomer = ref(newCustomer() as Customer)
|
||||
const alert = ref({ open: false, title: "", message: "", cancelText: "", onCancel: () => { }, confirmText: "", onConfirm: () => { } })
|
||||
|
||||
const alert = alertStore()
|
||||
|
||||
onMounted(async () => {
|
||||
const response = await axios.get('/api/paymentterms')
|
||||
@@ -191,31 +190,30 @@ const saveChanges = () => {
|
||||
|
||||
const cancelChanges = (event: Event | null) => {
|
||||
if (isDirty.value) {
|
||||
alert.value.title = "Wirklich schließen?"
|
||||
alert.value.message = "Es gibt ungespeicherte Änderungen, die dann verloren gehen."
|
||||
alert.value.cancelText = "Abbrechen"
|
||||
alert.value.onCancel = () => {
|
||||
alert.title = "Wirklich schließen?"
|
||||
alert.message = "Es gibt ungespeicherte Änderungen, die dann verloren gehen."
|
||||
alert.cancelText = "Abbrechen"
|
||||
alert.onCancel = () => {
|
||||
console.log('cancel')
|
||||
event?.preventDefault()
|
||||
event.returnValue = true
|
||||
alert.value.open = false
|
||||
alert.open = false
|
||||
}
|
||||
alert.value.confirmText = "Schließen"
|
||||
alert.value.onConfirm = () => {
|
||||
alert.actionText = "Schließen"
|
||||
// alert.actionVariant = "destructive"
|
||||
alert.onAction = () => {
|
||||
console.log('action')
|
||||
emit('cancel')
|
||||
isOpen.value = false
|
||||
alert.value.open = false
|
||||
alert.open = false
|
||||
}
|
||||
alert.value.open = true
|
||||
alert.open = true
|
||||
} else {
|
||||
emit('cancel')
|
||||
isOpen.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const confirmCancel = () => {
|
||||
return window.confirm('Es gibt ungespeicherte Änderungen. Möchtest Du die Seite wirklich verlassen?');
|
||||
}
|
||||
|
||||
const preview = function () {
|
||||
if (!invoice.value) return;
|
||||
window?.open('/invoice/' + invoice.value.id, '_blank')?.focus();
|
||||
@@ -383,7 +381,8 @@ const updateTotalAmount = () => {
|
||||
|
||||
<div class="flex flex-col m-0 items-end gap-0">
|
||||
<span class="text-md text-muted-foreground">{{ toCurrency(invoice.totalAmount) }}</span>
|
||||
<span class="text-2xl font-bold">{{ toCurrency(toFixedRounded(Number(invoice.totalAmount * 1.19), 2)) }}</span>
|
||||
<span class="text-2xl font-bold">{{ toCurrency(toFixedRounded(Number(invoice.totalAmount *
|
||||
1.19), 2)) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -582,23 +581,6 @@ const updateTotalAmount = () => {
|
||||
:disabled="!isDirty">Speichern</Button>
|
||||
</DialogFooter>
|
||||
|
||||
<AlertDialog v-model:open="alert.open" :asChild="true">
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>{{ alert.title }}</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
{{ alert.message }}
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<Button v-if="alert.onCancel" @click="alert.onCancel">{{ alert.cancelText }}</Button>
|
||||
<Button variant="destructive" v-if="alert.onConfirm" @click="alert.onConfirm">{{
|
||||
alert.confirmText
|
||||
}}</Button>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
|
||||
</DialogContent>
|
||||
|
||||
</Dialog>
|
||||
|
||||
Reference in New Issue
Block a user