Changes in Props

This commit is contained in:
2025-01-27 18:14:03 +01:00
parent cbc1f5a84d
commit 3188409bac

View File

@@ -2,21 +2,21 @@
import dayjs from "dayjs" import dayjs from "dayjs"
const props = defineProps({ const props = defineProps({
type: { type: {
type: String type: String,
required: true
}, },
elementId: { elementId: {
type: String type: String,
required: true
}, },
renderHeadline: { renderHeadline: {
type: Boolean type: Boolean,
default: false
} }
}) })
const { metaSymbol } = useShortcuts()
const profileStore = useProfileStore() const profileStore = useProfileStore()
const user = useSupabaseUser()
const supabase = useSupabaseClient() const supabase = useSupabaseClient()
const toast = useToast() const toast = useToast()
const {type, elementId} = props
const showAddHistoryItemModal = ref(false) const showAddHistoryItemModal = ref(false)
const colorMode = useColorMode() const colorMode = useColorMode()
@@ -24,8 +24,8 @@ const items = ref([])
const setup = async () => { const setup = async () => {
if(type && elementId){ if(props.type && props.elementId){
items.value = (await supabase.from("historyitems").select().eq(type,elementId).order("created_at",{ascending: true})).data || [] items.value = (await supabase.from("historyitems").select().eq(props.type,props.elementId).order("created_at",{ascending: true})).data || []
} else { } else {
items.value = (await supabase.from("historyitems").select().order("created_at",{ascending: true})).data || [] items.value = (await supabase.from("historyitems").select().order("created_at",{ascending: true})).data || []
@@ -39,8 +39,8 @@ setup()
const addHistoryItemData = ref({ const addHistoryItemData = ref({
text: "", text: "",
config: { config: {
type: type, type: props.type,
id: elementId id: props.elementId
} }
}) })
@@ -48,7 +48,7 @@ const addHistoryItem = async () => {
console.log(addHistoryItemData.value) console.log(addHistoryItemData.value)
addHistoryItemData.value.createdBy = profileStore.activeProfile.id addHistoryItemData.value.createdBy = profileStore.activeProfile.id
addHistoryItemData.value[type] = elementId addHistoryItemData.value[props.type] = props.elementId
const {data,error} = await supabase const {data,error} = await supabase
.from("historyitems") .from("historyitems")
@@ -71,7 +71,7 @@ const addHistoryItem = async () => {
profile: profiles.find(x => x.username === rawUsername).id, profile: profiles.find(x => x.username === rawUsername).id,
initiatingProfile: profileStore.activeProfile.id, initiatingProfile: profileStore.activeProfile.id,
title: "Sie wurden im Logbuch erwähnt", title: "Sie wurden im Logbuch erwähnt",
link: `/${type}s/show/${elementId}`, link: `/${props.type}s/show/${props.elementId}`,
message: addHistoryItemData.value.text message: addHistoryItemData.value.text
} }
}) })
@@ -129,7 +129,7 @@ const renderText = (text) => {
</UCard> </UCard>
</UModal> </UModal>
<Toolbar <Toolbar
v-if="!renderHeadline && elementId && type" v-if="!props.renderHeadline && props.elementId && props.type"
> >
<UButton <UButton
@click="showAddHistoryItemModal = true" @click="showAddHistoryItemModal = true"
@@ -137,7 +137,7 @@ const renderText = (text) => {
+ Eintrag + Eintrag
</UButton> </UButton>
</Toolbar> </Toolbar>
<div v-else-if="renderHeadline && elementId && type"> <div v-else-if="props.renderHeadline && props.elementId && props.type">
<div :class="`flex justify-between`"> <div :class="`flex justify-between`">
<p class=""><span class="text-xl">Logbuch</span> <UBadge variant="outline">{{items.length}}</UBadge></p> <p class=""><span class="text-xl">Logbuch</span> <UBadge variant="outline">{{items.length}}</UBadge></p>
<UButton <UButton