diff --git a/components/EntityShow.vue b/components/EntityShow.vue index dc3dec8..dbfb20b 100644 --- a/components/EntityShow.vue +++ b/components/EntityShow.vue @@ -45,6 +45,7 @@ const router = useRouter() const route = useRoute() const dataStore = useDataStore() const modal = useModal() +const auth = useAuthStore() const dataType = dataStore.dataTypes[type] @@ -97,6 +98,43 @@ const onTabChange = (index) => { router.push(`${router.currentRoute.value.path}?tabIndex=${index}`) } +const changePinned = async () => { + let newPins = [] + + if(auth.profile.pinned_on_navigation.find(i => i.datatype === type && i.id === props.item.id)){ + //Remove Pin + + newPins = auth.profile.pinned_on_navigation.filter(i => !(i.datatype === type && i.id === props.item.id)) + } else { + //Add Pin + + newPins = [ + ...auth.profile.pinned_on_navigation, + { + id: props.item.id, + icon: "i-heroicons-document", + type: "standardEntity", + datatype: type, + label: props.item[dataType.templateColumns.find(i => i.title).key] + } + ] + } + + const res = await useNuxtApp().$api(`/api/user/${auth.user.id}/profile`,{ + method: "PUT", + body: { + data: { + pinned_on_navigation: newPins + } + } + }) + + await auth.fetchMe() + + + +} + @@ -147,6 +185,13 @@ const onTabChange = (index) => { >{{item ? `${dataType.labelSingle}${props.item[dataType.templateColumns.find(i => i.title).key] ? ': ' + props.item[dataType.templateColumns.find(i => i.title).key] : ''}`: '' }} + diff --git a/components/MainNav.vue b/components/MainNav.vue index 4d16dd6..6ecd8fb 100644 --- a/components/MainNav.vue +++ b/components/MainNav.vue @@ -16,6 +16,13 @@ const links = computed(() => { target: "_blank", pinned: true } + }else if(pin.type === "standardEntity") { + return { + label: pin.label, + to: `/standardEntity/${pin.datatype}/show/${pin.id}`, + icon: pin.icon, + pinned: true + } } }), diff --git a/error.vue b/error.vue index fbeac53..814280f 100644 --- a/error.vue +++ b/error.vue @@ -7,11 +7,29 @@ const props = defineProps({ - - - Da ist etwas schief gelaufen - Zurück - + + + + Es gab ein Problem - {{error.statusCode}} + + + + - + + Zurück zur Startseite + + \ No newline at end of file diff --git a/pages/createDocument/edit/[[id]].vue b/pages/createDocument/edit/[[id]].vue index 1e0cf78..918ecb1 100644 --- a/pages/createDocument/edit/[[id]].vue +++ b/pages/createDocument/edit/[[id]].vue @@ -38,13 +38,13 @@ const itemInfo = ref({ dateOfPerformance: null, paymentDays: auth.activeTenantData.standardPaymentDays, customSurchargePercentage: 0, - createdBy: profileStore.activeProfile.id, + createdBy: auth.user.id, title: null, description: null, startText: null, endText: null, rows: [], - contactPerson: profileStore.activeProfile.id, + contactPerson: auth.user.id, contactPersonName: null, contactTel: null, contactEMail: null, @@ -621,6 +621,7 @@ const findDocumentErrors = computed(() => { if (itemInfo.value.customer === null) errors.push({message: "Es ist kein Kunde ausgewählt", type: "breaking"}) if (itemInfo.value.contact === null) errors.push({message: "Es ist kein Kontakt ausgewählt", type: "info"}) if (itemInfo.value.letterhead === null) errors.push({message: "Es ist kein Briefpapier ausgewählt", type: "breaking"}) + if (itemInfo.value.created_by === null || !itemInfo.value.created_by) errors.push({message: "Es ist kein Ansprechpartner ausgewählt", type: "breaking"}) if (itemInfo.value.address.street === null) errors.push({ message: "Es ist keine Straße im Adressat angegeben", type: "breaking" @@ -1370,49 +1371,59 @@ const saveDocument = async (state, resetup = false) => { if (resetup) await setupPage() } +const selectedTab = ref(0) + const closeDocument = async () => { - loaded.value = false + if(selectedTab.value === 0) { + await generateDocument() + selectedTab.value = 1 + } else { + loaded.value = false - await saveDocument("Gebucht") + await saveDocument("Gebucht") - await generateDocument() + await generateDocument() - let fileData = {} + let fileData = {} - fileData.project = itemInfo.value.project - fileData.createddocument = itemInfo.value.id + fileData.project = itemInfo.value.project + fileData.createddocument = itemInfo.value.id - let mappedType = itemInfo.value.type + let mappedType = itemInfo.value.type - if (mappedType === "advanceInvoices" || mappedType === "cancellationInvoices") { - mappedType = "invoices" - } - - const folders = await useEntities("folders").select() - console.log(folders) - fileData.folder = folders.find(i => i.function === mappedType && i.year === Number(dayjs().format("YYYY"))).id - - const tags = await useEntities("filetags").select() - fileData.type = tags.find(i => i.createddocumenttype === mappedType).id - - function dataURLtoFile(dataurl, filename) { - var arr = dataurl.split(","), - mime = arr[0].match(/:(.*?);/)[1], - bstr = atob(arr[arr.length - 1]), - n = bstr.length, - u8arr = new Uint8Array(n); - while (n--) { - u8arr[n] = bstr.charCodeAt(n); + if (mappedType === "advanceInvoices" || mappedType === "cancellationInvoices") { + mappedType = "invoices" } - return new File([u8arr], filename, {type: mime}); + + const folders = await useEntities("folders").select() + console.log(folders) + fileData.folder = folders.find(i => i.function === mappedType && i.year === Number(dayjs().format("YYYY"))).id + + const tags = await useEntities("filetags").select() + fileData.type = tags.find(i => i.createddocumenttype === mappedType).id + + function dataURLtoFile(dataurl, filename) { + var arr = dataurl.split(","), + mime = arr[0].match(/:(.*?);/)[1], + bstr = atob(arr[arr.length - 1]), + n = bstr.length, + u8arr = new Uint8Array(n); + while (n--) { + u8arr[n] = bstr.charCodeAt(n); + } + return new File([u8arr], filename, {type: mime}); + } + + let file = dataURLtoFile(uri.value, `${itemInfo.value.documentNumber}.pdf`) + + await useFiles().uploadFiles(fileData, [file]) + + await router.push(`/createDocument/show/${itemInfo.value.id}`) } - let file = dataURLtoFile(uri.value, `${itemInfo.value.documentNumber}.pdf`) - await useFiles().uploadFiles(fileData, [file]) - await router.push(`/createDocument/show/${itemInfo.value.id}`) } @@ -1512,11 +1523,11 @@ const setRowData = async (row, service = {sellingPriceComposed: {}}, product = { Archivieren @@ -1538,7 +1549,7 @@ const setRowData = async (row, service = {sellingPriceComposed: {}}, product = { @click="closeDocument" v-if="itemInfo.id && itemInfo.type !== 'serialInvoices'" > - Fertigstellen + {{selectedTab === 0 ? "Vorschau zeigen" : "Fertigstellen"}} - + diff --git a/pages/standardEntity/[type]/[[mode]]/[[id]].vue b/pages/standardEntity/[type]/[[mode]]/[[id]].vue index e5f4e4c..76ebd91 100644 --- a/pages/standardEntity/[type]/[[mode]]/[[id]].vue +++ b/pages/standardEntity/[type]/[[mode]]/[[id]].vue @@ -39,6 +39,8 @@ const setupPage = async (sort_column = null, sort_direction = null) => { //Load Data for Edit item.value = JSON.stringify(await useEntities(type).selectSingle(route.params.id)) + console.log(item.value) + } else if (mode.value === "create") { //Load Data for Create item.value = JSON.stringify({}) @@ -65,7 +67,7 @@ setupPage() :platform="platform" /> { const api = $fetch.create({ - baseURL: "https://backend.fedeo.io", + baseURL: "http://localhost:3100" /*"https://backend.fedeo.io"*/, credentials: "include", onRequest({ options }) { // Token aus Cookie holen