Przeglądaj źródła

listing fixes

version-14
Rushabh Mehta 13 lat temu
rodzic
commit
70e5d11fc9
6 zmienionych plików z 20 dodań i 14 usunięć
  1. +5
    -4
      js/core.min.js
  2. +10
    -5
      js/wn/ui/listing.js
  3. +1
    -2
      py/webnotes/__init__.py
  4. +1
    -1
      py/webnotes/boot.py
  5. +2
    -2
      py/webnotes/db.py
  6. +1
    -0
      py/webnotes/widgets/doclistview.py

+ 5
- 4
js/core.min.js Wyświetl plik

@@ -125,7 +125,7 @@ this.prepare_opts();$.extend(this,this.opts);$(this.parent).html(repl('\
</div>\
</div>\
\
<div style="height: 37px; margin-bottom:9px" class="list-toolbar-wrapper">\
<div style="margin-bottom:9px" class="list-toolbar-wrapper">\
<div class="list-toolbar" style="display:inline-block; margin-right: 10px;">\
</div>\
<div style="display:inline-block; width: 24px; margin-left: 4px">\
@@ -152,14 +152,15 @@ if(icon){$('<i>').addClass(icon).appendTo($button);}
$button.html(label).click(click);return $button}},show_view:function($btn,$div,$btn_unsel,$div_unsel){$btn_unsel.removeClass('btn-info');$btn_unsel.find('i').removeClass('icon-white');$div_unsel.toggle(false);$btn.addClass('btn-info');$btn.find('i').addClass('icon-white');$div.toggle(true);},set_events:function(){var me=this;this.$w.find('.btn-more').click(function(){me.run({append:true});});if(this.title){this.$w.find('h3').html(this.title).toggle(true);}
if(!(this.hide_refresh||this.no_refresh)){this.add_button('Refresh',function(){me.run();},'icon-refresh');}
if(this.new_doctype){this.add_button('New '+this.new_doctype,function(){newdoc(me.new_doctype)},'icon-plus');}
if(me.show_filters){this.add_button('Show Filters',function(){me.filter_list.show_filters();},'icon-search').addClass('btn-filter');}},make_filters:function(){this.filter_list=new wn.ui.FilterList({listobj:this,$parent:this.$w.find('.list-filters').toggle(true),doctype:this.doctype,filter_fields:this.filter_fields});},clear:function(){this.data=[];this.$w.find('.result-list').empty();this.$w.find('.result').toggle(true);this.$w.find('.no-result').toggle(false);this.start=0;},run:function(){var me=this;var a0=arguments[0];var a1=arguments[1];if(a0&&typeof a0=='function')
if(me.show_filters){this.add_button('Show Filters',function(){me.filter_list.show_filters();},'icon-search').addClass('btn-filter');}
if(me.no_toolbar||me.hide_toolbar){me.$w.find('.list-toolbar-wrapper').toggle(false);}},make_filters:function(){this.filter_list=new wn.ui.FilterList({listobj:this,$parent:this.$w.find('.list-filters').toggle(true),doctype:this.doctype,filter_fields:this.filter_fields});},clear:function(){this.data=[];this.$w.find('.result-list').empty();this.$w.find('.result').toggle(true);this.$w.find('.no-result').toggle(false);this.start=0;},run:function(){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))
this.start=0;me.set_working(true);wn.call({method:this.opts.method||'webnotes.widgets.query_builder.runquery',args:this.get_call_args(),callback:function(r){me.set_working(false);me.render_results(r)},no_spinner:this.opts.no_loading});},set_working:function(flag){this.$w.find('.img-load').toggle(flag);},get_call_args:function(){if(!this.method){this.query=this.get_query?this.get_query():this.query;this.add_limits();var args={query_max:this.query_max,as_dict:1}
this.start=0;me.set_working(true);wn.call({method:this.opts.method||'webnotes.widgets.query_builder.runquery',args:this.get_call_args(a0),callback:function(r){me.set_working(false);me.render_results(r)},no_spinner:this.opts.no_loading});},set_working:function(flag){this.$w.find('.img-load').toggle(flag);},get_call_args:function(opts){if(!this.method){this.query=this.get_query?this.get_query():this.query;this.add_limits();var args={query_max:this.query_max,as_dict:1}
args.simple_query=this.query;}else{var args={limit_start:this.start,limit_page_length:this.page_length}}
if(this.args)
$.extend(args,this.args)
if(this.get_args){$.extend(args,this.get_args());}
if(this.get_args){$.extend(args,this.get_args(opts));}
return args;},render_results:function(r){if(this.start==0)this.clear();this.$w.find('.btn-more').toggle(false);if(r.message)r.values=r.message;if(r.values&&r.values.length){this.data=this.data.concat(r.values);this.render_list(r.values);}else{if(this.start==0){this.$w.find('.result').toggle(false);this.$w.find('.no-result').toggle(true);}}
if(this.onrun)this.onrun();if(this.callback)this.callback(r);},render_list:function(values){var m=Math.min(values.length,this.page_length);for(var i=0;i<m;i++){this.render_row(this.add_row(),values[i],this,i);}
this.start+=m;if(values.length>=this.page_length)


+ 10
- 5
js/wn/ui/listing.js Wyświetl plik

@@ -43,6 +43,7 @@

// page_length (20)
// hide_refresh (False)
// no_toolbar
// new_doctype
// [function] render_row(parent, data)
// [function] onrun
@@ -92,7 +93,7 @@ wn.ui.Listing = Class.extend({
</div>\
</div>\
\
<div style="height: 37px; margin-bottom:9px" class="list-toolbar-wrapper">\
<div style="margin-bottom:9px" class="list-toolbar-wrapper">\
<div class="list-toolbar" style="display:inline-block; margin-right: 10px;">\
</div>\
<div style="display:inline-block; width: 24px; margin-left: 4px">\
@@ -180,6 +181,10 @@ wn.ui.Listing = Class.extend({
me.filter_list.show_filters();
}, 'icon-search').addClass('btn-filter');
}
if(me.no_toolbar || me.hide_toolbar) {
me.$w.find('.list-toolbar-wrapper').toggle(false);
}
},

make_filters: function() {
@@ -208,12 +213,12 @@ wn.ui.Listing = Class.extend({
if(a0 && a0.callback)
this.onrun = a0.callback;
if(!a1 && !(a0 && a0.append))
this.start = 0;
this.start = 0;

me.set_working(true);
wn.call({
method: this.opts.method || 'webnotes.widgets.query_builder.runquery',
args: this.get_call_args(),
args: this.get_call_args(a0),
callback: function(r) {
me.set_working(false);
me.render_results(r)
@@ -224,7 +229,7 @@ wn.ui.Listing = Class.extend({
set_working: function(flag) {
this.$w.find('.img-load').toggle(flag);
},
get_call_args: function() {
get_call_args: function(opts) {
// load query
if(!this.method) {
this.query = this.get_query ? this.get_query() : this.query;
@@ -246,7 +251,7 @@ wn.ui.Listing = Class.extend({
$.extend(args, this.args)
if(this.get_args) {
$.extend(args, this.get_args());
$.extend(args, this.get_args(opts));
}
return args;
},


+ 1
- 2
py/webnotes/__init__.py Wyświetl plik

@@ -145,8 +145,7 @@ def remove_file(path):
except OSError, e:
if e.args[0]!=2:
raise e


def connect(db_name=None):
"""
Connect to this db (or db), if called from command prompt


+ 1
- 1
py/webnotes/boot.py Wyświetl plik

@@ -64,7 +64,7 @@ def get_bootinfo():
# plugins
try:
import startup.event_handlers
if getattr(startup.event_handlers, 'boot_session'):
if getattr(startup.event_handlers, 'boot_session', None):
startup.event_handlers.boot_session(bootinfo)

except ImportError:


+ 2
- 2
py/webnotes/db.py Wyświetl plik

@@ -35,7 +35,7 @@ class Database:
"""
def __init__(self, host=None, user=None, password=None, ac_name=None, use_default = 0):
self.host = host or 'localhost'
self.user = user or getattr(conf, 'default_db_name', '')
self.user = user or conf.db_name

if ac_name:
self.user = self.get_db_login(ac_name) or conf.db_name
@@ -50,7 +50,7 @@ class Database:
self.auto_commit_on_many_writes = 0

self.password = password or webnotes.get_db_password(self.user)
self.connect()
if self.user != 'root':
self.use(self.user)


+ 1
- 0
py/webnotes/widgets/doclistview.py Wyświetl plik

@@ -36,6 +36,7 @@ def get(arg=None):
data = webnotes.form_dict
filters = json.loads(data['filters'])
fields = json.loads(data['fields'])
tables = ['`tab' + data['doctype'] + '`']
docstatus = json.loads(data['docstatus'])
if docstatus:


Ładowanie…
Anuluj
Zapisz