Changes in Tracking and some changes in general historyitems

This commit is contained in:
2024-09-22 14:10:04 +02:00
parent 516bf5dd7f
commit 51dbb10b45
7 changed files with 739 additions and 152 deletions

View File

@@ -58,53 +58,15 @@ const setup = async () => {
items.value = (await supabase.from("historyitems").select().eq("vehicle",elementId)).data || []
} else if(type === "space") {
items.value = (await supabase.from("historyitems").select().eq("space",elementId)).data || []
} else if(type === "trackingtrip") {
items.value = (await supabase.from("historyitems").select().eq("trackingtrip",elementId)).data || []
}
}
setup()
const historyItems = computed(() => {
let items = []
if(type === "customer") {
items = dataStore.historyItems.filter(i => i.customer === elementId)
} else if(type === "vendor") {
items = dataStore.historyItems.filter(i => i.vendor === elementId)
} else if(type === "project") {
items = dataStore.historyItems.filter(i => i.project === elementId)
} else if(type === "plant") {
items = dataStore.historyItems.filter(i => i.plant === elementId)
} else if(type === "incomingInvoice") {
items = dataStore.historyItems.filter(i => i.incomingInvoice === elementId)
} else if(type === "document") {
items = dataStore.historyItems.filter(i => i.document === elementId)
} else if(type === "contact") {
items = dataStore.historyItems.filter(i => i.contact === elementId)
} else if(type === "contract") {
items = dataStore.historyItems.filter(i => i.contract === elementId)
} else if(type === "inventoryitem") {
items = dataStore.historyItems.filter(i => i.inventoryitem === elementId)
} else if(type === "product") {
items = dataStore.historyItems.filter(i => i.product === elementId)
} else if(type === "profile") {
items = dataStore.historyItems.filter(i => i.profile === elementId)
} else if(type === "absencerequest") {
items = dataStore.historyItems.filter(i => i.absenceRequest === elementId)
} else if(type === "event") {
items = dataStore.historyItems.filter(i => i.event === elementId)
} else if(type === "task") {
items = dataStore.historyItems.filter(i => i.task === elementId)
} else if(type === "vehicle") {
items = dataStore.historyItems.filter(i => i.vehicle === elementId)
} else if(type === "space") {
items = dataStore.historyItems.filter(i => i.space === elementId)
}
return items
})
const addHistoryItemData = ref({
text: "",
})
@@ -145,6 +107,8 @@ const addHistoryItem = async () => {
addHistoryItemData.value.vehicle = elementId
} else if(type === "space") {
addHistoryItemData.value.space = elementId
} else if(type === "trackingtrip") {
addHistoryItemData.value.trackingtrip = elementId
}
@@ -203,7 +167,7 @@ const renderText = (text) => {
</UCard>
</UModal>
<Toolbar
v-if="!renderHeadline"
v-if="!renderHeadline"
>
<UButton
@click="showAddHistoryItemModal = true"
@@ -222,31 +186,39 @@ const renderText = (text) => {
</div>
<UDivider class="my-3"/>
</div>
<div
v-if="items.length > 0"
v-for="(item,index) in items.slice().reverse()"
>
<UDivider
class="my-3"
v-if="index !== 0"
/>
<div class="flex items-center gap-3">
<UAvatar
v-if="!item.createdBy"
:src="colorMode.value === 'light' ? '/Logo.png' : '/Logo_Dark.png' "
<!-- ITEM LIST -->
<div style="overflow-y: scroll">
<div
v-if="items.length > 0"
v-for="(item,index) in items.slice().reverse()"
>
<UDivider
class="my-3"
v-if="index !== 0"
/>
<UAvatar
:alt="dataStore.getProfileById(item.createdBy).fullName"
v-else
/>
<div>
<h3 v-if="item.createdBy">{{dataStore.getProfileById(item.createdBy) ? dataStore.getProfileById(item.createdBy).fullName : ""}}</h3>
<h3 v-else>FEDEO Bot</h3>
<span v-html="renderText(item.text)"/><br>
<span class="text-gray-500">{{dayjs(item.created_at).format("DD.MM.YY HH:mm")}}</span>
<div class="flex items-center gap-3">
<UAvatar
v-if="!item.createdBy"
:src="colorMode.value === 'light' ? '/Logo.png' : '/Logo_Dark.png' "
/>
<UAvatar
:alt="dataStore.getProfileById(item.createdBy).fullName"
v-else
/>
<div>
<h3 v-if="item.createdBy">{{dataStore.getProfileById(item.createdBy) ? dataStore.getProfileById(item.createdBy).fullName : ""}}</h3>
<h3 v-else>FEDEO Bot</h3>
<span v-html="renderText(item.text)"/><br>
<span class="text-gray-500">{{dayjs(item.created_at).format("DD.MM.YY HH:mm")}}</span>
</div>
</div>
</div>
</div>
</template>
<style scoped>

44
components/Map.vue Normal file
View File

@@ -0,0 +1,44 @@
<script setup>
const props = defineProps({
markers: {
type: Array,
required: true
}
})
const {markers} = props
const zoom =ref(2)
</script>
<template>
<div class="h-full w-full">
<LMap
style="height: 300px;"
:center="markers[0]"
:use-global-leaflet="false"
:zoom="10"
ref="map"
>
<LTileLayer
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
attribution="&amp;copy; <a href=&quot;https://www.openstreetmap.org/&quot;>OpenStreetMap</a> contributors"
layer-type="base"
name="OpenStreetMap"
/>
<LMarker
v-for="marker in markers"
:lat-lng="marker"
/>
</LMap>
</div>
</template>
<style scoped>
</style>