From b9004bd6d010d3e2dd98681f61f7f153ac411660 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 5 Mar 2012 18:28:33 +0530 Subject: [PATCH 1/4] doclist2 --- build.json | 3 +- .../selling/doctype/sales_order/listview.js | 13 +++++ erpnext/setup/page/import_data/import_data.js | 2 +- erpnext/utilities/page/users/users.js | 6 +-- js/all-app.js | 51 ++++++++++--------- js/all-web.js | 37 +++++++------- version.num | 2 +- 7 files changed, 66 insertions(+), 48 deletions(-) create mode 100644 erpnext/selling/doctype/sales_order/listview.js diff --git a/build.json b/build.json index 4af974d4cf..70f5636668 100644 --- a/build.json +++ b/build.json @@ -7,6 +7,7 @@ "lib/js/wn/assets.js", "lib/js/wn/require.js", "lib/js/wn/dom.js", + "lib/js/wn/model.js", "lib/js/wn/page.js", "lib/js/wn/misc/user.js", "lib/js/lib/json2.js", @@ -91,7 +92,6 @@ "lib/js/wn/ui/listing.js", "lib/js/legacy/widgets/layout.js", "lib/js/legacy/webpage/page_header.js", - "lib/js/legacy/widgets/select.js", "lib/js/legacy/webpage/history.js", "lib/js/legacy/webpage/search.js", "lib/js/legacy/webpage/spinner.js", @@ -135,7 +135,6 @@ "lib/js/legacy/widgets/layout.js", "lib/js/legacy/widgets/tabbedpage.js", "lib/js/legacy/webpage/page_header.js", - "lib/js/legacy/widgets/select.js", "lib/js/legacy/widgets/tags.js", "lib/js/legacy/widgets/export_query.js", "lib/js/legacy/webpage/history.js", diff --git a/erpnext/selling/doctype/sales_order/listview.js b/erpnext/selling/doctype/sales_order/listview.js new file mode 100644 index 0000000000..3566dd0641 --- /dev/null +++ b/erpnext/selling/doctype/sales_order/listview.js @@ -0,0 +1,13 @@ +fields = ["customer_name, per_delivered, per_billed, currency, grand_total_export"] + +// render +wn.provide('wn.pages.doclistview.renderfn'); + +wn.pages.doclistview.renderfn['Sales Order'] = function(parent, data) { + $(parent).html(repl('\ + %(name)s\ + %(customer_name)s\ + ', {role: this.roles[i]})); } $(this.dialog.body).append('
\ -
'); - $(this.dialog.body).find('button.btn-primary').click(function() { + '); + $(this.dialog.body).find('button.btn-info').click(function() { me.save(); }); $(this.dialog.body).find('.user-role a').click(function() { @@ -314,7 +314,7 @@ erpnext.RoleEditor = Class.extend({ unset_roles: JSON.stringify(unset_roles), uid: this.uid }, - btn: $(this.dialog.body).find('.btn-primary').get(0), + btn: $(this.dialog.body).find('.btn-info').get(0), callback: function() { } diff --git a/js/all-app.js b/js/all-app.js index fda2fd7fad..48b69c3ed7 100644 --- a/js/all-app.js +++ b/js/all-app.js @@ -160,6 +160,10 @@ c.className=className;} if(cs)wn.dom.css(c,cs);if(innerHTML)c.innerHTML=innerHTML;if(onclick)c.onclick=onclick;return c;} wn.dom.css=function(ele,s){if(ele&&s){for(var i in s)ele.style[i]=s[i];};return ele;} wn.get_cookie=function(c){var t=""+document.cookie;var ind=t.indexOf(c);if(ind==-1||c=="")return"";var ind1=t.indexOf(';',ind);if(ind1==-1)ind1=t.length;return unescape(t.substring(ind+c.length+1,ind1));} +/* + * lib/js/wn/model.js + */ +wn.provide('wn.model');wn.model.no_value_type=['Section Break','Column Break','HTML','Table','Button','Image']; /* * lib/js/wn/page.js */ @@ -344,7 +348,7 @@ span.set_working=function(){this.disabled=1;$di(this.loading_img);} span.done_working=function(){this.disabled=0;$dh(this.loading_img);} return span;}} function $ln(parent,label,onclick,style){return wn.ele.link({parent:parent,label:label,onclick:onclick,style:style})} -function $btn(parent,label,onclick,style,css_class,is_ajax){wn.require('lib/js/wn/ui/button.js');if(css_class==='green')css_class='btn-primary';return new wn.ui.Button({parent:parent,label:label,onclick:onclick,style:style,is_ajax:is_ajax,css_class:css_class}).btn;} +function $btn(parent,label,onclick,style,css_class,is_ajax){wn.require('lib/js/wn/ui/button.js');if(css_class==='green')css_class='btn-info';return new wn.ui.Button({parent:parent,label:label,onclick:onclick,style:style,is_ajax:is_ajax,css_class:css_class}).btn;} $item_normal=function(ele){$y(ele,{padding:'6px 8px',cursor:'pointer',marginRight:'8px',whiteSpace:'nowrap',overflow:'hidden',borderBottom:'1px solid #DDD'});$bg(ele,'#FFF');$fg(ele,'#000');} $item_active=function(ele){$bg(ele,'#FE8');$fg(ele,'#000');} $item_selected=function(ele){$bg(ele,'#777');$fg(ele,'#FFF');} @@ -352,6 +356,9 @@ $item_pressed=function(ele){$bg(ele,'#F90');$fg(ele,'#FFF');};(function($){$.fn. $.fn.done_working=function(){var ele=this.get(0);ele.disabled=0;if(ele.loading_img){$dh(ele.loading_img)};}})(jQuery);function set_opacity(ele,ieop){var op=ieop/100;if(ele.filters){try{ele.filters.item("DXImageTransform.Microsoft.Alpha").opacity=ieop;}catch(e){ele.style.filter='progid:DXImageTransform.Microsoft.Alpha(opacity='+ieop+')';}}else{ele.style.opacity=op;}} $br=function(ele,r,corners){if(corners){var cl=['top-left','top-right','bottom-right','bottom-left'];for(var i=0;i<4;i++){if(corners[i]){$(ele).css('-moz-border-radius-'+cl[i].replace('-',''),r).css('-webkit-'+cl[i]+'-border-radius',r);}}}else{$(ele).css('-moz-border-radius',r).css('-webkit-border-radius',r).css('border-radius',r);}} $bs=function(ele,r){$(ele).css('-moz-box-shadow',r).css('-webkit-box-shadow',r).css('box-shadow',r);} +function SelectWidget(parent,options,width,editable,bg_color){var me=this;this.inp=$a(parent,'select');if(options)add_sel_options(this.inp,options);if(width)$y(this.inp,{width:width});this.set_width=function(w){$y(this.inp,{width:w})};this.set_options=function(o){add_sel_options(this.inp,o);} +this.inp.onchange=function(){if(me.onchange)me.onchange(this);} +return;} function empty_select(s){if(s.custom_select){s.empty();return;} if(s.inp)s=s.inp;if(s){var tmplen=s.length;for(var i=0;i');html.push('';var div=$a(parent,'div');div.innerHTML='
';var ul_form=div.childNodes[0];var f_list=[];var inp_fdata=$a_input($a(ul_form,'span'),'file',{name:'filedata'},{marginLeft:'7px'});if(!('cmd'in args)){var inp=$a_input($a(ul_form,'span'),'hidden',{name:'cmd'});inp.value='uploadfile';} + style="width:0px; height:0px; border:0px">';var div=$a(parent,'div');div.innerHTML='
';var ul_form=div.childNodes[0];var f_list=[];var inp_fdata=$a_input($a(ul_form,'span'),'file',{name:'filedata'},{marginLeft:'7px'});if(!('cmd'in args)){var inp=$a_input($a(ul_form,'span'),'hidden',{name:'cmd'});inp.value='uploadfile';} var inp=$a_input($a(ul_form,'span'),'hidden',{name:'uploader_id'});inp.value=id;var inp=$a_input($a(ul_form,'span'),'submit',null,{marginLeft:'7px'});inp.value='Upload';$y(inp,{width:'80px'});for(var key in args){var inp=$a_input($a(ul_form,'span'),'hidden',{name:key});inp.value=args[key];} uploaders[id]=this;} function upload_callback(id,fid){uploaders[id].callback(fid);} @@ -1357,12 +1360,12 @@ this.setup();} */ var no_value_fields=['Section Break','Column Break','HTML','Table','FlexTable','Button','Image'];var codeid=0;var code_editors={};function Field(){this.with_label=1;} Field.prototype.make_body=function(){var ischk=(this.df.fieldtype=='Check'?1:0);if(this.parent) -this.wrapper=$a(this.parent,'div');else -this.wrapper=document.createElement('div');this.label_area=$a(this.wrapper,'div','',{margin:'8px 0px 2px 0px'});if(ischk&&!this.in_grid){this.input_area=$a(this.label_area,'span','',{marginRight:'4px'});this.disp_area=$a(this.label_area,'span','',{marginRight:'4px'});} +this.wrapper=$a(this.parent,(this.with_label?'div':'span'));else +this.wrapper=document.createElement((this.with_label?'div':'span'));this.label_area=$a(this.wrapper,'div','',{margin:'8px 0px 2px 0px'});if(ischk&&!this.in_grid){this.input_area=$a(this.label_area,'span','',{marginRight:'4px'});this.disp_area=$a(this.label_area,'span','',{marginRight:'4px'});} if(this.with_label){this.label_span=$a(this.label_area,'span','field_label') this.label_icon=$a(this.label_area,'img','',{margin:'-3px 4px -3px 4px'});$dh(this.label_icon);this.label_icon.src='lib/images/icons/error.gif';this.label_icon.title='Mandatory value needs to be entered';this.suggest_icon=$a(this.label_area,'img','',{margin:'-3px 4px -3px 0px'});$dh(this.suggest_icon);this.suggest_icon.src='lib/images/icons/bullet_arrow_down.png';this.suggest_icon.title='With suggestions';}else{this.label_span=$a(this.label_area,'span','',{marginRight:'4px'}) $dh(this.label_area);} -if(!this.input_area){this.input_area=$a(this.wrapper,'div');this.disp_area=$a(this.wrapper,'div');} +if(!this.input_area){this.input_area=$a(this.wrapper,(this.with_label?'div':'span'));this.disp_area=$a(this.wrapper,(this.with_label?'div':'span'));} if(this.in_grid){if(this.label_area)$dh(this.label_area);}else{this.input_area.className='input_area';$y(this.wrapper,{marginBottom:'4px'});this.set_description();} if(this.onmake)this.onmake();} Field.prototype.set_max_width=function(){var no_max=['Code','Text Editor','Text','Table','HTML'] @@ -1609,7 +1612,7 @@ var sp1=null;var sp2=null;if(doc.__islocal){label='Unsaved Draft';col='#F81';}el sp1=make_tag(label,col);this.set_in_recent(doc,col);return[sp1,sp2];} _f.FrmHeader.prototype.set_in_recent=function(doc,col){var tn=$i('rec_'+doc.doctype+'-'+doc.name);if(tn) $y(tn,{backgroundColor:col});} -_f.FrmHeader.prototype.set_save_submit_color=function(doc){var save_btn=this.page_head.buttons['Save'];var submit_btn=this.page_head.buttons['Submit'];if(cint(doc.docstatus)==0&&submit_btn&&save_btn){if(cint(doc.__unsaved)){$(save_btn).addClass('btn-primary');$(submit_btn).removeClass('btn-primary');}else{$(submit_btn).addClass('btn-primary');$(save_btn).removeClass('btn-primary');}}} +_f.FrmHeader.prototype.set_save_submit_color=function(doc){var save_btn=this.page_head.buttons['Save'];var submit_btn=this.page_head.buttons['Submit'];if(cint(doc.docstatus)==0&&submit_btn&&save_btn){if(cint(doc.__unsaved)){$(save_btn).addClass('btn-info');$(submit_btn).removeClass('btn-info');}else{$(submit_btn).addClass('btn-info');$(save_btn).removeClass('btn-info');}}} _f.FrmHeader.prototype.refresh_labels=function(f){var ph=this.page_head;var me=this;this.dt_area.innerHTML=get_doctype_label(f.doctype);this.dn_area.innerHTML='';if(!f.meta.issingle) this.dn_area.innerHTML=f.docname;var doc=locals[f.doctype][f.docname];var sl=this.get_status_tags(doc,f);this.set_save_submit_color(doc);var t=this.status_area;t.innerHTML='';t.appendChild(sl[0]);if(sl[1])t.appendChild(sl[1]);this.timestamp_area.innerHTML=me.get_timestamp(doc);} /* @@ -1793,10 +1796,10 @@ this.tray_item.show();if(this.expanded)this.row.show();} this.set_hidden=this.df.hidden;}} _f.ImageField=function(){this.images={};} _f.ImageField.prototype=new Field();_f.ImageField.prototype.onmake=function(){this.no_img=$a(this.wrapper,'div','no_img');this.no_img.innerHTML="No Image";$dh(this.no_img);} -_f.ImageField.prototype.get_image_src=function(doc){if(doc.file_list){file=doc.file_list.split(',');extn=file[0].split('.');extn=extn[extn.length-1].toLowerCase();var img_extn_list=['gif','jpg','bmp','jpeg','jp2','cgm','ief','jpm','jpx','png','tiff','jpe','tif'];if(in_list(img_extn_list,extn)){var src=outUrl+"?cmd=downloadfile&file_id="+file[1];}}else{var src="";} +_f.ImageField.prototype.get_image_src=function(doc){if(doc.file_list){file=doc.file_list.split(',');extn=file[0].split('.');extn=extn[extn.length-1].toLowerCase();var img_extn_list=['gif','jpg','bmp','jpeg','jp2','cgm','ief','jpm','jpx','png','tiff','jpe','tif'];if(in_list(img_extn_list,extn)){var src=webnotes.request.url+"?cmd=downloadfile&file_id="+file[1];}}else{var src="";} return src;} _f.ImageField.prototype.onrefresh=function(){var me=this;if(!this.images[this.docname])this.images[this.docname]=$a(this.wrapper,'img');else $di(this.images[this.docname]);var img=this.images[this.docname] -for(var dn in this.images)if(dn!=this.docname)$dh(this.images[dn]);var doc=locals[this.frm.doctype][this.frm.docname];if(!this.df.options)var src=this.get_image_src(doc);else var src=outUrl+'?cmd=get_file&fname='+this.df.options+"&__account="+account_id+(__sid150?("&sid150="+__sid150):'');if(src){$dh(this.no_img);if(img.getAttribute('src')!=src)img.setAttribute('src',src);canvas=this.wrapper;canvas.img=this.images[this.docname];canvas.style.overflow="auto";$w(canvas,"100%");if(!this.col_break_width)this.col_break_width='100%';var allow_width=cint(1000*(cint(this.col_break_width)-10)/100);if((!img.naturalWidth)||cint(img.naturalWidth)>allow_width) +for(var dn in this.images)if(dn!=this.docname)$dh(this.images[dn]);var doc=locals[this.frm.doctype][this.frm.docname];if(!this.df.options)var src=this.get_image_src(doc);else var src=webnotes.request.url+'?cmd=get_file&fname='+this.df.options+"&__account="+account_id+(__sid150?("&sid150="+__sid150):'');if(src){$dh(this.no_img);if(img.getAttribute('src')!=src)img.setAttribute('src',src);canvas=this.wrapper;canvas.img=this.images[this.docname];canvas.style.overflow="auto";$w(canvas,"100%");if(!this.col_break_width)this.col_break_width='100%';var allow_width=cint(1000*(cint(this.col_break_width)-10)/100);if((!img.naturalWidth)||cint(img.naturalWidth)>allow_width) $w(img,allow_width+'px');}else{$ds(this.no_img);}} _f.ImageField.prototype.set_disp=function(val){} _f.ImageField.prototype.set=function(val){} diff --git a/js/all-web.js b/js/all-web.js index 9d384063e5..cd2b345a12 100644 --- a/js/all-web.js +++ b/js/all-web.js @@ -106,6 +106,10 @@ c.className=className;} if(cs)wn.dom.css(c,cs);if(innerHTML)c.innerHTML=innerHTML;if(onclick)c.onclick=onclick;return c;} wn.dom.css=function(ele,s){if(ele&&s){for(var i in s)ele.style[i]=s[i];};return ele;} wn.get_cookie=function(c){var t=""+document.cookie;var ind=t.indexOf(c);if(ind==-1||c=="")return"";var ind1=t.indexOf(';',ind);if(ind1==-1)ind1=t.length;return unescape(t.substring(ind+c.length+1,ind1));} +/* + * lib/js/wn/model.js + */ +wn.provide('wn.model');wn.model.no_value_type=['Section Break','Column Break','HTML','Table','Button','Image']; /* * lib/js/wn/page.js */ @@ -290,7 +294,7 @@ span.set_working=function(){this.disabled=1;$di(this.loading_img);} span.done_working=function(){this.disabled=0;$dh(this.loading_img);} return span;}} function $ln(parent,label,onclick,style){return wn.ele.link({parent:parent,label:label,onclick:onclick,style:style})} -function $btn(parent,label,onclick,style,css_class,is_ajax){wn.require('lib/js/wn/ui/button.js');if(css_class==='green')css_class='btn-primary';return new wn.ui.Button({parent:parent,label:label,onclick:onclick,style:style,is_ajax:is_ajax,css_class:css_class}).btn;} +function $btn(parent,label,onclick,style,css_class,is_ajax){wn.require('lib/js/wn/ui/button.js');if(css_class==='green')css_class='btn-info';return new wn.ui.Button({parent:parent,label:label,onclick:onclick,style:style,is_ajax:is_ajax,css_class:css_class}).btn;} $item_normal=function(ele){$y(ele,{padding:'6px 8px',cursor:'pointer',marginRight:'8px',whiteSpace:'nowrap',overflow:'hidden',borderBottom:'1px solid #DDD'});$bg(ele,'#FFF');$fg(ele,'#000');} $item_active=function(ele){$bg(ele,'#FE8');$fg(ele,'#000');} $item_selected=function(ele){$bg(ele,'#777');$fg(ele,'#FFF');} @@ -298,6 +302,9 @@ $item_pressed=function(ele){$bg(ele,'#F90');$fg(ele,'#FFF');};(function($){$.fn. $.fn.done_working=function(){var ele=this.get(0);ele.disabled=0;if(ele.loading_img){$dh(ele.loading_img)};}})(jQuery);function set_opacity(ele,ieop){var op=ieop/100;if(ele.filters){try{ele.filters.item("DXImageTransform.Microsoft.Alpha").opacity=ieop;}catch(e){ele.style.filter='progid:DXImageTransform.Microsoft.Alpha(opacity='+ieop+')';}}else{ele.style.opacity=op;}} $br=function(ele,r,corners){if(corners){var cl=['top-left','top-right','bottom-right','bottom-left'];for(var i=0;i<4;i++){if(corners[i]){$(ele).css('-moz-border-radius-'+cl[i].replace('-',''),r).css('-webkit-'+cl[i]+'-border-radius',r);}}}else{$(ele).css('-moz-border-radius',r).css('-webkit-border-radius',r).css('border-radius',r);}} $bs=function(ele,r){$(ele).css('-moz-box-shadow',r).css('-webkit-box-shadow',r).css('box-shadow',r);} +function SelectWidget(parent,options,width,editable,bg_color){var me=this;this.inp=$a(parent,'select');if(options)add_sel_options(this.inp,options);if(width)$y(this.inp,{width:width});this.set_width=function(w){$y(this.inp,{width:w})};this.set_options=function(o){add_sel_options(this.inp,o);} +this.inp.onchange=function(){if(me.onchange)me.onchange(this);} +return;} function empty_select(s){if(s.custom_select){s.empty();return;} if(s.inp)s=s.inp;if(s){var tmplen=s.length;for(var i=0;iPlease check the following Errors\n'+errors.join('\n'));return null;} @@ -657,7 +664,7 @@ else if(d[0]=='Password'){c1.innerHTML=d[1];c2.style.overflow='auto';this.widget else if(d[0]=='Select'){c1.innerHTML=d[1];this.widgets[d[1]]=$a(c2,'select','',{width:'160px'}) if(d[2])$a(c2,'div','field_description').innerHTML=d[2];if(d[3])add_sel_options(this.widgets[d[1]],d[3],d[3][0]);} else if(d[0]=='Text'){c1.innerHTML=d[1];c2.style.overflow='auto';this.widgets[d[1]]=$a(c2,'textarea');if(d[2])$a(c2,'div','field_description').innerHTML=d[2];} -else if(d[0]=='Button'){c2.style.height='32px';var b=$btn(c2,d[1],function(btn){if(btn._onclick)btn._onclick(me)},null,null,1);b.dialog=me;if(!this.first_button){$(b).addClass('btn-primary');this.first_button=true;} +else if(d[0]=='Button'){c2.style.height='32px';var b=$btn(c2,d[1],function(btn){if(btn._onclick)btn._onclick(me)},null,null,1);b.dialog=me;if(!this.first_button){$(b).addClass('btn-info');this.first_button=true;} if(d[2]){b._onclick=d[2];} this.widgets[d[1]]=b;}} /* @@ -683,6 +690,7 @@ this.start=0;if(!this.opts.method){this.query=this.opts.get_query?this.opts.get_ args.simple_query=this.query;}else{var args={limit_start:this.start,limit_page_length:this.page_length}} if(this.opts.args) $.extend(args,this.opts.args) +if(this.opts.get_args){$.extend(args,this.opts.get_args());} if(this.loading_img)$di(this.loading_img);wn.call({method:this.opts.method||'webnotes.widgets.query_builder.runquery',args:args,callback:function(r,rt){me.make_results(r,rt)},no_spinner:this.opts.no_loading,btn:this.opts.run_btn});} this.refresh=this.run;this.add_limits=function(){this.query+=' LIMIT '+this.start+','+(this.page_length+1);} if(opts)this.make();} @@ -718,15 +726,9 @@ LayoutCell.prototype.hide=function(){$dh(this.wrapper);} var def_ph_style={wrapper:{marginBottom:'16px',backgroundColor:'#EEE'},main_heading:{},sub_heading:{marginBottom:'8px',color:'#555',display:'none'},separator:{borderTop:'3px solid #777'},toolbar_area:{padding:'3px 0px',display:'none',borderBottom:'1px solid #AAA'}} function PageHeader(parent,main_text,sub_text){this.wrapper=$a(parent,'div','page_header');this.t1=make_table($a(this.wrapper,'div','',def_ph_style.wrapper.backgroundColor),1,2,'100%',[null,'100px'],{padding:'2px'});$y(this.t1,{borderCollapse:'collapse'}) this.lhs=$td(this.t1,0,0);this.main_head=$a(this.lhs,'h1','',def_ph_style.main_heading);this.sub_head=$a(this.lhs,'h4','',def_ph_style.sub_heading);this.separator=$a(this.wrapper,'div','',def_ph_style.separator);this.toolbar_area=$a(this.wrapper,'div','',def_ph_style.toolbar_area);this.padding_area=$a(this.wrapper,'div','',{padding:'3px'});$y($td(this.t1,0,1),{textAlign:'right',padding:'3px'});this.close_btn=$a($td(this.t1,0,1),'span','close',{},'×');this.close_btn.onclick=function(){nav_obj.show_last_open();};if(main_text)this.main_head.innerHTML=main_text;if(sub_text)this.sub_head.innerHTML=sub_text;this.buttons={};this.buttons2={};} -PageHeader.prototype.add_button=function(label,fn,bold,icon,green){var tb=this.toolbar_area;if(this.buttons[label])return;var btn=$btn(tb,label,fn,{marginRight:'4px'},(green?'btn-primary':''));if(bold)$y(btn,{fontWeight:'bold'});this.buttons[label]=btn;$ds(this.toolbar_area);return btn;} +PageHeader.prototype.add_button=function(label,fn,bold,icon,green){var tb=this.toolbar_area;if(this.buttons[label])return;var btn=$btn(tb,label,fn,{marginRight:'4px'},(green?'btn-info':''));if(bold)$y(btn,{fontWeight:'bold'});this.buttons[label]=btn;$ds(this.toolbar_area);return btn;} PageHeader.prototype.clear_toolbar=function(){this.toolbar_area.innerHTML='';this.buttons={};} PageHeader.prototype.make_buttonset=function(){$(this.toolbar_area).buttonset();} -/* - * lib/js/legacy/widgets/select.js - */ -function SelectWidget(parent,options,width,editable,bg_color){var me=this;this.inp=$a(parent,'select');if(options)add_sel_options(this.inp,options);if(width)$y(this.inp,{width:width});this.set_width=function(w){$y(this.inp,{width:w})};this.set_options=function(o){add_sel_options(this.inp,o);} -this.inp.onchange=function(){if(me.onchange)me.onchange(this);} -return;} /* * lib/js/legacy/webpage/history.js */ @@ -746,13 +748,13 @@ var _history_current;function history_get_name(t){var parts=[];if(t.length>=3){f return parts.join('/')} nav_obj.get_page=function(loc){if(!loc)loc=window.location.hash;if(loc.substr(0,1)=='#'){loc=loc.substr(1);} if(loc.substr(0,1)=='!'){loc=loc.substr(1);} -if(!in_list(['Page/','Form/','Repor','DocBr','List/'],loc.substr(0,5))){loc='Page/'+loc;} +if(!in_list(['Page/','Form/','Repor','DocBr','List/','List2'],loc.substr(0,5))){loc='Page/'+loc;} return loc.split('/');} function historyChange(newLocation){var t=nav_obj.get_page(newLocation) for(var i=0;i';var div=$a(parent,'div');div.innerHTML='
';var ul_form=div.childNodes[0];var f_list=[];var inp_fdata=$a_input($a(ul_form,'span'),'file',{name:'filedata'},{marginLeft:'7px'});if(!('cmd'in args)){var inp=$a_input($a(ul_form,'span'),'hidden',{name:'cmd'});inp.value='uploadfile';} + style="width:0px; height:0px; border:0px">';var div=$a(parent,'div');div.innerHTML='
';var ul_form=div.childNodes[0];var f_list=[];var inp_fdata=$a_input($a(ul_form,'span'),'file',{name:'filedata'},{marginLeft:'7px'});if(!('cmd'in args)){var inp=$a_input($a(ul_form,'span'),'hidden',{name:'cmd'});inp.value='uploadfile';} var inp=$a_input($a(ul_form,'span'),'hidden',{name:'uploader_id'});inp.value=id;var inp=$a_input($a(ul_form,'span'),'submit',null,{marginLeft:'7px'});inp.value='Upload';$y(inp,{width:'80px'});for(var key in args){var inp=$a_input($a(ul_form,'span'),'hidden',{name:key});inp.value=args[key];} uploaders[id]=this;} function upload_callback(id,fid){uploaders[id].callback(fid);} diff --git a/version.num b/version.num index f08bce7b1c..e39afc8dd2 100644 --- a/version.num +++ b/version.num @@ -1 +1 @@ -841 \ No newline at end of file +868 \ No newline at end of file From 15da133de9b237d0740ded0d03c39de88b2e4a7c Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 6 Mar 2012 18:41:11 +0530 Subject: [PATCH 2/4] removed --- .../payable_voucher/payable_voucher.js | 4 +- .../receivable_voucher/receivable_voucher.js | 8 +-- erpnext/buying/doctype/indent/indent.js | 4 +- .../purchase_common/purchase_common.js | 6 +-- .../doctype/purchase_order/purchase_order.js | 9 ++-- erpnext/buying/doctype/supplier/supplier.js | 2 +- .../expense_voucher/expense_voucher.js | 3 +- .../page/question_view/question_view.js | 2 +- .../page/questions/questions.js | 2 +- erpnext/selling/doctype/customer/customer.js | 2 +- erpnext/selling/doctype/enquiry/enquiry.js | 2 +- erpnext/selling/doctype/lead/lead.js | 2 +- .../selling/doctype/quotation/quotation.js | 8 +-- .../doctype/sales_common/sales_common.js | 16 +++--- .../selling/doctype/sales_order/listview.js | 52 ++++++++++++++----- .../doctype/sales_order/sales_order.js | 8 +-- .../doctype/sales_partner/sales_partner.js | 2 +- .../doctype/delivery_note/delivery_note.js | 8 +-- .../purchase_receipt/purchase_receipt.js | 8 +-- js/all-app.js | 2 +- version.num | 2 +- 21 files changed, 90 insertions(+), 62 deletions(-) diff --git a/erpnext/accounts/doctype/payable_voucher/payable_voucher.js b/erpnext/accounts/doctype/payable_voucher/payable_voucher.js index 99bd24c6b8..bdb4e41e6b 100644 --- a/erpnext/accounts/doctype/payable_voucher/payable_voucher.js +++ b/erpnext/accounts/doctype/payable_voucher/payable_voucher.js @@ -17,8 +17,8 @@ cur_frm.cscript.tname = "PV Detail"; cur_frm.cscript.fname = "entries"; cur_frm.cscript.other_fname = "purchase_tax_details"; -$import(Purchase Other Charges) -$import(Purchase Common) +wn.require('erpnext/buying/doctype/purchase_other_charges/purchase_other_charges.js'); +wn.require('erpnext/buying/doctype/purchase_common/purchase_common.js'); // On Load // -------- diff --git a/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.js b/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.js index 391bbcd8ae..9747a2be30 100644 --- a/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.js +++ b/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.js @@ -22,9 +22,10 @@ cur_frm.cscript.sales_team_fname = "sales_team"; // print heading cur_frm.pformat.print_heading = 'Invoice'; -$import(Sales Common) -$import(Other Charges) -$import(SMS Control) +wn.require('erpnext/selling/doctype/sales_common/sales_common.js'); +wn.require('erpnext/setup/doctype/other_charges/other_charges.js'); +wn.require('erpnext/utilities/doctype/sms_control/sms_control.js'); +wn.require('erpnext/setup/doctype/notification_control/notification_control.js'); // On Load // ------- @@ -476,7 +477,6 @@ cur_frm.cscript.convert_into_recurring_invoice = function(doc) { } } -$import(Notification Control) cur_frm.cscript.on_submit = function(doc, cdt, cdn) { var args = { type: 'Sales Invoice', diff --git a/erpnext/buying/doctype/indent/indent.js b/erpnext/buying/doctype/indent/indent.js index 570e06c1b8..1940e5a606 100644 --- a/erpnext/buying/doctype/indent/indent.js +++ b/erpnext/buying/doctype/indent/indent.js @@ -17,8 +17,8 @@ cur_frm.cscript.tname = "Indent Detail"; cur_frm.cscript.fname = "indent_details"; -$import(Purchase Common) -$import(SMS Control) +wn.require('erpnext/buying/doctype/purchase_common/purchase_common.js'); +wn.require('erpnext/utilities/doctype/sms_control/sms_control.js'); cur_frm.cscript.indent_doctype_label = get_doctype_label('Indent'); //========================== On Load ================================================= diff --git a/erpnext/buying/doctype/purchase_common/purchase_common.js b/erpnext/buying/doctype/purchase_common/purchase_common.js index 9a414a364a..d15d5ceb94 100644 --- a/erpnext/buying/doctype/purchase_common/purchase_common.js +++ b/erpnext/buying/doctype/purchase_common/purchase_common.js @@ -71,9 +71,9 @@ cur_frm.cscript.update_item_details = function(doc, dt, dn, callback) { var set_dynamic_label_par = function(doc, cdt, cdn, base_curr) { //parent flds par_cols_base = {'net_total': 'Net Total', 'total_tax': 'Total Tax', 'grand_total': 'Grand Total', /*'rounded_total': 'Rounded Total',*/ - 'in_words': 'In Words', 'other_charges_added': 'Other Charges Added', 'other_charges_deducted': 'Other Charges Deducted'} + 'in_words': 'In Words', 'other_charges_added': 'wn.require('erpnext/setup/doctype/other_charges/other_charges.js'); Added', 'other_charges_deducted': 'wn.require('erpnext/setup/doctype/other_charges/other_charges.js'); Deducted'} par_cols_import = {'net_total_import': 'Net Total', 'grand_total_import': 'Grand Total', 'in_words_import': 'In Words', - 'other_charges_added_import': 'Other Charges Added', 'other_charges_deducted_import': 'Other Charges Deducted'}; + 'other_charges_added_import': 'wn.require('erpnext/setup/doctype/other_charges/other_charges.js'); Added', 'other_charges_deducted_import': 'wn.require('erpnext/setup/doctype/other_charges/other_charges.js'); Deducted'}; for (d in par_cols_base) cur_frm.fields_dict[d].label_area.innerHTML = par_cols_base[d]+' (' + base_curr + ')'; for (d in par_cols_import) cur_frm.fields_dict[d].label_area.innerHTML = par_cols_import[d]+' (' + doc.currency + ')'; @@ -430,7 +430,7 @@ cur_frm.cscript.calc_other_charges = function(doc , tname , fname , other_fname) // ------------------ - cur_frm.fields_dict['Tax Calculation'].disp_area.innerHTML = 'Calculation Details for Other Charges and Landed cost:'; + cur_frm.fields_dict['Tax Calculation'].disp_area.innerHTML = 'Calculation Details for wn.require('erpnext/setup/doctype/other_charges/other_charges.js'); and Landed cost:'; var cl = getchildren(tname, doc.name, fname); var tax = getchildren('Purchase Tax Detail', doc.name, other_fname,doc.doctype); // make display table diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.js b/erpnext/buying/doctype/purchase_order/purchase_order.js index 7af1204fa4..3588a525c3 100644 --- a/erpnext/buying/doctype/purchase_order/purchase_order.js +++ b/erpnext/buying/doctype/purchase_order/purchase_order.js @@ -17,9 +17,11 @@ cur_frm.cscript.tname = "PO Detail"; cur_frm.cscript.fname = "po_details"; cur_frm.cscript.other_fname = "purchase_tax_details"; -$import(Purchase Common) -$import(Purchase Other Charges) -$import(SMS Control) + +wn.require('erpnext/buying/doctype/purchase_other_charges/purchase_other_charges.js'); +wn.require('erpnext/buying/doctype/purchase_common/purchase_common.js'); +wn.require('erpnext/utilities/doctype/sms_control/sms_control.js'); +wn.require('erpnext/setup/doctype/notification_control/notification_control.js'); //========================== On Load ================================================= cur_frm.cscript.onload = function(doc, cdt, cdn) { @@ -270,7 +272,6 @@ cur_frm.pformat.indent_no = function(doc, cdt, cdn){ return out; } -$import(Notification Control) cur_frm.cscript.on_submit = function(doc, cdt, cdn) { var args = { type: 'Purchase Order', diff --git a/erpnext/buying/doctype/supplier/supplier.js b/erpnext/buying/doctype/supplier/supplier.js index 41889af04f..a348848a86 100644 --- a/erpnext/buying/doctype/supplier/supplier.js +++ b/erpnext/buying/doctype/supplier/supplier.js @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -$import(Contact Control) +wn.require('erpnext/setup/doctype/contact_control/contact_control.js'); cur_frm.cscript.onload = function(doc,dt,dn){ diff --git a/erpnext/hr/doctype/expense_voucher/expense_voucher.js b/erpnext/hr/doctype/expense_voucher/expense_voucher.js index 2e03567751..2363dbd696 100644 --- a/erpnext/hr/doctype/expense_voucher/expense_voucher.js +++ b/erpnext/hr/doctype/expense_voucher/expense_voucher.js @@ -100,7 +100,7 @@ cur_frm.cscript.sanctioned_amount = function(doc,cdt,cdn){ cur_frm.cscript.calculate_total(doc,cdt,cdn); } -$import(Notification Control); +wn.require('erpnext/setup/doctype/notification_control/notification_control.js'); cur_frm.cscript['Approve'] = function(doc,cdt,cdn){ @@ -244,7 +244,6 @@ cur_frm.cscript['Update Voucher'] = function(doc){ }); } -$import(Notification Control) cur_frm.cscript.on_submit = function(doc, cdt, cdn) { var args = { type: 'Expense Voucher', diff --git a/erpnext/knowledge_base/page/question_view/question_view.js b/erpnext/knowledge_base/page/question_view/question_view.js index 578347188e..6d17713918 100644 --- a/erpnext/knowledge_base/page/question_view/question_view.js +++ b/erpnext/knowledge_base/page/question_view/question_view.js @@ -185,4 +185,4 @@ KBAnswer = function(body, data, ans_list) { } -$import(knowledge_base/page/kb_common/kb_common.js); \ No newline at end of file +wn.require('erpnext/knowledge_base/page/kb_common/kb_common.js'); \ No newline at end of file diff --git a/erpnext/knowledge_base/page/questions/questions.js b/erpnext/knowledge_base/page/questions/questions.js index 7261cd88f9..cbea1c29db 100644 --- a/erpnext/knowledge_base/page/questions/questions.js +++ b/erpnext/knowledge_base/page/questions/questions.js @@ -215,4 +215,4 @@ KBQuestion = function(parent, det, kb) { this.make() } -$import(knowledge_base/page/kb_common/kb_common.js); \ No newline at end of file +wn.require('erpnext/knowledge_base/page/kb_common/kb_common.js'); \ No newline at end of file diff --git a/erpnext/selling/doctype/customer/customer.js b/erpnext/selling/doctype/customer/customer.js index 89b95fa89e..b5909c3c2e 100644 --- a/erpnext/selling/doctype/customer/customer.js +++ b/erpnext/selling/doctype/customer/customer.js @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -$import(Contact Control) +wn.require('erpnext/setup/doctype/contact_control/contact_control.js'); /* ********************************* onload ********************************************* */ diff --git a/erpnext/selling/doctype/enquiry/enquiry.js b/erpnext/selling/doctype/enquiry/enquiry.js index c3f0a0bc6b..bf2628feaf 100644 --- a/erpnext/selling/doctype/enquiry/enquiry.js +++ b/erpnext/selling/doctype/enquiry/enquiry.js @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -$import(SMS Control) +wn.require('erpnext/utilities/doctype/sms_control/sms_control.js'); cur_frm.cscript.refresh = function(doc, cdt, cdn){ diff --git a/erpnext/selling/doctype/lead/lead.js b/erpnext/selling/doctype/lead/lead.js index 7255636a41..a32acf7df5 100644 --- a/erpnext/selling/doctype/lead/lead.js +++ b/erpnext/selling/doctype/lead/lead.js @@ -16,7 +16,7 @@ // Module CRM -$import(SMS Control) +wn.require('erpnext/utilities/doctype/sms_control/sms_control.js'); cur_frm.cscript.onload = function(doc, cdt, cdn) { if(user =='Guest'){ diff --git a/erpnext/selling/doctype/quotation/quotation.js b/erpnext/selling/doctype/quotation/quotation.js index 7f40782d0c..c86c680510 100644 --- a/erpnext/selling/doctype/quotation/quotation.js +++ b/erpnext/selling/doctype/quotation/quotation.js @@ -21,9 +21,10 @@ cur_frm.cscript.other_fname = "other_charges"; cur_frm.cscript.sales_team_fname = "sales_team"; // ===================================================================================== -$import(Sales Common) -$import(Other Charges) -$import(SMS Control) +wn.require('erpnext/selling/doctype/sales_common/sales_common.js'); +wn.require('erpnext/setup/doctype/other_charges/other_charges.js'); +wn.require('erpnext/utilities/doctype/sms_control/sms_control.js'); +wn.require('erpnext/setup/doctype/notification_control/notification_control.js'); // ONLOAD // =================================================================================== @@ -326,7 +327,6 @@ cur_frm.fields_dict['quotation_details'].grid.get_field('item_code').get_query= return repl("SELECT name, item_name, description FROM tabItem WHERE `tabItem`.%(key)s LIKE '%s' %(cond)s ORDER BY tabItem.item_code DESC LIMIT 50", {cond:cond}); } -$import(Notification Control) cur_frm.cscript.on_submit = function(doc, cdt, cdn) { var args = { type: 'Quotation', diff --git a/erpnext/selling/doctype/sales_common/sales_common.js b/erpnext/selling/doctype/sales_common/sales_common.js index cad8ec16f7..3b33a07ca2 100644 --- a/erpnext/selling/doctype/sales_common/sales_common.js +++ b/erpnext/selling/doctype/sales_common/sales_common.js @@ -18,7 +18,7 @@ // ------ // cur_frm.cscript.tname - Details table name // cur_frm.cscript.fname - Details fieldname -// cur_frm.cscript.other_fname - Other Charges fieldname +// cur_frm.cscript.other_fname - wn.require('erpnext/setup/doctype/other_charges/other_charges.js'); fieldname // cur_frm.cscript.sales_team_fname - Sales Team fieldname // ============== Load Default Taxes =================== @@ -96,7 +96,7 @@ cur_frm.cscript.customer = function(doc, cdt, cdn) { var set_dynamic_label_par = function(doc, cdt, cdn, base_curr) { //parent flds - par_cols_base = {'net_total': 'Net Total', 'other_charges_total': 'Other Charges Total', + par_cols_base = {'net_total': 'Net Total', 'other_charges_total': 'wn.require('erpnext/setup/doctype/other_charges/other_charges.js'); Total', 'grand_total': 'Grand Total', 'rounded_total': 'Rounded Total', 'in_words': 'In Words'} par_cols_export = {'grand_total_export': 'Grand Total', 'rounded_total_export': 'Rounded Total', 'in_words_export': 'In Words'}; @@ -339,7 +339,7 @@ cur_frm.cscript.export_rate = function(doc,cdt,cdn) { // ************* GET OTHER CHARGES BASED ON COMPANY ************* cur_frm.fields_dict.charge.get_query = function(doc) { - return 'SELECT DISTINCT `tabOther Charges`.name FROM `tabOther Charges` WHERE `tabOther Charges`.company = "'+doc.company+'" AND `tabOther Charges`.company is not NULL AND `tabOther Charges`.docstatus != 2 AND `tabOther Charges`.%(key)s LIKE "%s" ORDER BY `tabOther Charges`.name LIMIT 50'; + return 'SELECT DISTINCT `tabwn.require('erpnext/setup/doctype/other_charges/other_charges.js');`.name FROM `tabwn.require('erpnext/setup/doctype/other_charges/other_charges.js');` WHERE `tabwn.require('erpnext/setup/doctype/other_charges/other_charges.js');`.company = "'+doc.company+'" AND `tabwn.require('erpnext/setup/doctype/other_charges/other_charges.js');`.company is not NULL AND `tabwn.require('erpnext/setup/doctype/other_charges/other_charges.js');`.docstatus != 2 AND `tabwn.require('erpnext/setup/doctype/other_charges/other_charges.js');`.%(key)s LIKE "%s" ORDER BY `tabwn.require('erpnext/setup/doctype/other_charges/other_charges.js');`.name LIMIT 50'; } // ********************* Get Charges **************************** @@ -433,14 +433,14 @@ cur_frm.cscript.calc_other_charges = function(doc , tname , fname , other_fname) doc = locals[doc.doctype][doc.name]; // Make Display Area - cur_frm.fields_dict['Other Charges Calculation'].disp_area.innerHTML = - 'Calculation Details for Other Charges:'; + cur_frm.fields_dict['wn.require('erpnext/setup/doctype/other_charges/other_charges.js'); Calculation'].disp_area.innerHTML = + 'Calculation Details for wn.require('erpnext/setup/doctype/other_charges/other_charges.js');:'; var cl = getchildren(tname, doc.name, fname); var tax = getchildren('RV Tax Detail', doc.name, other_fname,doc.doctype); // Make display table - var otc = make_table(cur_frm.fields_dict['Other Charges Calculation'].disp_area, + var otc = make_table(cur_frm.fields_dict['wn.require('erpnext/setup/doctype/other_charges/other_charges.js'); Calculation'].disp_area, cl.length + 1, tax.length + 1, '90%', [], { border:'1px solid #AAA', padding:'2px' }); $y(otc,{marginTop:'8px'}); @@ -795,10 +795,10 @@ cur_frm.cscript.allocated_percentage = function(doc, cdt, cdn) { // ================================================================================= cur_frm.cscript.validate = function(doc, cdt, cdn) { cur_frm.cscript.validate_items(doc); - var cl = getchildren('Other Charges', doc.name, 'other_charges'); + var cl = getchildren('wn.require('erpnext/setup/doctype/other_charges/other_charges.js');', doc.name, 'other_charges'); for(var i =0;i
\ - %(name)s\ - %(customer_name)s\ - \ + %(name)s\ + %(icon)s\ + %(customer_name)s\ + \ + \ + \ + \ + \ + \ + %(modified_date)s\ + %(currency)s %(grand_total_export)s\ + ', data)).addClass('list-row'); + } +} diff --git a/erpnext/selling/doctype/sales_order/sales_order.js b/erpnext/selling/doctype/sales_order/sales_order.js index a04423dd25..7d80607324 100644 --- a/erpnext/selling/doctype/sales_order/sales_order.js +++ b/erpnext/selling/doctype/sales_order/sales_order.js @@ -22,9 +22,10 @@ cur_frm.cscript.other_fname = "other_charges"; cur_frm.cscript.sales_team_fname = "sales_team"; -$import(Sales Common) -$import(Other Charges) -$import(SMS Control) +wn.require('erpnext/selling/doctype/sales_common/sales_common.js'); +wn.require('erpnext/setup/doctype/other_charges/other_charges.js'); +wn.require('erpnext/utilities/doctype/sms_control/sms_control.js'); +wn.require('erpnext/setup/doctype/notification_control/notification_control.js'); // ONLOAD @@ -352,7 +353,6 @@ cur_frm.fields_dict['territory'].get_query = function(doc,cdt,cdn) { return 'SELECT `tabTerritory`.`name`,`tabTerritory`.`parent_territory` FROM `tabTerritory` WHERE `tabTerritory`.`is_group` = "No" AND `tabTerritory`.`docstatus`!= 2 AND `tabTerritory`.%(key)s LIKE "%s" ORDER BY `tabTerritory`.`name` ASC LIMIT 50'; } -$import(Notification Control) cur_frm.cscript.on_submit = function(doc, cdt, cdn) { var args = { type: 'Sales Order', diff --git a/erpnext/setup/doctype/sales_partner/sales_partner.js b/erpnext/setup/doctype/sales_partner/sales_partner.js index 1194756412..588fc06c70 100644 --- a/erpnext/setup/doctype/sales_partner/sales_partner.js +++ b/erpnext/setup/doctype/sales_partner/sales_partner.js @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -$import(Contact Control) +wn.require('erpnext/setup/doctype/contact_control/contact_control.js'); cur_frm.cscript.onload = function(doc,dt,dn){ // history doctypes and scripts diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.js b/erpnext/stock/doctype/delivery_note/delivery_note.js index 1f5170be96..13922cb8a5 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.js +++ b/erpnext/stock/doctype/delivery_note/delivery_note.js @@ -20,9 +20,10 @@ cur_frm.cscript.fname = "delivery_note_details"; cur_frm.cscript.other_fname = "other_charges"; cur_frm.cscript.sales_team_fname = "sales_team"; -$import(Sales Common) -$import(Other Charges) -$import(SMS Control) +wn.require('erpnext/selling/doctype/sales_common/sales_common.js'); +wn.require('erpnext/setup/doctype/other_charges/other_charges.js'); +wn.require('erpnext/utilities/doctype/sms_control/sms_control.js'); +wn.require('erpnext/setup/doctype/notification_control/notification_control.js'); // ONLOAD // ================================================================================================ @@ -322,7 +323,6 @@ cur_frm.pformat.sales_order_no= function(doc, cdt, cdn){ return out; } -$import(Notification Control) cur_frm.cscript.on_submit = function(doc, cdt, cdn) { var args = { type: 'Delivery Note', diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js index 7ad9d91928..921eede2e9 100644 --- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js +++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js @@ -18,9 +18,10 @@ cur_frm.cscript.tname = "Purchase Receipt Detail"; cur_frm.cscript.fname = "purchase_receipt_details"; cur_frm.cscript.other_fname = "purchase_tax_details"; -$import(Purchase Common) -$import(Purchase Other Charges) -$import(SMS Control) +wn.require('erpnext/buying/doctype/purchase_other_charges/purchase_other_charges.js'); +wn.require('erpnext/buying/doctype/purchase_common/purchase_common.js'); +wn.require('erpnext/utilities/doctype/sms_control/sms_control.js'); +wn.require('erpnext/setup/doctype/notification_control/notification_control.js'); //========================== On Load ================================================================ cur_frm.cscript.onload = function(doc, cdt, cdn) { @@ -315,7 +316,6 @@ cur_frm.pformat.purchase_order_no = function(doc, cdt, cdn){ return out; } -$import(Notification Control) cur_frm.cscript.on_submit = function(doc, cdt, cdn) { var args = { type: 'Purchase Receipt', diff --git a/js/all-app.js b/js/all-app.js index a593e00323..cc3b99312c 100644 --- a/js/all-app.js +++ b/js/all-app.js @@ -2230,7 +2230,7 @@ if(user_roles.indexOf("System Manager")!=-1){$('.navbar .modules').append('
  • Date: Wed, 7 Mar 2012 18:19:41 +0530 Subject: [PATCH 3/4] new listing and changed wn.widgets.listing to wn.ui.listing --- build.json | 2 +- css/all-app.css | 75 +++++++++++- css/all-web.css | 1 - erpnext/buying/doctype/supplier/supplier.js | 4 +- erpnext/home/page/activity/activity.js | 2 +- .../home/page/event_updates/event_updates.js | 2 +- erpnext/home/page/my_company/my_company.js | 4 +- .../page/question_view/question_view.js | 2 +- .../page/questions/questions.js | 2 +- erpnext/selling/doctype/customer/customer.js | 4 +- .../selling/doctype/sales_order/listview.js | 19 ++- .../doctype/sales_partner/sales_partner.js | 4 +- erpnext/startup/js/modules.js | 2 +- .../doctype/support_ticket/support_ticket.js | 2 +- erpnext/utilities/page/messages/messages.js | 2 +- erpnext/website/doctype/blog/blog_page.js | 4 +- .../website/doctype/product/product_page.js | 2 +- erpnext/website/js/product_category.js | 2 +- erpnext/website/page/blog/blog.js | 2 +- erpnext/website/page/products/products.js | 2 +- js/all-app.js | 29 +---- js/all-web.js | 113 ++++++++++++++---- version.num | 2 +- 23 files changed, 202 insertions(+), 81 deletions(-) diff --git a/build.json b/build.json index 70f5636668..0a261d6615 100644 --- a/build.json +++ b/build.json @@ -62,6 +62,7 @@ "lib/css/legacy/dialog.css", "lib/css/legacy/tabs.css", "lib/css/legacy/sidebar.css", + "lib/css/ui/list.css", "lib/css/bootstrap/headings.css", "lib/css/bootstrap/buttons.css", "lib/css/bootstrap/navbar.css", @@ -131,7 +132,6 @@ "lib/js/wn/ui/dialog.js", "lib/js/legacy/widgets/dialog.js", "lib/js/legacy/widgets/listing.js", - "lib/js/wn/ui/listing.js", "lib/js/legacy/widgets/layout.js", "lib/js/legacy/widgets/tabbedpage.js", "lib/js/legacy/webpage/page_header.js", diff --git a/css/all-app.css b/css/all-app.css index 0dea8b7316..d9b5fb8278 100644 --- a/css/all-app.css +++ b/css/all-app.css @@ -239,7 +239,6 @@ div.std-footer-item { margin-bottom: -7px; max-width: 24px; } - /* * lib/css/legacy/messages.css */ @@ -1143,6 +1142,80 @@ div.psidebar div.section-item, div.psidebar .section-link { font-size: 11px; color: #666; } +/* + * lib/css/ui/list.css + */.hide { + display: none; +} + +.list-filters { + margin: 7px 0px; +} + +.wnlist .img-load { + display: none; + float: left; + margin-left: 11px; + margin-top: 8px; +} + +div.list-row { + border-bottom: 1px solid #eee; + padding: 3px 0px; +} +div.list-row:hover { + background-color: #eef +} + +div.show_filters { + display: none; +} + +div.filter_list { + padding: 13px; +} + +div.show_filters.well { + margin-top: 11px; + margin-bottom: 11px; +} + +div.filter_list .run_btn { + text-align: right; +} + +div.filter_list .add_filter { + margin: 3px 0px; +} + +div.list_filter { + margin: 7px 0px; +} + +div.list_filter input, div.list_filter select { + width: 130px; + margin-right: 7px; +} + +span.bar-outer { + display: inline-block; + margin: 0px 7px; + margin-top: 3px; + background-color: #fff; + border: 1px solid #aaa; + height: 10px; +} + +span.bar-inner { + display: inline-block; + background-color: #bdf; + height: 100%; + margin-bottom: 2px; +} +span.bar-complete { + background-color: green; +} + /* * lib/css/bootstrap/headings.css *//* heading from bootstrap */ diff --git a/css/all-web.css b/css/all-web.css index 36d9cda882..9acc25b1fd 100644 --- a/css/all-web.css +++ b/css/all-web.css @@ -239,7 +239,6 @@ div.std-footer-item { margin-bottom: -7px; max-width: 24px; } - /* * lib/css/legacy/messages.css */ diff --git a/erpnext/buying/doctype/supplier/supplier.js b/erpnext/buying/doctype/supplier/supplier.js index a348848a86..2ac62f2c11 100644 --- a/erpnext/buying/doctype/supplier/supplier.js +++ b/erpnext/buying/doctype/supplier/supplier.js @@ -54,7 +54,7 @@ cur_frm.cscript.refresh = function(doc,dt,dn) { cur_frm.cscript.make_address = function() { if(!cur_frm.address_list) { - cur_frm.address_list = new wn.widgets.Listing({ + cur_frm.address_list = new wn.ui.Listing({ parent: cur_frm.fields_dict['Address HTML'].wrapper, page_length: 2, new_doctype: "Address", @@ -96,7 +96,7 @@ cur_frm.cscript.make_address = function() { cur_frm.cscript.make_contact = function() { if(!cur_frm.contact_list) { - cur_frm.contact_list = new wn.widgets.Listing({ + cur_frm.contact_list = new wn.ui.Listing({ parent: cur_frm.fields_dict['Contact HTML'].wrapper, page_length: 2, new_doctype: "Contact", diff --git a/erpnext/home/page/activity/activity.js b/erpnext/home/page/activity/activity.js index 62604b79a8..83f018dc62 100644 --- a/erpnext/home/page/activity/activity.js +++ b/erpnext/home/page/activity/activity.js @@ -1,5 +1,5 @@ wn.pages['activity'].onload = function(wrapper) { - var list = new wn.widgets.Listing({ + var list = new wn.ui.Listing({ method: 'home.page.activity.activity.get_feed', parent: $('#activity-list'), render_row: function(row, data) { diff --git a/erpnext/home/page/event_updates/event_updates.js b/erpnext/home/page/event_updates/event_updates.js index d86a1d869c..2d9ecf6d9a 100644 --- a/erpnext/home/page/event_updates/event_updates.js +++ b/erpnext/home/page/event_updates/event_updates.js @@ -470,7 +470,7 @@ FeedList.prototype.make_list = function() { var me = this; this.list_area = $a(this.wrapper,'div') - this.list = new wn.widgets.Listing({ + this.list = new wn.ui.Listing({ parent: this.list_area, query: repl('select \ distinct t1.name, t1.feed_type, t1.doc_type, t1.doc_name, t1.subject, t1.modified_by, \ diff --git a/erpnext/home/page/my_company/my_company.js b/erpnext/home/page/my_company/my_company.js index 8217cc71c1..7b198df167 100644 --- a/erpnext/home/page/my_company/my_company.js +++ b/erpnext/home/page/my_company/my_company.js @@ -179,7 +179,7 @@ MemberList.prototype.make_list = function() { var me = this; this.lst_area = $a(this.list_wrapper, 'div'); - this.lst = new wn.widgets.Listing({ + this.lst = new wn.ui.Listing({ parent: this.lst_area, as_dict: 1, get_query: function() { @@ -692,7 +692,7 @@ MemberConversation = function(parent, uid, fullname) { this.my_messages_box = $a(this.lst_area, 'div', 'my-company-conversation-head', {marginBottom:'7px'}, 'Messages by everyone to me
    To send a message, click on the user on the left') } - this.lst = new wn.widgets.Listing({ + this.lst = new wn.ui.Listing({ parent: this.lst_area, as_dict: 1, no_result_message: (user==uid diff --git a/erpnext/knowledge_base/page/question_view/question_view.js b/erpnext/knowledge_base/page/question_view/question_view.js index 6d17713918..a193f16f11 100644 --- a/erpnext/knowledge_base/page/question_view/question_view.js +++ b/erpnext/knowledge_base/page/question_view/question_view.js @@ -131,7 +131,7 @@ KBAnswerList = function(args) { this.make_list = function() { - this.list = new wn.widgets.Listing({ + this.list = new wn.ui.Listing({ parent: me.parent, as_dict: 1, no_result_message: 'No answers yet, be the first one to answer!', diff --git a/erpnext/knowledge_base/page/questions/questions.js b/erpnext/knowledge_base/page/questions/questions.js index cbea1c29db..6b0ca25079 100644 --- a/erpnext/knowledge_base/page/questions/questions.js +++ b/erpnext/knowledge_base/page/questions/questions.js @@ -107,7 +107,7 @@ function KnowledgeBase(w) { this.list_area = $a(w, 'div', '', {marginRight:'13px'}) this.no_result = $a(w, 'div','help_box',{display:'none'},'No questions asked yet! Be the first one to ask') - this.list = new wn.widgets.Listing({ + this.list = new wn.ui.Listing({ parent: this.list_area, no_results_message: 'No questions found. Ask a new question!', as_dict: 1, diff --git a/erpnext/selling/doctype/customer/customer.js b/erpnext/selling/doctype/customer/customer.js index b5909c3c2e..d678077138 100644 --- a/erpnext/selling/doctype/customer/customer.js +++ b/erpnext/selling/doctype/customer/customer.js @@ -68,7 +68,7 @@ cur_frm.cscript.refresh = function(doc,dt,dn) { cur_frm.cscript.make_address = function() { if(!cur_frm.address_list) { - cur_frm.address_list = new wn.widgets.Listing({ + cur_frm.address_list = new wn.ui.Listing({ parent: cur_frm.fields_dict['Address HTML'].wrapper, page_length: 2, new_doctype: "Address", @@ -110,7 +110,7 @@ cur_frm.cscript.make_address = function() { cur_frm.cscript.make_contact = function() { if(!cur_frm.contact_list) { - cur_frm.contact_list = new wn.widgets.Listing({ + cur_frm.contact_list = new wn.ui.Listing({ parent: cur_frm.fields_dict['Contact HTML'].wrapper, page_length: 2, new_doctype: "Contact", diff --git a/erpnext/selling/doctype/sales_order/listview.js b/erpnext/selling/doctype/sales_order/listview.js index 0741841ce7..3c4fcb74c5 100644 --- a/erpnext/selling/doctype/sales_order/listview.js +++ b/erpnext/selling/doctype/sales_order/listview.js @@ -1,10 +1,19 @@ // render wn.doclistviews['Sales Order'] = { - fields: ["name", "owner", "modified", "customer_name", - "ifnull(per_delivered,0) as per_delivered", - "ifnull(per_billed,0) as per_billed", "currency", - "ifnull(grand_total_export,0) as grand_total_export", - "docstatus"], + fields: [ + { field: "name", name: "ID"}, + { field: "owner", name: "Created By"}, + { field: "modified", name: "Last Updated"}, + { field: "customer_name", name: "Customer", width:300}, + { field: "per_delivered", name: "% Delivered", + query: "ifnull(per_delivered,0) as per_delivered"}, + { field: "per_billed", name: "% Billed", + query: "ifnull(per_billed,0) as per_billed"}, + { field: "currency", name: "Currency"}, + { field: "grand_total_export", name: "Grand Total", + query:"ifnull(grand_total_export,0) as grand_total_export"}, + { field: "docstatus", name: "Status"} + ], render: function(row, data, listobj) { data.modified_date = dateutil.str_to_user(data.modified).split(' ')[0]; diff --git a/erpnext/setup/doctype/sales_partner/sales_partner.js b/erpnext/setup/doctype/sales_partner/sales_partner.js index 588fc06c70..0c315f6270 100644 --- a/erpnext/setup/doctype/sales_partner/sales_partner.js +++ b/erpnext/setup/doctype/sales_partner/sales_partner.js @@ -48,7 +48,7 @@ cur_frm.cscript.refresh = function(doc,dt,dn){ cur_frm.cscript.make_address = function() { if(!cur_frm.address_list) { - cur_frm.address_list = new wn.widgets.Listing({ + cur_frm.address_list = new wn.ui.Listing({ parent: cur_frm.fields_dict['Address HTML'].wrapper, page_length: 2, new_doctype: "Address", @@ -80,7 +80,7 @@ cur_frm.cscript.make_address = function() { cur_frm.cscript.make_contact = function() { if(!cur_frm.contact_list) { - cur_frm.contact_list = new wn.widgets.Listing({ + cur_frm.contact_list = new wn.ui.Listing({ parent: cur_frm.fields_dict['Contact HTML'].wrapper, page_length: 2, new_doctype: "Contact", diff --git a/erpnext/startup/js/modules.js b/erpnext/startup/js/modules.js index d43b0210b3..2e0e701197 100644 --- a/erpnext/startup/js/modules.js +++ b/erpnext/startup/js/modules.js @@ -61,7 +61,7 @@ erpnext.module_page.hide_links = function(wrapper) { erpnext.module_page.make_list = function(module, wrapper) { // make project listing - wrapper.list = new wn.widgets.Listing({ + wrapper.list = new wn.ui.Listing({ parent: $(wrapper).find('.reports-list').get(0), method: 'utilities.get_report_list', render_row: function(row, data) { diff --git a/erpnext/support/doctype/support_ticket/support_ticket.js b/erpnext/support/doctype/support_ticket/support_ticket.js index 86264a6433..ce6685540d 100644 --- a/erpnext/support/doctype/support_ticket/support_ticket.js +++ b/erpnext/support/doctype/support_ticket/support_ticket.js @@ -81,7 +81,7 @@ $.extend(cur_frm.cscript, { }, null, -1) // render thread - cs.thread_list = new wn.widgets.Listing({ + cs.thread_list = new wn.ui.Listing({ parent: cur_frm.fields_dict['Thread HTML'].wrapper, no_result_message: 'No responses yet', get_query: function() { diff --git a/erpnext/utilities/page/messages/messages.js b/erpnext/utilities/page/messages/messages.js index 6937796168..7e74fef657 100644 --- a/erpnext/utilities/page/messages/messages.js +++ b/erpnext/utilities/page/messages/messages.js @@ -91,7 +91,7 @@ erpnext.messages = { return user; }, make_list: function() { - erpnext.messages.list = new wn.widgets.Listing({ + erpnext.messages.list = new wn.ui.Listing({ parent: $('#message-list').get(0), method: 'utilities.page.messages.messages.get_list', args: { diff --git a/erpnext/website/doctype/blog/blog_page.js b/erpnext/website/doctype/blog/blog_page.js index 76cbf81c72..d419a0b5e1 100644 --- a/erpnext/website/doctype/blog/blog_page.js +++ b/erpnext/website/doctype/blog/blog_page.js @@ -21,7 +21,7 @@ pscript['onload_{{ doc.name }}'] = function(wrapper) { var side = $(wrapper).find('.web-side-section') .append('

    Recent Posts

    ').get(0); - wrapper.recent_list = new wn.widgets.Listing({ + wrapper.recent_list = new wn.ui.Listing({ parent: side, query: 'select name, title, left(content, 100) as content from tabBlog\ where ifnull(published,1)=1', @@ -39,7 +39,7 @@ pscript['onload_{{ doc.name }}'] = function(wrapper) { // comments $(wrapper).find('.web-main-section').append('

    Comments

    '); - wrapper.comment_list = new wn.widgets.Listing({ + wrapper.comment_list = new wn.ui.Listing({ parent: $(wrapper).find('.web-main-section').get(0), query: 'select comment, comment_by_fullname, modified\ from `tabComment Widget Record` where comment_doctype="Page"\ diff --git a/erpnext/website/doctype/product/product_page.js b/erpnext/website/doctype/product/product_page.js index 0f0c56b0ed..926ef69f87 100644 --- a/erpnext/website/doctype/product/product_page.js +++ b/erpnext/website/doctype/product/product_page.js @@ -30,7 +30,7 @@ pscript["onload_{{ doc.page_name }}"] = function(wrapper) { }); // similar products - wrapper.similar = new wn.widgets.Listing({ + wrapper.similar = new wn.ui.Listing({ parent: $(wrapper).find('.similar-products').get(0), hide_refresh: true, page_length: 5, diff --git a/erpnext/website/js/product_category.js b/erpnext/website/js/product_category.js index 9e0c7f0a51..956d7a65d3 100644 --- a/erpnext/website/js/product_category.js +++ b/erpnext/website/js/product_category.js @@ -18,7 +18,7 @@ erpnext.product_item_group = {} erpnext.make_product_categories = function(wrapper) { - wrapper.category_list = new wn.widgets.Listing({ + wrapper.category_list = new wn.ui.Listing({ parent: $(wrapper).find('.more-categories').get(0), query: 'select label, count(t2.name) as items, t1.item_group \ from `tabProduct Group` t1, `tabProduct` t2, tabItem t3\ diff --git a/erpnext/website/page/blog/blog.js b/erpnext/website/page/blog/blog.js index 9ca7392db4..bc7aec44b9 100644 --- a/erpnext/website/page/blog/blog.js +++ b/erpnext/website/page/blog/blog.js @@ -16,7 +16,7 @@ pscript.onload_blog = function(wrapper) { - wrapper.blog_list = new wn.widgets.Listing({ + wrapper.blog_list = new wn.ui.Listing({ parent: $(wrapper).find('.web-main-section').get(0), query: 'select tabBlog.name, title, left(content, 300) as content, tabBlog.modified, \ ifnull(first_name, "") as first_name, ifnull(last_name, "") as last_name \ diff --git a/erpnext/website/page/products/products.js b/erpnext/website/page/products/products.js index 7af551e92c..09ccba0ed2 100644 --- a/erpnext/website/page/products/products.js +++ b/erpnext/website/page/products/products.js @@ -57,7 +57,7 @@ erpnext.products.get_group = function() { } erpnext.products.make_product_list = function(wrapper) { - wrapper.mainlist = new wn.widgets.Listing({ + wrapper.mainlist = new wn.ui.Listing({ parent: $(wrapper).find('.web-main-section').get(0), run_btn: $(wrapper).find('.products-search .btn').get(0), hide_refresh: true, diff --git a/js/all-app.js b/js/all-app.js index cc3b99312c..14491a81a5 100644 --- a/js/all-app.js +++ b/js/all-app.js @@ -832,33 +832,6 @@ if((this.start+nr)==this.max_len||(!this.max_len&&nr=this.page_length)$ds(this.more_button_area);}else{if(this.start==0){$dh(this.results_area);$ds(this.no_results_area);}} -if(this.onrun)this.onrun();if(this.opts.onrun)this.opts.onrun();if(this.opts.callback)this.opts.callback(r);} -this.add_row=function(){return $a(this.results_area,'div','',(opts.cell_style?opts.cell_style:{padding:'3px 0px'}));} -this.run=function(callback,append){if(callback) -this.onrun=callback;if(!append) -this.start=0;if(!this.opts.method){this.query=this.opts.get_query?this.opts.get_query():this.opts.query;this.add_limits();var args={query_max:this.query_max||this.opts.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.opts.args) -$.extend(args,this.opts.args) -if(this.opts.get_args){$.extend(args,this.opts.get_args());} -if(this.loading_img)$di(this.loading_img);wn.call({method:this.opts.method||'webnotes.widgets.query_builder.runquery',args:args,callback:function(r,rt){me.make_results(r,rt)},no_spinner:this.opts.no_loading,btn:this.opts.run_btn});} -this.refresh=this.run;this.add_limits=function(){this.query+=' LIMIT '+this.start+','+(this.page_length+1);} -if(opts)this.make();} /* * lib/js/legacy/widgets/layout.js */ @@ -2191,7 +2164,7 @@ $(document).bind('startup',function(){erpnext.startup.start();}); */ wn.provide('erpnext.module_page');erpnext.module_page.setup_page=function(module,wrapper){erpnext.module_page.hide_links(wrapper);erpnext.module_page.make_list(module,wrapper);$(wrapper).find("a[title]").tooltip({delay:{show:500,hide:100}});} erpnext.module_page.hide_links=function(wrapper){$(wrapper).find('[href*="List/"]').each(function(){var href=$(this).attr('href');var dt=href.split('/')[1];if(wn.boot.profile.all_read.indexOf(get_label_doctype(dt))==-1){var txt=$(this).text();$(this).parent().css('color','#999').html(txt);}});$(wrapper).find('[data-doctype]').each(function(){var dt=$(this).attr('data-doctype');if(wn.boot.profile.all_read.indexOf(dt)==-1){var txt=$(this).text();$(this).parent().css('color','#999').html(txt);}});$(wrapper).find('[href*="Form/"]').each(function(){var href=$(this).attr('href');var dt=href.split('/')[1];if(wn.boot.profile.all_read.indexOf(get_label_doctype(dt))==-1){var txt=$(this).text();$(this).parent().css('color','#999').html(txt);}});} -erpnext.module_page.make_list=function(module,wrapper){wrapper.list=new wn.widgets.Listing({parent:$(wrapper).find('.reports-list').get(0),method:'utilities.get_report_list',render_row:function(row,data){if(!data.parent_doc_type)data.parent_doc_type=data.doc_type;$(row).html(repl('\ %(criteria_name)s',data))},args:{module:module},no_refresh:true,callback:function(r){erpnext.module_page.hide_links(wrapper)}});wrapper.list.run();} /* diff --git a/js/all-web.js b/js/all-web.js index cd2b345a12..ac2e7c1bc6 100644 --- a/js/all-web.js +++ b/js/all-web.js @@ -670,30 +670,97 @@ this.widgets[d[1]]=b;}} /* * lib/js/wn/ui/listing.js */ -wn.widgets.Listing=function(opts){this.opts=opts;this.page_length=20;this.btns={};this.start=0;var me=this;this.make=function(opts){if(this.opts.parent.jquery) -this.opts.parent=this.opts.parent.get(0);this.wrapper=$a(this.opts.parent,'div');this.filters_area=$a(this.wrapper,'div','listing-filters');this.toolbar_area=$a(this.wrapper,'div','listing-toolbar');this.results_area=$a(this.wrapper,'div','listing-results');this.more_button_area=$a(this.wrapper,'div','listing-more');this.no_results_area=$a(this.wrapper,'div','help_box',{display:'none'},(this.opts.no_result_message?this.opts.no_result_message:'No results'));if(opts)this.opts=opts;this.page_length=this.opts.page_length?this.opts.page_length:this.page_length;this.make_toolbar();this.make_filters();this.make_more_button();} -this.make_filters=function(){if(this.opts.filters){$ds(this.filters_area);this.filters=new wn.widgets.FieldGroup(this.filters_area,this.opts.fields);}} -this.make_toolbar=function(){if(!(this.opts.hide_refresh||this.opts.no_refresh)){if(this.opts.title){$a(this.toolbar_area,'h3','',{display:'inline-block',marginRight:'15px'},this.opts.title);} -this.ref_img=$a(this.toolbar_area,'span','link_type',{color:'#888'},'[refresh]');this.ref_img.onclick=function(){me.run();} -this.loading_img=$a(this.toolbar_area,'img','lib/images/ui/button-load.gif',{display:'none',marginLeft:'3px',marginBottom:'-2px'});} -if(this.opts.new_doctype){this.new_btn=$btn(this.toolbar_area,'New '+get_doctype_label(this.opts.new_doctype),function(){newdoc(me.opts.new_doctype,me.opts.new_doc_onload,me.opts.new_doc_indialog,me.opts.new_doc_onsave);},{marginLeft:'7px'});}} -this.make_more_button=function(){this.more_btn=$btn(this.more_button_area,'More...',function(){me.more_btn.set_working();me.run(function(){me.more_btn.done_working();},1);},'',0,1);$y(this.more_btn.loading_img,{marginBottom:'0px'});} -this.clear=function(){this.results_area.innerHTML='';this.table=null;$ds(this.results_area);$dh(this.no_results_area);} -this.make_results=function(r,rt){if(this.start==0)this.clear();$dh(this.more_button_area);if(this.loading_img)$dh(this.loading_img) -if(r.message)r.values=r.message;if(r.values&&r.values.length){this.values=r.values;var m=Math.min(r.values.length,this.page_length);for(var i=0;i=this.page_length)$ds(this.more_button_area);}else{if(this.start==0){$dh(this.results_area);$ds(this.no_results_area);}} -if(this.onrun)this.onrun();if(this.opts.onrun)this.opts.onrun();if(this.opts.callback)this.opts.callback(r);} -this.add_row=function(){return $a(this.results_area,'div','',(opts.cell_style?opts.cell_style:{padding:'3px 0px'}));} -this.run=function(callback,append){if(callback) -this.onrun=callback;if(!append) -this.start=0;if(!this.opts.method){this.query=this.opts.get_query?this.opts.get_query():this.opts.query;this.add_limits();var args={query_max:this.query_max||this.opts.query_max||'',as_dict:1} +wn.provide('wn.ui');wn.ui.Listing=Class.extend({init:function(opts){this.opts=opts||{};this.page_length=20;this.start=0;this.data=[];if(opts){this.make();}},prepare_opts:function(){if(this.opts.new_doctype) +this.opts.new_doctype=get_doctype_label(this.opts.new_doctype);},make:function(opts){if(opts){this.opts=opts;} +$.extend(this,this.opts);this.prepare_opts();$(this.parent).html(repl('\ +
    \ +
    \ + \ + List\ + \ + Grid\ +
    \ + \ +

    %(title)s

    \ + \ + \ +
    \ +
    \ +
    \ +
    \ +
    \ + \ +
    \ +
    \ +
    \ + \ +
    \ + %(no_result_message)s\ +
    \ + \ +
    \ +
    \ +
    \ +
    \ + \ +
    \ +
    \ +
    \ + \ + ',this.opts));this.$w=$(this.parent).find('.wnlist');this.set_events();this.make_filters();},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});});this.$w.find('.btn-list').click(function(){me.show_view($(this),me.$w.find('.result-list'),me.$w.find('.btn-grid'),me.$w.find('.result-grid'))});this.$w.find('.btn-grid').click(function(){me.show_view($(this),me.$w.find('.result-grid'),me.$w.find('.btn-list'),me.$w.find('.result-list'))});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').toggle(false);} +if(!me.show_filters){this.$w.find('.btn-filter').toggle(false);} +if(this.hide_refresh||this.no_refresh){this.$w.find('.btn-refresh').toggle(false);} +if(this.show_grid){this.$w.find('.select-view').toggle(true);}},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.$w.find('.img-load').toggle(true);wn.call({method:this.opts.method||'webnotes.widgets.query_builder.runquery',args:this.get_call_args(),callback:function(r){me.$w.find('.img-load').toggle(false);me.render_results(r)},no_spinner:this.opts.no_loading,btn:this.run_btn});},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.opts.args) -$.extend(args,this.opts.args) -if(this.opts.get_args){$.extend(args,this.opts.get_args());} -if(this.loading_img)$di(this.loading_img);wn.call({method:this.opts.method||'webnotes.widgets.query_builder.runquery',args:args,callback:function(r,rt){me.make_results(r,rt)},no_spinner:this.opts.no_loading,btn:this.opts.run_btn});} -this.refresh=this.run;this.add_limits=function(){this.query+=' LIMIT '+this.start+','+(this.page_length+1);} -if(opts)this.make();} +if(this.args) +$.extend(args,this.args) +if(this.get_args){$.extend(args,this.get_args());} +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);if(this.show_grid){this.render_grid();}}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_grid:function(){$.each(this.columns,function(i,c){if(!c.id)c.id=c.field;}) +wn.require('lib/js/lib/slickgrid/slick.grid.css');wn.require('lib/js/lib/slickgrid/slick-default-theme.css');wn.require('lib/js/lib/slickgrid/jquery.event.drag.min.js');wn.require('lib/js/lib/slickgrid/slick.core.js');wn.require('lib/js/lib/slickgrid/slick.grid.js');var options={enableCellNavigation:true,enableColumnReorder:false};grid=new Slick.Grid(this.$w.find('.result-grid').css('border','1px solid grey').css('height','500px').get(0),this.data,this.columns,options);},render_list:function(values){var m=Math.min(values.length,this.page_length);for(var i=0;i=this.page_length) +this.$w.find('.btn-more').toggle(true);},add_row:function(){return this.$w.find('.result-list').append('
    ').find('.list-row:last').get(0);},refresh:function(){this.run();},add_limits:function(){this.query+=' LIMIT '+this.start+','+(this.page_length+1);}});wn.ui.FilterList=Class.extend({init:function(opts){$.extend(this,opts);this.filters=[];this.$w=this.$parent;this.set_events();},set_events:function(){var me=this;this.listobj.$w.find('.btn-filter').bind('click',function(){me.$w.find('.show_filters').slideToggle();if(!me.filters.length) +me.add_filter();});this.$w.find('.add-filter-btn').bind('click',function(){me.add_filter();});},add_filter:function(fieldname,condition,value){this.filters.push(new wn.ui.Filter({flist:this,fieldname:fieldname,condition:condition,value:value}));},get_filters:function(){var values=[];$.each(this.filters,function(i,f){if(f.filter_field) +values.push(f.get_value());}) +return values;},update_filters:function(){var fl=[];$.each(this.filters,function(i,f){if(f.filter_field)fl.push(f);}) +this.filters=fl;}});wn.ui.Filter=Class.extend({init:function(opts){$.extend(this,opts);this.doctype=this.flist.doctype;this.fields_by_name={};this.make();this.make_options();this.set_events();},make:function(){this.flist.$w.find('.filter_area').append('
    \ + \ + \ + \ + ×\ +
    ');this.$w=this.flist.$w.find('.list_filter:last-child');this.$select=this.$w.find('.fieldname_select');},make_options:function(){if(this.filter_fields){for(var i in this.filter_fields) +this.add_field_option(this.filter_fields[i])}else{this.render_field_select();}},set_events:function(){var me=this;this.$w.find('.fieldname_select').bind('change',function(){me.set_field(this.value);});this.$w.find('a.close').bind('click',function(){me.$w.css('display','none');var value=me.filter_field.get_value();me.filter_field=null;if(!me.flist.get_filters().length){me.flist.$w.find('.set_filters').toggle(true);me.flist.$w.find('.show_filters').toggle(false);} +if(value){me.flist.listobj.run();} +me.flist.update_filters();return false;});if(me.fieldname){me.set_field(me.fieldname);if(me.condition)me.$w.find('.condition').val(me.condition) +if(me.value)me.filter_field.set_input(me.value)}else{me.set_field('name');}},render_field_select:function(){var me=this;me.table_fields=[];var std_filters=[{fieldname:'name',fieldtype:'Data',label:'ID',parent:me.doctype},{fieldname:'modified',fieldtype:'Date',label:'Last Modified',parent:me.doctype},{fieldname:'owner',fieldtype:'Data',label:'Created By',parent:me.doctype},{fieldname:'_user_tags',fieldtype:'Data',label:'Tags',parent:me.doctype}];$.each(std_filters.concat(fields_list[me.doctype]),function(i,df){me.add_field_option(df);});$.each(me.table_fields,function(i,table_df){if(table_df.options){$.each(fields_list[table_df.options],function(i,df){me.add_field_option(df);});}})},add_field_option:function(df){var me=this;if(me.doctype&&df.parent==me.doctype){var label=df.label;var table=get_label_doctype(me.doctype);if(df.fieldtype=='Table')me.table_fields.push(df);}else{var label=df.label+' ('+df.parent+')';var table=df.parent;} +if(wn.model.no_value_type.indexOf(df.fieldtype)==-1&&!me.fields_by_name[df.fieldname]){this.$select.append($('