diff --git a/build.json b/build.json
index 70f56366684..0a261d66159 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 0dea8b73165..d9b5fb8278d 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 36d9cda8825..9acc25b1fd9 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 a348848a86a..2ac62f2c114 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 62604b79a82..83f018dc625 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 d86a1d869cd..2d9ecf6d9ab 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 8217cc71c1a..7b198df1671 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 6d17713918b..a193f16f113 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 cbea1c29db0..6b0ca25079d 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 b5909c3c2ef..d6780771387 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 0741841ce71..3c4fcb74c52 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 588fc06c709..0c315f62705 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 d43b0210b35..2e0e701197b 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 86264a64339..ce6685540d0 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 69377961685..7e74fef6579 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 76cbf81c726..d419a0b5e19 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 0f0c56b0ed8..926ef69f873 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 9e0c7f0a510..956d7a65d3d 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 9ca7392db42..bc7aec44b9b 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 7af551e92cf..09ccba0ed24 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 cc3b99312c8..14491a81a55 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 cd2b345a122..ac2e7c1bc64 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('\
+ \
+
\
+ \
+
%(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($('