Added Notifications
Added Mentions in HistoryItems
This commit is contained in:
83
pages/communication/historyItems/index.vue
Normal file
83
pages/communication/historyItems/index.vue
Normal file
@@ -0,0 +1,83 @@
|
||||
<script setup>
|
||||
import dayjs from "dayjs"
|
||||
|
||||
const supabase = useSupabaseClient()
|
||||
const dataStore = useDataStore()
|
||||
const router = useRouter()
|
||||
|
||||
|
||||
const items = ref([])
|
||||
|
||||
const setup = async () => {
|
||||
|
||||
items.value = (await supabase.from("historyitems").select().like('text',`%@${dataStore.activeProfile.username}%`)/*.textSearch("text", `'@${dataStore.activeProfile.username}'`)*/.order("created_at")).data
|
||||
}
|
||||
|
||||
const navigateToHistoryItem = (item) => {
|
||||
/*if(item.customer) {
|
||||
router.push(`/customers/show/${item.customer}`)
|
||||
} else if(item.vendor) {
|
||||
router.push(`/vendors/show/${item.vendor}`)
|
||||
} else if(item.project) {
|
||||
router.push(`/projects/show/${item.project}`)
|
||||
} else if(item.plant) {
|
||||
router.push(`/plants/show/${item.plant}`)
|
||||
} else if(item.incomingInvoice) {
|
||||
router.push(`/incomingInvoices/show/${item.incomingInvoice}`)
|
||||
}/!* else if(item.document) {
|
||||
router.push(`/documents/show/${item.document}`)
|
||||
}*!/ else if(item.contact) {
|
||||
router.push(`/contacts/show/${item.contact}`)
|
||||
} else if(item.inventoryitem) {
|
||||
router.push(`/inventoryitems/show/${item.inventoryitem}`)
|
||||
} else if(item.product) {
|
||||
router.push(`/products/show/${item.product}`)
|
||||
} else if(item.profile) {
|
||||
router.push(`/profiles/show/${item.profile}`)
|
||||
} else if(item.absenceRequest) {
|
||||
router.push(`/absenceRequests/show/${item.absenceRequest}`)
|
||||
} else if(item.event) {
|
||||
router.push(`/events/show/${item.event}`)
|
||||
} else if(item.task) {
|
||||
router.push(`/tasks/show/${item.task}`)
|
||||
} else if(item.vehicle) {
|
||||
router.push(`/vehicle/show/${item.vehicle}`)
|
||||
} else if(item.bankStatement) {
|
||||
router.push(`/bankStatements/show/${item.bankStatement}`)
|
||||
} else if(item.space) {
|
||||
router.push(`/spaces/show/${item.space}`)
|
||||
} else if(item.trackingtrip) {
|
||||
router.push(`/trackingtrips/show/${item.trackingtrip}`)
|
||||
}*/
|
||||
if(item.config && item.config.type !== "document") {
|
||||
router.push(`/${item.config.type}s/show/${item.config.id}`)
|
||||
}
|
||||
}
|
||||
|
||||
setup()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<UDashboardNavbar title="Erwähnungen in Logbüchern" :badge="items.length">
|
||||
|
||||
</UDashboardNavbar>
|
||||
<UTable
|
||||
:rows="items"
|
||||
@select="navigateToHistoryItem"
|
||||
:columns="[{key:'created_at',label:'Datum'},{key:'config',label:'Typ'},{key:'text',label:'Text'}]"
|
||||
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Keine Erwähnungen anzuzeigen' }"
|
||||
class="w-full"
|
||||
:ui="{ divide: 'divide-gray-200 dark:divide-gray-800' }"
|
||||
>
|
||||
<template #config-data="{row}">
|
||||
<span v-if="row.config">{{dataStore.dataTypes[row.config.type + "s"].labelSingle}}</span>
|
||||
</template>
|
||||
<template #created_at-data="{row}">
|
||||
{{dayjs(row.created_at).format("HH:mm DD.MM.YYYY")}}
|
||||
</template>
|
||||
</UTable>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@@ -5,7 +5,7 @@
|
||||
<template #right>
|
||||
<UTooltip text="Notifications" :shortcuts="['N']">
|
||||
<UButton color="gray" variant="ghost" square @click="isNotificationsSlideoverOpen = true">
|
||||
<UChip :show="false" color="red" inset>
|
||||
<UChip :show="unreadMessages" color="primary" inset>
|
||||
<UIcon name="i-heroicons-bell" class="w-5 h-5" />
|
||||
</UChip>
|
||||
</UButton>
|
||||
@@ -88,6 +88,12 @@ const supabase = useSupabaseClient()
|
||||
|
||||
const user = useSupabaseUser()
|
||||
|
||||
const unreadMessages = ref(false)
|
||||
const setup = async () => {
|
||||
unreadMessages.value = (await supabase.from("notifications").select("id,read").eq("read",false)).data.length > 0
|
||||
}
|
||||
|
||||
setup()
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@@ -152,7 +152,7 @@ setupPage()
|
||||
<UCard class="w-1/2">
|
||||
<HistoryDisplay
|
||||
type="plant"
|
||||
v-if="itemInfo"
|
||||
v-if="itemInfo.id"
|
||||
:element-id="itemInfo.id"
|
||||
render-headline
|
||||
/>
|
||||
|
||||
@@ -265,7 +265,7 @@ const isLight = computed({
|
||||
v-model="itemInfo.employeeNumber"
|
||||
/>
|
||||
</UFormGroup>
|
||||
<UFormGroup
|
||||
<UFormGroup
|
||||
label="E-Mail"
|
||||
class="flex-auto"
|
||||
>
|
||||
@@ -273,6 +273,14 @@ const isLight = computed({
|
||||
v-model="itemInfo.email"
|
||||
/>
|
||||
</UFormGroup>
|
||||
<UFormGroup
|
||||
label="Benutzername"
|
||||
class="flex-auto"
|
||||
>
|
||||
<UInput
|
||||
v-model="itemInfo.username"
|
||||
/>
|
||||
</UFormGroup>
|
||||
</InputGroup>
|
||||
<InputGroup class="w-full">
|
||||
<UFormGroup
|
||||
|
||||
Reference in New Issue
Block a user