Compare commits
2 Commits
e7fb2df5c7
...
5edc90bd4d
| Author | SHA1 | Date | |
|---|---|---|---|
| 5edc90bd4d | |||
| d140251aa0 |
@@ -1,14 +1,9 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import dayjs from "dayjs";
|
const {$api, $dayjs} = useNuxtApp()
|
||||||
|
|
||||||
// Zugriff auf $api und Toast Notification
|
|
||||||
const { $api } = useNuxtApp()
|
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
|
|
||||||
defineShortcuts({
|
defineShortcuts({
|
||||||
'/': () => {
|
'/': () => document.getElementById("searchinput").focus()
|
||||||
document.getElementById("searchinput").focus()
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const tempStore = useTempStore()
|
const tempStore = useTempStore()
|
||||||
@@ -18,238 +13,280 @@ const route = useRoute()
|
|||||||
const bankstatements = ref([])
|
const bankstatements = ref([])
|
||||||
const bankaccounts = ref([])
|
const bankaccounts = ref([])
|
||||||
const filterAccount = ref([])
|
const filterAccount = ref([])
|
||||||
|
|
||||||
// Status für den Lade-Button
|
|
||||||
const isSyncing = ref(false)
|
const isSyncing = ref(false)
|
||||||
|
const loadingDocs = ref(true) // Startet im Ladezustand
|
||||||
|
|
||||||
|
// Zeitraum-Optionen
|
||||||
|
const periodOptions = [
|
||||||
|
{label: 'Aktueller Monat', key: 'current_month'},
|
||||||
|
{label: 'Letzter Monat', key: 'last_month'},
|
||||||
|
{label: 'Aktuelles Quartal', key: 'current_quarter'},
|
||||||
|
{label: 'Letztes Quartal', key: 'last_quarter'},
|
||||||
|
{label: 'Benutzerdefiniert', key: 'custom'}
|
||||||
|
]
|
||||||
|
|
||||||
|
// Initialisierungswerte
|
||||||
|
const selectedPeriod = ref(periodOptions[0])
|
||||||
|
const dateRange = ref({
|
||||||
|
start: $dayjs().startOf('month').format('YYYY-MM-DD'),
|
||||||
|
end: $dayjs().endOf('month').format('YYYY-MM-DD')
|
||||||
|
})
|
||||||
|
|
||||||
const setupPage = async () => {
|
const setupPage = async () => {
|
||||||
bankstatements.value = (await useEntities("bankstatements").select("*, statementallocations(*)", "date", false))
|
loadingDocs.value = true
|
||||||
bankaccounts.value = await useEntities("bankaccounts").select()
|
try {
|
||||||
if(bankaccounts.value.length > 0) filterAccount.value = bankaccounts.value
|
const [statements, accounts] = await Promise.all([
|
||||||
|
useEntities("bankstatements").select("*, statementallocations(*)", "valueDate", false),
|
||||||
|
useEntities("bankaccounts").select()
|
||||||
|
])
|
||||||
|
|
||||||
|
bankstatements.value = statements
|
||||||
|
bankaccounts.value = accounts
|
||||||
|
|
||||||
|
if (bankaccounts.value.length > 0 && filterAccount.value.length === 0) {
|
||||||
|
filterAccount.value = bankaccounts.value
|
||||||
|
}
|
||||||
|
|
||||||
|
// Erst nach dem Laden der Daten die Store-Werte anwenden
|
||||||
|
const savedBanking = tempStore.settings?.['banking'] || {}
|
||||||
|
if (savedBanking.periodKey) {
|
||||||
|
const found = periodOptions.find(p => p.key === savedBanking.periodKey)
|
||||||
|
if (found) selectedPeriod.value = found
|
||||||
|
}
|
||||||
|
if (savedBanking.range) {
|
||||||
|
dateRange.value = savedBanking.range
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error("Setup Error:", err)
|
||||||
|
} finally {
|
||||||
|
loadingDocs.value = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Funktion für den Bankabruf
|
// Watcher für Schnellwahlen & Persistenz
|
||||||
|
watch([selectedPeriod, dateRange], ([newPeriod, newRange], [oldPeriod, oldRange]) => {
|
||||||
|
const now = $dayjs()
|
||||||
|
|
||||||
|
// Nur berechnen, wenn sich die Periode geändert hat
|
||||||
|
if (newPeriod.key !== oldPeriod?.key) {
|
||||||
|
switch (newPeriod.key) {
|
||||||
|
case 'current_month':
|
||||||
|
dateRange.value = {start: now.startOf('month').format('YYYY-MM-DD'), end: now.endOf('month').format('YYYY-MM-DD')}
|
||||||
|
break
|
||||||
|
case 'last_month':
|
||||||
|
const lastMonth = now.subtract(1, 'month')
|
||||||
|
dateRange.value = {start: lastMonth.startOf('month').format('YYYY-MM-DD'), end: lastMonth.endOf('month').format('YYYY-MM-DD')}
|
||||||
|
break
|
||||||
|
case 'current_quarter':
|
||||||
|
dateRange.value = {start: now.startOf('quarter').format('YYYY-MM-DD'), end: now.endOf('quarter').format('YYYY-MM-DD')}
|
||||||
|
break
|
||||||
|
case 'last_quarter':
|
||||||
|
const lastQuarter = now.subtract(1, 'quarter')
|
||||||
|
dateRange.value = {start: lastQuarter.startOf('quarter').format('YYYY-MM-DD'), end: lastQuarter.endOf('quarter').format('YYYY-MM-DD')}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Speichern im Store
|
||||||
|
tempStore.modifyBankingPeriod(selectedPeriod.value.key, dateRange.value)
|
||||||
|
}, { deep: true })
|
||||||
|
|
||||||
const syncBankStatements = async () => {
|
const syncBankStatements = async () => {
|
||||||
isSyncing.value = true
|
isSyncing.value = true
|
||||||
try {
|
try {
|
||||||
await $api('/api/functions/services/bankstatementsync', { method: 'POST' })
|
await $api('/api/functions/services/bankstatementsync', {method: 'POST'})
|
||||||
|
toast.add({title: 'Erfolg', description: 'Bankdaten synchronisiert.', color: 'green'})
|
||||||
toast.add({
|
|
||||||
title: 'Erfolg',
|
|
||||||
description: 'Bankdaten wurden erfolgreich synchronisiert.',
|
|
||||||
icon: 'i-heroicons-check-circle',
|
|
||||||
color: 'green'
|
|
||||||
})
|
|
||||||
|
|
||||||
// Wichtig: Daten neu laden, damit die neuen Buchungen direkt sichtbar sind
|
|
||||||
await setupPage()
|
await setupPage()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
toast.add({title: 'Fehler', description: 'Fehler beim Abruf.', color: 'red'})
|
||||||
toast.add({
|
|
||||||
title: 'Fehler',
|
|
||||||
description: 'Beim Abrufen der Bankdaten ist ein Fehler aufgetreten.',
|
|
||||||
icon: 'i-heroicons-exclamation-circle',
|
|
||||||
color: 'red'
|
|
||||||
})
|
|
||||||
} finally {
|
} finally {
|
||||||
isSyncing.value = false
|
isSyncing.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const templateColumns = [
|
const templateColumns = [
|
||||||
{
|
{key: "account", label: "Konto"},
|
||||||
key: "account",
|
{key: "valueDate", label: "Valuta"},
|
||||||
label: "Konto"
|
{key: "amount", label: "Betrag"},
|
||||||
},{
|
{key: "openAmount", label: "Offen"},
|
||||||
key: "valueDate",
|
{key: "partner", label: "Name"},
|
||||||
label: "Valuta"
|
{key: "text", label: "Beschreibung"}
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "amount",
|
|
||||||
label: "Betrag"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "openAmount",
|
|
||||||
label: "Offener Betrag"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "partner",
|
|
||||||
label: "Name"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "text",
|
|
||||||
label: "Beschreibung"
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
const selectedColumns = ref(templateColumns)
|
|
||||||
const columns = computed(() => templateColumns.filter((column) => selectedColumns.value.includes(column)))
|
|
||||||
|
|
||||||
|
const searchString = ref(tempStore.searchStrings["bankstatements"] || '')
|
||||||
|
const selectedFilters = ref(tempStore.filters?.["banking"]?.["main"] || ['Nur offene anzeigen'])
|
||||||
|
|
||||||
const searchString = ref(tempStore.searchStrings["bankstatements"] ||'')
|
const shouldShowMonthDivider = (row, index) => {
|
||||||
|
if (index === 0) return true;
|
||||||
const clearSearchString = () => {
|
const prevRow = filteredRows.value[index - 1];
|
||||||
tempStore.clearSearchString("bankstatements")
|
return $dayjs(row.valueDate).format('MMMM YYYY') !== $dayjs(prevRow.valueDate).format('MMMM YYYY');
|
||||||
searchString.value = ''
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const displayCurrency = (value, currency = "€") => {
|
|
||||||
return `${Number(value).toFixed(2).replace(".",",")} ${currency}`
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const calculateOpenSum = (statement) => {
|
const calculateOpenSum = (statement) => {
|
||||||
let startingAmount = 0
|
const allocated = statement.statementallocations?.reduce((acc, curr) => acc + curr.amount, 0) || 0;
|
||||||
|
return (statement.amount - allocated).toFixed(2);
|
||||||
statement.statementallocations.forEach(item => {
|
|
||||||
startingAmount += item.amount
|
|
||||||
})
|
|
||||||
|
|
||||||
return (statement.amount - startingAmount).toFixed(2)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const selectedFilters = ref(tempStore.filters?.["banking"]?.["main"] ? tempStore.filters["banking"]["main"] : ['Nur offene anzeigen'])
|
|
||||||
|
|
||||||
const filteredRows = computed(() => {
|
const filteredRows = computed(() => {
|
||||||
let temp = bankstatements.value
|
if (!bankstatements.value.length) return []
|
||||||
|
|
||||||
if(route.query.filter) {
|
let temp = [...bankstatements.value]
|
||||||
console.log(route.query.filter)
|
|
||||||
temp = temp.filter(i => JSON.parse(route.query.filter).includes(i.id))
|
|
||||||
} else {
|
|
||||||
if(selectedFilters.value.includes("Nur offene anzeigen")){
|
|
||||||
temp = temp.filter(i => Number(calculateOpenSum(i)) !== 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
if(selectedFilters.value.includes("Nur positive anzeigen")){
|
// Filterung nach Datum
|
||||||
temp = temp.filter(i => i.amount >= 0)
|
if (dateRange.value.start) {
|
||||||
}
|
temp = temp.filter(i => $dayjs(i.valueDate).isSameOrAfter($dayjs(dateRange.value.start), 'day'))
|
||||||
|
}
|
||||||
if(selectedFilters.value.includes("Nur negative anzeigen")){
|
if (dateRange.value.end) {
|
||||||
temp = temp.filter(i => i.amount < 0)
|
temp = temp.filter(i => $dayjs(i.valueDate).isSameOrBefore($dayjs(dateRange.value.end), 'day'))
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return useSearch(searchString.value, temp.filter(i => filterAccount.value.find(x => x.id === i.account)))
|
// Status Filter
|
||||||
|
if (selectedFilters.value.includes("Nur offene anzeigen")) {
|
||||||
|
temp = temp.filter(i => Number(calculateOpenSum(i)) !== 0)
|
||||||
|
}
|
||||||
|
if (selectedFilters.value.includes("Nur positive anzeigen")) {
|
||||||
|
temp = temp.filter(i => i.amount >= 0)
|
||||||
|
}
|
||||||
|
if (selectedFilters.value.includes("Nur negative anzeigen")) {
|
||||||
|
temp = temp.filter(i => i.amount < 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Konto Filter & Suche
|
||||||
|
let results = temp.filter(i => filterAccount.value.find(x => x.id === i.account))
|
||||||
|
|
||||||
|
if (searchString.value) {
|
||||||
|
results = useSearch(searchString.value, results)
|
||||||
|
}
|
||||||
|
|
||||||
|
return results.sort((a, b) => $dayjs(b.valueDate).unix() - $dayjs(a.valueDate).unix())
|
||||||
})
|
})
|
||||||
|
|
||||||
setupPage()
|
const displayCurrency = (value) => `${Number(value).toFixed(2).replace(".", ",")} €`
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
setupPage()
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<UDashboardNavbar title="Bankbuchungen" :badge="filteredRows.length">
|
<UDashboardNavbar title="Bankbuchungen" :badge="filteredRows.length">
|
||||||
<template #right>
|
<template #right>
|
||||||
|
|
||||||
<UButton
|
<UButton
|
||||||
label="Bankabruf"
|
label="Bankabruf"
|
||||||
icon="i-heroicons-arrow-path"
|
icon="i-heroicons-arrow-path"
|
||||||
color="primary"
|
|
||||||
variant="solid"
|
|
||||||
:loading="isSyncing"
|
:loading="isSyncing"
|
||||||
@click="syncBankStatements"
|
@click="syncBankStatements"
|
||||||
class="mr-2"
|
class="mr-2"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<UInput
|
<UInput
|
||||||
id="searchinput"
|
id="searchinput"
|
||||||
name="searchinput"
|
|
||||||
v-model="searchString"
|
v-model="searchString"
|
||||||
icon="i-heroicons-funnel"
|
icon="i-heroicons-magnifying-glass"
|
||||||
autocomplete="off"
|
|
||||||
placeholder="Suche..."
|
placeholder="Suche..."
|
||||||
class="hidden lg:block"
|
|
||||||
@keydown.esc="$event.target.blur()"
|
|
||||||
@change="tempStore.modifySearchString('bankstatements',searchString)"
|
@change="tempStore.modifySearchString('bankstatements',searchString)"
|
||||||
>
|
|
||||||
<template #trailing>
|
|
||||||
<UKbd value="/" />
|
|
||||||
</template>
|
|
||||||
</UInput>
|
|
||||||
<UButton
|
|
||||||
icon="i-heroicons-x-mark"
|
|
||||||
variant="outline"
|
|
||||||
color="rose"
|
|
||||||
@click="clearSearchString()"
|
|
||||||
v-if="searchString.length > 0"
|
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</UDashboardNavbar>
|
</UDashboardNavbar>
|
||||||
|
|
||||||
<UDashboardToolbar>
|
<UDashboardToolbar>
|
||||||
<template #left>
|
<template #left>
|
||||||
<USelectMenu
|
<div class="flex items-center gap-3">
|
||||||
:options="bankaccounts"
|
<USelectMenu
|
||||||
v-model="filterAccount"
|
:options="bankaccounts"
|
||||||
option-attribute="iban"
|
v-model="filterAccount"
|
||||||
multiple
|
option-attribute="iban"
|
||||||
by="id"
|
multiple
|
||||||
:ui-menu="{ width: 'min-w-max' }"
|
by="id"
|
||||||
>
|
placeholder="Konten"
|
||||||
<template #label>
|
class="w-48"
|
||||||
Konto
|
/>
|
||||||
</template>
|
<UDivider orientation="vertical" class="h-6"/>
|
||||||
</USelectMenu>
|
<div class="flex items-center gap-2">
|
||||||
|
<USelectMenu
|
||||||
|
v-model="selectedPeriod"
|
||||||
|
:options="periodOptions"
|
||||||
|
class="w-44"
|
||||||
|
icon="i-heroicons-calendar-days"
|
||||||
|
/>
|
||||||
|
<div v-if="selectedPeriod.key === 'custom'" class="flex items-center gap-1">
|
||||||
|
<UInput type="date" v-model="dateRange.start" size="xs" class="w-32"/>
|
||||||
|
<UInput type="date" v-model="dateRange.end" size="xs" class="w-32"/>
|
||||||
|
</div>
|
||||||
|
<div v-else class="text-xs text-gray-400 hidden sm:block italic">
|
||||||
|
{{ $dayjs(dateRange.start).format('DD.MM.') }} - {{ $dayjs(dateRange.end).format('DD.MM.YYYY') }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #right>
|
<template #right>
|
||||||
<USelectMenu
|
<USelectMenu
|
||||||
icon="i-heroicons-adjustments-horizontal-solid"
|
icon="i-heroicons-adjustments-horizontal"
|
||||||
multiple
|
multiple
|
||||||
v-model="selectedFilters"
|
v-model="selectedFilters"
|
||||||
:options="['Nur offene anzeigen','Nur positive anzeigen','Nur negative anzeigen']"
|
:options="['Nur offene anzeigen','Nur positive anzeigen','Nur negative anzeigen']"
|
||||||
:color="selectedFilters.length > 0 ? 'primary' : 'white'"
|
|
||||||
:ui-menu="{ width: 'min-w-max' }"
|
|
||||||
@change="tempStore.modifyFilter('banking','main',selectedFilters)"
|
@change="tempStore.modifyFilter('banking','main',selectedFilters)"
|
||||||
>
|
/>
|
||||||
<template #label>
|
|
||||||
Filter
|
|
||||||
</template>
|
|
||||||
</USelectMenu>
|
|
||||||
</template>
|
</template>
|
||||||
</UDashboardToolbar>
|
</UDashboardToolbar>
|
||||||
<UTable
|
|
||||||
:rows="filteredRows"
|
|
||||||
:columns="columns"
|
|
||||||
class="w-full"
|
|
||||||
:ui="{ divide: 'divide-gray-200 dark:divide-gray-800' }"
|
|
||||||
@select="(i) => router.push(`/banking/statements/edit/${i.id}`)"
|
|
||||||
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Keine Buchungen anzuzeigen' }"
|
|
||||||
>
|
|
||||||
|
|
||||||
<template #account-data="{row}">
|
<div class="overflow-y-auto relative" style="height: calc(100vh - 200px)">
|
||||||
{{row.account ? bankaccounts.find(i => i.id === row.account).iban : ""}}
|
<div v-if="loadingDocs" class="p-20 flex flex-col items-center justify-center">
|
||||||
</template>
|
<UProgress animation="carousel" class="w-1/3 mb-4" />
|
||||||
<template #valueDate-data="{row}">
|
<span class="text-sm text-gray-500 italic">Bankbuchungen werden geladen...</span>
|
||||||
{{dayjs(row.valueDate).format("DD.MM.YY")}}
|
</div>
|
||||||
</template>
|
|
||||||
<template #amount-data="{row}">
|
<table v-else class="w-full text-left border-collapse">
|
||||||
<span
|
<thead class="sticky top-0 bg-white dark:bg-gray-900 z-10 shadow-sm">
|
||||||
v-if="row.amount >= 0"
|
<tr class="text-xs font-semibold text-gray-500 uppercase">
|
||||||
class="text-primary-500"
|
<th v-for="col in templateColumns" :key="col.key" class="p-4 border-b dark:border-gray-800">
|
||||||
>{{String(row.amount.toFixed(2)).replace(".",",")}} €</span>
|
{{ col.label }}
|
||||||
<span
|
</th>
|
||||||
v-else-if="row.amount < 0"
|
</tr>
|
||||||
class="text-rose-500"
|
</thead>
|
||||||
>{{String(row.amount.toFixed(2)).replace(".",",")}} €</span>
|
<tbody>
|
||||||
</template>
|
<template v-for="(row, index) in filteredRows" :key="row.id">
|
||||||
<template #openAmount-data="{row}">
|
<tr v-if="shouldShowMonthDivider(row, index)">
|
||||||
{{displayCurrency(calculateOpenSum(row))}}
|
<td colspan="6" class="bg-gray-50 dark:bg-gray-800/50 p-2 pl-4 text-sm font-bold text-primary-600 border-y dark:border-gray-800">
|
||||||
</template>
|
<div class="flex items-center gap-2">
|
||||||
<template #partner-data="{row}">
|
<UIcon name="i-heroicons-calendar" class="w-4 h-4"/>
|
||||||
<span
|
{{ $dayjs(row.valueDate).format('MMMM YYYY') }}
|
||||||
v-if="row.amount < 0"
|
</div>
|
||||||
>
|
</td>
|
||||||
{{row.credName}}
|
</tr>
|
||||||
</span>
|
<tr
|
||||||
<span
|
class="hover:bg-gray-50 dark:hover:bg-gray-800/30 cursor-pointer border-b dark:border-gray-800 text-sm group"
|
||||||
v-else-if="row.amount > 0"
|
@click="router.push(`/banking/statements/edit/${row.id}`)"
|
||||||
>
|
>
|
||||||
{{row.debName}}
|
<td class="p-4 text-[10px] text-gray-400 font-mono truncate max-w-[150px]">
|
||||||
</span>
|
{{ row.account ? bankaccounts.find(i => i.id === row.account)?.iban : "" }}
|
||||||
</template>
|
</td>
|
||||||
</UTable>
|
<td class="p-4 whitespace-nowrap">{{ $dayjs(row.valueDate).format("DD.MM.YY") }}</td>
|
||||||
|
<td class="p-4 font-semibold">
|
||||||
|
<span :class="row.amount >= 0 ? 'text-green-600 dark:text-green-400' : 'text-rose-600 dark:text-rose-400'">
|
||||||
|
{{ displayCurrency(row.amount) }}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
<td class="p-4 text-gray-400 italic text-xs">
|
||||||
|
{{ Number(calculateOpenSum(row)) !== 0 ? displayCurrency(calculateOpenSum(row)) : '-' }}
|
||||||
|
</td>
|
||||||
|
<td class="p-4 truncate max-w-[180px] font-medium">
|
||||||
|
{{ row.amount < 0 ? row.credName : row.debName }}
|
||||||
|
</td>
|
||||||
|
<td class="p-4 text-gray-500 truncate max-w-[350px] text-xs">
|
||||||
|
{{ row.text }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</template>
|
||||||
|
<tr v-if="filteredRows.length === 0">
|
||||||
|
<td colspan="6" class="p-32 text-center text-gray-400">
|
||||||
|
<div class="flex flex-col items-center">
|
||||||
|
<UIcon name="i-heroicons-magnifying-glass-circle" class="w-12 h-12 mb-3 opacity-20"/>
|
||||||
|
<p class="font-medium">Keine Buchungen gefunden</p>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
<PageLeaveGuard :when="isSyncing"/>
|
<PageLeaveGuard :when="isSyncing"/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
|
|
||||||
</style>
|
|
||||||
@@ -1,47 +1,28 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
|
import { ref, computed, watch } from 'vue';
|
||||||
|
|
||||||
import {BlobReader, BlobWriter, ZipWriter} from "@zip.js/zip.js";
|
|
||||||
import DocumentDisplayModal from "~/components/DocumentDisplayModal.vue";
|
import DocumentDisplayModal from "~/components/DocumentDisplayModal.vue";
|
||||||
import DocumentUploadModal from "~/components/DocumentUploadModal.vue";
|
import DocumentUploadModal from "~/components/DocumentUploadModal.vue";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import arraySort from "array-sort";
|
import arraySort from "array-sort";
|
||||||
|
|
||||||
|
// --- Shortcuts ---
|
||||||
|
|
||||||
defineShortcuts({
|
defineShortcuts({
|
||||||
'+': () => {
|
'/': () => document.getElementById("searchinput").focus(),
|
||||||
//Hochladen
|
'+': () => { uploadModalOpen.value = true },
|
||||||
uploadModalOpen.value = true
|
|
||||||
},
|
|
||||||
'Enter': {
|
'Enter': {
|
||||||
usingInput: true,
|
usingInput: true,
|
||||||
handler: () => {
|
handler: () => {
|
||||||
let entry = renderedFileList.value[selectedFileIndex.value]
|
const entry = renderedFileList.value[selectedFileIndex.value]
|
||||||
|
if (!entry) return
|
||||||
if(entry.type === "file") {
|
if (entry.type === "file") showFile(entry.id)
|
||||||
showFile(entry.id)
|
else if (entry.type === "folder") changeFolder(folders.value.find(i => i.id === entry.id))
|
||||||
} else if(createFolderModalOpen.value === false && entry.type === "folder") {
|
|
||||||
changeFolder(currentFolders.value.find(i => i.id === entry.id))
|
|
||||||
} else if(createFolderModalOpen.value === true) {
|
|
||||||
createFolder()
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'arrowdown': () => {
|
'arrowdown': () => {
|
||||||
if(selectedFileIndex.value < renderedFileList.value.length - 1) {
|
if (selectedFileIndex.value < renderedFileList.value.length - 1) selectedFileIndex.value++
|
||||||
selectedFileIndex.value += 1
|
|
||||||
} else {
|
|
||||||
selectedFileIndex.value = 0
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
'arrowup': () => {
|
'arrowup': () => {
|
||||||
if(selectedFileIndex.value === 0) {
|
if (selectedFileIndex.value > 0) selectedFileIndex.value--
|
||||||
selectedFileIndex.value = renderedFileList.value.length - 1
|
|
||||||
} else {
|
|
||||||
selectedFileIndex.value -= 1
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -50,486 +31,362 @@ const tempStore = useTempStore()
|
|||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const modal = useModal()
|
const modal = useModal()
|
||||||
|
|
||||||
const auth = useAuthStore()
|
const auth = useAuthStore()
|
||||||
|
|
||||||
const uploadModalOpen = ref(false)
|
|
||||||
const createFolderModalOpen = ref(false)
|
|
||||||
const uploadInProgress = ref(false)
|
|
||||||
const fileUploadFormData = ref({
|
|
||||||
tags: ["Eingang"],
|
|
||||||
path: "",
|
|
||||||
tenant: auth.activeTenant,
|
|
||||||
folder: null
|
|
||||||
})
|
|
||||||
|
|
||||||
const files = useFiles()
|
const files = useFiles()
|
||||||
|
|
||||||
const displayMode = ref("list")
|
// --- State ---
|
||||||
const displayModes = ref([{label: 'Liste',key:'list', icon: 'i-heroicons-list-bullet'},{label: 'Kacheln',key:'rectangles', icon: 'i-heroicons-squares-2x2'}])
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const documents = ref([])
|
const documents = ref([])
|
||||||
const folders = ref([])
|
const folders = ref([])
|
||||||
const filetags = ref([])
|
const filetags = ref([])
|
||||||
|
|
||||||
const currentFolder = ref(null)
|
const currentFolder = ref(null)
|
||||||
|
const loadingDocs = ref(true)
|
||||||
const loadingDocs = ref(false)
|
|
||||||
const isDragTarget = ref(false)
|
|
||||||
|
|
||||||
const loaded = ref(false)
|
const loaded = ref(false)
|
||||||
|
const displayMode = ref("list")
|
||||||
|
const displayModes = [
|
||||||
|
{ label: 'Liste', key: 'list', icon: 'i-heroicons-list-bullet' },
|
||||||
|
{ label: 'Kacheln', key: 'rectangles', icon: 'i-heroicons-squares-2x2' }
|
||||||
|
]
|
||||||
|
|
||||||
|
const createFolderModalOpen = ref(false)
|
||||||
|
const createFolderData = ref({ name: '', standardFiletype: null, standardFiletypeIsOptional: true })
|
||||||
|
const selectedFiles = ref({})
|
||||||
|
const selectedFileIndex = ref(0)
|
||||||
|
|
||||||
|
// --- Search & Debounce ---
|
||||||
|
const searchString = ref(tempStore.searchStrings["files"] || '')
|
||||||
|
const debouncedSearch = ref(searchString.value)
|
||||||
|
let debounceTimeout = null
|
||||||
|
|
||||||
|
watch(searchString, (val) => {
|
||||||
|
clearTimeout(debounceTimeout)
|
||||||
|
debounceTimeout = setTimeout(() => {
|
||||||
|
debouncedSearch.value = val
|
||||||
|
tempStore.modifySearchString('files', val)
|
||||||
|
}, 300)
|
||||||
|
})
|
||||||
|
|
||||||
|
// --- Logic ---
|
||||||
const setupPage = async () => {
|
const setupPage = async () => {
|
||||||
folders.value = await useEntities("folders").select()
|
loadingDocs.value = true
|
||||||
|
const [fRes, dRes, tRes] = await Promise.all([
|
||||||
|
useEntities("folders").select(),
|
||||||
|
files.selectDocuments(),
|
||||||
|
useEntities("filetags").select()
|
||||||
|
])
|
||||||
|
folders.value = fRes
|
||||||
|
documents.value = dRes
|
||||||
|
filetags.value = tRes
|
||||||
|
|
||||||
documents.value = await files.selectDocuments()
|
if (route.query?.folder) {
|
||||||
|
currentFolder.value = folders.value.find(i => i.id === route.query.folder) || null
|
||||||
filetags.value = await useEntities("filetags").select()
|
|
||||||
|
|
||||||
if(route.query) {
|
|
||||||
if(route.query.folder) {
|
|
||||||
currentFolder.value = await useEntities("folders").selectSingle(route.query.folder)
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const dropZone = document.getElementById("drop_zone")
|
|
||||||
dropZone.ondragover = function (event) {
|
|
||||||
modal.open(DocumentUploadModal,{fileData: {folder: currentFolder.value.id, type: currentFolder.value.standardFiletype, typeEnabled: currentFolder.value.standardFiletypeIsOptional}, onUploadFinished: () => {
|
|
||||||
setupPage()
|
|
||||||
}})
|
|
||||||
event.preventDefault()
|
|
||||||
}
|
|
||||||
|
|
||||||
dropZone.ondragleave = function (event) {
|
|
||||||
isDragTarget.value = false
|
|
||||||
}
|
|
||||||
|
|
||||||
dropZone.ondrop = async function (event) {
|
|
||||||
event.preventDefault()
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
loadingDocs.value = false
|
loadingDocs.value = false
|
||||||
loaded.value = true
|
loaded.value = true
|
||||||
|
|
||||||
}
|
}
|
||||||
setupPage()
|
|
||||||
|
onMounted(() => setupPage())
|
||||||
|
|
||||||
const currentFolders = computed(() => {
|
const currentFolders = computed(() => {
|
||||||
if(folders.value.length > 0) {
|
return folders.value
|
||||||
|
.filter(i => currentFolder.value ? i.parent === currentFolder.value.id : !i.parent)
|
||||||
let tempFolders = folders.value.filter(i => currentFolder.value ? i.parent === currentFolder.value.id : !i.parent)
|
.sort((a, b) => a.name.localeCompare(b.name, undefined, { sensitivity: 'base' }))
|
||||||
|
|
||||||
return tempFolders
|
|
||||||
} else return []
|
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const breadcrumbLinks = computed(() => {
|
const breadcrumbLinks = computed(() => {
|
||||||
|
const links = [{ label: "Home", icon: "i-heroicons-home", click: () => changeFolder(null) }]
|
||||||
if(currentFolder.value) {
|
if (currentFolder.value) {
|
||||||
let parents = []
|
let path = []
|
||||||
|
let curr = currentFolder.value
|
||||||
const addParent = (parent) => {
|
while (curr) {
|
||||||
parents.push(parent)
|
path.unshift({
|
||||||
if(parent.parent) {
|
label: curr.name,
|
||||||
addParent(folders.value.find(i => i.id === parent.parent))
|
icon: "i-heroicons-folder",
|
||||||
}
|
click: () => changeFolder(folders.value.find(f => f.id === curr.id))
|
||||||
|
})
|
||||||
|
curr = folders.value.find(f => f.id === curr.parent)
|
||||||
}
|
}
|
||||||
|
return [...links, ...path]
|
||||||
if(currentFolder.value.parent) {
|
|
||||||
addParent(folders.value.find(i => i.id === currentFolder.value.parent))
|
|
||||||
}
|
|
||||||
|
|
||||||
return [{
|
|
||||||
label: "Home",
|
|
||||||
click: () => {
|
|
||||||
changeFolder(null)
|
|
||||||
},
|
|
||||||
icon: "i-heroicons-folder"
|
|
||||||
},
|
|
||||||
...parents.map(i => {
|
|
||||||
return {
|
|
||||||
label: folders.value.find(x => x.id === i.id).name,
|
|
||||||
click: () => {
|
|
||||||
changeFolder(i)
|
|
||||||
},
|
|
||||||
icon: "i-heroicons-folder"
|
|
||||||
}
|
|
||||||
}).reverse(),
|
|
||||||
{
|
|
||||||
label: currentFolder.value.name,
|
|
||||||
click: () => {
|
|
||||||
changeFolder(currentFolder.value)
|
|
||||||
},
|
|
||||||
icon: "i-heroicons-folder"
|
|
||||||
}]
|
|
||||||
|
|
||||||
} else {
|
|
||||||
return [{
|
|
||||||
label: "Home",
|
|
||||||
click: () => {
|
|
||||||
changeFolder(null)
|
|
||||||
},
|
|
||||||
icon: "i-heroicons-folder"
|
|
||||||
}]
|
|
||||||
}
|
}
|
||||||
|
return links
|
||||||
})
|
})
|
||||||
|
|
||||||
const filteredDocuments = computed(() => {
|
const renderedFileList = computed(() => {
|
||||||
|
const folderList = currentFolders.value.map(i => ({
|
||||||
|
label: i.name,
|
||||||
|
id: i.id,
|
||||||
|
type: "folder",
|
||||||
|
createdAt: i.createdAt
|
||||||
|
}))
|
||||||
|
|
||||||
return documents.value.filter(i => currentFolder.value ? i.folder === currentFolder.value.id : !i.folder)
|
const fileList = documents.value
|
||||||
|
.filter(i => currentFolder.value ? i.folder === currentFolder.value.id : !i.folder)
|
||||||
|
.map(i => ({
|
||||||
|
label: i.path.split("/").pop(),
|
||||||
|
id: i.id,
|
||||||
|
type: "file",
|
||||||
|
createdAt: i.createdAt
|
||||||
|
}))
|
||||||
|
.sort((a, b) => a.label.localeCompare(b.label, undefined, { sensitivity: 'base' }))
|
||||||
|
|
||||||
|
let combined = [...folderList, ...fileList]
|
||||||
|
if (debouncedSearch.value) {
|
||||||
|
combined = useSearch(debouncedSearch.value, combined)
|
||||||
|
}
|
||||||
|
return combined
|
||||||
})
|
})
|
||||||
|
|
||||||
const changeFolder = async (newFolder) => {
|
const changeFolder = async (folder) => {
|
||||||
loadingDocs.value = true
|
currentFolder.value = folder
|
||||||
currentFolder.value = newFolder
|
await router.push(folder ? `/files?folder=${folder.id}` : `/files`)
|
||||||
|
}
|
||||||
if(newFolder) {
|
|
||||||
fileUploadFormData.value.folder = newFolder.id
|
|
||||||
await router.push(`/files?folder=${newFolder.id}`)
|
|
||||||
} else {
|
|
||||||
fileUploadFormData.value.folder = null
|
|
||||||
await router.push(`/files`)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
const createFolder = async () => {
|
||||||
|
await useEntities("folders").create({
|
||||||
|
parent: currentFolder.value?.id,
|
||||||
|
name: createFolderData.value.name,
|
||||||
|
standardFiletype: createFolderData.value.standardFiletype,
|
||||||
|
standardFiletypeIsOptional: createFolderData.value.standardFiletypeIsOptional
|
||||||
|
})
|
||||||
|
createFolderModalOpen.value = false
|
||||||
|
createFolderData.value = { name: '', standardFiletype: null, standardFiletypeIsOptional: true }
|
||||||
setupPage()
|
setupPage()
|
||||||
}
|
}
|
||||||
|
|
||||||
const createFolderData = ref({})
|
const showFile = (fileId) => {
|
||||||
const createFolder = async () => {
|
modal.open(DocumentDisplayModal, {
|
||||||
const res = await useEntities("folders").create({
|
documentData: documents.value.find(i => i.id === fileId),
|
||||||
parent: currentFolder.value ? currentFolder.value.id : undefined,
|
onUpdatedNeeded: () => setupPage()
|
||||||
name: createFolderData.value.name,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
createFolderModalOpen.value = false
|
|
||||||
|
|
||||||
setupPage()
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const downloadSelected = async () => {
|
const downloadSelected = async () => {
|
||||||
|
const ids = Object.keys(selectedFiles.value).filter(k => selectedFiles.value[k])
|
||||||
let files = []
|
await useFiles().downloadFile(undefined, ids)
|
||||||
|
|
||||||
files = filteredDocuments.value.filter(i => selectedFiles.value[i.id] === true).map(i => i.path)
|
|
||||||
|
|
||||||
|
|
||||||
await useFiles().downloadFile(undefined,Object.keys(selectedFiles.value))
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
const searchString = ref(tempStore.searchStrings["files"] ||'')
|
|
||||||
const renderedFileList = computed(() => {
|
|
||||||
let files = filteredDocuments.value.map(i => {
|
|
||||||
return {
|
|
||||||
label: i.path.split("/")[i.path.split("/").length -1],
|
|
||||||
id: i.id,
|
|
||||||
type: "file"
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
arraySort(files, (a,b) => {
|
|
||||||
let aVal = a.path ? a.path.split("/")[a.path.split("/").length -1] : null
|
|
||||||
let bVal = b.path ? b.path.split("/")[b.path.split("/").length -1] : null
|
|
||||||
|
|
||||||
if(aVal && bVal) {
|
|
||||||
return aVal.localeCompare(bVal)
|
|
||||||
} else if(!aVal && bVal) {
|
|
||||||
return 1
|
|
||||||
} else {
|
|
||||||
return -1
|
|
||||||
}
|
|
||||||
}, {reverse: true})
|
|
||||||
|
|
||||||
if(searchString.value.length > 0) {
|
|
||||||
files = useSearch(searchString.value, files)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
let folders = currentFolders.value.map(i => {
|
|
||||||
return {
|
|
||||||
label: i.name,
|
|
||||||
id: i.id,
|
|
||||||
type: "folder"
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
arraySort(folders, "label")
|
|
||||||
|
|
||||||
/*folders.sort(function(a, b) {
|
|
||||||
|
|
||||||
// Compare the 2 dates
|
|
||||||
if (a.name < b.name) return -1;
|
|
||||||
if (a.name > b.name) return 1;
|
|
||||||
return 0;
|
|
||||||
});*/
|
|
||||||
return [...folders,...files]
|
|
||||||
|
|
||||||
})
|
|
||||||
const selectedFileIndex = ref(0)
|
|
||||||
|
|
||||||
const showFile = (fileId) => {
|
|
||||||
modal.open(DocumentDisplayModal,{
|
|
||||||
documentData: documents.value.find(i => i.id === fileId),
|
|
||||||
onUpdatedNeeded: setupPage()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
const selectedFiles = ref({});
|
|
||||||
|
|
||||||
const selectAll = () => {
|
|
||||||
if(Object.keys(selectedFiles.value).find(i => selectedFiles.value[i] === true)) {
|
|
||||||
selectedFiles.value = {}
|
|
||||||
} else {
|
|
||||||
selectedFiles.value = Object.fromEntries(filteredDocuments.value.map(i => i.id).map(k => [k,true]))
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const clearSearchString = () => {
|
const clearSearchString = () => {
|
||||||
tempStore.clearSearchString("files")
|
|
||||||
searchString.value = ''
|
searchString.value = ''
|
||||||
|
debouncedSearch.value = ''
|
||||||
|
tempStore.clearSearchString("files")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const selectAll = (event) => {
|
||||||
|
if (event.target.checked) {
|
||||||
|
const obj = {}
|
||||||
|
renderedFileList.value.filter(e => e.type === 'file').forEach(e => obj[e.id] = true)
|
||||||
|
selectedFiles.value = obj
|
||||||
|
} else {
|
||||||
|
selectedFiles.value = {}
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
<UDashboardNavbar title="Dateien">
|
||||||
<UDashboardNavbar
|
|
||||||
title="Dateien"
|
|
||||||
>
|
|
||||||
<template #right>
|
<template #right>
|
||||||
<UInput
|
<UInput
|
||||||
id="searchinput"
|
id="searchinput"
|
||||||
v-model="searchString"
|
v-model="searchString"
|
||||||
icon="i-heroicons-funnel"
|
icon="i-heroicons-magnifying-glass"
|
||||||
autocomplete="off"
|
autocomplete="off"
|
||||||
placeholder="Suche..."
|
placeholder="Suche..."
|
||||||
class="hidden lg:block"
|
class="hidden lg:block w-64"
|
||||||
@keydown.esc="$event.target.blur()"
|
@keydown.esc="$event.target.blur()"
|
||||||
@change="tempStore.modifySearchString('files',searchString)"
|
|
||||||
>
|
>
|
||||||
<template #trailing>
|
<template #trailing>
|
||||||
<UKbd value="/" />
|
<div class="flex items-center gap-1">
|
||||||
|
<UKbd value="/" />
|
||||||
|
<UButton
|
||||||
|
v-if="searchString.length > 0"
|
||||||
|
icon="i-heroicons-x-mark"
|
||||||
|
variant="ghost"
|
||||||
|
color="gray"
|
||||||
|
size="xs"
|
||||||
|
@click="clearSearchString"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</UInput>
|
</UInput>
|
||||||
<UButton
|
|
||||||
icon="i-heroicons-x-mark"
|
|
||||||
variant="outline"
|
|
||||||
color="rose"
|
|
||||||
@click="clearSearchString()"
|
|
||||||
v-if="searchString.length > 0"
|
|
||||||
/>
|
|
||||||
</template>
|
</template>
|
||||||
</UDashboardNavbar>
|
</UDashboardNavbar>
|
||||||
<UDashboardToolbar>
|
|
||||||
|
<UDashboardToolbar class="sticky top-0 z-10 bg-white dark:bg-gray-900 border-b border-gray-200 dark:border-gray-800">
|
||||||
<template #left>
|
<template #left>
|
||||||
<UBreadcrumb
|
<UBreadcrumb :links="breadcrumbLinks" :ui="{ ol: 'gap-x-2', li: 'text-sm' }" />
|
||||||
:links="breadcrumbLinks"
|
|
||||||
/>
|
|
||||||
</template>
|
</template>
|
||||||
<template #right>
|
<template #right>
|
||||||
<USelectMenu
|
<USelectMenu
|
||||||
:options="displayModes"
|
v-model="displayMode"
|
||||||
value-attribute="key"
|
:options="displayModes"
|
||||||
option-attribute="label"
|
value-attribute="key"
|
||||||
v-model="displayMode"
|
class="w-32"
|
||||||
:ui-menu="{ width: 'min-w-max'}"
|
|
||||||
>
|
>
|
||||||
<template #label>
|
<template #label>
|
||||||
<UIcon class="w-5 h-5" :name="displayModes.find(i => i.key === displayMode).icon"/>
|
<UIcon :name="displayModes.find(i => i.key === displayMode).icon" class="w-4 h-4" />
|
||||||
|
<span>{{ displayModes.find(i => i.key === displayMode).label }}</span>
|
||||||
</template>
|
</template>
|
||||||
</USelectMenu>
|
</USelectMenu>
|
||||||
|
|
||||||
|
<UButtonGroup size="sm">
|
||||||
|
<UButton
|
||||||
|
icon="i-heroicons-document-plus"
|
||||||
|
color="primary"
|
||||||
|
@click="modal.open(DocumentUploadModal, {
|
||||||
|
fileData: {
|
||||||
|
folder: currentFolder?.id,
|
||||||
|
type: currentFolder?.standardFiletype,
|
||||||
|
typeEnabled: currentFolder?.standardFiletypeIsOptional
|
||||||
|
},
|
||||||
|
onUploadFinished: () => setupPage()
|
||||||
|
})"
|
||||||
|
>Datei</UButton>
|
||||||
|
<UButton
|
||||||
|
icon="i-heroicons-folder-plus"
|
||||||
|
color="white"
|
||||||
|
@click="createFolderModalOpen = true"
|
||||||
|
>Ordner</UButton>
|
||||||
|
</UButtonGroup>
|
||||||
|
|
||||||
<UButton
|
<UButton
|
||||||
:disabled="!currentFolder"
|
v-if="Object.values(selectedFiles).some(Boolean)"
|
||||||
@click="modal.open(DocumentUploadModal,{fileData: {folder: currentFolder.id, type: currentFolder.standardFiletype, typeEnabled: currentFolder.standardFiletypeIsOptional}, onUploadFinished: () => {setupPage()}})"
|
|
||||||
>+ Datei</UButton>
|
|
||||||
<UButton
|
|
||||||
@click="createFolderModalOpen = true"
|
|
||||||
variant="outline"
|
|
||||||
>+ Ordner</UButton>
|
|
||||||
<UButton
|
|
||||||
@click="downloadSelected"
|
|
||||||
icon="i-heroicons-cloud-arrow-down"
|
icon="i-heroicons-cloud-arrow-down"
|
||||||
variant="outline"
|
color="gray"
|
||||||
v-if="Object.keys(selectedFiles).find(i => selectedFiles[i] === true)"
|
variant="solid"
|
||||||
>Herunterladen</UButton>
|
@click="downloadSelected"
|
||||||
<UModal v-model="createFolderModalOpen">
|
>Download</UButton>
|
||||||
<UCard :ui="{ body: { base: 'space-y-4' } }">
|
</template>
|
||||||
<template #header>
|
</UDashboardToolbar>
|
||||||
<div class="flex items-center justify-between">
|
|
||||||
<h3 class="text-base font-semibold leading-6 text-gray-900 dark:text-white">
|
|
||||||
Ordner Erstellen
|
|
||||||
</h3>
|
|
||||||
<UButton color="gray" variant="ghost" icon="i-heroicons-x-mark-20-solid" class="-my-1" @click="createFolderModalOpen = false" />
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<UFormGroup label="Name des Ordners" required>
|
<div id="drop_zone" class="flex-1 overflow-hidden flex flex-col relative">
|
||||||
<UInput
|
<div v-if="!loaded" class="p-10 flex justify-center">
|
||||||
v-model="createFolderData.name"
|
<UProgress animation="carousel" class="w-1/2" />
|
||||||
placeholder="z.B. Rechnungen 2024"
|
</div>
|
||||||
autofocus
|
|
||||||
/>
|
<UDashboardPanelContent v-else class="p-0 overflow-y-auto">
|
||||||
|
<div v-if="displayMode === 'list'" class="min-w-full inline-block align-middle">
|
||||||
|
<table class="min-w-full divide-y divide-gray-300 dark:divide-gray-700">
|
||||||
|
<thead class="bg-gray-50 dark:bg-gray-800 sticky top-0 z-20">
|
||||||
|
<tr>
|
||||||
|
<th scope="col" class="py-3.5 pl-4 pr-3 sm:pl-6 w-10">
|
||||||
|
<UCheckbox @change="selectAll" />
|
||||||
|
</th>
|
||||||
|
<th scope="col" class="py-3.5 pl-4 pr-3 text-left text-sm font-semibold text-gray-900 dark:text-white sm:pl-6">Name</th>
|
||||||
|
<th scope="col" class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900 dark:text-white">Erstellt am</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody class="divide-y divide-gray-200 dark:divide-gray-800 bg-white dark:bg-gray-900">
|
||||||
|
<tr
|
||||||
|
v-for="(entry, index) in renderedFileList"
|
||||||
|
:key="entry.id"
|
||||||
|
class="hover:bg-gray-50 dark:hover:bg-gray-800/50 cursor-pointer transition-colors"
|
||||||
|
:class="{'bg-primary-50 dark:bg-primary-900/10': index === selectedFileIndex}"
|
||||||
|
@click="entry.type === 'folder' ? changeFolder(entry) : showFile(entry.id)"
|
||||||
|
>
|
||||||
|
<td class="relative w-12 px-6 sm:w-16 sm:px-8" @click.stop>
|
||||||
|
<UCheckbox v-if="entry.type === 'file'" v-model="selectedFiles[entry.id]" />
|
||||||
|
</td>
|
||||||
|
<td class="whitespace-nowrap py-4 pl-4 pr-3 text-sm sm:pl-6">
|
||||||
|
<div class="flex items-center">
|
||||||
|
<UIcon
|
||||||
|
:name="entry.type === 'folder' ? 'i-heroicons-folder-solid' : 'i-heroicons-document-text'"
|
||||||
|
class="flex-shrink-0 h-5 w-5 mr-3"
|
||||||
|
:class="entry.type === 'folder' ? 'text-primary-500' : 'text-gray-400'"
|
||||||
|
/>
|
||||||
|
<span class="font-medium text-gray-900 dark:text-white truncate max-w-md">
|
||||||
|
{{ entry.label }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500 dark:text-gray-400">
|
||||||
|
{{ dayjs(entry.createdAt).format("DD.MM.YY · HH:mm") }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-else class="p-6">
|
||||||
|
<div class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-6 xl:grid-cols-8 gap-4">
|
||||||
|
<div
|
||||||
|
v-for="folder in currentFolders"
|
||||||
|
:key="folder.id"
|
||||||
|
class="group relative bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl p-4 flex flex-col items-center hover:border-primary-500 transition-all cursor-pointer"
|
||||||
|
@click="changeFolder(folder)"
|
||||||
|
>
|
||||||
|
<UIcon name="i-heroicons-folder-solid" class="w-12 h-12 text-primary-500 mb-2 group-hover:scale-110 transition-transform" />
|
||||||
|
<span class="text-sm font-medium text-center truncate w-full">{{ folder.name }}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-for="doc in renderedFileList.filter(e => e.type === 'file')"
|
||||||
|
:key="doc.id"
|
||||||
|
class="group relative bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl p-4 flex flex-col items-center hover:border-primary-500 transition-all cursor-pointer"
|
||||||
|
@click="showFile(doc.id)"
|
||||||
|
>
|
||||||
|
<UCheckbox v-model="selectedFiles[doc.id]" class="absolute top-2 left-2 opacity-0 group-hover:opacity-100 transition-opacity" @click.stop />
|
||||||
|
<UIcon name="i-heroicons-document-text" class="w-12 h-12 text-gray-400 mb-2 group-hover:scale-110 transition-transform" />
|
||||||
|
<span class="text-sm font-medium text-center truncate w-full">{{ doc.label }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</UDashboardPanelContent>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<UModal v-model="createFolderModalOpen">
|
||||||
|
<UCard>
|
||||||
|
<template #header>
|
||||||
|
<div class="flex items-center justify-between">
|
||||||
|
<h3 class="text-lg font-bold">Ordner erstellen</h3>
|
||||||
|
<UButton color="gray" variant="ghost" icon="i-heroicons-x-mark" @click="createFolderModalOpen = false" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<div class="space-y-4">
|
||||||
|
<UFormGroup label="Name" required>
|
||||||
|
<UInput v-model="createFolderData.name" placeholder="Name eingeben..." autofocus @keyup.enter="createFolder" />
|
||||||
</UFormGroup>
|
</UFormGroup>
|
||||||
|
|
||||||
<UFormGroup
|
<UFormGroup label="Standard-Dateityp">
|
||||||
label="Standard Dateityp"
|
|
||||||
>
|
|
||||||
<USelectMenu
|
<USelectMenu
|
||||||
v-model="createFolderData.standardFiletype"
|
v-model="createFolderData.standardFiletype"
|
||||||
:options="filetags"
|
:options="filetags"
|
||||||
option-attribute="name"
|
option-attribute="name"
|
||||||
value-attribute="id"
|
value-attribute="id"
|
||||||
searchable
|
placeholder="Kein Standard"
|
||||||
searchable-placeholder="Typ suchen..."
|
/>
|
||||||
placeholder="Kein Standard-Typ"
|
|
||||||
clear-search-on-close
|
|
||||||
>
|
|
||||||
<template #label>
|
|
||||||
<span v-if="createFolderData.standardFiletype">
|
|
||||||
{{ filetags.find(t => t.id === createFolderData.standardFiletype)?.name }}
|
|
||||||
</span>
|
|
||||||
<span v-else class="text-gray-400">Kein Typ ausgewählt</span>
|
|
||||||
</template>
|
|
||||||
</USelectMenu>
|
|
||||||
</UFormGroup>
|
</UFormGroup>
|
||||||
|
|
||||||
<div v-if="createFolderData.standardFiletype">
|
<UCheckbox
|
||||||
<UCheckbox
|
v-if="createFolderData.standardFiletype"
|
||||||
v-model="createFolderData.standardFiletypeIsOptional"
|
v-model="createFolderData.standardFiletypeIsOptional"
|
||||||
name="isOptional"
|
label="Typ ist optional"
|
||||||
label="Dateityp ist optional"
|
/>
|
||||||
help="Wenn deaktiviert, MUSS der Nutzer beim Upload diesen Typ verwenden."
|
</div>
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<div class="flex justify-end gap-2">
|
<div class="flex justify-end gap-2">
|
||||||
<UButton color="gray" variant="ghost" @click="createFolderModalOpen = false">
|
<UButton color="gray" variant="soft" @click="createFolderModalOpen = false">Abbrechen</UButton>
|
||||||
Abbrechen
|
<UButton color="primary" :disabled="!createFolderData.name" @click="createFolder">Erstellen</UButton>
|
||||||
</UButton>
|
|
||||||
<UButton @click="createFolder" :disabled="!createFolderData.name">
|
|
||||||
Erstellen
|
|
||||||
</UButton>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</UCard>
|
|
||||||
</UModal>
|
|
||||||
|
|
||||||
</template>
|
|
||||||
</UDashboardToolbar>
|
|
||||||
<div id="drop_zone" class="h-full scrollList" >
|
|
||||||
<div v-if="loaded">
|
|
||||||
<UDashboardPanelContent>
|
|
||||||
<div v-if="displayMode === 'list'">
|
|
||||||
<table class="w-full">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<UCheckbox
|
|
||||||
v-if="renderedFileList.find(i => i.type === 'file')"
|
|
||||||
@change="selectAll"
|
|
||||||
/>
|
|
||||||
</td>
|
|
||||||
<td class="font-bold">Name</td>
|
|
||||||
<td class="font-bold">Erstellt am</td>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tr v-for="(entry,index) in renderedFileList">
|
|
||||||
<td>
|
|
||||||
<UCheckbox
|
|
||||||
v-if="entry.type === 'file'"
|
|
||||||
v-model="selectedFiles[entry.id]"
|
|
||||||
/>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<UIcon class="mr-1" :name="entry.type === 'folder' ? 'i-heroicons-folder' : 'i-heroicons-document'"/>
|
|
||||||
<a
|
|
||||||
style="cursor: pointer"
|
|
||||||
:class="[...index === selectedFileIndex ? ['text-primary', 'text-xl'] : ['dark:text-white','text-black','text-xl']]"
|
|
||||||
@click="entry.type === 'folder' ? changeFolder(currentFolders.find(i => i.id === entry.id)) : showFile(entry.id)"
|
|
||||||
>{{entry.label}}</a>
|
|
||||||
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<span v-if="entry.type === 'file'" class="text-xl">{{dayjs(documents.find(i => i.id === entry.id).createdAt).format("DD.MM.YY HH:mm")}}</span>
|
|
||||||
<span v-if="entry.type === 'folder'" class="text-xl">{{dayjs(currentFolders.find(i => i.id === entry.id).createdAt).format("DD.MM.YY HH:mm")}}</span>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="displayMode === 'rectangles'">
|
</template>
|
||||||
<div class="flex flex-row w-full flex-wrap" v-if="currentFolders.length > 0">
|
</UCard>
|
||||||
<a
|
</UModal>
|
||||||
class="w-1/6 folderIcon flex flex-col p-5 m-2"
|
|
||||||
v-for="folder in currentFolders"
|
|
||||||
@click="changeFolder(folder)"
|
|
||||||
>
|
|
||||||
|
|
||||||
<UIcon
|
|
||||||
name="i-heroicons-folder"
|
|
||||||
class="w-20 h-20"
|
|
||||||
/>
|
|
||||||
<span class="text-center truncate">{{folder.name}}</span>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<UDivider class="my-5" v-if="currentFolder">{{currentFolder.name}}</UDivider>
|
|
||||||
<UDivider class="my-5" v-else>Ablage</UDivider>
|
|
||||||
|
|
||||||
<div v-if="!loadingDocs">
|
|
||||||
<DocumentList
|
|
||||||
v-if="filteredDocuments.length > 0"
|
|
||||||
:documents="filteredDocuments"
|
|
||||||
@selectDocument="(info) => console.log(info)"
|
|
||||||
/>
|
|
||||||
<UAlert
|
|
||||||
v-else
|
|
||||||
class="mt-5 w-1/2 mx-auto"
|
|
||||||
icon="i-heroicons-light-bulb"
|
|
||||||
title="Keine Dokumente vorhanden"
|
|
||||||
color="primary"
|
|
||||||
variant="outline"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<UProgress
|
|
||||||
animation="carousel"
|
|
||||||
v-else
|
|
||||||
class="w-2/3 my-5 mx-auto"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</UDashboardPanelContent>
|
|
||||||
</div>
|
|
||||||
<UProgress animation="carousel" v-else class="w-5/6 mx-auto mt-5"/>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.folderIcon {
|
#drop_zone::after {
|
||||||
border: 1px solid lightgrey;
|
content: 'Datei hierher ziehen';
|
||||||
border-radius: 10px;
|
@apply absolute inset-0 flex items-center justify-center bg-primary-500/10 border-4 border-dashed border-primary-500 opacity-0 pointer-events-none transition-opacity z-50 rounded-xl m-4;
|
||||||
color: dimgrey;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.folderIcon:hover {
|
#drop_zone:hover::after {
|
||||||
border: 1px solid #69c350;
|
/* In der setupPage Logik wird das Modal getriggert,
|
||||||
color: #69c350;
|
dieser Style dient nur der visuellen Hilfe */
|
||||||
}
|
}
|
||||||
|
|
||||||
tr:nth-child(odd) {
|
/* Custom Table Shadows & Borders */
|
||||||
background-color: rgba(0, 0, 0, 0.05);
|
table {
|
||||||
|
border-collapse: separate;
|
||||||
|
border-spacing: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
@@ -3,10 +3,16 @@ import duration from 'dayjs/plugin/duration'
|
|||||||
import relativeTime from 'dayjs/plugin/relativeTime'
|
import relativeTime from 'dayjs/plugin/relativeTime'
|
||||||
import localizedFormat from 'dayjs/plugin/localizedFormat'
|
import localizedFormat from 'dayjs/plugin/localizedFormat'
|
||||||
import 'dayjs/locale/de'
|
import 'dayjs/locale/de'
|
||||||
|
import quarterOfYear from 'dayjs/plugin/quarterOfYear'
|
||||||
|
import isSameOrAfter from "dayjs/plugin/isSameOrAfter"
|
||||||
|
import isSameOrBefore from "dayjs/plugin/isSameOrBefore"
|
||||||
|
|
||||||
dayjs.extend(duration)
|
dayjs.extend(duration)
|
||||||
dayjs.extend(relativeTime)
|
dayjs.extend(relativeTime)
|
||||||
dayjs.extend(localizedFormat)
|
dayjs.extend(localizedFormat)
|
||||||
|
dayjs.extend(quarterOfYear)
|
||||||
|
dayjs.extend(isSameOrAfter)
|
||||||
|
dayjs.extend(isSameOrBefore)
|
||||||
dayjs.locale('de')
|
dayjs.locale('de')
|
||||||
|
|
||||||
export default defineNuxtPlugin(() => {
|
export default defineNuxtPlugin(() => {
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import {defineStore} from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
export const useTempStore = defineStore('temp', () => {
|
export const useTempStore = defineStore('temp', () => {
|
||||||
|
|
||||||
const auth = useAuthStore()
|
const auth = useAuthStore()
|
||||||
|
|
||||||
const searchStrings = ref({})
|
const searchStrings = ref({})
|
||||||
@@ -20,21 +19,21 @@ export const useTempStore = defineStore('temp', () => {
|
|||||||
filters: filters.value
|
filters: filters.value
|
||||||
}
|
}
|
||||||
|
|
||||||
await useNuxtApp().$api(`/api/profiles/${auth.profile.id}`,{
|
await useNuxtApp().$api(`/api/profiles/${auth.profile.id}`, {
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
body: {temp_config: config}
|
body: { temp_config: config }
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function setStoredTempConfig (config) {
|
function setStoredTempConfig(config) {
|
||||||
searchStrings.value = config.searchStrings
|
searchStrings.value = config.searchStrings || {}
|
||||||
columns.value = config.columns
|
columns.value = config.columns || {}
|
||||||
pages.value = config.pages
|
pages.value = config.pages || {}
|
||||||
settings.value = config.settings
|
settings.value = config.settings || {}
|
||||||
filters.value = config.filters || {}
|
filters.value = config.filters || {}
|
||||||
}
|
}
|
||||||
|
|
||||||
function modifySearchString(type,input) {
|
function modifySearchString(type, input) {
|
||||||
searchStrings.value[type] = input
|
searchStrings.value[type] = input
|
||||||
storeTempConfig()
|
storeTempConfig()
|
||||||
}
|
}
|
||||||
@@ -44,28 +43,36 @@ export const useTempStore = defineStore('temp', () => {
|
|||||||
storeTempConfig()
|
storeTempConfig()
|
||||||
}
|
}
|
||||||
|
|
||||||
function modifyFilter(domain,type,input) {
|
function modifyFilter(domain, type, input) {
|
||||||
if(!filters.value[domain]) filters.value[domain] = {}
|
if (!filters.value[domain]) filters.value[domain] = {}
|
||||||
|
|
||||||
filters.value[domain][type] = input
|
filters.value[domain][type] = input
|
||||||
storeTempConfig()
|
storeTempConfig()
|
||||||
}
|
}
|
||||||
|
|
||||||
function modifyColumns(type,input) {
|
function modifyColumns(type, input) {
|
||||||
columns.value[type] = input
|
columns.value[type] = input
|
||||||
storeTempConfig()
|
storeTempConfig()
|
||||||
}
|
}
|
||||||
|
|
||||||
function modifyPages(type,input) {
|
function modifyPages(type, input) {
|
||||||
pages.value[type] = input
|
pages.value[type] = input
|
||||||
storeTempConfig()
|
storeTempConfig()
|
||||||
}
|
}
|
||||||
|
|
||||||
function modifySettings(type,input) {
|
function modifySettings(type, input) {
|
||||||
settings.value[type] = input
|
settings.value[type] = input
|
||||||
storeTempConfig()
|
storeTempConfig()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Spezifisch für das Banking-Datum
|
||||||
|
function modifyBankingPeriod(periodKey, range) {
|
||||||
|
if (!settings.value['banking']) settings.value['banking'] = {}
|
||||||
|
|
||||||
|
settings.value['banking'].periodKey = periodKey
|
||||||
|
settings.value['banking'].range = range
|
||||||
|
|
||||||
|
storeTempConfig()
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
setStoredTempConfig,
|
setStoredTempConfig,
|
||||||
@@ -79,8 +86,7 @@ export const useTempStore = defineStore('temp', () => {
|
|||||||
modifyPages,
|
modifyPages,
|
||||||
pages,
|
pages,
|
||||||
modifySettings,
|
modifySettings,
|
||||||
|
modifyBankingPeriod, // Neue Funktion exportiert
|
||||||
settings
|
settings
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
})
|
})
|
||||||
Reference in New Issue
Block a user