From bc24f49476f2870607d5f9035d8c962d9c732902 Mon Sep 17 00:00:00 2001 From: flfeders Date: Wed, 5 Jun 2024 14:34:23 +0200 Subject: [PATCH] Many Changes in Navigation, Shortcuts, Search and Data Pulling directly from Supabase --- components/GlobalSearch.vue | 22 +++-- components/HelpSlideover.vue | 15 +++- composables/useDashboard.ts | 6 ++ composables/useSearch.js | 19 +--- composables/useSupabase.js | 47 ++++++++++ layouts/default.vue | 10 +++ pages/contacts/[mode]/[[id]].vue | 69 +++++++++------ pages/contacts/index.vue | 41 ++++++++- pages/contracts/[mode]/[[id]].vue | 55 ++++++++---- pages/contracts/index.vue | 43 ++++++--- pages/createDocument/index.vue | 68 ++++++++++----- pages/createDocument/show/[id].vue | 8 ++ pages/customers/[mode]/[[id]].vue | 66 +++++++------- pages/customers/index.vue | 49 +++++++---- pages/incomingInvoices/[mode]/[[id]].vue | 12 +-- pages/incomingInvoices/index.vue | 51 ++++++++--- pages/plants/index.vue | 51 +++++++---- pages/products/[mode]/[[id]].vue | 56 ++++++++---- pages/products/index.vue | 55 +++++++++--- pages/projects/[mode]/[[id]].vue | 106 +++++++++++++++-------- pages/projects/index.vue | 51 +++++++++-- pages/spaces/index.vue | 46 +++++++--- pages/tasks/index.vue | 10 +-- pages/vehicles/[mode]/[[id]].vue | 57 +++++++----- pages/vehicles/index.vue | 47 +++++++--- pages/vendors/index.vue | 41 +++++---- stores/data.js | 15 +++- 27 files changed, 779 insertions(+), 337 deletions(-) create mode 100644 composables/useSupabase.js diff --git a/components/GlobalSearch.vue b/components/GlobalSearch.vue index 95cd1bc..45ef81a 100644 --- a/components/GlobalSearch.vue +++ b/components/GlobalSearch.vue @@ -20,6 +20,13 @@ defineShortcuts({ }) const actions = [ + + { + id: 'new-task', + label: 'Aufgabe hinzufügen', + icon: 'i-heroicons-rectangle-stack', + to: "/tasks/create" , + }, { id: 'new-customer', label: 'Kunde hinzufügen', @@ -39,12 +46,11 @@ const actions = [ to: "/contacts/create" , }, { - id: 'new-task', - label: 'Aufgabe hinzufügen', - icon: 'i-heroicons-rectangle-stack', - to: "/tasks/create" , - }, - { + id: 'new-project', + label: 'Projekt hinzufügen', + icon: 'i-heroicons-clipboard-document-check', + to: "/projects/create" , + },{ id: 'new-plant', label: 'Objekt hinzufügen', icon: 'i-heroicons-clipboard-document', @@ -87,6 +93,10 @@ const groups = computed(() => key: "plants", label: "Objekte", commands: dataStore.plants.map(item => { return {id: item.id, label: item.name, to: `/plants/show/${item.id}`}}) + },{ + key: "projects", + label: "Projekte", + commands: dataStore.projects.map(item => { return {id: item.id, label: item.name, to: `/projects/show/${item.id}`}}) } ].filter(Boolean)) diff --git a/components/HelpSlideover.vue b/components/HelpSlideover.vue index 43ab35c..61e59b0 100644 --- a/components/HelpSlideover.vue +++ b/components/HelpSlideover.vue @@ -46,10 +46,21 @@ const categories = computed(() => [{ title: 'Navigation', items: [ { shortcuts: ['G', 'H'], name: 'Gehe zu Dashboard' }, - { shortcuts: ['G', 'A'], name: 'Gehe zu Aufgaben' },/* + { shortcuts: ['G', 'A'], name: 'Gehe zu Aufgaben' }, + { shortcuts: ['G', 'D'], name: 'Gehe zu Dokumente' }, + { shortcuts: ['G', 'K'], name: 'Gehe zu Kunden' }, + { shortcuts: ['G', 'L'], name: 'Gehe zu Lieferanten' }, + { shortcuts: ['G', 'P'], name: 'Gehe zu Projekte' }, + { shortcuts: ['G', 'V'], name: 'Gehe zu Verträge' }, + { shortcuts: ['G', 'O'], name: 'Gehe zu Objekte' },/* { shortcuts: ['G', 'I'], name: 'Go to Inbox' }, { shortcuts: ['G', 'U'], name: 'Go to Users' },*/ - { shortcuts: ['G', 'S'], name: 'Gehe zu Einstellungen' } + { shortcuts: ['G', 'S'], name: 'Gehe zu Einstellungen' }, + { shortcuts: ['↑'], name: 'Vorheriger Eintrag' }, + { shortcuts: ['↓'], name: 'Nächster Eintrag' }, + { shortcuts: ['↵'], name: 'Eintrag Öffnen' }, + { shortcuts: ['←'], name: 'Tab nach links wechseln' }, + { shortcuts: ['→'], name: 'Tab nach rechts wechseln' }, ] }, /*{ title: 'Inbox', diff --git a/composables/useDashboard.ts b/composables/useDashboard.ts index 1f65cae..1607b7b 100644 --- a/composables/useDashboard.ts +++ b/composables/useDashboard.ts @@ -9,7 +9,13 @@ const _useDashboard = () => { defineShortcuts({ 'g-h': () => router.push('/'), 'g-a': () => router.push('/tasks'), + 'g-d': () => router.push('/documents'), + 'g-k': () => router.push('/customers'), + 'g-l': () => router.push('/vendors'), 'g-s': () => router.push('/settings'), + 'g-p': () => router.push('/projects'), + 'g-v': () => router.push('/contracts'), + 'g-o': () => router.push('/plants'), '?': () => isHelpSlideoverOpen.value = !isHelpSlideoverOpen.value, n: () => isNotificationsSlideoverOpen.value = !isNotificationsSlideoverOpen.value }) diff --git a/composables/useSearch.js b/composables/useSearch.js index 34f2f7f..bca0adc 100644 --- a/composables/useSearch.js +++ b/composables/useSearch.js @@ -1,31 +1,14 @@ export const useSearch = (searchString,items) => { - const dataStore = useDataStore() if(!searchString) { return items } - items = items.map(item => { - - return { - ...item, - customer: dataStore.getCustomerById(item.customer) - } - }) - - console.log(items) - - - return items.filter(i => JSON.stringify(i).toLowerCase().includes(searchString.toLowerCase())) - /*return items.filter(item => { - return Object.values(item).some((value) => { - return String(value).toLowerCase().includes(searchString.toLowerCase()) - }) - })*/ + } \ No newline at end of file diff --git a/composables/useSupabase.js b/composables/useSupabase.js new file mode 100644 index 0000000..d55ec6a --- /dev/null +++ b/composables/useSupabase.js @@ -0,0 +1,47 @@ + + +export const useSupabaseSelect = async (relation,select = '*', sortColumn = null) => { + const supabase = useSupabaseClient() + const dataStore = useDataStore() + let data = null + + + if(sortColumn !== null ) { + data = (await supabase + .from(relation) + .select(select) + .eq("tenant", dataStore.currentTenant) + .order(sortColumn, {ascending: true})).data + } else { + data = (await supabase + .from(relation) + .select(select) + .eq("tenant", dataStore.currentTenant)).data + } + + return data +} + +export const useSupabaseSelectSingle = async (relation,idToEq,select = '*' ) => { + const supabase = useSupabaseClient() + const dataStore = useDataStore() + let data = null + + + if(idToEq !== null) { + data = (await supabase + .from(relation) + .select(select) + .eq("tenant", dataStore.currentTenant) + .eq("id",idToEq) + .single()).data + } else { + data = (await supabase + .from(relation) + .select(select) + .eq("tenant", dataStore.currentTenant) + .single()).data + } + + return data +} \ No newline at end of file diff --git a/layouts/default.vue b/layouts/default.vue index 0c94c84..19aeac1 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -414,6 +414,12 @@ const actions = [ label: 'Artikel hinzufügen', icon: 'i-heroicons-puzzle-piece', to: "/products/create" , + }, + { + id: 'new-project', + label: 'Projekt hinzufügen', + icon: 'i-heroicons-clipboard-document-check', + to: "/projects/create" , } ] @@ -446,6 +452,10 @@ const groups = computed(() => key: "plants", label: "Objekte", commands: dataStore.plants.map(item => { return {id: item.id, label: item.name, to: `/plants/show/${item.id}`}}) + },{ + key: "projects", + label: "Projekte", + commands: dataStore.projects.map(item => { return {id: item.id, label: item.name, to: `/projects/show/${item.id}`}}) } ].filter(Boolean)) const footerLinks = [/*{ diff --git a/pages/contacts/[mode]/[[id]].vue b/pages/contacts/[mode]/[[id]].vue index b27b32c..d5c2f2d 100644 --- a/pages/contacts/[mode]/[[id]].vue +++ b/pages/contacts/[mode]/[[id]].vue @@ -1,19 +1,35 @@ diff --git a/pages/contracts/[mode]/[[id]].vue b/pages/contracts/[mode]/[[id]].vue index 1558415..2d691a5 100644 --- a/pages/contracts/[mode]/[[id]].vue +++ b/pages/contracts/[mode]/[[id]].vue @@ -1,18 +1,35 @@