Merge branch 'hotfix'

This commit is contained in:
Nabin Hait 2016-08-26 12:41:05 +05:30
commit 88655111a7
4 changed files with 23 additions and 16 deletions

View file

@ -13,7 +13,7 @@ import os, sys, importlib, inspect, json
from .exceptions import *
from .utils.jinja import get_jenv, get_template, render_template
__version__ = "7.0.28"
__version__ = "7.0.29"
local = Local()

View file

@ -11,7 +11,7 @@ import frappe.permissions
from frappe.utils import flt, cint, getdate, get_datetime, get_time, make_filter_tuple, get_filter
from frappe import _
from frappe.model import optional_fields
from frappe.model.utils.list_settings import update_list_settings
from frappe.model.utils.list_settings import get_list_settings, update_list_settings
class DatabaseQuery(object):
def __init__(self, doctype):
@ -492,14 +492,13 @@ class DatabaseQuery(object):
def update_list_settings(self):
# update list settings if new search
if not cint(self.limit_start) or cint(self.limit_page_length) != 20:
list_settings = {
'filters': self.filters,
'limit': self.limit_page_length,
'order_by': self.order_by
}
if self.save_list_settings_fields:
list_settings['fields'] = self.fields
list_settings = json.loads(get_list_settings(self.doctype) or '{}')
list_settings['filters'] = self.filters
list_settings['limit'] = self.limit_page_length
list_settings['order_by'] = self.order_by
update_list_settings(self.doctype, list_settings)
if self.save_list_settings_fields:
list_settings['fields'] = self.fields
update_list_settings(self.doctype, list_settings)

View file

@ -24,7 +24,7 @@
</div>
<div class="result-list"></div>
</div>
<div class="list-paging-area" style="display: none;">
<div class="list-paging-area">
<div class="row">
<div class="col-xs-6">
<button class="btn btn-default btn-more btn-sm">{%= _more %}...</button>

View file

@ -92,16 +92,24 @@ frappe.ui.Listing = Class.extend({
// next page
this.$w.find('.btn-more').click(function() {
me.run({append: true });
me.run(true);
});
this.$w.find(".btn-group-paging .btn").click(function() {
me.page_length = cint($(this).attr("data-value"));
me.$w.find(".btn-group-paging .btn-info").removeClass("btn-info");
$(this).addClass("btn-info");
me.run({append: true});
// always reset when changing list page length
me.run();
});
// select the correct page length
if(this.opts.page_length != 20) {
this.$w.find(".btn-group-paging .btn-info").removeClass("btn-info");
this.$w.find(".btn-group-paging .btn[data-value='"+ this.opts.page_length +"']").addClass('btn-info');
}
// title
if(this.title) {
this.$w.find('h3').html(this.title).toggle(true);
@ -297,7 +305,7 @@ frappe.ui.Listing = Class.extend({
render_results: function(r) {
if(this.start===0) this.clear();
this.$w.find('.list-paging-area, .list-loading').toggle(false);
this.$w.find('.btn-more, .list-loading').toggle(false);
if(r.message) {
r.values = this.get_values_from_response(r.message);
@ -394,7 +402,7 @@ frappe.ui.Listing = Class.extend({
},
update_paging: function(values) {
if(values.length >= this.page_length) {
this.$w.find('.list-paging-area').toggle(true);
this.$w.find('.btn-more').toggle(true);
this.start += this.page_length;
}
},