mirror of
https://github.com/frappe/books.git
synced 2024-12-26 12:28:12 +00:00
ea441c240b
- Add Submit Buttons - Disable inputs in submitted form - Simplify FormLayout template
60 lines
1.5 KiB
Vue
60 lines
1.5 KiB
Vue
<template>
|
|
<div class="frappe-form-actions d-flex justify-content-between align-items-center p-3 border-bottom">
|
|
<h5 class="m-0">{{ title }}</h5>
|
|
<f-button primary v-if="isDirty" @click="$emit('save')">{{ _('Save') }}</f-button>
|
|
<f-button primary v-if="showSubmit" @click="$emit('submit')">{{ _('Submit') }}</f-button>
|
|
<f-button secondary v-if="showRevert" @click="$emit('revert')">{{ _('Revert') }}</f-button>
|
|
</div>
|
|
</template>
|
|
<script>
|
|
import frappe from 'frappejs';
|
|
|
|
export default {
|
|
props: ['doc'],
|
|
data() {
|
|
return {
|
|
isDirty: false,
|
|
showSubmit: false,
|
|
showRevert: false
|
|
}
|
|
},
|
|
created() {
|
|
this.doc.on('change', () => {
|
|
this.isDirty = this.doc._dirty;
|
|
this.updateShowSubmittable();
|
|
});
|
|
this.updateShowSubmittable();
|
|
},
|
|
methods: {
|
|
updateShowSubmittable() {
|
|
this.showSubmit =
|
|
this.meta.isSubmittable
|
|
&& !this.isDirty
|
|
&& !this.doc._notInserted
|
|
&& this.doc.submitted === 0;
|
|
|
|
this.showRevert =
|
|
this.meta.isSubmittable
|
|
&& !this.isDirty
|
|
&& !this.doc._notInserted
|
|
&& this.doc.submitted === 1;
|
|
}
|
|
},
|
|
computed: {
|
|
meta() {
|
|
return frappe.getMeta(this.doc.doctype);
|
|
},
|
|
title() {
|
|
const _ = this._;
|
|
|
|
if (this.doc._notInserted) {
|
|
return _('New {0}', _(this.doc.doctype));
|
|
}
|
|
|
|
const titleField = this.meta.titleField || 'name';
|
|
return this.doc[titleField];
|
|
}
|
|
}
|
|
}
|
|
</script>
|