Add way to hide save/cancel buttons for model-crud

This commit is contained in:
Lance Edgar 2019-11-12 17:51:10 -06:00
parent 0c247866c4
commit a6555b7bae

View file

@ -36,7 +36,7 @@
Edit This Edit This
</b-button> </b-button>
<div v-if="mode == 'creating' || mode == 'editing'" <div v-if="showButtons"
class="buttons"> class="buttons">
<b-button type="is-primary" <b-button type="is-primary"
:disabled="saveDisabled" :disabled="saveDisabled"
@ -131,6 +131,10 @@ export default {
type: Boolean, type: Boolean,
default: true, default: true,
}, },
hideButtons: {
type: Boolean,
default: false,
},
saveDisabled: { saveDisabled: {
type: Boolean, type: Boolean,
default: false, default: false,
@ -144,6 +148,21 @@ export default {
} }
}, },
computed: {
showButtons: function() {
if (this.hideButtons) {
return false
}
if (this.mode == 'creating') {
return true
}
if (this.mode == 'editing') {
return true
}
return false
},
},
// TODO: why doesn't beforeRouteUpdate() work instead? // TODO: why doesn't beforeRouteUpdate() work instead?
// cf. https://router.vuejs.org/guide/essentials/dynamic-matching.html#reacting-to-params-changes // cf. https://router.vuejs.org/guide/essentials/dynamic-matching.html#reacting-to-params-changes
watch: { watch: {