From 87d501ac7282f9d45dd788baef44aea238d8c10a Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Fri, 8 Aug 2014 16:53:45 +0530 Subject: [PATCH 1/2] [fixes] minor --- frappe/public/js/frappe/form/control.js | 2 +- frappe/public/js/frappe/request.js | 5 +++-- frappe/public/js/frappe/ui/appframe.js | 7 +++++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/frappe/public/js/frappe/form/control.js b/frappe/public/js/frappe/form/control.js index 73b7c0d4fa..99fa0781d4 100644 --- a/frappe/public/js/frappe/form/control.js +++ b/frappe/public/js/frappe/form/control.js @@ -16,7 +16,7 @@ function make_field(docfield, doctype, parent, frm, in_grid, hide_label) { // Fa df: docfield, doctype: doctype, parent: parent, - hide_label: hide_label, + only_input: hide_label, frm: frm }); } diff --git a/frappe/public/js/frappe/request.js b/frappe/public/js/frappe/request.js index efa65fbdcb..87aee102f5 100644 --- a/frappe/public/js/frappe/request.js +++ b/frappe/public/js/frappe/request.js @@ -33,7 +33,8 @@ frappe.call = function(opts) { freeze: opts.freeze, show_spinner: !opts.no_spinner, progress_bar: opts.progress_bar, - async: opts.async + async: opts.async, + url: opts.url || frappe.request.url, }); } @@ -160,7 +161,7 @@ frappe.request.prepare = function(opts) { } // no cmd? - if(!opts.args.cmd) { + if(!opts.args.cmd && !opts.url) { console.log(opts) throw "Incomplete Request"; } diff --git a/frappe/public/js/frappe/ui/appframe.js b/frappe/public/js/frappe/ui/appframe.js index a02983bfc8..a452553fc3 100644 --- a/frappe/public/js/frappe/ui/appframe.js +++ b/frappe/public/js/frappe/ui/appframe.js @@ -337,16 +337,19 @@ frappe.ui.make_app_page = function(opts) { ').appendTo($wrapper); if(opts.single_column) { - $('
').appendTo($wrapper.find(".appframe")); + opts.parent.body = $('
').appendTo($wrapper.find(".appframe")); } else { - $('
\ + opts.parent.layout = $('
\
\
\
').appendTo($wrapper.find(".appframe")); + + opts.parent.body = opts.parent.layout.find(".layout-main-section"); } opts.parent.appframe = new frappe.ui.AppFrame($wrapper); if(opts.set_document_title!==undefined) opts.parent.appframe.set_document_title = opts.set_document_title; if(opts.title) opts.parent.appframe.set_title(opts.title); if(opts.icon) opts.parent.appframe.get_main_icon(opts.icon); + } From 493c426f29cdbec1296f6c2eda7bbd68d123460d Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Fri, 8 Aug 2014 17:07:24 +0530 Subject: [PATCH 2/2] [minor] ignore duplicate filters --- frappe/public/js/frappe/ui/filters.js | 24 +++++++++++++++++--- frappe/public/js/frappe/views/doclistview.js | 6 +++-- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/frappe/public/js/frappe/ui/filters.js b/frappe/public/js/frappe/ui/filters.js index 0fae9df667..5817592227 100644 --- a/frappe/public/js/frappe/ui/filters.js +++ b/frappe/public/js/frappe/ui/filters.js @@ -30,18 +30,36 @@ frappe.ui.FilterList = Class.extend({ }, add_filter: function(tablename, fieldname, condition, value) { - this.push_new_filter(tablename, fieldname, condition, value); this.$w.find('.show_filters').toggle(true); + return this.push_new_filter(tablename, fieldname, condition, value); }, push_new_filter: function(tablename, fieldname, condition, value) { - this.filters.push(new frappe.ui.Filter({ + if(this.filter_exists(tablename, fieldname, condition, value)) return; + + var filter = new frappe.ui.Filter({ flist: this, tablename: tablename, fieldname: fieldname, condition: condition, value: value - })); + }); + + this.filters.push(filter); + + return filter; + }, + + filter_exists: function(tablename, fieldname, condition, value) { + for(var i in this.filters) { + if(this.filters[i].field) { + var f = this.filters[i].get_value(); + if(f[0]==tablename && f[1]==fieldname && f[2]==condition + && f[3]==value) return true; + + } + } + return false; }, get_filters: function() { diff --git a/frappe/public/js/frappe/views/doclistview.js b/frappe/public/js/frappe/views/doclistview.js index a2495aa53a..8a55d84269 100644 --- a/frappe/public/js/frappe/views/doclistview.js +++ b/frappe/public/js/frappe/views/doclistview.js @@ -121,6 +121,7 @@ frappe.views.DocListView = frappe.ui.Listing.extend({ var me = this; this.$page.on("click", ".filterable", function(e) { var filters = $(this).attr("data-filter").split("|"); + var added = false; $.each(filters, function(i, f) { f = f.split(","); if(f[2]==="Today") { @@ -128,9 +129,10 @@ frappe.views.DocListView = frappe.ui.Listing.extend({ } else if(f[2]=="User") { f[2] = user; } - me.filter_list.add_filter(me.doctype, f[0], f[1], f.slice(2).join(",")); + added = added || me.filter_list.add_filter(me.doctype, + f[0], f[1], f.slice(2).join(",")); }); - me.run(); + added && me.run(); }) },