feat: Add create button visibility control to CrudDataTable and integrate permission checks in project management
This commit is contained in:
parent
ef77c1e6f1
commit
5b030b84c9
@ -24,6 +24,7 @@
|
|||||||
/>
|
/>
|
||||||
<slot name="header-actions">
|
<slot name="header-actions">
|
||||||
<Button
|
<Button
|
||||||
|
v-if="showCreateButton"
|
||||||
:label="createLabel"
|
:label="createLabel"
|
||||||
icon="pi pi-plus"
|
icon="pi pi-plus"
|
||||||
@click="$emit('create')"
|
@click="$emit('create')"
|
||||||
@ -217,6 +218,10 @@ const props = defineProps({
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
},
|
},
|
||||||
|
showCreateButton: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
|
},
|
||||||
showEditButton: {
|
showEditButton: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true
|
default: true
|
||||||
|
|||||||
@ -9,6 +9,7 @@
|
|||||||
data-source="/api/contacts"
|
data-source="/api/contacts"
|
||||||
storage-key="contactTableColumns"
|
storage-key="contactTableColumns"
|
||||||
:show-view-button="canView"
|
:show-view-button="canView"
|
||||||
|
:show-create-button="canCreate"
|
||||||
:show-edit-button="canEdit"
|
:show-edit-button="canEdit"
|
||||||
:show-delete-button="canDelete"
|
:show-delete-button="canDelete"
|
||||||
:show-export-button="canExport"
|
:show-export-button="canExport"
|
||||||
|
|||||||
@ -9,6 +9,7 @@
|
|||||||
data-source="/api/projects"
|
data-source="/api/projects"
|
||||||
storage-key="projectTableColumns"
|
storage-key="projectTableColumns"
|
||||||
:show-view-button="canView"
|
:show-view-button="canView"
|
||||||
|
:show-create-button="canCreate"
|
||||||
:show-edit-button="canEdit"
|
:show-edit-button="canEdit"
|
||||||
:show-delete-button="canDelete"
|
:show-delete-button="canDelete"
|
||||||
:show-export-button="canExport"
|
:show-export-button="canExport"
|
||||||
@ -850,6 +851,7 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref, onMounted, computed } from 'vue'
|
import { ref, onMounted, computed } from 'vue'
|
||||||
import { useToast } from 'primevue/usetoast'
|
import { useToast } from 'primevue/usetoast'
|
||||||
|
import { usePermissionStore } from '../stores/permissions'
|
||||||
import CrudDataTable from '../components/CrudDataTable.vue'
|
import CrudDataTable from '../components/CrudDataTable.vue'
|
||||||
import Dialog from 'primevue/dialog'
|
import Dialog from 'primevue/dialog'
|
||||||
import Button from 'primevue/button'
|
import Button from 'primevue/button'
|
||||||
@ -873,6 +875,7 @@ import GitContributionChart from '../components/GitContributionChart.vue'
|
|||||||
import DocumentUpload from '../components/DocumentUpload.vue'
|
import DocumentUpload from '../components/DocumentUpload.vue'
|
||||||
|
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
|
const permissionStore = usePermissionStore()
|
||||||
const tableRef = ref(null)
|
const tableRef = ref(null)
|
||||||
const projectDialog = ref(false)
|
const projectDialog = ref(false)
|
||||||
const viewDialog = ref(false)
|
const viewDialog = ref(false)
|
||||||
@ -912,11 +915,12 @@ const gitProviders = [
|
|||||||
{ label: 'Lokal', value: 'local' }
|
{ label: 'Lokal', value: 'local' }
|
||||||
]
|
]
|
||||||
|
|
||||||
// Permission checks (will be replaced with actual permission checks)
|
// Permission checks
|
||||||
const canView = computed(() => true)
|
const canView = computed(() => permissionStore.canView('projects'))
|
||||||
const canEdit = computed(() => true)
|
const canCreate = computed(() => permissionStore.canCreate('projects'))
|
||||||
const canDelete = computed(() => true)
|
const canEdit = computed(() => permissionStore.canEdit('projects'))
|
||||||
const canExport = computed(() => true)
|
const canDelete = computed(() => permissionStore.canDelete('projects'))
|
||||||
|
const canExport = computed(() => permissionStore.canExport('projects'))
|
||||||
|
|
||||||
// Column definitions
|
// Column definitions
|
||||||
const projectColumns = ref([
|
const projectColumns = ref([
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user