Changes in Standard Entity Components

This commit is contained in:
2024-12-30 09:30:30 +01:00
parent 92ec684066
commit ee5ebfe0b9
3 changed files with 54 additions and 27 deletions

View File

@@ -35,6 +35,7 @@ defineShortcuts({
const router = useRouter()
const dataStore = useDataStore()
const profileStore = useProfileStore()
const supabase = useSupabaseClient()
const dataType = dataStore.dataTypes[type]
@@ -52,7 +53,7 @@ setup()
const openTab = ref(0)
const renderedPhases = computed(() => {
console.log(props.item.phases)
if(type === "projects" && props.item.phases) {
return props.item.phases.map((phase,index,array) => {
@@ -81,7 +82,32 @@ const renderedPhases = computed(() => {
}
})
const changeActivePhase = async (key) => {
let item = await useSupabaseSelectSingle("projects",props.item.id,'*')
let phaseLabel = ""
item.phases = item.phases.map(p => {
if(p.active) p.active = false
if(p.key === key) {
p.active = true
p.activated_at = dayjs().format()
p.activated_by = profileStore.activeProfile.id
phaseLabel = p.label
}
return p
})
await supabase.from("projects").update({phases: item.phases}).eq("id",item.id)
const {error} = await supabase.from("historyitems").insert({
createdBy: profileStore.activeProfile.id,
tenant: profileStore.currentTenant,
text: `Aktive Phase zu "${phaseLabel}" gewechselt`,
project: item.id
})
}
</script>
@@ -321,7 +347,7 @@ const renderedPhases = computed(() => {
<template #item="{item, index}">
<UCard class="mx-5">
<template #header>
<span class="text-black">{{item.label}}</span>
<span class="dark:text-white text-black">{{item.label}}</span>
</template>
<InputGroup>
<!-- TODO: Reactive Change Phase -->
@@ -341,9 +367,9 @@ const renderedPhases = computed(() => {
</InputGroup>
<div>
<p v-if="item.activated_at" class="text-black">Aktiviert am: {{dayjs(item.activated_at).format("DD.MM.YY HH:mm")}} Uhr</p>
<p v-if="item.activated_by" class="text-black">Aktiviert durch: {{profileStore.getProfileById(item.activated_by).fullName}}</p>
<p v-if="item.description" class="text-black">Beschreibung: {{item.description}}</p>
<p v-if="item.activated_at" class="dark:text-white text-black">Aktiviert am: {{dayjs(item.activated_at).format("DD.MM.YY HH:mm")}} Uhr</p>
<p v-if="item.activated_by" class="dark:text-white text-black">Aktiviert durch: {{profileStore.getProfileById(item.activated_by).fullName}}</p>
<p v-if="item.description" class="dark:text-white text-black">Beschreibung: {{item.description}}</p>
</div>
</UCard>