Banknotizen automatisch speichern
All checks were successful
Build and Push Docker Images / build-backend (push) Successful in 37s
Build and Push Docker Images / build-website (push) Successful in 36s
Build and Push Docker Images / build-frontend (push) Successful in 2m8s
Build and Push Docker Images / build-central-services-api (push) Successful in 36s
Build and Push Docker Images / build-docs (push) Successful in 35s
Build and Push Docker Images / build-central-services-admin (push) Successful in 35s

This commit is contained in:
2026-08-08 09:18:17 +02:00
parent 93d2769f23
commit 3d829c3bc0

View File

@@ -40,6 +40,9 @@ const ownaccounts = ref([])
const loading = ref(true) const loading = ref(true)
const loadingDocuments = ref(true) const loadingDocuments = ref(true)
const savingNotes = ref(false) const savingNotes = ref(false)
const notesSaveDelay = 800
let notesSaveTimer = null
let notesSaveQueued = false
const rebuildDocumentLists = () => { const rebuildDocumentLists = () => {
const documents = createddocuments.value.filter(i => i.type === "invoices" || i.type === "advanceInvoices") const documents = createddocuments.value.filter(i => i.type === "invoices" || i.type === "advanceInvoices")
@@ -262,14 +265,26 @@ const removeAllocation = async (allocationId) => {
} }
const saveNotes = async () => { const saveNotes = async () => {
if (!itemInfo.value?.id || !notesChanged.value) return
if (savingNotes.value) {
notesSaveQueued = true
return
}
const notes = String(itemInfo.value.notes || "").trim() || null
savingNotes.value = true savingNotes.value = true
try { try {
const notes = String(itemInfo.value.notes || "").trim() || null
const updated = await useEntities("bankstatements").update(itemInfo.value.id, {notes}, true) const updated = await useEntities("bankstatements").update(itemInfo.value.id, {notes}, true)
itemInfo.value.notes = updated.notes
oldItemInfo.value.notes = updated.notes oldItemInfo.value.notes = updated.notes
if (String(itemInfo.value.notes || "").trim() === String(notes || "")) {
itemInfo.value.notes = updated.notes
}
} finally { } finally {
savingNotes.value = false savingNotes.value = false
if (notesSaveQueued || notesChanged.value) {
notesSaveQueued = false
scheduleNotesSave()
}
} }
} }
@@ -277,6 +292,26 @@ const notesChanged = computed(() =>
String(itemInfo.value?.notes || "").trim() !== String(oldItemInfo.value?.notes || "").trim() String(itemInfo.value?.notes || "").trim() !== String(oldItemInfo.value?.notes || "").trim()
) )
const scheduleNotesSave = () => {
if (notesSaveTimer) clearTimeout(notesSaveTimer)
notesSaveTimer = setTimeout(() => {
notesSaveTimer = null
void saveNotes()
}, notesSaveDelay)
}
watch(() => itemInfo.value?.notes, () => {
if (!loading.value && notesChanged.value) scheduleNotesSave()
})
onBeforeRouteLeave(async () => {
if (notesSaveTimer) {
clearTimeout(notesSaveTimer)
notesSaveTimer = null
}
if (notesChanged.value) await saveNotes()
})
const searchString = ref(tempStore.searchStrings["bankstatementsedit"] || '') const searchString = ref(tempStore.searchStrings["bankstatementsedit"] || '')
const clearSearchString = () => { const clearSearchString = () => {
@@ -616,22 +651,12 @@ setup()
<UFormField label="Notiz" size="sm"> <UFormField label="Notiz" size="sm">
<UTextarea <UTextarea
v-model="itemInfo.notes" v-model="itemInfo.notes"
class="w-full"
:rows="3" :rows="3"
autoresize autoresize
placeholder="Interne Notiz zu dieser Bankbuchung hinzufügen …" placeholder="Interne Notiz zu dieser Bankbuchung hinzufügen …"
/> />
</UFormField> </UFormField>
<div class="mt-2 flex justify-end">
<UButton
icon="i-heroicons-check"
size="sm"
:disabled="!notesChanged"
:loading="savingNotes"
@click="saveNotes"
>
Notiz speichern
</UButton>
</div>
</div> </div>
<div class="mt-4"> <div class="mt-4">