This commit is contained in:
2024-04-10 10:09:56 +02:00
parent 9fa1059301
commit bf04b9c563
12 changed files with 230 additions and 241 deletions

View File

@@ -13,7 +13,7 @@ const links = [{
shortcuts.value = true shortcuts.value = true
} }
}, { }, {
label: 'Homepage', label: 'Webseite',
icon: 'i-heroicons-book-open', icon: 'i-heroicons-book-open',
to: 'https://fedeo.de', to: 'https://fedeo.de',
target: '_blank' target: '_blank'

View File

@@ -63,11 +63,11 @@ const historyItems = computed(() => {
}) })
const addHistoryItemData = ref({ const addHistoryItemData = ref({
text: "", text: "",
user: ""
}) })
const addHistoryItem = async () => { const addHistoryItem = async () => {
addHistoryItemData.value.user = user.value.id console.log(addHistoryItemData.value)
addHistoryItemData.value.createdBy = dataStore.activeProfile.id
if(type === "customer") { if(type === "customer") {
addHistoryItemData.value.customer = elementId addHistoryItemData.value.customer = elementId
@@ -197,7 +197,7 @@ const renderText = (text) => {
/> />
<div> <div>
<h3 v-if="item.createdBy">{{dataStore.getProfileById(item.createdBy) ? dataStore.getProfileById(item.createdBy).fullName : ""}}</h3> <h3 v-if="item.createdBy">{{dataStore.getProfileById(item.createdBy) ? dataStore.getProfileById(item.createdBy).fullName : ""}}</h3>
<h3 v-else>Spaces Bot</h3> <h3 v-else>FEDEO Bot</h3>
<span v-html="renderText(item.text)"/><br> <span v-html="renderText(item.text)"/><br>
<span class="text-gray-500">{{dayjs(item.created_at).format("DD.MM.YY HH:mm")}}</span> <span class="text-gray-500">{{dayjs(item.created_at).format("DD.MM.YY HH:mm")}}</span>
</div> </div>

View File

@@ -12,34 +12,7 @@ const items = computed(() => [
slot: 'account', slot: 'account',
label: '', label: '',
disabled: true disabled: true
}], [{ }], [{
label: 'Suche',
icon: 'i-heroicons-command-line',
shortcuts: [metaSymbol.value, 'K'],
click: () => {
isDashboardSearchModalOpen.value = true
}
}, {
label: 'Hilfe & Support',
icon: 'i-heroicons-question-mark-circle',
shortcuts: ['?'],
click: () => isHelpSlideoverOpen.value = true
}], [{
label: 'Webseite',
icon: 'i-heroicons-book-open',
to: 'https://fedeo.de',
target: '_blank'
},/* {
label: 'GitHub repository',
icon: 'i-simple-icons-github',
to: 'https://github.com/nuxt/ui-pro',
target: '_blank'
}, {
label: 'Buy Nuxt UI Pro',
icon: 'i-heroicons-credit-card',
to: 'https://ui.nuxt.com/pro/purchase',
target: '_blank'
}*/], [{
label: 'Abmelden', label: 'Abmelden',
icon: 'i-heroicons-arrow-left-on-rectangle', icon: 'i-heroicons-arrow-left-on-rectangle',
click: async () => { click: async () => {

View File

@@ -270,7 +270,7 @@ let links = computed(() => {
defaultOpen: false, defaultOpen: false,
children: [ children: [
{ {
label: "Steuerung", label: "Vorgänge",
to: "/inventory", to: "/inventory",
icon: "i-heroicons-square-3-stack-3d" icon: "i-heroicons-square-3-stack-3d"
}, },
@@ -456,7 +456,16 @@ const footerLinks = [/*{
<UDashboardSearchButton label="Suche..."/> <UDashboardSearchButton label="Suche..."/>
</template> </template>
<UDashboardSidebarLinks :links="links" /> <UDashboardSidebarLinks :links="links" >
</UDashboardSidebarLinks>
<!-- <UAccordion
:items="links"
>
</UAccordion>-->
<div class="flex-1" /> <div class="flex-1" />

View File

@@ -116,7 +116,7 @@ setupPage()
<UTabs <UTabs
v-if="currentItem && mode == 'show'" v-if="currentItem && mode == 'show'"
:items="[{label: 'Informationen'}, /*{label: 'Logbuch'},*/ {label: 'Projekte'},{label: 'Objekte'},{label: 'Verträge'}, {label: 'Ansprechpartner'}]" :items="[{label: 'Informationen'},{label: 'Projekte'},{label: 'Objekte'},{label: 'Verträge'}]"
class="p-5" class="p-5"
> >
<template #item="{item}"> <template #item="{item}">
@@ -223,7 +223,7 @@ setupPage()
<UButton <UButton
@click="router.push(`/contracts/create?customer=${currentItem.id}`)" @click="router.push(`/contracts/create?customer=${currentItem.id}`)"
> >
+ Objekt + Vertrag
</UButton> </UButton>
</Toolbar> </Toolbar>
<UTable <UTable

View File

@@ -206,7 +206,7 @@ setupPage()
></USelectMenu> ></USelectMenu>
<UButton <UButton
@click="itemInfo.resources.push(dataStore.getResourcesList.find(i => i.id === resourceToAdd))" @click="itemInfo.resources.push(dataStore.getResourcesList.find(i => i.id === resourceToAdd))"
:disabled="itemInfo.resources.find(i => i.id === resourceToAdd)" :disabled="itemInfo.resources.find(i => i.id === resourceToAdd)"
> >
+ Hinzufügen + Hinzufügen
</UButton> </UButton>

View File

@@ -134,7 +134,7 @@ function changeFocusToQuantity() {
<USelectMenu <USelectMenu
:options="dataStore.spaces" :options="dataStore.spaces"
searchable searchable
option-attribute="description" option-attribute="spaceNumber"
:color="checkSpaceId(inventoryChangeData.spaceId) ? 'primary' : 'rose'" :color="checkSpaceId(inventoryChangeData.spaceId) ? 'primary' : 'rose'"
v-model="inventoryChangeData.spaceId" v-model="inventoryChangeData.spaceId"
v-on:select="changeFocusToQuantity" v-on:select="changeFocusToQuantity"

View File

@@ -9,6 +9,7 @@ const user = useSupabaseUser()
const router = useRouter() const router = useRouter()
const colorMode = useColorMode() const colorMode = useColorMode()
const dataStore = useDataStore() const dataStore = useDataStore()
const toast = useToast()
const isLight = computed({ const isLight = computed({
get () { get () {
@@ -43,9 +44,12 @@ const onSubmit = async (data) => {
password: data.password password: data.password
}) })
if(error) { if(error) {
console.log(error.toString()) if(error.toString().toLowerCase().includes("invalid")){
toast.add({title:"Zugangsdaten falsch",color:"rose"})
}
} else { } else {
console.log("Login Successful") //console.log("Login Successful")
dataStore.initializeData(user.id) dataStore.initializeData(user.id)
router.push("/") router.push("/")

View File

@@ -13,7 +13,9 @@ let currentItem = ref(null)
//Working //Working
const mode = ref(route.params.mode || "show") const mode = ref(route.params.mode || "show")
const itemInfo = ref({}) const itemInfo = ref({
profile: dataStore.activeProfile.id
})
const oldItemInfo = ref({}) const oldItemInfo = ref({})
const categories = ["Offen", "In Bearbeitung", "Dringed", "Erledigt"] const categories = ["Offen", "In Bearbeitung", "Dringed", "Erledigt"]

View File

@@ -65,7 +65,7 @@ const setupPage = () => {
} }
if(mode.value === "edit") itemInfo.value = currentItem.value if(mode.value === "edit") itemInfo.value = currentItem.value
if(currentItem.value.id) oldItemInfo.value = JSON.parse(JSON.stringify(currentItem.value)) if(currentItem.value) oldItemInfo.value = JSON.parse(JSON.stringify(currentItem.value))
} }
const cancelEditorCreate = () => { const cancelEditorCreate = () => {

View File

@@ -55,6 +55,7 @@ setupPage()
</UButton> </UButton>
<UButton <UButton
v-else-if="mode === 'edit' && !itemInfo.id" v-else-if="mode === 'edit' && !itemInfo.id"
@click="dataStore.createNewItem('workingtimes',itemInfo)"
> >
Erstellen Erstellen
</UButton> </UButton>

View File

@@ -490,218 +490,218 @@ export const useDataStore = defineStore('data', () => {
//console.log(oldData) //console.log(oldData)
//console.log(newData) //console.log(newData)
let itemsToCreate = [] if(dataTypes[dataType].historyItemHolder){
let itemsToCreate = []
const checkPropState = (key,propContent) => { const checkPropState = (key,propContent) => {
//console.log(propContent) //console.log(propContent)
if(propContent.type && propContent.data){ if(propContent.type && propContent.data){
if(propContent.type === "updated" ||propContent.type === "created"){ if(propContent.type === "updated" ||propContent.type === "created"){
createHistoryItem(key,propContent) createHistoryItem(key,propContent)
}
} else {
for (let prop in propContent) {
checkPropState(prop,propContent[prop])
}
} }
}
const createHistoryItem = (key,prop) => {
//console.log("OLD: " + prop.data.o)
//console.log("NEW: " + prop.data.n)
let name = "" || key
let oldVal = prop.data.o || "-"
let newVal = prop.data.n || "-"
if(key === "project") {
name = "Projekt"
oldVal = oldVal !== "-" ? projects.value.find(i => i.id === prop.data.o).name : "-"
newVal = projects.value.find(i => i.id === prop.data.n).name
} else if (key === "title") {
name = "Titel"
} else if(key === "type") {
name = "Typ"
} else if(key === "notes") {
name = "Notizen"
} else if(key === "link") {
name = "Link"
} else if(key === "start") {
name = "Start"
oldVal = dayjs(prop.data.o).format("DD.MM.YYYY HH:mm")
newVal = dayjs(prop.data.n).format("DD.MM.YYYY HH:mm")
} else if(key === "end") {
name = "Ende"
oldVal = dayjs(prop.data.o).format("DD.MM.YYYY HH:mm")
newVal = dayjs(prop.data.n).format("DD.MM.YYYY HH:mm")
} else if(key === "birthday") {
name = "Geburtstag"
oldVal = dayjs(prop.data.o).format("DD.MM.YYY")
newVal = dayjs(prop.data.n).format("DD.MM.YYY")
} else if(key === "resources") {
name = "Resourcen"
oldVal = prop.data.o.map(i => i.title).join(", ")
newVal = prop.data.n.map(i => i.title).join(", ")
} else if(key === "customerNumber") {
name = "Kundennummer"
} else if(key === "active") {
name = "Aktiv"
if(oldVal === true){
oldVal = "Aktiv"
newVal = "Gesperrt"
} else if(oldVal === "-") {
oldVal = "Gesperrt"
newVal = "Aktiv"
}
} else if(key === "isCompany") {
name = "Firmenkunde"
if(oldVal === true){
oldVal = "Firma"
newVal = "Privatkunde"
} else if(oldVal === "-") {
oldVal = "Privatkunde"
newVal = "Firma"
}
} else if(key === "special") {
name = "Adresszusatz"
} else if(key === "street") {
name = "Straße & Hausnummer"
} else if(key === "city") {
name = "Ort"
} else if(key === "zip") {
name = "Postleitzahl"
} else if(key === "country") {
name = "Land"
} else if(key === "web") {
name = "Webseite"
} else if(key === "email") {
name = "E-Mail"
} else if(key === "tel") {
name = "Telefon"
} else if(key === "ustid") {
name = "USt-ID"
} else if(key === "role") {
name = "Rolle"
} else if(key === "phoneHome") {
name = "Festnetz"
} else if(key === "phoneMobile") {
name = "Mobiltelefon"
} else if(key === "salutation") {
name = "Anrede"
} else if(key === "firstName") {
name = "Vorname"
} else if(key === "lastName") {
name = "Nachname"
} else if(key === "name") {
name = "Name"
} else if(key === "customer") {
name = "Kunde"
oldVal = customers.value.find(i => i.id === prop.data.o).name
newVal = customers.value.find(i => i.id === prop.data.n).name
} else if(key === "vendor") {
name = "Lieferant"
oldVal = vendors.value.find(i => i.id === prop.data.o).name
newVal = vendors.value.find(i => i.id === prop.data.n).name
} else if(key === "description") {
name = "Beschreibung"
} else if(key === "categorie") {
name = "Kategorie"
} else if(key === "profile") {
name = "Mitarbeiter"
oldVal = profiles.value.find(i => i.id === prop.data.o).fullName
newVal = profiles.value.find(i => i.id === prop.data.n).fullName
} else if(key === "plant") {
name = "Objekt"
oldVal = plants.value.find(i => i.id === prop.data.o).name
newVal = plants.value.find(i => i.id === prop.data.n).name
} else if(key === "annualPaidLeaveDays") {
name = "Urlaubstage"
} else if(key === "employeeNumber") {
name = "Mitarbeiternummer"
} else if(key === "weeklyWorkingDays") {
name = "Wöchentliche Arbeitstage"
} else if(key === "weeklyWorkingHours") {
name = "Wöchentliche Arbeitszeit"
} else if(key === "licensePlate") {
name = "Kennzeichen"
} else if(key === "driver") {
name = "Fahrer"
oldVal = profiles.value.find(i => i.id === prop.data.o).fullName
newVal = profiles.value.find(i => i.id === prop.data.n).fullName
}
let text = ""
if(prop.type === "updated" && newVal !== "-" && oldVal !== "-") {
text = `Gerändert: ${name} von "${oldVal}" zu "${newVal}"`
} else if(prop.type === "updated" && newVal !== "-" && oldVal === "-") {
text = `Hinzugefügt: ${name} "${newVal}"`
} else if(prop.type === "created") {
text = `Hinzugefügt: ${name} "${newVal}"`
} else if(prop.type === "updated" && newVal === "-" && oldVal !== "-") {
text = `Entfernt: ${name} "${oldVal}"`
}
let historyItem = {
text: text,
createdBy: activeProfile.value.id,
oldVal: prop.data.o,
newVal: prop.data.n,
tenant: currentTenant.value
}
historyItem[dataTypes[dataType].historyItemHolder] = newData.id
const checkIfNaN = (x) => {
return typeof x === "number" && x !== x;
}
//console.log(key)
//console.log(checkIfNaN(key))
if(key !== "fullName" && key !== "phases") {
//console.log(historyItem)
itemsToCreate.push(historyItem)
}
}
if(oldData) {
let result = deepDiffMapper.map(oldData,newData)
//console.log(result)
for (let prop in result) {
//console.log(prop)
checkPropState(prop,result[prop])
}
} else { } else {
for (let prop in propContent) { let historyItem = {
checkPropState(prop,propContent[prop]) text: `${dataTypes[dataType].labelSingle} erstellt`,
createdBy: activeProfile.value.id,
tenant: currentTenant.value
} }
}
}
const createHistoryItem = (key,prop) => { historyItem[dataTypes[dataType].historyItemHolder] = newData.id
//console.log("OLD: " + prop.data.o)
//console.log("NEW: " + prop.data.n)
let name = "" || key
let oldVal = prop.data.o || "-"
let newVal = prop.data.n || "-"
if(key === "project") {
name = "Projekt"
oldVal = projects.value.find(i => i.id === prop.data.o).name
newVal = projects.value.find(i => i.id === prop.data.n).name
} else if (key === "title") {
name = "Titel"
} else if(key === "type") {
name = "Typ"
} else if(key === "notes") {
name = "Notizen"
} else if(key === "link") {
name = "Link"
} else if(key === "start") {
name = "Start"
oldVal = dayjs(prop.data.o).format("DD.MM.YYYY HH:mm")
newVal = dayjs(prop.data.n).format("DD.MM.YYYY HH:mm")
} else if(key === "end") {
name = "Ende"
oldVal = dayjs(prop.data.o).format("DD.MM.YYYY HH:mm")
newVal = dayjs(prop.data.n).format("DD.MM.YYYY HH:mm")
} else if(key === "birthday") {
name = "Geburtstag"
oldVal = dayjs(prop.data.o).format("DD.MM.YYY")
newVal = dayjs(prop.data.n).format("DD.MM.YYY")
} else if(key === "resources") {
name = "Resourcen"
oldVal = prop.data.o.map(i => i.title).join(", ")
newVal = prop.data.n.map(i => i.title).join(", ")
} else if(key === "customerNumber") {
name = "Kundennummer"
} else if(key === "active") {
name = "Aktiv"
if(oldVal === true){
oldVal = "Aktiv"
newVal = "Gesperrt"
} else if(oldVal === "-") {
oldVal = "Gesperrt"
newVal = "Aktiv"
}
} else if(key === "isCompany") {
name = "Firmenkunde"
if(oldVal === true){
oldVal = "Firma"
newVal = "Privatkunde"
} else if(oldVal === "-") {
oldVal = "Privatkunde"
newVal = "Firma"
}
} else if(key === "special") {
name = "Adresszusatz"
} else if(key === "street") {
name = "Straße & Hausnummer"
} else if(key === "city") {
name = "Ort"
} else if(key === "zip") {
name = "Postleitzahl"
} else if(key === "country") {
name = "Land"
} else if(key === "web") {
name = "Webseite"
} else if(key === "email") {
name = "E-Mail"
} else if(key === "tel") {
name = "Telefon"
} else if(key === "ustid") {
name = "USt-ID"
} else if(key === "role") {
name = "Rolle"
} else if(key === "phoneHome") {
name = "Festnetz"
} else if(key === "phoneMobile") {
name = "Mobiltelefon"
} else if(key === "salutation") {
name = "Anrede"
} else if(key === "firstName") {
name = "Vorname"
} else if(key === "lastName") {
name = "Nachname"
} else if(key === "name") {
name = "Name"
} else if(key === "customer") {
name = "Kunde"
oldVal = customers.value.find(i => i.id === prop.data.o).name
newVal = customers.value.find(i => i.id === prop.data.n).name
} else if(key === "vendor") {
name = "Lieferant"
oldVal = vendors.value.find(i => i.id === prop.data.o).name
newVal = vendors.value.find(i => i.id === prop.data.n).name
} else if(key === "description") {
name = "Beschreibung"
} else if(key === "categorie") {
name = "Kategorie"
} else if(key === "profile") {
name = "Mitarbeiter"
oldVal = profiles.value.find(i => i.id === prop.data.o).fullName
newVal = profiles.value.find(i => i.id === prop.data.n).fullName
} else if(key === "plant") {
name = "Objekt"
oldVal = plants.value.find(i => i.id === prop.data.o).name
newVal = plants.value.find(i => i.id === prop.data.n).name
} else if(key === "annualPaidLeaveDays") {
name = "Urlaubstage"
} else if(key === "employeeNumber") {
name = "Mitarbeiternummer"
} else if(key === "weeklyWorkingDays") {
name = "Wöchentliche Arbeitstage"
} else if(key === "weeklyWorkingHours") {
name = "Wöchentliche Arbeitszeit"
} else if(key === "licensePlate") {
name = "Kennzeichen"
} else if(key === "driver") {
name = "Fahrer"
oldVal = profiles.value.find(i => i.id === prop.data.o).fullName
newVal = profiles.value.find(i => i.id === prop.data.n).fullName
}
let text = ""
if(prop.type === "updated" && newVal !== "-" && oldVal !== "-") {
text = `Gerändert: ${name} von "${oldVal}" zu "${newVal}"`
} else if(prop.type === "updated" && newVal !== "-" && oldVal === "-") {
text = `Hinzugefügt: ${name} "${newVal}"`
} else if(prop.type === "created") {
text = `Hinzugefügt: ${name} "${newVal}"`
} else if(prop.type === "updated" && newVal === "-" && oldVal !== "-") {
text = `Entfernt: ${name} "${oldVal}"`
}
let historyItem = {
text: text,
createdBy: activeProfile.value.id,
oldVal: prop.data.o,
newVal: prop.data.n,
tenant: currentTenant.value
}
historyItem[dataTypes[dataType].historyItemHolder] = newData.id
const checkIfNaN = (x) => {
return typeof x === "number" && x !== x;
}
//console.log(key)
//console.log(checkIfNaN(key))
if(key !== "fullName" && key !== "phases") {
//console.log(historyItem) //console.log(historyItem)
itemsToCreate.push(historyItem) itemsToCreate.push(historyItem)
} }
} const {data,error} = await supabase.from("historyitems").insert(itemsToCreate)
if(oldData) {
let result = deepDiffMapper.map(oldData,newData)
//console.log(result)
for (let prop in result) {
//console.log(prop)
checkPropState(prop,result[prop])
if(error) {
console.log(error)
} else {
fetchHistoryItems()
} }
} else {
let historyItem = {
text: `${dataTypes[dataType].labelSingle} erstellt`,
createdBy: activeProfile.value.id,
tenant: currentTenant.value
}
historyItem[dataTypes[dataType].historyItemHolder] = newData.id
//console.log(historyItem)
itemsToCreate.push(historyItem)
} }
const {data,error} = await supabase.from("historyitems").insert(itemsToCreate)
if(error) {
console.log(error)
} else {
fetchHistoryItems()
}
} }