2
0
mirror of https://github.com/frappe/books.git synced 2025-02-10 16:08:35 +00:00

Enable Save only when form is dirty

This commit is contained in:
Faris Ansari 2018-06-26 16:42:51 +05:30
parent a05858277d
commit 64f166470d
3 changed files with 35 additions and 30 deletions

View File

@ -5,6 +5,7 @@
:doctype="doctype"
:name="name"
:title="formTitle"
:isDirty="isDirty"
@save="save"
/>
<div class="p-3">
@ -37,6 +38,7 @@ export default {
docLoaded: false,
notFound: false,
invalid: false,
isDirty: false,
invalidFields: []
}
},
@ -58,6 +60,9 @@ export default {
if (!this.name) return;
try {
this.doc = await frappe.getDoc(this.doctype, this.name);
this.doc.on('change', () => {
this.isDirty = this.doc._dirty;
});
this.docLoaded = true;
} catch(e) {
this.notFound = true;

View File

@ -1,11 +1,11 @@
<template>
<div class="frappe-form-actions d-flex justify-content-between align-items-center p-3 border-bottom">
<h5 class="m-0">{{ title || name }}</h5>
<button class="btn btn-primary btn-sm" @click="$emit('save')">Save</button>
<f-button primary :disabled="!isDirty" @click="$emit('save')">{{ _('Save') }}</f-button>
</div>
</template>
<script>
export default {
props: ['doctype', 'name', 'title']
props: ['doctype', 'name', 'title', 'isDirty']
}
</script>