From fe74e7d91bf020b54aaacd8c95be2ef6862e04d3 Mon Sep 17 00:00:00 2001 From: flfeders Date: Tue, 30 Jan 2024 21:18:46 +0100 Subject: [PATCH] Changes in RLS and Tenants Many Changes in Invoice Editor Page Loading Rebuilt Started Rights Management --- spaces/app.vue | 374 +---------------- spaces/components/DocumentDisplay.vue | 2 +- spaces/layouts/default.vue | 375 +++++++++++++++++- .../edit/[[id]].vue} | 164 +++++--- spaces/pages/createDocument/show/[id].vue | 25 ++ spaces/pages/login.vue | 39 +- spaces/pages/projects/[mode]/[[id]].vue | 23 +- .../incomingInvoices}/[mode]/[[id]].vue | 20 +- .../{incominginvoices => receipts}/index.vue | 70 +++- spaces/pages/settings/numberRanges.vue | 4 +- spaces/pages/settings/rights.vue | 78 ++++ spaces/pages/vehicles/[mode]/[[id]].vue | 2 +- spaces/stores/{data.ts => data.js} | 236 +++++++---- 13 files changed, 885 insertions(+), 527 deletions(-) rename spaces/pages/{outgoingInvoices.vue => createDocument/edit/[[id]].vue} (90%) create mode 100644 spaces/pages/createDocument/show/[id].vue rename spaces/pages/{incominginvoices => receipts/incomingInvoices}/[mode]/[[id]].vue (97%) rename spaces/pages/{incominginvoices => receipts}/index.vue (64%) create mode 100644 spaces/pages/settings/rights.vue rename spaces/stores/{data.ts => data.js} (73%) diff --git a/spaces/app.vue b/spaces/app.vue index d5de348..f454bf2 100644 --- a/spaces/app.vue +++ b/spaces/app.vue @@ -3,47 +3,20 @@ import GlobalSearch from "~/components/GlobalSearch.vue"; - +const supabase = useSupabaseClient() const user = useSupabaseUser() //console.log(user.value) -const router = useRouter() const route = useRoute() -const colorMode = useColorMode() -const supabase = useSupabaseClient() const tenants = (await supabase.from("tenants").select()).data + const dataStore = useDataStore() -const isLight = computed({ - get () { - return colorMode.value !== 'dark' - }, - set () { - colorMode.preference = colorMode.value === 'dark' ? 'light' : 'dark' - } -}) -const userProfile = (user.value ? dataStore.getProfileById(user.value.id) : {}) + //console.log(userProfile) -const showUserMenu = ref(false) -const userMenuItems = ref([ - { - label: "Profil", - badge: dataStore.notifications.filter(item => item.read).length, - icon: "i-heroicons-user-20-solid" - }, - { - label: "Nummernkreise", - icon: "i-heroicons-cog-8-tooth", - to: "/settings/numberRanges" - }, - { - label: 'Benutzer', - icon: 'i-heroicons-user-group', - to: "/users" - } -]) + @@ -56,151 +29,9 @@ watch(viewport.breakpoint, (newBreakpoint, oldBreakpoint) => { }) -dataStore.fetchData() +dataStore.initializeData() + -const navLinks = [ - { - label: "Home", - to: "/", - icon: 'i-heroicons-home' - }, - { - label: "Kontakte", - icon: 'i-heroicons-user-group', - children: [ - { - label: "Kunden", - to: "/customers", - icon: "i-heroicons-user-group" - }, - { - label: "Lieferanten", - to: "/vendors", - icon: "i-heroicons-truck" - }, - { - label: "Ansprechpartner", - to: "/contacts", - icon: "i-heroicons-user-group" - }, - ] - }, - { - label: "Buchhaltung", - icon: 'i-heroicons-document-chart-bar', - children: [ - { - label: "Eingangsrechnungen", - to: "/incominginvoices", - icon: "i-heroicons-document-text" - }, - /*{ - label: "Ausgangsrechnungen", - to: "/customerinvoices", - icon: "i-heroicons-document-text" - },*/ - { - label: "Bank", - to: "/banking", - icon: "i-heroicons-currency-euro" - }, - ] - }, - { - label: "Aufträge", - icon: "i-heroicons-square-3-stack-3d", - children: [ - { - label: "Projekte", - to: "/projects", - icon: "i-heroicons-clipboard-document-check" - }, - { - label: "Verträge", - to: "/contracts", - icon: "i-heroicons-clipboard-document" - }, - { - label: "Objekte", - to: "/plants", - icon: "i-heroicons-clipboard-document" - }, - ] - }, - { - label: "Verwaltung", - icon: "i-heroicons-square-3-stack-3d", - children: [ - { - label: "Aufgaben", - to: "/tasks", - icon: "i-heroicons-rectangle-stack" - }, - { - label: "Plantafel", - to: "/calendar/timeline", - icon: "i-heroicons-calendar-days" - }, - { - label: "Kalender", - to: "/calendar/grid", - icon: "i-heroicons-calendar-days" - }, - { - label: "Dokumente", - to: "/documents", - icon: "i-heroicons-document" - }, - ] - }, - { - label: "Chat", - to: "/chat", - icon:'i-heroicons-chat-bubble-left-right' - }, - { - label: "Mitarbeiter", - icon: 'i-heroicons-user', - children: [ - { - label: "Zeiterfassung", - to: "/employees/timetracking", - icon: "i-heroicons-clock" - }, - { - label: "Abwesenheiten", - to: "/absenceRequests", - icon: "i-heroicons-document-text" - } - ] - }, - { - label: "Lager", - icon: 'i-heroicons-home', - children: [ - { - label: "Steuerung", - to: "/inventory", - icon: "i-heroicons-square-3-stack-3d" - }, - { - label: "Artikelstamm", - to: "/products", - icon: "i-heroicons-puzzle-piece" - }, - { - label: "Lagerplätze", - to: "/spaces", - icon: "i-heroicons-square-3-stack-3d" - }, - { - label: "Fahrzeuge", - to: "/vehicles", - icon: "i-heroicons-truck" - }, - ] - }, -] const linksForBreadcrumbs = ref([]) @@ -209,8 +40,8 @@ const linksForBreadcrumbs = ref([]) -const userTenant = ref({}) -if(user) userTenant.value = tenants.find(tenant => tenant.id === user.value.app_metadata.tenant) +//const userTenant = ref({}) +//if(user) userTenant.value = tenants.find(tenant => tenant.id === user.value.app_metadata.tenant) @@ -275,189 +106,10 @@ const items = [ + + +
+ +
+
- + +
diff --git a/spaces/pages/outgoingInvoices.vue b/spaces/pages/createDocument/edit/[[id]].vue similarity index 90% rename from spaces/pages/outgoingInvoices.vue rename to spaces/pages/createDocument/edit/[[id]].vue index d1bf22f..bb9e481 100644 --- a/spaces/pages/outgoingInvoices.vue +++ b/spaces/pages/createDocument/edit/[[id]].vue @@ -2,6 +2,11 @@ import dayjs from "dayjs" const dataStore = useDataStore() const user = useSupabaseUser() +const route = useRoute() + + + + const tabItems = [ { @@ -13,52 +18,46 @@ const tabItems = [ ] const itemInfo = ref({ - customer: 13, - contact: 8, + type: "invoices", + customer: null, + contact: null, address: { street: null, special: null, zip: null, city: null, }, - project: 6, - documentNumber: "RE23-1409", - documentDate: "10.01.2024", - deliveryDate: "10.01.2024", + project: null, + documentNumber: null, + documentDate: null, + deliveryDate: null, dateOfPerformance: null, createdBy: user.value.id, - title: "TITEL", - description: "BESCHREIBUNG", + title: null, + description: null, startText: "Sehr geehrte Frau Sindern,\n" + "wir bedanken uns für Ihr entgegengebrachtes Vertrauen und Ihren Auftrag und stellen Ihnen\n" + "folgende Positionen in Rechnung: ", endText: "Bitte überweisen Sie den Rechnungsbetrag unter Angabe der Rechnungsnummer im Verwendungszweck innerhalb von 10 Tagen auf das unten angegebene Konto. Wir bedanken uns für das entgegengebrachte Vertrauen und freuen uns auf eine weitere gute Zusammenarbeit.", rows: [ - { - id: 1, - pos: 1, - mode: "free", - text: "FahrtkostenFahrtkostenFahrtkostenFahrtkosten", - quantity: 204, - unit: 3, - price: 0.80, - taxPercent: 19, - discountPercent: 0 - }, - { - id: 2, - pos: 2, - mode: "free", - text: "Test", - quantity: 1, - unit: 1, - price: 10, - taxPercent: 19, - discountPercent: 0 - } + ] }) +const setupPage = () => { + if(route.params) { + if(route.params.id) itemInfo.value = dataStore.getCreatedDocumentById(Number(route.params.id)) + } + + if(route.query) { + if(route.query.type) itemInfo.value.type = route.query.type + if(route.query.project) itemInfo.value.project = Number(route.query.project) + if(route.query.customer) itemInfo.value.customer = Number(route.query.customer) + } +} + + + const getRowAmount = (row) => { return String(Number(Number(row.quantity) * Number(row.price) * (1 - Number(row.discountPercent) /100) ).toFixed(2)).replace('.',',') } @@ -218,7 +217,6 @@ const generateDocument = async () => { uri.value = await useCreatePdf(getDocumentData()) //alert(uri.value) showDocument.value = true - } const onChangeTab = (index) => { @@ -238,20 +236,80 @@ const setPosNumbers = () => { }) } +const saveDocument = async () => { + let createData = { + type: itemInfo.value.type, + customer: itemInfo.value.customer, + contact: itemInfo.value.contact, + address: itemInfo.value.address, + project: itemInfo.value.project, + documentNumber: itemInfo.value.documentNumber, + documentDate: itemInfo.value.documentDate, + state: "Entwurf", + info: { + + }, + createdBy: itemInfo.value.createdBy, + title: itemInfo.value.title, + description: itemInfo.value.description, + startText: itemInfo.value.startText, + endText: itemInfo.value.endText, + rows: itemInfo.value.rows + } + + if(route.params.id) { + await dataStore.updateItem("createdDocuments", {...createData, id: itemInfo.value.id}) + } else { + await dataStore.createNewItem("createdDocuments", createData) + } + +} + +const closeDocument = () => { + generateDocument() + console.log(uri) +} + + +setupPage()