Added Phases to Projects

This commit is contained in:
2024-02-05 20:48:15 +01:00
parent 22a3b8698c
commit 2fc45b3ea0
5 changed files with 190 additions and 38 deletions

View File

@@ -123,7 +123,8 @@ const renderText = (text) => {
</template>
<div
v-if="historyItems.length > 0"
v-for="(item,index) in historyItems"
v-for="(item,index) in historyItems.slice().reverse()
"
>
<UDivider
class="my-3"

View File

@@ -18,12 +18,13 @@ const id = ref(route.params.id ? route.params.id : null )
let currentItem = ref(null)
const tabItems = [
/*{
key: "phases",
label: "Phasen"
},*/{
{
key: "information",
label: "Informationen"
},
{
key: "phases",
label: "Phasen"
},{
key: "tasks",
label: "Aufgaben"
@@ -172,6 +173,52 @@ const projectHours = () => {
}
/*const phasesTemplate = ref([{
label: 'Erstkontakt',
icon: 'i-heroicons-clipboard-document',
active: true
}, {
label: 'Überprüfung Vor Ort',
icon: 'i-heroicons-magnifying-glass'
}, {
label: 'Angebotserstellung',
icon: 'i-heroicons-document-text'
}, {
label: 'Auftragsvergabe',
icon: 'i-heroicons-document-check'
}, {
label: 'Umsetzung',
icon: 'i-heroicons-wrench-screwdriver'
},{
label: 'Rechnungsstellung',
icon: 'i-heroicons-document-text'
}, {
label: 'Abgeschlossen',
icon: 'i-heroicons-check'
}])*/
const phasesTemplateSelected = ref(dataStore.phasesTemplates[0].id)
const changeActivePhase = (phase) => {
currentItem.value.phases = currentItem.value.phases.map(p => {
if(p.active) delete p.active
if(p.label === phase.label) p.active = true
return p
})
savePhases()
}
const savePhases = () => {
dataStore.updateItem("projects", currentItem.value)
}
const loadPhases = async () => {
currentItem.value.phases = dataStore.phasesTemplates.find(i => i.id === phasesTemplateSelected.value).initialPhases
await dataStore.updateItem("projects", currentItem.value)
}
setupPage()
</script>
@@ -183,29 +230,69 @@ setupPage()
<UTabs :items="tabItems" class="w-full">
<template #item="{ item }">
<!--
<div v-if="item.key === 'information'">
<InputGroup>
<UButton
@click="router.push(`/customers/show/${currentItem.customer}`)"
class="mb-3"
>
Zum Kunden
</UButton>
<UButton
@click="router.push(`/plants/show/${currentItem.plant}`)"
class="mb-3"
>
Zum Objekt
</UButton>
</InputGroup>
Kunde: {{dataStore.getCustomerById(currentItem.customer).name}}<br>
Objekt: {{currentItem.plant ? dataStore.getPlantById(currentItem.plant).name : ""}}<br>
Notizen:<br>
{{currentItem.notes}}
</div>
<div v-if="item.key === 'phases'" class="space-y-3">
<p>Hier wird aktuell noch gearbeitet</p>
&lt;!&ndash; <div id="phaseList">
<a
v-for="phase in []"
@click="selectedPhase = phase"
<UFormGroup
label="Vorlage laden"
v-if="currentItem.phases.length === 0"
>
<div
class="phaseContainer"
<InputGroup>
<USelectMenu
:options="dataStore.phasesTemplates"
option-attribute="name"
value-attribute="id"
v-model="phasesTemplateSelected"
class="flex-auto"
>
<span>{{phase.name}} - {{phase.position}}</span>
</USelectMenu>
<UButton
@click="loadPhases"
>
Vorlage laden
</UButton>
</InputGroup>
</UFormGroup>
<UAccordion
:items="currentItem.phases"
>
<template #item="{item}">
<InputGroup>
<UButton
v-if="!item.active"
@click="changeActivePhase(item)"
>
Phase aktivieren
</UButton>
<!-- <UButton>
+ Phase
</UButton>-->
</InputGroup>
</template>
</UAccordion>
</div>
<a class="plusIcon" @click="addPhase(phase)">
<UDivider icon="i-heroicons-plus-circle"/>
</a>
</a>
</div>&ndash;&gt;
</div>
-->
<div v-if="item.key === 'tasks'" class="space-y-3">
<InputGroup>
<UButton

View File

@@ -1,11 +1,16 @@
<template>
<InputGroup>
<InputGroup >
<UButton @click="router.push(`/projects/create/`)">+ Projekt</UButton>
<UInput
v-model="searchString"
placeholder="Suche..."
/>
<UCheckbox
label="Abgeschlossene anzeigen"
v-model="showFinished"
/>
</InputGroup>
@@ -16,6 +21,9 @@
:columns="itemColumns"
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Noch keine Einträge' }"
>
<template #phase-data="{row}">
{{getActivePhaseLabel(row)}}
</template>
<template #customer-data="{row}">
{{dataStore.getCustomerById(row.customer) ? dataStore.getCustomerById(row.customer).name : ""}}
</template>
@@ -35,6 +43,10 @@ const supabase = useSupabaseClient()
const router = useRouter()
const itemColumns = [
{
key: "phase",
label: "Phase"
},
{
key: "measure",
label: "Gewerk"
@@ -43,13 +55,13 @@ const itemColumns = [
label: "Name"
},
{
key: "notes",
label: "Notizen",
key: "customer",
label: "Kunde",
sortable: true
},
{
key: "customer",
label: "Kunde",
key: "notes",
label: "Notizen",
sortable: true
},
{
@@ -64,15 +76,49 @@ const selectItem = (item) => {
router.push(`/projects/show/${item.id} `)
}
const getActivePhaseLabel = (item) => {
if(item.phases) {
if(item.phases.length > 0) {
let activePhase = item.phases.find(i => i.active)
if(activePhase) {
return activePhase.label
} else {
return ""
}
}
}
}
const searchString = ref('')
const showFinished = ref(false)
const filteredRows = computed(() => {
if(!searchString.value) {
return dataStore.projects
let items = dataStore.projects
items = items.map(item => {
return {
...item,
phaseLabel: getActivePhaseLabel(item)
}
})
if(showFinished.value) {
items = items.filter(i => i.phaseLabel === "Abgeschlossen")
} else {
items = items.filter(i => i.phaseLabel !== "Abgeschlossen")
}
return dataStore.projects.filter(product => {
return Object.values(product).some((value) => {
if(!searchString.value) {
return items
}
return items.filter(project => {
return Object.values(project).some((value) => {
return String(value).toLowerCase().includes(searchString.value.toLowerCase())
})
})

View File

@@ -85,10 +85,20 @@ setupPage()
{{currentItem.name}}
</template>
<InputGroup>
<UButton
v-if="currentItem.project"
@click="router.push(`/projects/show/${currentItem.project}`)"
class="mb-3"
>
Zum Projekt
</UButton>
</InputGroup>
Beschreibung:<br>
{{currentItem.description}}<br>
Projekt: {{currentItem.project ? dataStore.getProjectById(currentItem.project).name : "Kein Projekt zugeordnet"}}

View File

@@ -156,6 +156,7 @@ export const useDataStore = defineStore('data', () => {
const messages = ref([])
const createddocuments = ref([])
const workingtimes = ref([])
const phasesTemplates = ref([])
const rights = ref({
@@ -271,6 +272,7 @@ export const useDataStore = defineStore('data', () => {
await fetchMessages()
await fetchCreatedDocuments()
await fetchWorkingTimes()
await fetchPhasesTemplates()
loaded.value = true
}
@@ -310,6 +312,7 @@ export const useDataStore = defineStore('data', () => {
messages.value = []
createddocuments.value = []
workingtimes.value = []
phasesTemplates.value = []
}
function hasRight (right) {
@@ -333,7 +336,7 @@ export const useDataStore = defineStore('data', () => {
schema: 'public',
},
(payload) => {
console.log(payload)
//console.log(payload)
if(payload.eventType === 'INSERT') {
const c = payload.table + '.value.push(' + JSON.stringify(payload.new) + ')'
@@ -347,7 +350,7 @@ export const useDataStore = defineStore('data', () => {
.subscribe()
async function createNewItem (dataType,data){
console.log(dataType)
//console.log(dataType)
if(dataTypes[dataType].numberRangeHolder) {
const numberRange = useNumberRange(dataType)
@@ -368,7 +371,7 @@ export const useDataStore = defineStore('data', () => {
if(supabaseError) {
console.log(supabaseError)
} else if (supabaseData) {
await eval( dataType + '.value.push(' + JSON.stringify(...supabaseData) + ')')
//await eval( dataType + '.value.push(' + JSON.stringify(...supabaseData) + ')')
toast.add({title: `${dataTypes[dataType].labelSingle} hinzugefügt`})
if(dataTypes[dataType].redirect) await router.push(`/${dataType}/show/${supabaseData[0].id}`)
return supabaseData
@@ -556,6 +559,10 @@ export const useDataStore = defineStore('data', () => {
workingtimes.value = (await supabase.from("workingtimes").select().eq('tenant', currentTenant.value).order('created_at', {ascending:true})).data
}
async function fetchPhasesTemplates() {
phasesTemplates.value = (await supabase.from("phasesTemplates").select().eq('tenant', currentTenant.value).order('created_at', {ascending:true})).data
}
async function fetchDocuments () {
let tempDocuments = (await supabase.from("documents").select().eq('tenant', currentTenant.value)).data
@@ -959,6 +966,7 @@ export const useDataStore = defineStore('data', () => {
messages,
createddocuments,
workingtimes,
phasesTemplates,
documentTypesForCreation,
//Functions
createNewItem,