Misc. tweaks for model-crud, customer-field

This commit is contained in:
Lance Edgar 2022-08-11 00:17:34 -05:00
parent 4189bdf919
commit 2a1f5764a1
2 changed files with 26 additions and 15 deletions

View file

@ -4,6 +4,7 @@
<byjove-autocomplete v-if="!readonly && !useDropdown"
v-model="customerUUID"
ref="autocomplete"
:service-url="autocompleteUrl"
@input="customerChanged">
</byjove-autocomplete>
@ -148,6 +149,13 @@ export default {
this.$emit('input', value)
},
setCustomer(customer) {
this.$refs.autocomplete.selectionMade({
value: customer.uuid,
label: customer._str,
})
},
},
}

View file

@ -37,6 +37,7 @@
<div v-if="showButtons"
class="buttons" style="margin-top: 1rem;">
<b-button :type="getSaveButtonType()"
v-if="!hideSaveButton"
:icon-left="getSaveButtonIcon()"
:disabled="saveDisabled"
@click="save()">
@ -158,6 +159,10 @@ export default {
type: Boolean,
default: false,
},
createRowPermission: {
type: String,
default: null,
},
createRowButtonText: {
type: String,
default: "Create New Row",
@ -214,6 +219,10 @@ export default {
type: Boolean,
default: false,
},
hideSaveButton: {
type: Boolean,
default: false,
},
saveDisabled: {
type: Boolean,
default: false,
@ -427,23 +436,11 @@ export default {
return this.getModelSlug()
},
// TODO: should use this.$hasPerm()
hasPerm(perm) {
// if user is root then assume permission
if (this.$store.state.user && this.$store.state.user.is_root) {
return true
}
// otherwise do true perm check for user
return this.$store.state.permissions.includes(perm)
},
hasModelPerm(perm) {
// do normal check, but first add prefix
let prefix = this.getModelPermissionPrefix()
return this.hasPerm(prefix + '.' + perm)
return this.$byjoveHasPerm(prefix + '.' + perm)
},
renderLabel(obj) {
@ -665,9 +662,15 @@ export default {
if (this.mode != 'viewing') {
return false
}
if (this.createRowPermission) {
if (!this.$byjoveHasPerm(this.createRowPermission)) {
return false
}
} else {
if (!this.hasModelPerm('create_row')) {
return false
}
}
return true
},