Added Modals for Adding, Editing, Showing
This commit is contained in:
@@ -51,6 +51,7 @@ export const useDataStore = defineStore('data', () => {
|
||||
const profileStore = useProfileStore()
|
||||
const toast = useToast()
|
||||
const router = useRouter()
|
||||
const modal = useModal()
|
||||
|
||||
const dataTypes = {
|
||||
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') {
|
||||
data = {...data, tenant: profileStore.currentTenant}
|
||||
} else if(typeof(data) === 'array') {
|
||||
@@ -2476,19 +2477,19 @@ export const useDataStore = defineStore('data', () => {
|
||||
|
||||
|
||||
toast.add({title: `${dataTypes[dataType].labelSingle} hinzugefügt`})
|
||||
if(dataTypes[dataType].redirect) {
|
||||
if(dataTypes[dataType].redirect && !noRedirect) {
|
||||
if(dataTypes[dataType].isStandardEntity) {
|
||||
await router.push(dataTypes[dataType].redirectToList ? `/standardEntity/${dataType}` : `/standardEntity/${dataType}/show/${returnData.id}`)
|
||||
} else {
|
||||
await router.push(dataTypes[dataType].redirectToList ? `/${dataType}` : `/${dataType}/show/${returnData.id}`)
|
||||
}
|
||||
}
|
||||
|
||||
return supabaseData
|
||||
modal.close()
|
||||
return supabaseData[0]
|
||||
}
|
||||
}
|
||||
|
||||
async function updateItem (dataType, data, oldData = null) {
|
||||
async function updateItem (dataType, data, oldData = null, noRedirect = false) {
|
||||
//console.log(dataType, data)
|
||||
//Temporary Fix TODO: Remove and build Solution
|
||||
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]))
|
||||
//if(dataType === 'profiles') await fetchProfiles()
|
||||
toast.add({title: `${dataTypes[dataType].labelSingle} gespeichert`})
|
||||
if(dataTypes[dataType].redirect) {
|
||||
if(dataTypes[dataType].redirect && !noRedirect) {
|
||||
if(dataTypes[dataType].isStandardEntity) {
|
||||
await router.push(dataTypes[dataType].redirectToList ? `/standardEntity/${dataType}` : `/standardEntity/${dataType}/show/${data.id}`)
|
||||
} else {
|
||||
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