Many Changes in Navigation, Shortcuts, Search and Data Pulling directly from Supabase
This commit is contained in:
@@ -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
|
||||
})
|
||||
|
||||
@@ -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())
|
||||
})
|
||||
})*/
|
||||
|
||||
|
||||
|
||||
}
|
||||
47
composables/useSupabase.js
Normal file
47
composables/useSupabase.js
Normal file
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user