listing/messages fix

This commit is contained in:
Rushabh Mehta 2012-03-22 13:44:10 +05:30
parent 5a297fac64
commit c17aeee6e1
5 changed files with 24 additions and 23 deletions

View file

@ -8,7 +8,6 @@
.wnlist .img-load {
display: none;
float: left;
margin-left: 11px;
margin-top: 8px;
}

14
js/core.min.js vendored
View file

@ -133,9 +133,9 @@ this.prepare_opts();$.extend(this,this.opts);$(this.parent).html(repl('\
<i class="icon-plus"></i> New</a>\
<a class="btn btn-small btn-filter">\
<i class="icon-search"></i> Filter</a>\
<img src="lib/images/ui/button-load.gif" \
class="img-load"/>\
</div>\
<img src="lib/images/ui/button-load.gif" \
class="img-load" style="float: left;"/>\
</div><div style="clear:both"></div>\
\
<div class="no-result help hide">\
@ -151,7 +151,7 @@ this.prepare_opts();$.extend(this,this.opts);$(this.parent).html(repl('\
<button class="btn btn-small btn-more hide">More...</div>\
</div>\
</div>\
',this.opts));this.$w=$(this.parent).find('.wnlist');this.set_events();this.make_filters();},add_button:function(html,onclick,before){$(html).click(onclick).insertBefore(this.$w.find('.list-toolbar '+before));this.btn_groupify();},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-refresh').click(function(){me.run();});this.$w.find('.btn-more').click(function(){me.run({append:true});});if(this.title){this.$w.find('h3').html(this.title).toggle(true);}
',this.opts));this.$w=$(this.parent).find('.wnlist');this.set_events();if(this.show_filters){this.make_filters();}},add_button:function(html,onclick,before){$(html).click(onclick).insertBefore(this.$w.find('.list-toolbar '+before));this.btn_groupify();},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-refresh').click(function(){me.run();});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.new_doctype){this.$w.find('.btn-new').toggle(true).click(function(){newdoc(me.new_doctype);})}else{this.$w.find('.btn-new').remove();}
if(!me.show_filters){this.$w.find('.btn-filter').remove();}
if(this.hide_refresh||this.no_refresh){this.$w.find('.btn-refresh').remove();}
@ -159,7 +159,7 @@ this.btn_groupify();},btn_groupify:function(){var nbtns=this.$w.find('.list-tool
if(nbtns==0){this.$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,btn:this.run_btn});},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(),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}
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)
@ -204,7 +204,8 @@ return[me.$w.find('.fieldname_select option:selected').attr('table'),me.field.df
*/
wn.provide('wn.pages');wn.provide('wn.views');wn.views.Container=Class.extend({init:function(){this.container=$('#body_div').get(0);this.page=null;this.pagewidth=$('#body_div').width();this.pagemargin=50;},add_page:function(label,onshow,onhide){var page=$('<div class="content"></div>').appendTo(this.container).get(0);if(onshow)
$(page).bind('show',onshow);if(onshow)
$(page).bind('hide',onhide);page.label=label;wn.pages[label]=page;return page;},change_to:function(label){var me=this;if(label.tagName){var page=label;}else{var page=wn.pages[label];}
$(page).bind('hide',onhide);page.label=label;wn.pages[label]=page;return page;},change_to:function(label){if(this.page&&this.page.label==label){return;}
var me=this;if(label.tagName){var page=label;}else{var page=wn.pages[label];}
if(!page){console.log('Page not found '+label);return;}
if(this.page){$(this.page).toggle(false);$(this.page).trigger('hide');}
this.page=page;$(this.page).fadeIn();$(this.page).trigger('show');this.page._route=window.location.hash;document.title=this.page.label;return this.page;}})
@ -286,8 +287,7 @@ if(data.docstatus==0||data.docstatus==null){data.docstatus_icon='icon-pencil';da
*/
wn.provide('wn.views.pageview');wn.views.pageview={pages:{},with_page:function(name,callback){if(!locals.Page[name]){wn.call({method:'webnotes.widgets.page.getpage',args:{'name':name},callback:callback});}else{callback();}},show:function(name){wn.views.pageview.with_page(name,function(){if(!wn.pages[name]){wn.views.pageview.pages[name]=new wn.views.Page(name);}
wn.container.change_to(name);});}}
wn.views.Page=Class.extend({init:function(name){this.name=name;this.render();},render:function(){var me=this;this.pagedoc=locals.Page[this.name];this.wrapper=wn.container.add_page(this.name);this.wrapper.label=this.pagedoc.title||this.pagedoc.name;this.wrapper.innerHTML=this.pagedoc.content;wn.dom.eval(this.pagedoc.__script||this.pagedoc.script||'');wn.dom.set_style(this.pagedoc.style);this.trigger('onload');$(this.wrapper).bind('show',function(){cur_frm=null;me.trigger('onshow');});},trigger:function(event){var me=this;try{if(pscript[event+'_'+this.name]){pscript[event+'_'+this.name](me.wrapper);}
if(me.wrapper[event]){me.wrapper[event](me.wrapper);}}catch(e){console.log(e);}}})
wn.views.Page=Class.extend({init:function(name){this.name=name;this.render();},render:function(){var me=this;this.pagedoc=locals.Page[this.name];this.wrapper=wn.container.add_page(this.name);this.wrapper.label=this.pagedoc.title||this.pagedoc.name;this.wrapper.innerHTML=this.pagedoc.content;wn.dom.eval(this.pagedoc.__script||this.pagedoc.script||'');wn.dom.set_style(this.pagedoc.style);this.trigger('onload');$(this.wrapper).bind('show',function(){cur_frm=null;me.trigger('onshow');console.log(1)});},trigger:function(event){var me=this;try{if(pscript[event+'_'+this.name]){pscript[event+'_'+this.name](me.wrapper);}else if(me.wrapper[event]){me.wrapper[event](me.wrapper);}}catch(e){console.log(e);}}})
/*
* lib/js/wn/views/formview.js
*/

View file

@ -99,9 +99,9 @@ wn.ui.Listing = Class.extend({
<i class="icon-plus"></i> New</a>\
<a class="btn btn-small btn-filter">\
<i class="icon-search"></i> Filter</a>\
<img src="lib/images/ui/button-load.gif" \
class="img-load"/>\
</div>\
<img src="lib/images/ui/button-load.gif" \
class="img-load" style="float: left;"/>\
</div><div style="clear:both"></div>\
\
<div class="no-result help hide">\
@ -120,7 +120,10 @@ wn.ui.Listing = Class.extend({
', this.opts));
this.$w = $(this.parent).find('.wnlist');
this.set_events();
this.make_filters();
if(this.show_filters) {
this.make_filters();
}
},
add_button: function(html, onclick, before) {
$(html).click(onclick).insertBefore(this.$w.find('.list-toolbar ' + before));
@ -221,8 +224,7 @@ wn.ui.Listing = Class.extend({
me.set_working(false);
me.render_results(r)
},
no_spinner: this.opts.no_loading,
btn: this.run_btn
no_spinner: this.opts.no_loading
});
},
set_working: function(flag) {

View file

@ -22,6 +22,11 @@ wn.views.Container = Class.extend({
return page;
},
change_to: function(label) {
if(this.page && this.page.label == label) {
// don't trigger double events
return;
}
var me = this;
if(label.tagName) {
// if sent the div, get the table

View file

@ -26,11 +26,7 @@ wn.views.pageview = {
wn.views.Page = Class.extend({
init: function(name) {
this.name = name;
this.render();
},
render: function() {
var me = this;
this.pagedoc = locals.Page[this.name];
this.wrapper = wn.container.add_page(this.name);
this.wrapper.label = this.pagedoc.title || this.pagedoc.name;
@ -48,14 +44,13 @@ wn.views.Page = Class.extend({
me.trigger('onshow');
});
},
trigger: function(event) {
trigger: function(eventname) {
var me = this;
try {
if(pscript[event+'_'+this.name]) {
pscript[event+'_'+this.name](me.wrapper);
}
if(me.wrapper[event]) {
me.wrapper[event](me.wrapper);
if(pscript[eventname+'_'+this.name]) {
pscript[eventname+'_'+this.name](me.wrapper);
} else if(me.wrapper[eventname]) {
me.wrapper[eventname](me.wrapper);
}
} catch(e) {
console.log(e);