diff --git a/components/EntityList.vue b/components/EntityList.vue
index f2050be..b5ba3c7 100644
--- a/components/EntityList.vue
+++ b/components/EntityList.vue
@@ -71,12 +71,26 @@ const filteredRows = computed(() => {
if(selectedFilters.value.length > 0) {
selectedFilters.value.forEach(filterName => {
let filter = dataType.filters.find(i => i.name === filterName)
-
tempItems = tempItems.filter(filter.filterFunction)
-
})
}
+ if(!useRole().generalAvailableRights.value[type].showToAllUsers) {
+ if(useRole().checkRight(`${type}-viewAll`)){
+ console.log("Right to Show All")
+ } else if(useRole().checkRight(type)){
+ console.log("Only Righty to show Own")
+ console.log(tempItems)
+ tempItems = tempItems.filter(item => item.profiles.includes(dataStore.activeProfile.id))
+ } else {
+ console.log("No Right to Show")
+ tempItems = []
+ }
+ }
+
+
+
+
return useSearch(searchString.value, tempItems)
})
@@ -139,7 +153,7 @@ const filteredRows = computed(() => {
:columns="columns"
class="w-full"
:ui="{ divide: 'divide-gray-200 dark:divide-gray-800' }"
- @select="(i) => router.push(`/projects/show/${i.id}`) "
+ @select="(i) => router.push(`/${type}/show/${i.id}`) "
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: `Keine ${dataType.label} anzuzeigen` }"
>
@@ -175,29 +189,6 @@ const filteredRows = computed(() => {
{{row[column.key]}}
-
-
-
-
-
diff --git a/components/MainNav.vue b/components/MainNav.vue
index 4863277..8a4c3c3 100644
--- a/components/MainNav.vue
+++ b/components/MainNav.vue
@@ -73,21 +73,21 @@ const links = computed(() => {
defaultOpen: false,
icon: "i-heroicons-user-group",
children: [
- {
+ ... role.checkRight("customers") ? [{
label: "Kunden",
to: "/customers",
icon: "i-heroicons-user-group"
- },
- {
+ }] : [],
+ ... role.checkRight("vendors") ? [{
label: "Lieferanten",
to: "/vendors",
icon: "i-heroicons-truck"
- },
- {
+ }] : [],
+ ... role.checkRight("contacts") ? [{
label: "Ansprechpartner",
to: "/contacts",
icon: "i-heroicons-user-group"
- },
+ }] : [],
]
},] : [],
{
@@ -95,7 +95,7 @@ const links = computed(() => {
defaultOpen:false,
icon: "i-heroicons-user-group",
children: [
- ... dataStore.ownTenant.features.timeTracking ? [{
+ ... dataStore.ownTenant.features.timeTracking ? [{
label: "Zeiterfassung",
to: "/employees/timetracking",
icon: "i-heroicons-clock"
@@ -137,7 +137,7 @@ const links = computed(() => {
},
]
},] : [],
- ... dataStore.ownTenant.features.inventory ? [{
+ ... role.checkRight("inventory") ? [{
label: "Lager",
icon: "i-heroicons-puzzle-piece",
defaultOpen: false,
@@ -151,28 +151,28 @@ const links = computed(() => {
to: "/inventory/stocks",
icon: "i-heroicons-square-3-stack-3d"
},
- {
+ ... role.checkRight("spaces") ? [{
label: "Lagerplätze",
to: "/spaces",
icon: "i-heroicons-square-3-stack-3d"
- },
- {
+ }] : [],
+ ... role.checkRight("inventoryitems") ? [{
label: "Inventar",
to: "/inventoryitems",
icon: "i-heroicons-puzzle-piece"
- },
+ }] : [],
]
},] : [],
- ... dataStore.ownTenant.features.vehicles ? [{
+ ... role.checkRight("vehicles") ? [{
label: "Fuhrpark",
defaultOpen: false,
icon: "i-heroicons-truck",
children: [
- {
+ ... role.checkRight("vehicles") ? [{
label: "Fahrzeuge",
to: "/vehicles",
icon: "i-heroicons-truck"
- },{
+ }] : [],{
label: "Fahrten",
to: "/trackingTrips",
icon: "i-heroicons-map"
@@ -184,23 +184,26 @@ const links = computed(() => {
defaultOpen: false,
icon: "i-heroicons-clipboard-document",
children: [
- {
+ ... role.checkRight("products") ? [{
label: "Artikel",
to: "/products",
icon: "i-heroicons-puzzle-piece"
- },{
+ }] : [],
+ ... role.checkRight("productcategories") ? [{
label: "Artikelkategorien",
to: "/productcategories",
icon: "i-heroicons-puzzle-piece"
- },{
+ }] : [],
+ ... role.checkRight("services") ? [{
label: "Leistungen",
to: "/services",
icon: "i-heroicons-puzzle-piece"
- },{
+ }] : [],
+ ... role.checkRight("servicecategories") ? [{
label: "Leistungskategorien",
to: "/servicecategories",
icon: "i-heroicons-puzzle-piece"
- },
+ }] : [],
]
},
... role.checkRight("checks") ? [{
@@ -208,17 +211,17 @@ const links = computed(() => {
to: "/checks",
icon: "i-heroicons-magnifying-glass"
},] : [],
- ... (role.checkRight("projects") && dataStore.ownTenant.features.projects) ? [{
+ ... role.checkRight("projects") ? [{
label: "Projekte",
to: "/projects",
icon: "i-heroicons-clipboard-document-check"
},] : [],
- ... (role.checkRight("contracts") && dataStore.ownTenant.features.contracts) ? [{
+ ... role.checkRight("contracts") ? [{
label: "Verträge",
to: "/contracts",
icon: "i-heroicons-clipboard-document"
}] : [],
- ... (role.checkRight("plants") && dataStore.ownTenant.features.objects) ? [{
+ ... role.checkRight("plants") ? [{
label: "Objekte",
to: "/plants",
icon: "i-heroicons-clipboard-document"
@@ -237,6 +240,10 @@ const links = computed(() => {
label: "Mitarbeiter",
to: "/profiles",
icon: "i-heroicons-clipboard-document-list"
+ },{
+ label: "Rollen",
+ to: "/roles",
+ icon: "i-heroicons-clipboard-document-list"
},{
label: "E-Mail Konten",
to: "/settings/emailAccounts",
diff --git a/composables/useRole.js b/composables/useRole.js
index 8b67f72..e30a876 100644
--- a/composables/useRole.js
+++ b/composables/useRole.js
@@ -4,63 +4,186 @@
export const useRole = () => {
- const supabase = useSupabaseClient()
const dataStore = useDataStore()
- const rights = ref({
+ const generalAvailableRights = ref({
projects: {
- label: "Projekte"
+ label: "Projekte",
+ showToAllUsers: false
},
"projects-viewAll": {
label: "Alle Projekte einsehen",
parent: "projects"
},
- "projects-viewOwn": {
- label: "Eigene Projekte einsehen",
- parent: "projects"
- },
"projects-create": {
label: "Projekte erstellen",
parent: "projects"
},
contracts: {
- label: "Verträge"
+ label: "Verträge",
+ showToAllUsers: false
},
- objects: {
- label: "Objekte"
+ "contracts-viewAll": {
+ label: "Alle Verträge einsehen",
+ parent: "contracts"
+ },
+ "contracts-create": {
+ label: "Verträge erstellen",
+ parent: "contracts"
+ },
+ plants: {
+ label: "Objekte",
+ showToAllUsers: false
+ },
+ "plants-viewAll": {
+ label: "Alle Objekte einsehen",
+ parent: "plants"
+ },
+ "plants-create": {
+ label: "Objekte erstellen",
+ parent: "plants"
+ },
+ products: {
+ label: "Artikel",
+ showToAllUsers: true
+ },
+ "products-create": {
+ label: "Artikel erstellen",
+ parent: "products"
+ },
+ productcategories: {
+ label: "Artikelkategorie",
+ showToAllUsers: true
+ },
+ "productcategories-create": {
+ label: "Artikelkategorie erstellen",
+ parent: "productcategories"
+ },
+ services: {
+ label: "Leistungen",
+ showToAllUsers: true
+ },
+ "services-create": {
+ label: "Leistungen erstellen",
+ parent: "services"
+ },
+ servicecategories: {
+ label: "Leistungskategorien",
+ showToAllUsers: true
+ },
+ "servicecategories-create": {
+ label: "Leistungskategorien erstellen",
+ parent: "servicecategories"
+ },
+ customers: {
+ label: "Kunden",
+ showToAllUsers: false
+ },
+ "customers-viewAll": {
+ label: "Alle Kunden einsehen",
+ parent: "customers"
+ },
+ "customers-create": {
+ label: "Kunden erstellen",
+ parent: "customers"
+ },
+ contacts: {
+ label: "Kontakte",
+ showToAllUsers: false
+ },
+ "contacts-viewAll": {
+ label: "Alle Kontakte einsehen",
+ parent: "contacts"
+ },
+ "contacts-create": {
+ label: "Kontakte erstellen",
+ parent: "contacts"
+ },
+ vendors: {
+ label: "Lieferanten",
+ showToAllUsers: false
+ },
+ "vendors-viewAll": {
+ label: "Alle Lieferanten einsehen",
+ parent: "vendors"
+ },
+ "vendors-create": {
+ label: "Lieferanten erstellen",
+ parent: "vendors"
},
checks: {
- label: "Überprüfungen"
+ label: "Überprüfungen",
+ showToAllUsers: false
+ },
+ "checks-viewAll": {
+ label: "Alle Überprüfungen einsehen",
+ parent: "checks"
+ },
+ "checks-create": {
+ label: "Überprüfungen erstellen",
+ parent: "checks"
+ },
+ vehicles: {
+ label: "Fahrzeuge",
+ showToAllUsers: false
+ },
+ "vehicles-viewAll": {
+ label: "Alle Fahrzeuge einsehen",
+ parent: "vehicles"
+ },
+ "vehicles-create": {
+ label: "Fahrzeuge erstellen",
+ parent: "vehicles"
+ },
+ inventoryitems: {
+ label: "Inventarartikel",
+ showToAllUsers: false
+ },
+ "inventoryitems-viewAll": {
+ label: "Alle Inventarartikel einsehen",
+ parent: "inventoryitems"
+ },
+ "inventoryitems-create": {
+ label: "Inventarartikel erstellen",
+ parent: "inventoryitems"
+ },
+ spaces: {
+ label: "Lagerplätze",
+ showToAllUsers: false
+ },
+ "spaces-viewAll": {
+ label: "Alle Lagerplätze einsehen",
+ parent: "spaces"
+ },
+ "spaces-create": {
+ label: "Lagerplätze erstellen",
+ parent: "spaces"
+ },
+ roles: {
+ label: "Rollen",
+ showToAllUsers: false
+ },
+ "roles-viewAll": {
+ label: "Alle Rollen einsehen",
+ parent: "roles"
+ },
+ "roles-create": {
+ label: "Rollen erstellen",
+ parent: "roles"
+ },
+ "inventory": {
+ label: "Lager",
},
})
let role = dataStore.activeProfile.role
- /*const checkRight = (right) => {
- let rightsToCheck = [right]
-
- if(rights.value[right].parent) {
- rightsToCheck.push(rights.value[right].parent)
- }
-
- let hasAllNeccessaryRights = false
-
- rightsToCheck.forEach(i => {
- if(role.rights.includes(i)){
- hasAllNeccessaryRights = true
- } else {
- hasAllNeccessaryRights = false
- }
- })
-
- return hasAllNeccessaryRights
- }*/
-
const checkRight = (right) => {
let rightsToCheck = [right]
+
//console.log(right.split("-"))
if(right.split("-").length > 1) {
@@ -78,13 +201,12 @@ export const useRole = () => {
}
})
- //console.log(hasAllNeccessaryRights)
-
return hasAllNeccessaryRights
}
return {
role,
+ generalAvailableRights,
checkRight
}
diff --git a/pages/contacts/index.vue b/pages/contacts/index.vue
index 917e553..a1cf1aa 100644
--- a/pages/contacts/index.vue
+++ b/pages/contacts/index.vue
@@ -3,67 +3,6 @@
type="contacts"
:items="items"
>
-
-
\ No newline at end of file
diff --git a/pages/roles/index.vue b/pages/roles/index.vue
new file mode 100644
index 0000000..36a1d43
--- /dev/null
+++ b/pages/roles/index.vue
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pages/vendors/index.vue b/pages/vendors/index.vue
index 6069dc9..2b7943c 100644
--- a/pages/vendors/index.vue
+++ b/pages/vendors/index.vue
@@ -3,64 +3,6 @@
:items="items"
type="vendors"
/>
-
-
-
-