Added Notifications
Added Mentions in HistoryItems
This commit is contained in:
@@ -69,6 +69,10 @@ setup()
|
||||
|
||||
const addHistoryItemData = ref({
|
||||
text: "",
|
||||
config: {
|
||||
type: type,
|
||||
id: elementId
|
||||
}
|
||||
})
|
||||
|
||||
const addHistoryItem = async () => {
|
||||
@@ -120,6 +124,29 @@ const addHistoryItem = async () => {
|
||||
if(error) {
|
||||
console.log(error)
|
||||
} else {
|
||||
if(addHistoryItemData.value.text.includes("@")){
|
||||
let usernames = [...addHistoryItemData.value.text.matchAll(/@(\S*)/gm)]
|
||||
|
||||
const {data:profiles} = await supabase.from("profiles").select("id,username")
|
||||
|
||||
let notifications = usernames.map(i => {
|
||||
let rawUsername = i[1]
|
||||
|
||||
return {
|
||||
tenant: dataStore.currentTenant,
|
||||
profile: profiles.find(x => x.username === rawUsername).id,
|
||||
initiatingProfile: dataStore.activeProfile.id,
|
||||
title: "Sie wurden im Logbuch erwähnt",
|
||||
link: `/${type}s/show/${elementId}`,
|
||||
message: addHistoryItemData.value.text
|
||||
}
|
||||
})
|
||||
|
||||
console.log(notifications)
|
||||
|
||||
const {error} = await supabase.from("notifications").insert(notifications)
|
||||
}
|
||||
|
||||
addHistoryItemData.value = {}
|
||||
toast.add({title: "Eintrag erfolgreich erstellt"})
|
||||
showAddHistoryItemModal.value = false
|
||||
@@ -188,7 +215,6 @@ const renderText = (text) => {
|
||||
</div>
|
||||
|
||||
<!-- ITEM LIST -->
|
||||
|
||||
<div style="height: 90%; overflow-y: scroll">
|
||||
<div
|
||||
v-if="items.length > 0"
|
||||
|
||||
Reference in New Issue
Block a user