fix: show read only indicator

This commit is contained in:
Shariq Ansari 2022-10-23 20:21:09 +05:30
parent e3a67b1aa1
commit 3f3bf04395
2 changed files with 10 additions and 5 deletions

View file

@ -64,7 +64,7 @@ class FormBuilder {
() => this.store.dirty,
(dirty) => {
if (dirty) {
this.page.set_indicator("Not Saved", "orange");
this.page.set_indicator(__("Not Saved"), "orange");
this.reset_changes_btn.show();
} else {
this.page.clear_indicator();
@ -85,7 +85,10 @@ class FormBuilder {
watch(
() => this.store.read_only,
(value) => this.primary_btn.toggle(!value),
(value) => {
this.primary_btn.toggle(!value);
value && this.page.set_indicator(__("Read Only"), "orange");
},
{ immediate: true }
);
}

View file

@ -53,10 +53,8 @@ export const useStore = defineStore("store", {
doc.doc_type = this.doctype;
let r = await frappe.call({ method: "fetch_to_customize", doc });
this.doc = r.docs[0];
this.read_only = false;
} else {
this.doc = await frappe.db.get_doc("DocType", this.doctype);
this.read_only = !frappe.boot.developer_mode && !this.doc.custom;
}
if (!this.get_docfields.length) {
@ -72,7 +70,11 @@ export const useStore = defineStore("store", {
this.layout = this.get_layout();
this.active_tab = this.layout.tabs[0].df.name;
nextTick(() => (this.dirty = false));
nextTick(() => {
this.dirty = false;
this.read_only =
!this.is_customize_form && !frappe.boot.developer_mode && !this.doc.custom;
});
},
async reset_changes() {
await this.fetch();