From 9035c304921986b741145d0146a47981d4ddda57 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 18 Feb 2015 19:52:56 +0530 Subject: [PATCH] [ui] add_custom_button will show button in inner toolbar --- frappe/__init__.py | 5 +++++ frappe/public/css/form.css | 5 +++++ frappe/public/js/legacy/form.js | 17 ++++++++++------- frappe/public/less/form.less | 7 +++++++ 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/frappe/__init__.py b/frappe/__init__.py index 7d783f40cc..4647ab63b5 100644 --- a/frappe/__init__.py +++ b/frappe/__init__.py @@ -469,6 +469,10 @@ def delete_doc_if_exists(doctype, name): if db.exists(doctype, name): delete_doc(doctype, name) +def reload_doctype(doctype): + """Reload DocType from model (`[module]/[doctype]/[name]/[name].json`) files.""" + reload_doc(db.get_value("DocType", doctype, "module"), "doctype", doctype) + def reload_doc(module, dt=None, dn=None, force=False): """Reload Document from model (`[module]/[doctype]/[name]/[name].json`) files. @@ -477,6 +481,7 @@ def reload_doc(module, dt=None, dn=None, force=False): :param dn: Document name. :param force: Reload even if `modified` timestamp matches. """ + import frappe.modules return frappe.modules.reload_doc(module, dt, dn, force=force) diff --git a/frappe/public/css/form.css b/frappe/public/css/form.css index e69253cecc..31ca5d017f 100644 --- a/frappe/public/css/form.css +++ b/frappe/public/css/form.css @@ -11,6 +11,11 @@ padding: 10px 0px; border-bottom: 1px solid #d1d8dd; } +.form-inner-toolbar { + padding: 10px 15px; + background-color: #fafbfc; + text-align: right; +} .form-clickable-section { border-top: 1px solid #d1d8dd; padding: 10px 15px; diff --git a/frappe/public/js/legacy/form.js b/frappe/public/js/legacy/form.js index ceff84a516..1967047f10 100644 --- a/frappe/public/js/legacy/form.js +++ b/frappe/public/js/legacy/form.js @@ -98,8 +98,6 @@ _f.Frm.prototype.setup = function() { page: this.page }); - this.frm_head = this.toolbar; - // print layout this.setup_print_layout(); @@ -222,8 +220,8 @@ _f.Frm.prototype.onhide = function() { _f.Frm.prototype.setup_std_layout = function() { this.form_wrapper = $('
').appendTo(this.layout_main); - this.body_header = $("
").appendTo(this.form_wrapper); - this.body = $("
").appendTo(this.form_wrapper); + this.inner_toolbar = $('
').appendTo(this.form_wrapper); + this.body = $('
').appendTo(this.form_wrapper); // only tray this.meta.section_style='Simple'; // always simple! @@ -324,10 +322,12 @@ _f.Frm.prototype.refresh_header = function() { frappe.ui.toolbar.recent.add(this.doctype, this.docname, 1); // show / hide buttons - if(this.frm_head) { - this.frm_head.refresh(); + if(this.toolbar) { + this.toolbar.refresh(); } + this.clear_custom_buttons(); + this.show_web_link(); } @@ -748,10 +748,13 @@ _f.Frm.prototype.set_footnote = function(txt) { _f.Frm.prototype.add_custom_button = function(label, fn, icon, toolbar_or_class) { - this.page.add_menu_item(label, fn); + return $('