From b98b3ab723f1c327202d411fc369f074219e09a6 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 4 Jun 2013 17:10:27 +0530 Subject: [PATCH] [listview] fix, [ui] show module icon if exists --- core/page/todo/todo.js | 2 +- public/js/wn/ui/appframe.js | 6 ++++-- public/js/wn/ui/listing.js | 25 ++++++++++--------------- public/js/wn/views/doclistview.js | 5 ++--- public/js/wn/views/listview.js | 9 +++++---- 5 files changed, 22 insertions(+), 25 deletions(-) diff --git a/core/page/todo/todo.js b/core/page/todo/todo.js index 638f8d2618..edd443c05f 100644 --- a/core/page/todo/todo.js +++ b/core/page/todo/todo.js @@ -197,7 +197,7 @@ wn.pages.todo.onload = function(wrapper) {
\ '); - wrapper.appframe.add_breadcrumb(wn.modules["To Do"].icon); + wrapper.appframe.add_module_icon("To Do"); wrapper.appframe.add_button('Refresh', erpnext.todo.refresh, 'icon-refresh'); wrapper.appframe.add_button('Add', function() { erpnext.todo.make_dialog({ diff --git a/public/js/wn/ui/appframe.js b/public/js/wn/ui/appframe.js index c9e93a3031..9b15c1f2e6 100644 --- a/public/js/wn/ui/appframe.js +++ b/public/js/wn/ui/appframe.js @@ -16,7 +16,8 @@ wn.ui.AppFrame = Class.extend({
\

\ -

\ + \ + \
\
\ @@ -69,9 +70,10 @@ wn.ui.AppFrame = Class.extend({ add_module_icon: function(module) { var module_info = wn.modules[module]; - if(module_info) { + if(module_info && module_info.icon) { this.$w.find(".title-icon").html(' ') + .toggle(true) .css({ "background-color": module_info.color, }) diff --git a/public/js/wn/ui/listing.js b/public/js/wn/ui/listing.js index 4ef97fd261..283fafe093 100644 --- a/public/js/wn/ui/listing.js +++ b/public/js/wn/ui/listing.js @@ -209,25 +209,20 @@ wn.ui.Listing = Class.extend({ this.$w.find('.no-result').toggle(false); this.start = 0; }, - run: function() { - // in old - arguments: 0 = callback, 1 = append + run: function(more) { var me = this; - var a0 = arguments[0]; var a1 = arguments[1]; - - if(a0 && typeof a0=='function') - this.onrun = a0; - if(a0 && a0.callback) - this.onrun = a0.callback; - if(!a1 && !(a0 && a0.append)) + if(!more) { this.start = 0; - + if(this.onreset) this.onreset(); + } + if(!me.opts.no_loading) me.set_working(true); wn.call({ method: this.opts.method || 'webnotes.widgets.query_builder.runquery', type: "GET", - args: this.get_call_args(a0), + args: this.get_call_args(), callback: function(r) { if(!me.opts.no_loading) me.set_working(false); @@ -240,7 +235,7 @@ wn.ui.Listing = Class.extend({ set_working: function(flag) { this.$w.find('.img-load').toggle(flag); }, - get_call_args: function(opts) { + get_call_args: function() { // load query if(!this.method) { var query = this.get_query ? this.get_query() : this.query; @@ -262,12 +257,12 @@ wn.ui.Listing = Class.extend({ $.extend(args, this.args) if(this.get_args) { - $.extend(args, this.get_args(opts)); + $.extend(args, this.get_args()); } return args; }, render_results: function(r) { - if(this.start==0) this.clear(); + if(this.start===0) this.clear(); this.$w.find('.btn-more').toggle(false); @@ -280,7 +275,7 @@ wn.ui.Listing = Class.extend({ this.render_list(r.values); this.update_paging(r.values); } else { - if(this.start==0) { + if(this.start===0) { this.$w.find('.result').toggle(false); var msg = this.get_no_result_message diff --git a/public/js/wn/views/doclistview.js b/public/js/wn/views/doclistview.js index cefe1e9441..63a8d6d468 100644 --- a/public/js/wn/views/doclistview.js +++ b/public/js/wn/views/doclistview.js @@ -166,7 +166,7 @@ wn.views.DocListView = wn.ui.Listing.extend({ if((auto_run !== false) && (auto_run !== 0)) this.run(); }, - run: function() { + run: function(more) { // set filter from route var route = wn.get_route(); var me = this; @@ -175,8 +175,7 @@ wn.views.DocListView = wn.ui.Listing.extend({ me.set_filter(key, val, true); }); } - this.listview && this.listview.run(); - this._super(arguments[0], arguments[1]); + this._super(more); }, make_no_result: function() { diff --git a/public/js/wn/views/listview.js b/public/js/wn/views/listview.js index ae77b44387..8f53bbba66 100644 --- a/public/js/wn/views/listview.js +++ b/public/js/wn/views/listview.js @@ -22,10 +22,11 @@ wn.views.ListView = Class.extend({ this.set_columns(); if(this.settings.group_by) this.group_by = this.settings.group_by; - }, - run: function() { - if(this.doclistview.start===0) - this.id_list = []; + + var me = this; + this.doclistview.onreset = function() { + me.id_list = []; + } }, set_fields: function() { var me = this;