From a83f391c674016fb52f87bd8906818dcb67470d2 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Fri, 24 May 2013 16:00:55 +0530 Subject: [PATCH] [form/list] ui fixes, [note] new table to merge question + answer --- public/js/legacy/widgets/form/form.js | 3 +- public/js/legacy/widgets/form/print_format.js | 22 +++++++---- public/js/wn/form/editors.js | 16 ++------ public/js/wn/form/grid.js | 2 +- public/js/wn/misc/user.js | 4 ++ public/js/wn/ui/button.js | 2 +- public/js/wn/views/listview.js | 37 ++++++++++++++----- public/js/wn/views/sidebar_stats.js | 2 +- webnotes/widgets/form/load.py | 2 +- 9 files changed, 55 insertions(+), 35 deletions(-) diff --git a/public/js/legacy/widgets/form/form.js b/public/js/legacy/widgets/form/form.js index abe8a178ba..b8a70b2168 100644 --- a/public/js/legacy/widgets/form/form.js +++ b/public/js/legacy/widgets/form/form.js @@ -174,7 +174,6 @@ _f.Frm.prototype.setup_print_layout = function() { this.print_body = $(this.print_wrapper).find(".print-format-area").get(0); } - _f.Frm.prototype.onhide = function() { if(_f.cur_grid_cell) _f.cur_grid_cell.grid.cell_deselect(); } @@ -333,7 +332,7 @@ _f.Frm.prototype.refresh_print_layout = function() { } // create print format here - _p.build(this.$print_view_select.val(), print_callback, null, 1); + _p.build(this.$print_view_select.val(), print_callback, false, true, true); } diff --git a/public/js/legacy/widgets/form/print_format.js b/public/js/legacy/widgets/form/print_format.js index b218d3ae00..96f58f0c15 100644 --- a/public/js/legacy/widgets/form/print_format.js +++ b/public/js/legacy/widgets/form/print_format.js @@ -130,7 +130,7 @@ $.extend(_p, { + no_letterhead + only_body */ - build: function(fmtname, onload, no_letterhead, only_body) { + build: function(fmtname, onload, no_letterhead, only_body, no_heading) { if(!fmtname) { fmtname= "Standard"; } @@ -151,11 +151,12 @@ $.extend(_p, { var doc = locals[cur_frm.doctype][cur_frm.docname]; if(args.fmtname == 'Standard') { args.onload(_p.render({ - body: _p.print_std(args.no_letterhead), + body: _p.print_std(args.no_letterhead, no_heading), style: _p.print_style, doc: doc, title: doc.name, no_letterhead: args.no_letterhead, + no_heading: no_heading, only_body: args.only_body })); } else { @@ -170,6 +171,7 @@ $.extend(_p, { doc: doc, title: doc.name, no_letterhead: args.no_letterhead, + no_heading: no_heading, only_body: args.only_body })); } @@ -179,10 +181,12 @@ $.extend(_p, { var container = document.createElement('div'); var stat = ''; - // if draft/archived, show draft/archived banner - stat += _p.show_draft(args); - stat += _p.show_archived(args); - stat += _p.show_cancelled(args); + if(!args.no_heading) { + // if draft/archived, show draft/archived banner + stat += _p.show_draft(args); + stat += _p.show_archived(args); + stat += _p.show_cancelled(args); + } // Append args.body's content as a child of container container.innerHTML = args.body; @@ -433,7 +437,7 @@ $.extend(_p, { margin: 8px 0px; \ }", - print_std: function(no_letterhead) { + print_std: function(no_letterhead, no_heading) { // Get doctype, docname, layout for a doctype var docname = cur_frm.docname; var doctype = cur_frm.doctype; @@ -597,7 +601,9 @@ $.extend(_p, { } }); - this.build_head(data, doctype, docname); + if(!no_heading) { + this.build_head(data, doctype, docname); + } this.build_data(data, doctype, docname); diff --git a/public/js/wn/form/editors.js b/public/js/wn/form/editors.js index 0209670139..94751f7e53 100644 --- a/public/js/wn/form/editors.js +++ b/public/js/wn/form/editors.js @@ -76,7 +76,7 @@ wn.editors.BootstrapWYSIWYG = Class.extend({ \ \ \ - ').appendTo(this.opts.parent); +
').appendTo(this.opts.parent); this.$parent = $(this.opts.parent); this.$editor = $("#" + this.myid); this.$parent.find(".btn-add-link").click(function() { @@ -131,17 +131,6 @@ wn.editors.BootstrapWYSIWYG = Class.extend({ fontName + '')); }); - //this.$parent.find('a[title]').tooltip({container:'body'}); - - this.$parent.find('.dropdown-menu input').click(function() {return false;}) - .change(function () { - $(this).parent('.dropdown-menu').siblings('.dropdown-toggle') - .dropdown('toggle'); - }) - .keydown('esc', function () { - this.value='';$(this).change(); - }); - // magic-overlay this.$parent.find('[data-role=magic-overlay]').each(function () { var overlay = $(this), target = $(overlay.data('target')); @@ -188,6 +177,9 @@ wn.editors.BootstrapWYSIWYG = Class.extend({ }, set_input: function(value) { + if(this.opts.field.inside_change_event) + return; + if(this.value!=value) { this.value = value==null ? "" : value; this.$editor.html(this.value); diff --git a/public/js/wn/form/grid.js b/public/js/wn/form/grid.js index 39bfeb362b..0ece5f440d 100644 --- a/public/js/wn/form/grid.js +++ b/public/js/wn/form/grid.js @@ -155,7 +155,7 @@ wn.ui.form.GridRow = Class.extend({ title="'+wn._("Close")+'"\ style="margin-left: 7px;">\ \ - \ diff --git a/public/js/wn/misc/user.js b/public/js/wn/misc/user.js index 1815116066..28792dce2f 100644 --- a/public/js/wn/misc/user.js +++ b/public/js/wn/misc/user.js @@ -92,6 +92,10 @@ $.extend(wn.user, { if(wn.boot.allowed_pages.indexOf(wn.modules[m].link)!=-1) ret = m; break; + case "list": + if(wn.model.can_read(wn.modules[m].doctype)) + ret = m; + break; case "view": ret = m; break; diff --git a/public/js/wn/ui/button.js b/public/js/wn/ui/button.js index 91e24971cb..6fb7f480cd 100644 --- a/public/js/wn/ui/button.js +++ b/public/js/wn/ui/button.js @@ -24,7 +24,7 @@ wn.ui.Button = function(args) { var me = this; $.extend(this, { make: function() { - me.btn = wn.dom.add(args.parent, 'button', 'btn ' + (args.css_class || '')); + me.btn = wn.dom.add(args.parent, 'button', 'btn ' + (args.css_class || 'btn-default')); me.btn.args = args; // ajax loading diff --git a/public/js/wn/views/listview.js b/public/js/wn/views/listview.js index d6a0fff9ab..0755683931 100644 --- a/public/js/wn/views/listview.js +++ b/public/js/wn/views/listview.js @@ -78,6 +78,7 @@ wn.views.ListView = Class.extend({ if(wn.model.is_submittable(this.doctype)) { this.columns.push({colspan: 0.5, content:'docstatus'}); } + this.columns.push({colspan: 2, content:'name'}); if(this.workflow_state_fieldname) { @@ -104,7 +105,9 @@ wn.views.ListView = Class.extend({ colspan = "1"; } else if(d.fieldtype=="Check" || d.fieldname=="file_list") { colspan = "1"; - } else if(d.fieldname=="subject") { // subjects are longer + } else if(d.fieldname=="subject" || d.fieldname=="title") { // subjects are longer + colspan = "3"; + } else if(d.fieldtype=="Text Editor" || d.fieldtype=="Text") { colspan = "3"; } me.columns.push({colspan: colspan, content: d.fieldname, @@ -118,9 +121,13 @@ wn.views.ListView = Class.extend({ }); } - this.columns.push({colspan: 2, content:'modified', - css: {'text-align': 'right', 'color':'#222'}}); - + // expand "name" if there are few columns + var total_colspan = 0; + $.each(this.columns, function(i, c) { total_colspan += c.colspan }); + if(total_colspan < 8) { + $.each(this.columns, + function(i, c) { if(c.content==="name") { c.colspan = 4; return false; } }); + } }, render: function(row, data) { @@ -129,7 +136,7 @@ wn.views.ListView = Class.extend({ .appendTo(row).css({"padding": "5px 0px", "padding-bottom": "0px", "margin-bottom": "5px", - "border-bottom": "1px solid #f2f2f2" + "border-bottom": "1px solid #eee" }), colspans = 0, me = this; @@ -151,18 +158,30 @@ wn.views.ListView = Class.extend({ } }); + // row #2 + var row2 = $('').appendTo(body); + + // modified + row2.find(".col-lg-3").html(comment_when(data.modified)); + // add tags - var tag_col = $('
').appendTo(body); var tag_editor = new wn.ui.TagEditor({ - parent: tag_col, + parent: row2.find(".list-tag"), doctype: this.doctype, docname: data.name, user_tags: data._user_tags }); - tag_editor.$w.addClass("hidden-sm").on("click", ".tagit-label", function() { + tag_editor.$w.on("click", ".tagit-label", function() { me.doclistview.set_filter("_user_tags", $(this).text()); - }) + }); }, make_column: function(body, colspan, is_small) { colspan = colspan==0.5 ? "50" : colspan; diff --git a/public/js/wn/views/sidebar_stats.js b/public/js/wn/views/sidebar_stats.js index 6e5bb59a9d..3d2f51f6b7 100644 --- a/public/js/wn/views/sidebar_stats.js +++ b/public/js/wn/views/sidebar_stats.js @@ -12,7 +12,7 @@ wn.provide('wn.views'); wn.views.SidebarStats = Class.extend({ init: function(opts) { $.extend(this, opts); - this.wrapper = $("
").appendTo(this.parent); + this.wrapper = $("
").css({"padding-bottom": "15px"}).appendTo(this.parent); this.get_stats(); }, get_stats: function() { diff --git a/webnotes/widgets/form/load.py b/webnotes/widgets/form/load.py index 548d86f1fe..5857ba5973 100644 --- a/webnotes/widgets/form/load.py +++ b/webnotes/widgets/form/load.py @@ -85,7 +85,7 @@ def load_single_doc(dt, dn, user): except Exception, e: webnotes.errprint(webnotes.utils.getTraceback()) - webnotes.msgprint('Error in script while loading') + webnotes.msgprint('Did not load.') raise e if dl and not dn.startswith('_'):