Fixed auth, NAV, projecttypes,numberranges,tenant,textemplates
This commit is contained in:
@@ -289,19 +289,14 @@ const links = computed(() => {
|
|||||||
icon: "i-heroicons-cog-8-tooth",
|
icon: "i-heroicons-cog-8-tooth",
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
label: "Abrechnung",
|
|
||||||
to: "https://billing.stripe.com/p/login/cN29Eb32Vdx0gOk288",
|
|
||||||
icon: "i-heroicons-document-currency-euro",
|
|
||||||
target: "_blank"
|
|
||||||
},{
|
|
||||||
label: "Nummernkreise",
|
label: "Nummernkreise",
|
||||||
to: "/settings/numberRanges",
|
to: "/settings/numberRanges",
|
||||||
icon: "i-heroicons-clipboard-document-list"
|
icon: "i-heroicons-clipboard-document-list"
|
||||||
},{
|
},/*{
|
||||||
label: "Rollen",
|
label: "Rollen",
|
||||||
to: "/roles",
|
to: "/roles",
|
||||||
icon: "i-heroicons-key"
|
icon: "i-heroicons-key"
|
||||||
},{
|
},*/{
|
||||||
label: "E-Mail Konten",
|
label: "E-Mail Konten",
|
||||||
to: "/settings/emailAccounts",
|
to: "/settings/emailAccounts",
|
||||||
icon: "i-heroicons-envelope",
|
icon: "i-heroicons-envelope",
|
||||||
|
|||||||
@@ -21,8 +21,6 @@ defineShortcuts({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const openTab = ref(0)
|
const openTab = ref(0)
|
||||||
const dataStore = useDataStore()
|
|
||||||
const supabase = useSupabaseClient()
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
@@ -53,9 +51,9 @@ const setKeys = () => {
|
|||||||
const setupPage = async() => {
|
const setupPage = async() => {
|
||||||
|
|
||||||
if(mode.value === "show" ){
|
if(mode.value === "show" ){
|
||||||
itemInfo.value = await useSupabaseSelectSingle("projecttypes",route.params.id,"*")
|
itemInfo.value = await useEntities("projecttypes").selectSingle(route.params.id,"*")
|
||||||
} else if (mode.value === "edit") {
|
} else if (mode.value === "edit") {
|
||||||
itemInfo.value = await useSupabaseSelectSingle("projecttypes",route.params.id,"*")
|
itemInfo.value = await useEntities("projecttypes").selectSingle(route.params.id,"*")
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mode.value === "create") {
|
if(mode.value === "create") {
|
||||||
@@ -99,13 +97,13 @@ const addPhase = () => {
|
|||||||
<template #right>
|
<template #right>
|
||||||
<UButton
|
<UButton
|
||||||
v-if="mode === 'edit'"
|
v-if="mode === 'edit'"
|
||||||
@click="dataStore.updateItem('projecttypes',itemInfo,oldItemInfo)"
|
@click="useEntities('projecttypes').update(itemInfo.id, itemInfo)"
|
||||||
>
|
>
|
||||||
Speichern
|
Speichern
|
||||||
</UButton>
|
</UButton>
|
||||||
<UButton
|
<UButton
|
||||||
v-else-if="mode === 'create'"
|
v-else-if="mode === 'create'"
|
||||||
@click="dataStore.createNewItem('projecttypes', itemInfo)"
|
@click="useEntities('projecttypes').create( itemInfo)"
|
||||||
>
|
>
|
||||||
Erstellen
|
Erstellen
|
||||||
</UButton>
|
</UButton>
|
||||||
|
|||||||
@@ -34,14 +34,14 @@ defineShortcuts({
|
|||||||
|
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
const tempStore = useTempStore()
|
||||||
|
|
||||||
const items = ref([])
|
const items = ref([])
|
||||||
const selectedItem = ref(0)
|
const selectedItem = ref(0)
|
||||||
|
|
||||||
|
|
||||||
const setup = async () => {
|
const setup = async () => {
|
||||||
items.value = await useSupabaseSelect("projecttypes","*")
|
items.value = await useEntities("projecttypes").select()
|
||||||
}
|
}
|
||||||
|
|
||||||
setup()
|
setup()
|
||||||
@@ -56,7 +56,7 @@ const templateColumns = [
|
|||||||
const selectedColumns = ref(templateColumns)
|
const selectedColumns = ref(templateColumns)
|
||||||
const columns = computed(() => templateColumns.filter((column) => selectedColumns.value.includes(column)))
|
const columns = computed(() => templateColumns.filter((column) => selectedColumns.value.includes(column)))
|
||||||
|
|
||||||
const searchString = ref("")
|
const searchString = ref(tempStore.searchStrings["projecttypes"] || '')
|
||||||
|
|
||||||
const filteredRows = computed(() => {
|
const filteredRows = computed(() => {
|
||||||
return useListFilter(searchString.value, items.value)
|
return useListFilter(searchString.value, items.value)
|
||||||
@@ -75,6 +75,7 @@ const filteredRows = computed(() => {
|
|||||||
placeholder="Suche..."
|
placeholder="Suche..."
|
||||||
class="hidden lg:block"
|
class="hidden lg:block"
|
||||||
@keydown.esc="$event.target.blur()"
|
@keydown.esc="$event.target.blur()"
|
||||||
|
@change="tempStore.modifySearchString('projecttypes',searchString)"
|
||||||
>
|
>
|
||||||
<template #trailing>
|
<template #trailing>
|
||||||
<UKbd value="/"/>
|
<UKbd value="/"/>
|
||||||
|
|||||||
@@ -1,11 +1,5 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
|
const auth = useAuthStore()
|
||||||
|
|
||||||
const supabase = useSupabaseClient()
|
|
||||||
const dataStore = useDataStore()
|
|
||||||
const profileStore = useProfileStore()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const resources = {
|
const resources = {
|
||||||
customers: {
|
customers: {
|
||||||
@@ -43,16 +37,19 @@ const resources = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const numberRanges = ref(profileStore.ownTenant.numberRanges)
|
const numberRanges = ref(auth.activeTenantData.numberRanges)
|
||||||
|
|
||||||
const updateNumberRanges = async (range) => {
|
const updateNumberRanges = async (range) => {
|
||||||
|
|
||||||
const {data,error} = await supabase
|
const res = await useNuxtApp().$api(`/api/tenant/numberrange/${range}`,{
|
||||||
.from("tenants")
|
method: "PUT",
|
||||||
.update({numberRanges: numberRanges.value})
|
body: {
|
||||||
.eq('id',profileStore.currentTenant)
|
numberRange: numberRanges.value[range]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
console.log(res)
|
||||||
|
|
||||||
await profileStore.fetchOwnTenant()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -89,13 +86,13 @@ const updateNumberRanges = async (range) => {
|
|||||||
<td>
|
<td>
|
||||||
<UInput
|
<UInput
|
||||||
v-model="numberRanges[key].prefix"
|
v-model="numberRanges[key].prefix"
|
||||||
@change="updateNumberRanges"
|
@change="updateNumberRanges(key)"
|
||||||
/>
|
/>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<UInput
|
<UInput
|
||||||
v-model="numberRanges[key].nextNumber"
|
v-model="numberRanges[key].nextNumber"
|
||||||
@change="updateNumberRanges"
|
@change="updateNumberRanges(key)"
|
||||||
type="number"
|
type="number"
|
||||||
step="1"
|
step="1"
|
||||||
/>
|
/>
|
||||||
@@ -103,7 +100,7 @@ const updateNumberRanges = async (range) => {
|
|||||||
<td>
|
<td>
|
||||||
<UInput
|
<UInput
|
||||||
v-model="numberRanges[key].suffix"
|
v-model="numberRanges[key].suffix"
|
||||||
@change="updateNumberRanges"
|
@change="updateNumberRanges(key)"
|
||||||
/>
|
/>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
|
|
||||||
const dataStore = useDataStore()
|
const auth = useAuthStore()
|
||||||
const profileStore = useProfileStore()
|
|
||||||
const supabase = useSupabaseClient()
|
|
||||||
|
|
||||||
const itemInfo = ref({
|
const itemInfo = ref({
|
||||||
features: {},
|
features: {},
|
||||||
@@ -11,20 +9,21 @@ const itemInfo = ref({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const setupPage = async () => {
|
const setupPage = async () => {
|
||||||
itemInfo.value = (await supabase.from("tenants").select().eq("id",profileStore.currentTenant).single()).data
|
itemInfo.value = auth.activeTenantData
|
||||||
console.log(itemInfo.value)
|
console.log(itemInfo.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
const features = ref(profileStore.ownTenant.features)
|
const features = ref(auth.activeTenantData.features)
|
||||||
const businessInfo = ref(profileStore.ownTenant.businessInfo)
|
const businessInfo = ref(auth.activeTenantData.businessInfo)
|
||||||
|
|
||||||
const updateTenant = async (newData) => {
|
const updateTenant = async (newData) => {
|
||||||
const {data,error} = await supabase.from("tenants")
|
|
||||||
.update(newData)
|
|
||||||
.eq("id",profileStore.currentTenant)
|
|
||||||
.select()
|
|
||||||
|
|
||||||
if (error) console.log(error)
|
const res = await useNuxtApp().$api(`/api/tenant/other/${auth.activeTenant}`, {
|
||||||
|
method: "PUT",
|
||||||
|
body: {
|
||||||
|
data: newData,
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
setupPage()
|
setupPage()
|
||||||
|
|||||||
@@ -10,9 +10,11 @@
|
|||||||
const editTemplateModalOpen = ref(false)
|
const editTemplateModalOpen = ref(false)
|
||||||
const itemInfo = ref({})
|
const itemInfo = ref({})
|
||||||
const texttemplates = ref([])
|
const texttemplates = ref([])
|
||||||
|
const loading = ref(true)
|
||||||
|
|
||||||
const setup = async () => {
|
const setup = async () => {
|
||||||
texttemplates.value = (await useSupabaseSelect("texttemplates")).filter(i => !i.archived)
|
texttemplates.value = (await useEntities("texttemplates").select()).filter(i => !i.archived)
|
||||||
|
loading.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
setup()
|
setup()
|
||||||
@@ -78,7 +80,9 @@
|
|||||||
<UTable
|
<UTable
|
||||||
class="mt-3"
|
class="mt-3"
|
||||||
:rows="texttemplates"
|
:rows="texttemplates"
|
||||||
v-model:expand="expand"
|
:loading-state="{ icon: 'i-heroicons-arrow-path-20-solid', label: 'Loading...' }"
|
||||||
|
:loading="loading"
|
||||||
|
v-model:expand="expand" :empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Keine Textvorlagen anzuzeigen' }"
|
||||||
:columns="[{key:'name',label:'Name'},{key:'documentType',label:'Dokumententyp'},{key:'default',label:'Standard'},{key:'pos',label:'Position'}]"
|
:columns="[{key:'name',label:'Name'},{key:'documentType',label:'Dokumententyp'},{key:'default',label:'Standard'},{key:'pos',label:'Position'}]"
|
||||||
>
|
>
|
||||||
<template #documentType-data="{row}">
|
<template #documentType-data="{row}">
|
||||||
@@ -191,7 +195,7 @@
|
|||||||
</UFormGroup>
|
</UFormGroup>
|
||||||
</UForm>
|
</UForm>
|
||||||
|
|
||||||
|
<!-- TODO: Update und Create -->
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<UButton
|
<UButton
|
||||||
@click="dataStore.createNewItem('texttemplates',itemInfo);
|
@click="dataStore.createNewItem('texttemplates',itemInfo);
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { defineStore } from "pinia"
|
import { defineStore } from "pinia"
|
||||||
|
import router from "#app/plugins/router";
|
||||||
|
|
||||||
export const useAuthStore = defineStore("auth", {
|
export const useAuthStore = defineStore("auth", {
|
||||||
state: () => ({
|
state: () => ({
|
||||||
@@ -7,6 +8,7 @@ export const useAuthStore = defineStore("auth", {
|
|||||||
tenants: [] as { tenant_id: string; role: string; tenants: { id: string; name: string } }[],
|
tenants: [] as { tenant_id: string; role: string; tenants: { id: string; name: string } }[],
|
||||||
permissions: [] as string[],
|
permissions: [] as string[],
|
||||||
activeTenant: null as any,
|
activeTenant: null as any,
|
||||||
|
activeTenantData: null as any,
|
||||||
loading: true as boolean,
|
loading: true as boolean,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -51,10 +53,17 @@ export const useAuthStore = defineStore("auth", {
|
|||||||
this.user = me.user
|
this.user = me.user
|
||||||
this.permissions = me.permissions
|
this.permissions = me.permissions
|
||||||
this.tenants = me.tenants
|
this.tenants = me.tenants
|
||||||
|
|
||||||
|
this.tenants.sort(function (a, b) {
|
||||||
|
if (a.id < b.id) return -1
|
||||||
|
if (a.id > b.id) return 1
|
||||||
|
})
|
||||||
|
|
||||||
this.profile = me.profile
|
this.profile = me.profile
|
||||||
|
|
||||||
if(me.activeTenant) {
|
if(me.activeTenant) {
|
||||||
this.activeTenant = me.activeTenant
|
this.activeTenant = me.activeTenant
|
||||||
|
this.activeTenantData = me.tenants.find(i => i.id === me.activeTenant)
|
||||||
this.loading = false
|
this.loading = false
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -75,6 +84,7 @@ export const useAuthStore = defineStore("auth", {
|
|||||||
})
|
})
|
||||||
useCookie("token").value = token
|
useCookie("token").value = token
|
||||||
await this.init(token)
|
await this.init(token)
|
||||||
|
navigateTo("/")
|
||||||
},
|
},
|
||||||
|
|
||||||
hasPermission(key: string) {
|
hasPermission(key: string) {
|
||||||
|
|||||||
Reference in New Issue
Block a user