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