Merge branch 'refs/heads/dev' into beta
This commit is contained in:
@@ -7,12 +7,20 @@ const props = defineProps({
|
|||||||
required: true,
|
required: true,
|
||||||
type: String
|
type: String
|
||||||
},
|
},
|
||||||
|
createQuery: {
|
||||||
|
type: Object
|
||||||
|
},
|
||||||
item: {
|
item: {
|
||||||
required: true,
|
required: true,
|
||||||
type: Object
|
type: Object
|
||||||
|
},
|
||||||
|
inModal: {
|
||||||
|
type: Boolean,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const emit = defineEmits(["returnData"])
|
||||||
|
|
||||||
|
|
||||||
const {type} = props
|
const {type} = props
|
||||||
|
|
||||||
@@ -38,6 +46,7 @@ const route = useRoute()
|
|||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
const profileStore = useProfileStore()
|
const profileStore = useProfileStore()
|
||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
|
const modal = useModal()
|
||||||
|
|
||||||
const dataType = dataStore.dataTypes[type]
|
const dataType = dataStore.dataTypes[type]
|
||||||
const openTab = ref(0)
|
const openTab = ref(0)
|
||||||
@@ -73,17 +82,20 @@ const setupCreate = () => {
|
|||||||
setupCreate()
|
setupCreate()
|
||||||
|
|
||||||
const setupQuery = () => {
|
const setupQuery = () => {
|
||||||
if(route.query) {
|
if(props.mode === "create" && (route.query || props.createQuery)) {
|
||||||
Object.keys(route.query).forEach(key => {
|
|
||||||
|
let data = !props.inModal ? route.query : props.createQuery
|
||||||
|
|
||||||
|
Object.keys(data).forEach(key => {
|
||||||
if(dataType.templateColumns.find(i => i.key === key)) {
|
if(dataType.templateColumns.find(i => i.key === key)) {
|
||||||
if (["customer", "contract", "plant", "contact", "project"].includes(key)) {
|
if (["customer", "contract", "plant", "contact", "project"].includes(key)) {
|
||||||
item.value[key] = Number(route.query[key])
|
item.value[key] = Number(data[key])
|
||||||
} else {
|
} else {
|
||||||
item.value[key] = route.query[key]
|
item.value[key] = data[key]
|
||||||
}
|
}
|
||||||
} else if(key === "resources") {
|
} else if(key === "resources") {
|
||||||
/*item.value[key] = route.query[key]*/
|
/*item.value[key] = data[key]*/
|
||||||
JSON.parse(route.query[key]).forEach(async (i) => {
|
JSON.parse(data[key]).forEach(async (i) => {
|
||||||
console.log(i)
|
console.log(i)
|
||||||
let type = i.substring(0,1)
|
let type = i.substring(0,1)
|
||||||
let id = i.substring(2,i.length)
|
let id = i.substring(2,i.length)
|
||||||
@@ -180,10 +192,37 @@ const calcSaveAllowed = (item) => {
|
|||||||
watch(item.value, async (newItem, oldItem) => {
|
watch(item.value, async (newItem, oldItem) => {
|
||||||
calcSaveAllowed(newItem)
|
calcSaveAllowed(newItem)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const createItem = async () => {
|
||||||
|
let ret = null
|
||||||
|
|
||||||
|
if(props.inModal) {
|
||||||
|
ret = await dataStore.createNewItem(type,item.value,true)
|
||||||
|
} else {
|
||||||
|
ret = dataStore.createNewItem(type,item.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
emit('returnData', ret)
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateItem = async () => {
|
||||||
|
let ret = null
|
||||||
|
|
||||||
|
if(props.inModal) {
|
||||||
|
ret = await dataStore.updateItem(type,item.value, oldItem.value,true)
|
||||||
|
} else {
|
||||||
|
ret = await dataStore.updateItem(type,item.value, oldItem.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
emit('returnData', ret)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<UDashboardNavbar
|
<UDashboardNavbar
|
||||||
|
v-if="!props.inModal"
|
||||||
:ui="{center: 'flex items-stretch gap-1.5 min-w-0'}"
|
:ui="{center: 'flex items-stretch gap-1.5 min-w-0'}"
|
||||||
>
|
>
|
||||||
<template #left>
|
<template #left>
|
||||||
@@ -217,14 +256,14 @@ watch(item.value, async (newItem, oldItem) => {
|
|||||||
</ButtonWithConfirm>
|
</ButtonWithConfirm>
|
||||||
<UButton
|
<UButton
|
||||||
v-if="item.id"
|
v-if="item.id"
|
||||||
@click="dataStore.updateItem(type,item, oldItem)"
|
@click="updateItem"
|
||||||
:disabled="!saveAllowed"
|
:disabled="!saveAllowed"
|
||||||
>
|
>
|
||||||
Speichern
|
Speichern
|
||||||
</UButton>
|
</UButton>
|
||||||
<UButton
|
<UButton
|
||||||
v-else
|
v-else
|
||||||
@click="dataStore.createNewItem(type,item)"
|
@click="createItem"
|
||||||
:disabled="!saveAllowed"
|
:disabled="!saveAllowed"
|
||||||
>
|
>
|
||||||
Erstellen
|
Erstellen
|
||||||
@@ -238,6 +277,40 @@ watch(item.value, async (newItem, oldItem) => {
|
|||||||
</UButton>
|
</UButton>
|
||||||
</template>
|
</template>
|
||||||
</UDashboardNavbar>
|
</UDashboardNavbar>
|
||||||
|
<UDashboardNavbar
|
||||||
|
v-else
|
||||||
|
:ui="{center: 'flex items-stretch gap-1.5 min-w-0'}"
|
||||||
|
>
|
||||||
|
<template #center>
|
||||||
|
<h1
|
||||||
|
v-if="item"
|
||||||
|
:class="['text-xl','font-medium']"
|
||||||
|
>{{item.id ? `${dataType.labelSingle} bearbeiten` : `${dataType.labelSingle} erstellen` }}</h1>
|
||||||
|
</template>
|
||||||
|
<template #right>
|
||||||
|
<UButton
|
||||||
|
v-if="item.id"
|
||||||
|
@click="updateItem"
|
||||||
|
:disabled="!saveAllowed"
|
||||||
|
>
|
||||||
|
Speichern
|
||||||
|
</UButton>
|
||||||
|
<UButton
|
||||||
|
v-else
|
||||||
|
@click="createItem"
|
||||||
|
:disabled="!saveAllowed"
|
||||||
|
>
|
||||||
|
Erstellen
|
||||||
|
</UButton>
|
||||||
|
<UButton
|
||||||
|
@click="modal.close()"
|
||||||
|
color="red"
|
||||||
|
class="ml-2"
|
||||||
|
icon="i-heroicons-x-mark"
|
||||||
|
variant="outline"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</UDashboardNavbar>
|
||||||
<UDashboardPanelContent>
|
<UDashboardPanelContent>
|
||||||
<UForm
|
<UForm
|
||||||
class="p-5"
|
class="p-5"
|
||||||
|
|||||||
82
components/EntityModalButtons.vue
Normal file
82
components/EntityModalButtons.vue
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
<script setup>
|
||||||
|
import StandardEntityModal from "~/components/StandardEntityModal.vue";
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
type: {
|
||||||
|
type: String,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
id: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
createQuery: {
|
||||||
|
type: Object,
|
||||||
|
},
|
||||||
|
buttonShow: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
buttonEdit: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
buttonCreate: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const emit = defineEmits(["returnData"])
|
||||||
|
|
||||||
|
|
||||||
|
const modal = useModal()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<UButton
|
||||||
|
variant="outline"
|
||||||
|
class="w-25 ml-2"
|
||||||
|
v-if="props.id && props.buttonShow"
|
||||||
|
icon="i-heroicons-eye"
|
||||||
|
@click="modal.open(StandardEntityModal, {
|
||||||
|
id: props.id,
|
||||||
|
type: props.type,
|
||||||
|
mode: 'show',
|
||||||
|
})"
|
||||||
|
/>
|
||||||
|
<UButton
|
||||||
|
variant="outline"
|
||||||
|
class="w-25 ml-2"
|
||||||
|
v-if="props.id && props.buttonEdit"
|
||||||
|
icon="i-heroicons-pencil-solid"
|
||||||
|
@click="modal.open(StandardEntityModal, {
|
||||||
|
id: props.id,
|
||||||
|
type: props.type,
|
||||||
|
mode: 'edit',
|
||||||
|
onReturnData(data) {
|
||||||
|
emit('returnData', data)
|
||||||
|
}
|
||||||
|
})"
|
||||||
|
/>
|
||||||
|
<UButton
|
||||||
|
variant="outline"
|
||||||
|
class="w-25 ml-2"
|
||||||
|
v-if="!props.id && props.buttonCreate"
|
||||||
|
icon="i-heroicons-plus"
|
||||||
|
@click="modal.open(StandardEntityModal, {
|
||||||
|
type: props.type,
|
||||||
|
mode: 'create',
|
||||||
|
createQuery: props.createQuery,
|
||||||
|
onReturnData(data) {
|
||||||
|
emit('returnData', data)
|
||||||
|
}
|
||||||
|
})"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
|
||||||
|
</style>
|
||||||
@@ -9,6 +9,9 @@ const props = defineProps({
|
|||||||
item: {
|
item: {
|
||||||
required: true,
|
required: true,
|
||||||
type: Object
|
type: Object
|
||||||
|
},
|
||||||
|
inModal: {
|
||||||
|
type: Boolean,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -37,6 +40,7 @@ const dataStore = useDataStore()
|
|||||||
const profileStore = useProfileStore()
|
const profileStore = useProfileStore()
|
||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
const files = useFiles()
|
const files = useFiles()
|
||||||
|
const modal = useModal()
|
||||||
|
|
||||||
const dataType = dataStore.dataTypes[type]
|
const dataType = dataStore.dataTypes[type]
|
||||||
|
|
||||||
@@ -168,6 +172,7 @@ const getAvailableQueryStringData = (keys) => {
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<UDashboardNavbar
|
<UDashboardNavbar
|
||||||
|
v-if="!props.inModal"
|
||||||
:ui="{center: 'flex items-stretch gap-1.5 min-w-0'}"
|
:ui="{center: 'flex items-stretch gap-1.5 min-w-0'}"
|
||||||
>
|
>
|
||||||
<template #left>
|
<template #left>
|
||||||
@@ -200,6 +205,26 @@ const getAvailableQueryStringData = (keys) => {
|
|||||||
</UButton>
|
</UButton>
|
||||||
</template>
|
</template>
|
||||||
</UDashboardNavbar>
|
</UDashboardNavbar>
|
||||||
|
<UDashboardNavbar
|
||||||
|
v-else
|
||||||
|
:ui="{center: 'flex items-stretch gap-1.5 min-w-0'}"
|
||||||
|
>
|
||||||
|
<template #center>
|
||||||
|
<h1
|
||||||
|
v-if="item"
|
||||||
|
:class="['text-xl','font-medium']"
|
||||||
|
>{{item ? `${dataType.labelSingle}${props.item[dataType.templateColumns.find(i => i.title).key] ? ': ' + props.item[dataType.templateColumns.find(i => i.title).key] : ''}`: '' }}</h1>
|
||||||
|
</template>
|
||||||
|
<template #right>
|
||||||
|
<UButton
|
||||||
|
@click="modal.close()"
|
||||||
|
color="red"
|
||||||
|
class="ml-2"
|
||||||
|
icon="i-heroicons-x-mark"
|
||||||
|
variant="outline"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</UDashboardNavbar>
|
||||||
<UTabs
|
<UTabs
|
||||||
:items="dataType.showTabs"
|
:items="dataType.showTabs"
|
||||||
v-if="props.item.id"
|
v-if="props.item.id"
|
||||||
|
|||||||
97
components/StandardEntityModal.vue
Normal file
97
components/StandardEntityModal.vue
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
<script setup>
|
||||||
|
|
||||||
|
const toast = useToast()
|
||||||
|
const dataStore = useDataStore()
|
||||||
|
const supabase = useSupabaseClient()
|
||||||
|
const modal = useModal()
|
||||||
|
const props = defineProps({
|
||||||
|
type: {
|
||||||
|
type: String,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
mode: {
|
||||||
|
type: String,
|
||||||
|
required: true,
|
||||||
|
default: "show"
|
||||||
|
},
|
||||||
|
createQuery: {
|
||||||
|
type: Object
|
||||||
|
},
|
||||||
|
id: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const emit = defineEmits(["updateNeeded","returnData"])
|
||||||
|
|
||||||
|
const dataType = dataStore.dataTypes[props.type]
|
||||||
|
|
||||||
|
const loaded = ref(false)
|
||||||
|
const items = ref([])
|
||||||
|
const item = ref({})
|
||||||
|
|
||||||
|
const setupPage = async () => {
|
||||||
|
if(props.mode === "show") {
|
||||||
|
//Load Data for Show
|
||||||
|
item.value = await useSupabaseSelectSingle(props.type, props.id, dataType.supabaseSelectWithInformation || "*")
|
||||||
|
} else if(props.mode === "edit") {
|
||||||
|
//Load Data for Edit
|
||||||
|
const data = JSON.stringify((await supabase.from(props.type).select().eq("id", props.id).single()).data)
|
||||||
|
//await useSupabaseSelectSingle(type, route.params.id)
|
||||||
|
item.value = data
|
||||||
|
|
||||||
|
} else if(props.mode === "create") {
|
||||||
|
//Load Data for Create
|
||||||
|
item.value = JSON.stringify({})
|
||||||
|
|
||||||
|
} else if(props.mode === "list") {
|
||||||
|
//Load Data for List
|
||||||
|
items.value = await useSupabaseSelect(props.type, dataType.supabaseSelectWithInformation || "*", dataType.supabaseSortColumn,dataType.supabaseSortAscending || false)
|
||||||
|
}
|
||||||
|
|
||||||
|
loaded.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
setupPage()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<UModal :fullscreen="props.mode === 'show'">
|
||||||
|
<EntityShow
|
||||||
|
v-if="loaded && props.mode === 'show'"
|
||||||
|
:type="props.type"
|
||||||
|
:item="item"
|
||||||
|
@updateNeeded="setupPage"
|
||||||
|
:key="item"
|
||||||
|
:in-modal="true"
|
||||||
|
/>
|
||||||
|
<EntityEdit
|
||||||
|
v-else-if="loaded && (props.mode === 'edit' || props.mode === 'create')"
|
||||||
|
:type="props.type"
|
||||||
|
:item="item"
|
||||||
|
:inModal="true"
|
||||||
|
@return-data="(data) => emit('return-data',data)"
|
||||||
|
:createQuery="props.createQuery"
|
||||||
|
/>
|
||||||
|
<!-- <EntityList
|
||||||
|
v-else-if="loaded && props.mode === 'list'"
|
||||||
|
:type="props.type"
|
||||||
|
:items="items"
|
||||||
|
/>-->
|
||||||
|
<UProgress
|
||||||
|
v-else
|
||||||
|
animation="carousel"
|
||||||
|
class="p-5 mt-10"
|
||||||
|
/>
|
||||||
|
</UModal>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
|
||||||
|
</style>
|
||||||
@@ -3,12 +3,15 @@ import dayjs from "dayjs"
|
|||||||
import Handlebars from "handlebars"
|
import Handlebars from "handlebars"
|
||||||
import { v4 as uuidv4 } from 'uuid';
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
import {useFunctions} from "~/composables/useFunctions.js";
|
import {useFunctions} from "~/composables/useFunctions.js";
|
||||||
|
import StandardEntityModal from "~/components/StandardEntityModal.vue";
|
||||||
|
import EntityModalButtons from "~/components/EntityModalButtons.vue";
|
||||||
|
|
||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
const profileStore = useProfileStore()
|
const profileStore = useProfileStore()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
|
const modal = useModal()
|
||||||
|
|
||||||
|
|
||||||
definePageMeta({
|
definePageMeta({
|
||||||
@@ -326,7 +329,14 @@ const setTaxType = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const setCustomerData = () => {
|
const setCustomerData = async (customerId) => {
|
||||||
|
|
||||||
|
if(customerId){
|
||||||
|
itemInfo.value.customer = customerId
|
||||||
|
}
|
||||||
|
|
||||||
|
customers.value = await useSupabaseSelect("customers")
|
||||||
|
|
||||||
|
|
||||||
let customer = customers.value.find(i => i.id === itemInfo.value.customer)
|
let customer = customers.value.find(i => i.id === itemInfo.value.customer)
|
||||||
console.log(customer)
|
console.log(customer)
|
||||||
@@ -1363,31 +1373,67 @@ const setRowData = (row) => {
|
|||||||
searchable-placeholder="Suche..."
|
searchable-placeholder="Suche..."
|
||||||
v-model="itemInfo.customer"
|
v-model="itemInfo.customer"
|
||||||
@change="setCustomerData"
|
@change="setCustomerData"
|
||||||
class="flex-auto mr-2"
|
class="flex-auto"
|
||||||
>
|
>
|
||||||
<UButton
|
<UButton
|
||||||
:color="itemInfo.customer ? 'primary' : 'rose'"
|
:color="itemInfo.customer ? 'primary' : 'rose'"
|
||||||
variant="outline"
|
variant="outline"
|
||||||
class="w-full"
|
class="w-full"
|
||||||
>
|
>
|
||||||
{{itemInfo.customer ? customers.find(i => i.id === itemInfo.customer).name : "Kein Kunde ausgewählt"}}
|
{{customers.find(i => i.id === itemInfo.customer) ? customers.find(i => i.id === itemInfo.customer).name : "Kein Kunde ausgewählt"}}
|
||||||
|
|
||||||
<UIcon name="i-heroicons-chevron-right-20-solid" class="w-5 h-5 transition-transform text-gray-400 dark:text-gray-500" :class="['transform rotate-90']" />
|
<UIcon name="i-heroicons-chevron-right-20-solid" class="w-5 h-5 transition-transform text-gray-400 dark:text-gray-500" :class="['transform rotate-90']" />
|
||||||
</UButton>
|
</UButton>
|
||||||
</USelectMenu>
|
</USelectMenu>
|
||||||
|
<EntityModalButtons
|
||||||
|
type="customers"
|
||||||
|
:id="itemInfo.customer"
|
||||||
|
@return-data="(data) => setCustomerData(data.id)"
|
||||||
|
/>
|
||||||
|
<!-- <UButton
|
||||||
|
variant="outline"
|
||||||
|
class="w-25 ml-2"
|
||||||
|
v-if="itemInfo.customer"
|
||||||
|
icon="i-heroicons-eye"
|
||||||
|
@click="modal.open(StandardEntityModal, {
|
||||||
|
id: itemInfo.customer,
|
||||||
|
type: 'customers',
|
||||||
|
mode: 'show',
|
||||||
|
})"
|
||||||
|
/>
|
||||||
<UButton
|
<UButton
|
||||||
variant="outline"
|
variant="outline"
|
||||||
class="w-25"
|
class="w-25 ml-2"
|
||||||
v-if="itemInfo.customer"
|
v-if="itemInfo.customer"
|
||||||
icon="i-heroicons-arrow-right-end-on-rectangle"
|
icon="i-heroicons-pencil-solid"
|
||||||
@click="router.push(`/standardEntity/customers/show/${itemInfo.customer}`)"
|
@click="modal.open(StandardEntityModal, {
|
||||||
>Kunde</UButton>
|
id: itemInfo.customer,
|
||||||
|
type: 'customers',
|
||||||
|
mode: 'edit',
|
||||||
|
onReturnData(data) {
|
||||||
|
setCustomerData()
|
||||||
|
}
|
||||||
|
})"
|
||||||
|
/>
|
||||||
|
<UButton
|
||||||
|
variant="outline"
|
||||||
|
class="w-25 ml-2"
|
||||||
|
v-if="!itemInfo.customer"
|
||||||
|
icon="i-heroicons-plus"
|
||||||
|
@click="modal.open(StandardEntityModal, {
|
||||||
|
type: 'customers',
|
||||||
|
mode: 'create',
|
||||||
|
onReturnData(data) {
|
||||||
|
setCustomerData(data.id)
|
||||||
|
}
|
||||||
|
})"
|
||||||
|
/>-->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<UAlert
|
<UAlert
|
||||||
v-if="itemInfo.customer"
|
v-if="customers.find(i => i.id === itemInfo.customer)"
|
||||||
class="mt-2"
|
class="mt-2"
|
||||||
variant="solid"
|
variant="solid"
|
||||||
color="white"
|
color="white"
|
||||||
@@ -1432,12 +1478,18 @@ const setRowData = (row) => {
|
|||||||
{{dataStore.getContactById(itemInfo.contact) ? dataStore.getContactById(itemInfo.contact).fullName : "Kein Kontakt ausgewählt"}}
|
{{dataStore.getContactById(itemInfo.contact) ? dataStore.getContactById(itemInfo.contact).fullName : "Kein Kontakt ausgewählt"}}
|
||||||
</template>
|
</template>
|
||||||
</USelectMenu>
|
</USelectMenu>
|
||||||
<UButton
|
<!-- <UButton
|
||||||
variant="outline"
|
variant="outline"
|
||||||
v-if="itemInfo.contact"
|
v-if="itemInfo.contact"
|
||||||
icon="i-heroicons-arrow-right-end-on-rectangle"
|
icon="i-heroicons-arrow-right-end-on-rectangle"
|
||||||
@click="router.push(`/standardEntity/contacts/show/${itemInfo.contact}`)"
|
@click="router.push(`/standardEntity/contacts/show/${itemInfo.contact}`)"
|
||||||
>Kontakt</UButton>
|
>Kontakt</UButton>-->
|
||||||
|
<EntityModalButtons
|
||||||
|
type="contacts"
|
||||||
|
:id="itemInfo.contact"
|
||||||
|
:create-query="{customerId: itemInfo.customer}"
|
||||||
|
@return-data="(data) => itemInfo.contact = data.id"
|
||||||
|
/>
|
||||||
</InputGroup>
|
</InputGroup>
|
||||||
|
|
||||||
</UFormGroup>
|
</UFormGroup>
|
||||||
@@ -1634,12 +1686,12 @@ const setRowData = (row) => {
|
|||||||
icon="i-heroicons-x-mark"
|
icon="i-heroicons-x-mark"
|
||||||
@click="itemInfo.plant = null"
|
@click="itemInfo.plant = null"
|
||||||
/>
|
/>
|
||||||
<UButton
|
<EntityModalButtons
|
||||||
variant="outline"
|
type="plants"
|
||||||
v-if="itemInfo.plant"
|
:id="itemInfo.plant"
|
||||||
icon="i-heroicons-arrow-right-end-on-rectangle"
|
:create-query="{customer: itemInfo.customer}"
|
||||||
@click="router.push(`/standardEntity/plants/show/${itemInfo.plant}`)"
|
@return-data="(data) => itemInfo.plant = data.id"
|
||||||
>Objekt</UButton>
|
/>
|
||||||
</InputGroup>
|
</InputGroup>
|
||||||
|
|
||||||
</UFormGroup>
|
</UFormGroup>
|
||||||
@@ -1673,12 +1725,12 @@ const setRowData = (row) => {
|
|||||||
icon="i-heroicons-x-mark"
|
icon="i-heroicons-x-mark"
|
||||||
@click="itemInfo.project = null"
|
@click="itemInfo.project = null"
|
||||||
/>
|
/>
|
||||||
<UButton
|
<EntityModalButtons
|
||||||
variant="outline"
|
type="projects"
|
||||||
v-if="itemInfo.project"
|
:id="itemInfo.project"
|
||||||
icon="i-heroicons-arrow-right-end-on-rectangle"
|
:create-query="{customer: itemInfo.customer, plant: itemInfo.plant}"
|
||||||
@click="router.push(`/standardEntity/projects/show/${itemInfo.project}`)"
|
@return-data="(data) => itemInfo.project = data.id"
|
||||||
>Projekt</UButton>
|
/>
|
||||||
</InputGroup>
|
</InputGroup>
|
||||||
|
|
||||||
</UFormGroup>
|
</UFormGroup>
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ export const useDataStore = defineStore('data', () => {
|
|||||||
const profileStore = useProfileStore()
|
const profileStore = useProfileStore()
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
const modal = useModal()
|
||||||
|
|
||||||
const dataTypes = {
|
const dataTypes = {
|
||||||
tasks: {
|
tasks: {
|
||||||
@@ -2417,7 +2418,7 @@ export const useDataStore = defineStore('data', () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function createNewItem (dataType,data){
|
async function createNewItem (dataType,data,noRedirect=false){
|
||||||
if(typeof(data) === 'object') {
|
if(typeof(data) === 'object') {
|
||||||
data = {...data, tenant: profileStore.currentTenant}
|
data = {...data, tenant: profileStore.currentTenant}
|
||||||
} else if(typeof(data) === 'array') {
|
} else if(typeof(data) === 'array') {
|
||||||
@@ -2476,19 +2477,19 @@ export const useDataStore = defineStore('data', () => {
|
|||||||
|
|
||||||
|
|
||||||
toast.add({title: `${dataTypes[dataType].labelSingle} hinzugefügt`})
|
toast.add({title: `${dataTypes[dataType].labelSingle} hinzugefügt`})
|
||||||
if(dataTypes[dataType].redirect) {
|
if(dataTypes[dataType].redirect && !noRedirect) {
|
||||||
if(dataTypes[dataType].isStandardEntity) {
|
if(dataTypes[dataType].isStandardEntity) {
|
||||||
await router.push(dataTypes[dataType].redirectToList ? `/standardEntity/${dataType}` : `/standardEntity/${dataType}/show/${returnData.id}`)
|
await router.push(dataTypes[dataType].redirectToList ? `/standardEntity/${dataType}` : `/standardEntity/${dataType}/show/${returnData.id}`)
|
||||||
} else {
|
} else {
|
||||||
await router.push(dataTypes[dataType].redirectToList ? `/${dataType}` : `/${dataType}/show/${returnData.id}`)
|
await router.push(dataTypes[dataType].redirectToList ? `/${dataType}` : `/${dataType}/show/${returnData.id}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
modal.close()
|
||||||
return supabaseData
|
return supabaseData[0]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function updateItem (dataType, data, oldData = null) {
|
async function updateItem (dataType, data, oldData = null, noRedirect = false) {
|
||||||
//console.log(dataType, data)
|
//console.log(dataType, data)
|
||||||
//Temporary Fix TODO: Remove and build Solution
|
//Temporary Fix TODO: Remove and build Solution
|
||||||
data = JSON.parse(JSON.stringify(data))
|
data = JSON.parse(JSON.stringify(data))
|
||||||
@@ -2536,14 +2537,15 @@ export const useDataStore = defineStore('data', () => {
|
|||||||
//await eval(dataType + '.value[' + dataType + '.value.findIndex(i => i.id === ' + JSON.stringify(data.id) + ')] = ' + JSON.stringify(supabaseData[0]))
|
//await eval(dataType + '.value[' + dataType + '.value.findIndex(i => i.id === ' + JSON.stringify(data.id) + ')] = ' + JSON.stringify(supabaseData[0]))
|
||||||
//if(dataType === 'profiles') await fetchProfiles()
|
//if(dataType === 'profiles') await fetchProfiles()
|
||||||
toast.add({title: `${dataTypes[dataType].labelSingle} gespeichert`})
|
toast.add({title: `${dataTypes[dataType].labelSingle} gespeichert`})
|
||||||
if(dataTypes[dataType].redirect) {
|
if(dataTypes[dataType].redirect && !noRedirect) {
|
||||||
if(dataTypes[dataType].isStandardEntity) {
|
if(dataTypes[dataType].isStandardEntity) {
|
||||||
await router.push(dataTypes[dataType].redirectToList ? `/standardEntity/${dataType}` : `/standardEntity/${dataType}/show/${data.id}`)
|
await router.push(dataTypes[dataType].redirectToList ? `/standardEntity/${dataType}` : `/standardEntity/${dataType}/show/${data.id}`)
|
||||||
} else {
|
} else {
|
||||||
await router.push(dataTypes[dataType].redirectToList ? `/${dataType}` : `/${dataType}/show/${data.id}`)
|
await router.push(dataTypes[dataType].redirectToList ? `/${dataType}` : `/${dataType}/show/${data.id}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return supabaseData
|
modal.close()
|
||||||
|
return supabaseData[0]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user