2018-06-27 14:38:27 +00:00
|
|
|
<template>
|
|
|
|
<div class="frappe-form-actions d-flex justify-content-between align-items-center p-3 border-bottom">
|
2018-07-10 13:35:43 +00:00
|
|
|
<h5 class="m-0">{{ title }}</h5>
|
2018-07-14 14:58:18 +00:00
|
|
|
<div class="d-flex">
|
|
|
|
<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>
|
|
|
|
<dropdown v-if="links.length" :label="'Next Action'" :options="links"></dropdown>
|
|
|
|
</div>
|
2018-06-27 14:38:27 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script>
|
2018-07-10 13:35:43 +00:00
|
|
|
import frappe from 'frappejs';
|
2018-07-14 14:58:18 +00:00
|
|
|
import Dropdown from '../Dropdown';
|
2018-07-10 13:35:43 +00:00
|
|
|
|
2018-06-27 14:38:27 +00:00
|
|
|
export default {
|
2018-07-14 14:58:18 +00:00
|
|
|
props: ['doc', 'links'],
|
|
|
|
components: {
|
|
|
|
Dropdown
|
|
|
|
},
|
2018-07-10 13:35:43 +00:00
|
|
|
data() {
|
|
|
|
return {
|
2018-07-12 07:47:56 +00:00
|
|
|
isDirty: false,
|
|
|
|
showSubmit: false,
|
|
|
|
showRevert: false
|
2018-07-10 13:35:43 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.doc.on('change', () => {
|
|
|
|
this.isDirty = this.doc._dirty;
|
2018-07-12 07:47:56 +00:00
|
|
|
this.updateShowSubmittable();
|
2018-07-10 13:35:43 +00:00
|
|
|
});
|
2018-07-12 07:47:56 +00:00
|
|
|
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;
|
|
|
|
}
|
2018-07-10 13:35:43 +00:00
|
|
|
},
|
|
|
|
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];
|
|
|
|
}
|
|
|
|
}
|
2018-06-27 14:38:27 +00:00
|
|
|
}
|
|
|
|
</script>
|