diff --git a/frappe/config/setup.py b/frappe/config/setup.py index 873d9d9afc..b057876096 100644 --- a/frappe/config/setup.py +++ b/frappe/config/setup.py @@ -164,7 +164,7 @@ def get_data(): { "type": "doctype", "name": "Print Format", - "description": _("Customized HTML Templates for printing transctions.") + "description": _("Customized HTML Templates for printing transactions.") }, ] }, diff --git a/frappe/public/css/form.css b/frappe/public/css/form.css index 31ca5d017f..acad3f3aa8 100644 --- a/frappe/public/css/form.css +++ b/frappe/public/css/form.css @@ -32,7 +32,10 @@ margin: 0px; padding: 15px; } -.form-section:nth-child(even), +.empty-section { + display: none !important; +} +.shaded-section, .timeline-item:nth-child(even) { background-color: #fafbfc; } @@ -117,6 +120,9 @@ .frappe-control .help-box { margin-top: 3px; } +.hide-control { + display: none !important; +} .shared-user { margin-bottom: 10px; } diff --git a/frappe/public/css/slickgrid.css b/frappe/public/css/slickgrid.css index 9ac5bbcd19..e1d9345782 100644 --- a/frappe/public/css/slickgrid.css +++ b/frappe/public/css/slickgrid.css @@ -41,6 +41,11 @@ border-color: #d1d8dd !important; color: #8d99a6 !important; } +.slick-header-column:hover, +.slick-header-column-active { + background-image: none; + background-color: #d9e7f1; +} .slick-row.odd .slick-cell { background-color: #fafbfc; } diff --git a/frappe/public/js/frappe/form/control.js b/frappe/public/js/frappe/form/control.js index 84b67cd808..db4610fb4a 100644 --- a/frappe/public/js/frappe/form/control.js +++ b/frappe/public/js/frappe/form/control.js @@ -57,7 +57,7 @@ frappe.ui.form.Control = Class.extend({ refresh: function() { this.disp_status = this.get_status(); this.$wrapper - && this.$wrapper.toggle(this.disp_status!="None") + && this.$wrapper.toggleClass("hide-control", this.disp_status=="None") && this.$wrapper.trigger("refresh"); }, get_doc: function() { diff --git a/frappe/public/js/frappe/form/grid.js b/frappe/public/js/frappe/form/grid.js index 0415e86919..bfb34062dc 100644 --- a/frappe/public/js/frappe/form/grid.js +++ b/frappe/public/js/frappe/form/grid.js @@ -524,7 +524,7 @@ frappe.ui.form.GridRow = Class.extend({ $.extend(me.fields_dict[fieldname], fi); } - this.toggle_add_delete_button_display(this.wrapper.find(".panel:first")); + this.toggle_add_delete_button_display(this.wrapper); this.grid.open_grid_row = this; this.frm.script_manager.trigger(this.doc.parentfield + "_on_form_rendered", this); diff --git a/frappe/public/js/frappe/form/layout.js b/frappe/public/js/frappe/form/layout.js index f83a08e968..03495aee4a 100644 --- a/frappe/public/js/frappe/form/layout.js +++ b/frappe/public/js/frappe/form/layout.js @@ -68,6 +68,9 @@ frappe.ui.form.Layout = Class.extend({ // dependent fields this.refresh_dependency(); + + // refresh sections + this.refresh_sections(); }, render: function() { var me = this; @@ -188,14 +191,41 @@ frappe.ui.form.Layout = Class.extend({ wrapper: section }; section.refresh = function() { - if(!this.df) return; - $(this).toggle(this.df.hidden || this.df.hidden_due_to_dependency - ? false : (me.frm ? !!me.frm.get_perm(this.df.permlevel, "read") : true)); + if(!this.df) + return; + + // hide if explictly hidden + var hide = this.df.hidden || this.df.hidden_due_to_dependency; + + // hide if no perm + if(!hide && me.frm && !me.frm.get_perm(this.df.permlevel || 0, "read")) { + hide = true; + } + + $(this).toggleClass("hide-control", !!hide); } this.column = null; section.refresh.call(section); return this.section; }, + refresh_sections: function() { + var cnt = 0; + this.wrapper.find(".form-section:not(.hide-control)").each(function() { + var $this = $(this).removeClass("empty-section") + .removeClass("visible-section") + .removeClass("shaded-section"); + if(!$(this).find(".frappe-control:not(.hide-control)").length) { + // nothing visible, hide the section + $(this).addClass("empty-section"); + } else { + $(this).addClass("visible-section"); + if(cnt % 2) { + $(this).addClass("shaded-section"); + } + cnt ++; + } + }); + }, refresh_section_count: function() { this.wrapper.find(".section-count-label:visible").each(function(i) { $(this).html(i+1); diff --git a/frappe/public/js/frappe/ui/toolbar/awesome_bar.js b/frappe/public/js/frappe/ui/toolbar/awesome_bar.js index 8362cf4cc7..080f5c1ab4 100644 --- a/frappe/public/js/frappe/ui/toolbar/awesome_bar.js +++ b/frappe/public/js/frappe/ui/toolbar/awesome_bar.js @@ -100,9 +100,14 @@ frappe.search.verbs = [ function(txt) { var route = frappe.get_route(); if(route[0]==="List" && txt.indexOf(" in") === -1) { + // search in title field + var meta = frappe.get_meta(frappe.container.page.doclistview.doctype); + var search_field = meta.title_field || "name"; + var options = {}; + options[search_field] = ["like", "%" + txt + "%"]; frappe.search.options.push({ value: __('Find {0} in {1}', [""+txt+"", "" + route[1] + ""]), - route_options: {"name": ["like", "%" + txt + "%"]}, + route_options: options, onclick: function() { frappe.container.page.doclistview.set_route_options(); }, diff --git a/frappe/public/js/legacy/form.js b/frappe/public/js/legacy/form.js index 1fe468b056..2af9d36320 100644 --- a/frappe/public/js/legacy/form.js +++ b/frappe/public/js/legacy/form.js @@ -214,10 +214,6 @@ _f.Frm.prototype.watch_model_updates = function() { }); } -_f.Frm.prototype.onhide = function() { - if(_f.cur_grid_cell) _f.cur_grid_cell.grid.cell_deselect(); -} - _f.Frm.prototype.setup_std_layout = function() { this.form_wrapper = $('
').appendTo(this.layout_main); this.inner_toolbar = $('').appendTo(this.form_wrapper); @@ -306,11 +302,6 @@ _f.Frm.prototype.setup_meta = function(doctype) { if(this.meta.istable) { this.meta.in_dialog = 1 } } -_f.Frm.prototype.defocus_rest = function() { - // deselect others - if(_f.cur_grid_cell) _f.cur_grid_cell.grid.cell_deselect(); -} - _f.Frm.prototype.refresh_header = function() { // set title // main title @@ -493,6 +484,7 @@ _f.Frm.prototype.setnewdoc = function() { // this.check_doctype_conflict(docname); var me = this; + // hide any open grid this.script_manager.trigger("before_load", this.doctype, this.docname, function() { me.script_manager.trigger("onload"); me.opendocs[me.docname] = true; @@ -562,6 +554,9 @@ _f.Frm.prototype.save = function(save_action, callback, btn, on_error) { btn && $(btn).prop("disabled", true); $(document.activeElement).blur(); + var open_form = frappe.ui.form.get_open_grid_form(); + open_form && open_form.hide_form(); + // let any pending js process finish var me = this; setTimeout(function() { me._save(save_action, callback, btn, on_error) }, 100); diff --git a/frappe/public/less/form.less b/frappe/public/less/form.less index 45e4ddce56..0ca2347fe3 100644 --- a/frappe/public/less/form.less +++ b/frappe/public/less/form.less @@ -43,7 +43,11 @@ padding: 15px; } -.form-section:nth-child(even), .timeline-item:nth-child(even) { +.empty-section { + display: none !important; +} + +.shaded-section, .timeline-item:nth-child(even) { background-color: @light-bg; } @@ -123,7 +127,6 @@ font-weight: bold; } - .control-label, .grid-heading-row { color: @text-muted; font-size: 85%; @@ -152,6 +155,10 @@ } } +.hide-control { + display: none !important; +} + .shared-user { margin-bottom: 10px; } diff --git a/frappe/public/less/slickgrid.less b/frappe/public/less/slickgrid.less index bfb0f3c8ab..33e359ce5d 100644 --- a/frappe/public/less/slickgrid.less +++ b/frappe/public/less/slickgrid.less @@ -46,6 +46,10 @@ border-color: @border-color !important; color: @text-muted !important; } +.slick-header-column:hover, .slick-header-column-active { + background-image: none; + background-color: darken(@panel-bg, 8%); +} .slick-row.odd .slick-cell { background-color: @light-bg;