Browse Source

[fix] in form header refresh, if doc is switched, reset this.current_status, so that correct primary/secondary buttons are rendered

version-14
Anand Doshi 10 years ago
parent
commit
b37a08d413
1 changed files with 12 additions and 6 deletions
  1. +12
    -6
      frappe/public/js/legacy/form.js

+ 12
- 6
frappe/public/js/legacy/form.js View File

@@ -298,7 +298,7 @@ _f.Frm.prototype.setup_meta = function(doctype) {
if(this.meta.istable) { this.meta.in_dialog = 1 } if(this.meta.istable) { this.meta.in_dialog = 1 }
} }


_f.Frm.prototype.refresh_header = function() {
_f.Frm.prototype.refresh_header = function(is_a_different_doc) {
// set title // set title
// main title // main title
if(!this.meta.in_dialog || this.in_form) { if(!this.meta.in_dialog || this.in_form) {
@@ -310,6 +310,10 @@ _f.Frm.prototype.refresh_header = function() {


// show / hide buttons // show / hide buttons
if(this.toolbar) { if(this.toolbar) {
if (is_a_different_doc) {
this.toolbar.current_status = undefined;
}

this.toolbar.refresh(); this.toolbar.refresh();
} }


@@ -341,8 +345,10 @@ _f.Frm.prototype.check_doc_perm = function() {
} }


_f.Frm.prototype.refresh = function(docname) { _f.Frm.prototype.refresh = function(docname) {
// record switch
var is_a_different_doc = docname ? true : false;

if(docname) { if(docname) {
// record switch
if(this.docname != docname && (!this.meta.in_dialog || this.in_form) && if(this.docname != docname && (!this.meta.in_dialog || this.in_form) &&
!this.meta.istable) { !this.meta.istable) {
scroll(0, 0); scroll(0, 0);
@@ -388,7 +394,7 @@ _f.Frm.prototype.refresh = function(docname) {
cur_frm.cscript.is_onload = true; cur_frm.cscript.is_onload = true;
this.setnewdoc(); this.setnewdoc();
} else { } else {
this.render_form();
this.render_form(is_a_different_doc);
} }


// if print format is shown, refresh the format // if print format is shown, refresh the format
@@ -398,7 +404,7 @@ _f.Frm.prototype.refresh = function(docname) {
} }
} }


_f.Frm.prototype.render_form = function() {
_f.Frm.prototype.render_form = function(is_a_different_doc) {
if(!this.meta.istable) { if(!this.meta.istable) {
this.layout.doc = this.doc; this.layout.doc = this.doc;
this.layout.attach_doc_and_docfields() this.layout.attach_doc_and_docfields()
@@ -410,7 +416,7 @@ _f.Frm.prototype.render_form = function() {


// header must be refreshed before client methods // header must be refreshed before client methods
// because add_custom_button // because add_custom_button
this.refresh_header();
this.refresh_header(is_a_different_doc);


// call trigger // call trigger
this.script_manager.trigger("refresh"); this.script_manager.trigger("refresh");
@@ -438,7 +444,7 @@ _f.Frm.prototype.render_form = function() {
} }


} else { } else {
this.refresh_header();
this.refresh_header(is_a_different_doc);
} }


$(cur_frm.wrapper).trigger('render_complete'); $(cur_frm.wrapper).trigger('render_complete');


Loading…
Cancel
Save