From a46f2011d424ed17526a329f2d8b20f7efe347c5 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Fri, 26 Apr 2013 12:10:59 +0530 Subject: [PATCH] [form] updated toolbars --- public/css/ui/common.css | 6 +++ public/js/legacy/widgets/form/fields.js | 2 +- public/js/legacy/widgets/form/form.js | 3 +- public/js/wn/form/toolbar.js | 57 ++++++++++++++--------- public/js/wn/model/perm.js | 6 ++- public/js/wn/ui/appframe.js | 62 +++++++++---------------- public/js/wn/ui/toolbar/toolbar.js | 20 ++++---- 7 files changed, 79 insertions(+), 77 deletions(-) diff --git a/public/css/ui/common.css b/public/css/ui/common.css index f7429bf4b5..5ff29597fd 100644 --- a/public/css/ui/common.css +++ b/public/css/ui/common.css @@ -107,6 +107,12 @@ a { font-size: 12px; } +.slick-header * { + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; +} + .slick-headerrow-column { background: #87ceeb; text-overflow: clip; diff --git a/public/js/legacy/widgets/form/fields.js b/public/js/legacy/widgets/form/fields.js index 4f6cac7d3d..1638dcd28f 100644 --- a/public/js/legacy/widgets/form/fields.js +++ b/public/js/legacy/widgets/form/fields.js @@ -364,7 +364,7 @@ function HTMLField() { this.set_input = function(val) { me.set_disp(val); } - this.onrefresh = function() { + this.refresh = function() { if(me.df.options) me.set_disp(me.df.options); } diff --git a/public/js/legacy/widgets/form/form.js b/public/js/legacy/widgets/form/form.js index a0d46db69e..f902317dea 100644 --- a/public/js/legacy/widgets/form/form.js +++ b/public/js/legacy/widgets/form/form.js @@ -316,8 +316,7 @@ _f.Frm.prototype.set_footnote = function(txt) { _f.Frm.prototype.add_custom_button = function(label, fn, icon) { - this.toolbar.make_actions_menu(); - this.appframe.add_dropdown_button("Actions", label, fn, icon); + this.appframe.add_button(label, fn, icon, true); } _f.Frm.prototype.clear_custom_buttons = function() { this.toolbar.refresh() diff --git a/public/js/wn/form/toolbar.js b/public/js/wn/form/toolbar.js index 8dc21e5c40..6a88c9cc8f 100644 --- a/public/js/wn/form/toolbar.js +++ b/public/js/wn/form/toolbar.js @@ -26,44 +26,45 @@ wn.ui.form.Toolbar = Class.extend({ // New if(p[CREATE]) { - this.appframe.add_dropdown_button("File", "New " + me.frm.doctype, function() { + this.appframe.add_dropdown_button("File", wn._("New") + " " + + wn._(me.frm.doctype), function() { new_doc(me.frm.doctype);}, 'icon-plus'); } // Save if(docstatus==0 && p[WRITE] && !this.read_only) { - this.appframe.add_dropdown_button("File", "Save", function() { + this.appframe.add_dropdown_button("File", wn._("Save"), function() { me.frm.save('Save', null, this);}, 'icon-save'); } // Print if(!(me.frm.doc.__islocal || me.frm.meta.allow_print)) { - this.appframe.add_dropdown_button("File", "Print...", function() { + this.appframe.add_dropdown_button("File", wn._("Print..."), function() { me.frm.print_doc();}, 'icon-print'); } // email if(!(me.frm.doc.__islocal || me.frm.meta.allow_email)) { - this.appframe.add_dropdown_button("File", "Email...", function() { + this.appframe.add_dropdown_button("File", wn._("Email..."), function() { me.frm.email_doc();}, 'icon-envelope'); } // copy if(in_list(profile.can_create, me.frm.doctype) && !me.frm.meta.allow_copy) { - this.appframe.add_dropdown_button("File", "Make Copy", function() { + this.appframe.add_dropdown_button("File", wn._("Make Copy"), function() { me.frm.copy_doc();}, 'icon-file'); } // rename if(me.frm.meta.allow_rename && me.frm.perm[0][WRITE]) { - this.appframe.add_dropdown_button("File", "Rename...", function() { + this.appframe.add_dropdown_button("File", wn._("Rename..."), function() { me.frm.rename_doc();}, 'icon-retweet'); } // delete if((cint(me.frm.doc.docstatus) != 1) && !me.frm.doc.__islocal && wn.model.can_delete(me.frm.doctype)) { - this.appframe.add_dropdown_button("File", "Delete", function() { + this.appframe.add_dropdown_button("File", wn._("Delete"), function() { me.frm.savetrash();}, 'icon-remove-sign'); } @@ -72,20 +73,20 @@ wn.ui.form.Toolbar = Class.extend({ var me = this; // Edit if(this.frm.meta.read_only_onload && !this.frm.doc.__islocal) { - this.appframe.add_dropdown_button("View", 'Print View', function() { + this.appframe.add_dropdown_button("View", wn._('Print View'), function() { me.frm.last_view_is_edit[me.frm.docname] = 0; me.frm.refresh(); }, 'icon-print'); } if(this.frm.meta.read_only_onload && !this.frm.doc.__islocal) { - this.appframe.add_dropdown_button("View", 'Edit', function() { + this.appframe.add_dropdown_button("View", wn._('Edit'), function() { me.frm.last_view_is_edit[me.frm.docname] = 1; me.frm.refresh(); }, 'icon-edit'); } // Linked With if(!me.frm.doc.__islocal && !me.frm.meta.issingle) { - this.appframe.add_dropdown_button("View", 'Linked With', function() { + this.appframe.add_dropdown_button("View", wn._('Linked With'), function() { if(!me.frm.linked_with) { me.frm.linked_with = new wn.ui.form.LinkedWith({ frm: me.frm @@ -94,6 +95,20 @@ wn.ui.form.Toolbar = Class.extend({ me.frm.linked_with.show(); }, "icon-link") } + + if(!this.frm.meta.issingle) { + this.appframe.add_menu_divider("View"); + this.appframe.add_dropdown_button("View", + wn._(this.frm.doctype) + ' ' + wn._('List'), function() { + wn.set_route("List", me.frm.doctype); + }, 'icon-list'); + + this.appframe.add_dropdown_button("View", + wn._(this.frm.doctype) + ' ' + wn._('Report View'), function() { + wn.set_route("Report2", me.frm.doctype); + }, 'icon-table'); + } + }, set_title_button: function() { var me = this; @@ -103,20 +118,20 @@ wn.ui.form.Toolbar = Class.extend({ if(!wn.model.get("Workflow", {document_type: me.frm.doctype}).length) { if(docstatus==0 && p[SUBMIT] && (!me.frm.doc.__islocal)) { - this.appframe.add_title_button('Submit', function() { - me.frm.savesubmit(this);}, 'icon-lock'); + this.appframe.add_button('Submit', function() { + me.frm.savesubmit(this);}, 'icon-lock', true).addClass("btn-primary"); } else if(docstatus==0) { - this.appframe.add_title_button('Save', function() { - me.frm.save('Save', null, this);}, 'icon-save'); + this.appframe.add_button('Save', function() { + me.frm.save('Save', null, this);}, 'icon-save', true).addClass("btn-primary"); } else if(docstatus==1 && p[CANCEL]) { - this.appframe.add_title_button('Cancel', function() { + this.appframe.add_dropdown_button("File", 'Cancel', function() { me.frm.savecancel(this) }, 'icon-remove'); } else if(docstatus==2 && p[AMEND]) { - this.appframe.add_title_button('Amend', function() { - me.frm.amend_doc() }, 'icon-pencil'); + this.appframe.add_button('Amend', function() { + me.frm.amend_doc() }, 'icon-pencil', true); } } }, @@ -127,11 +142,11 @@ wn.ui.form.Toolbar = Class.extend({ // show update button if unsaved var docstatus = cint(me.frm.doc.docstatus); - if(docstatus==1 && me.frm.perm[0][SUBMIT]) { - me.appframe.$w.find(".title-button-area").empty(); - me.appframe.add_title_button("Update", function() { + if(docstatus==1 && me.frm.perm[0][SUBMIT] + && !me.appframe.$w.find(".action-update").length) { + me.appframe.add_button("Update", function() { me.frm.save('Update', null, me); - }, 'icon-save') + }, 'icon-save', true).addClass("btn-primary action-update"); } }) }, diff --git a/public/js/wn/model/perm.js b/public/js/wn/model/perm.js index f5631dc016..9241203dbc 100644 --- a/public/js/wn/model/perm.js +++ b/public/js/wn/model/perm.js @@ -173,8 +173,10 @@ $.extend(wn.perm, { if(explain) console.log("By Submit:" + ret) // allow on submit - var allow_on_submit = cint(df.allow_on_submit); - + var allow_on_submit = df.fieldtype!= "Table" ? + cint(df.allow_on_submit) : + 0; + // if(allow_on_submit && doc.parent) { // parent_df = wn.model.get("DocField", { // "parent": doc.parenttype, diff --git a/public/js/wn/ui/appframe.js b/public/js/wn/ui/appframe.js index 2ace611b2a..a1881bf4a1 100644 --- a/public/js/wn/ui/appframe.js +++ b/public/js/wn/ui/appframe.js @@ -17,11 +17,13 @@ wn.ui.AppFrame = Class.extend({ \ \
\ -
\ +
\

\

\
\ + \
\ ').appendTo(this.$w); @@ -29,6 +31,8 @@ wn.ui.AppFrame = Class.extend({ window.history.back(); }) + this.toolbar = this.$w.find(".appframe-toolbar"); + if(title) this.set_title(title); @@ -154,7 +158,6 @@ wn.ui.AppFrame = Class.extend({ }, add_help_button: function(txt) { - this.add_toolbar(); $('') .data('help-text', txt) @@ -163,59 +166,36 @@ wn.ui.AppFrame = Class.extend({ }, clear_buttons: function() { - this.toolbar && this.toolbar.empty(); + this.toolbar && this.toolbar.empty().toggle(false); $(".custom-menu").remove(); }, - add_toolbar: function() { - if(!this.toolbar) { - this.toolbar = $('').appendTo(this.$w.find(".toolbar-area")).find(".nav"); - } - }, - add_button: function(label, click, icon) { - this.add_toolbar(); - args = { label: label, icon:'' }; - if(icon) { - args.icon = ''; - } - this.buttons[label] = $(repl('
  • \ - %(icon)s %(label)s
  • ', args)) - .appendTo(this.toolbar) - .find("a") - .click(click); - return this.buttons[label]; - }, - add_title_button: function(label, click, icon) { + add_button: function(label, click, icon, title_toolbar) { + !title_toolbar && this.toolbar.toggle(true); + args = { label: label, icon:'' }; if(icon) { args.icon = ''; } - this.buttons[label] = $(repl('', args)) - .appendTo(this.$w.find(".title-button-area")) + .appendTo(title_toolbar ? this.$w.find(".title-button-area") : this.toolbar) .click(click); return this.buttons[label]; }, - add_dropdown: function(label) { - this.add_toolbar(); - this.buttons[label] = $('
  • ').appendTo(menu); }, add_dropdown_button: function(parent, label, click, icon) { - var menu = $("#navbar-" + parent.toLowerCase()); + var menu = this.get_menu(parent); if(menu.find("li:not(.custom-menu)").length && !menu.find(".divider").length) { - $('
  • ').appendTo(menu); + this.add_menu_divider(menu); } return $('
  • \ - '+wn._("Actions")+'\ - \ -
  • '); - }, + // make_actions: function() { + // $('.navbar .nav:first').append(''); + // }, make_tools: function() { $('.navbar .nav:first').append('