diff --git a/frappe/public/js/frappe/form/control.js b/frappe/public/js/frappe/form/control.js index d8d7278a03..87f0afd507 100644 --- a/frappe/public/js/frappe/form/control.js +++ b/frappe/public/js/frappe/form/control.js @@ -39,7 +39,8 @@ frappe.ui.form.Control = Class.extend({ }, toggle: function(show) { - this.$wrapper.toggleClass("hide-control", !!!show); + this.df.hidden = show ? 0 : 1; + this.refresh(); }, // returns "Read", "Write" or "None" diff --git a/frappe/public/js/frappe/form/toolbar.js b/frappe/public/js/frappe/form/toolbar.js index 33d5b5cfa2..63862d1d94 100644 --- a/frappe/public/js/frappe/form/toolbar.js +++ b/frappe/public/js/frappe/form/toolbar.js @@ -20,8 +20,10 @@ frappe.ui.form.Toolbar = Class.extend({ } else { if(this.frm.doc.__islocal) { this.page.hide_menu(); + this.print_icon && this.print_icon.addClass("hide"); } else { this.page.show_menu(); + this.print_icon && this.print_icon.removeClass("hide"); } } }, @@ -154,14 +156,22 @@ frappe.ui.form.Toolbar = Class.extend({ this.frm.linked_with.show(); }, set_primary_action: function(dirty) { - var me = this, - status = null; - if (!dirty) { // don't clear actions menu if dirty this.page.clear_user_actions(); } + status = this.get_action_status(); + if (status) { + if (status !== this.current_status) { + this.set_page_actions(status); + } + } else { + this.page.clear_actions(); + } + }, + get_action_status: function() { + var status = null; if (this.can_submit()) { status = "Submit"; } else if (this.can_save()) { @@ -175,51 +185,48 @@ frappe.ui.form.Toolbar = Class.extend({ } else if (this.can_amend()) { status = "Amend"; } + return status; + }, + set_page_actions: function(status) { + var me = this; + this.page.clear_actions(); - if (status) { - if (status !== this.current_status) { - this.page.clear_actions(); - - var perm_to_check = this.frm.action_perm_type_map[status]; - if(!this.frm.perm[0][perm_to_check]) { - return; - } - - if(status == "Cancel") { - this.page.set_secondary_action(__(status), function() { - me.frm.savecancel(this); - }, "octicon octicon-circle-slash"); - } else { - var click = { - "Save": function() { - me.frm.save('Save', null, this); - }, - "Submit": function() { - me.frm.savesubmit(this); - }, - "Update": function() { - me.frm.save('Update', null, this); - }, - "Amend": function() { - me.frm.amend_doc(); - } - }[status]; - - var icon = { - "Save": "octicon octicon-check", - "Submit": "octicon octicon-lock", - "Update": "octicon octicon-check", - "Amend": "octicon octicon-split" - }[status]; - - this.page.set_primary_action(__(status), click, icon); - } - - this.current_status = status; - } - } else { - this.page.clear_actions(); + var perm_to_check = this.frm.action_perm_type_map[status]; + if(!this.frm.perm[0][perm_to_check]) { + return; } + + if(status == "Cancel") { + this.page.set_secondary_action(__(status), function() { + me.frm.savecancel(this); + }, "octicon octicon-circle-slash"); + } else { + var click = { + "Save": function() { + me.frm.save('Save', null, this); + }, + "Submit": function() { + me.frm.savesubmit(this); + }, + "Update": function() { + me.frm.save('Update', null, this); + }, + "Amend": function() { + me.frm.amend_doc(); + } + }[status]; + + var icon = { + "Save": "octicon octicon-check", + "Submit": "octicon octicon-lock", + "Update": "octicon octicon-check", + "Amend": "octicon octicon-split" + }[status]; + + this.page.set_primary_action(__(status), click, icon); + } + + this.current_status = status; }, make_cancel_amend_button: function() { var me = this; diff --git a/frappe/public/js/frappe/ui/page.js b/frappe/public/js/frappe/ui/page.js index 3c5760cc88..ec6c5f9f44 100644 --- a/frappe/public/js/frappe/ui/page.js +++ b/frappe/public/js/frappe/ui/page.js @@ -168,11 +168,17 @@ frappe.ui.Page = Class.extend({ show_menu: function() { this.menu_btn_group.removeClass("hide"); - this.icon_group.removeClass("hide"); }, hide_menu: function() { this.menu_btn_group.addClass("hide"); + }, + + show_icon_group: function() { + this.icon_group.removeClass("hide"); + }, + + hide_icon_group: function() { this.icon_group.addClass("hide"); }, @@ -268,17 +274,11 @@ frappe.ui.Page = Class.extend({ }, add_help_button: function(txt) { - this.add_icon_btn("2", "icon-question-sign", __("Help"), - function() { msgprint($(this).data('help-text'), 'Help'); }) - .data("help-text", txt); - }, - - add_icon_btn: function(group, icon, label, click) { - return this.iconbar.add_btn(group, icon, label, click); + // }, add_button: function(label, click, icon, is_title) { - return this.add_icon_btn("1", icon, __(label), click); + // }, add_dropdown_button: function(parent, label, click, icon) {