Allow override of "create" permission for model index

This commit is contained in:
Lance Edgar 2021-09-03 18:29:49 -05:00
parent a0a405f849
commit 720fc6182d
2 changed files with 10 additions and 2 deletions

View file

@ -35,7 +35,7 @@
<slot></slot>
<div v-if="showButtons"
class="buttons">
class="buttons" style="margin-top: 1rem;">
<b-button :type="getSaveButtonType()"
:icon-left="getSaveButtonIcon()"
:disabled="saveDisabled"

View file

@ -8,7 +8,7 @@
</nav>
<div class="buttons"
v-if="allowCreate && hasModelPerm('create')">
v-if="allowCreate && userCanCreate()">
<b-button class="new-object"
type="is-primary"
tag="router-link"
@ -66,6 +66,7 @@ export default {
type: Boolean,
default: true,
},
createPermCheck: Function,
paginated: {
type: Boolean,
default: true,
@ -182,6 +183,13 @@ export default {
return this.getModelSlug()
},
userCanCreate() {
if (this.createPermCheck) {
return this.createPermCheck()
}
return this.hasModelPerm('create')
},
hasModelPerm(perm) {
// do normal check, but first add prefix