Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
pdvyas committed Apr 21, 2014
2 parents ba2ba60 + be5f4e6 commit f54eb3c
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 40 deletions.
2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"base_template": "lib/website/templates/base.html",
"framework_version": "3.13.2",
"framework_version": "3.13.3",
"modules": {
"Calendar": {
"color": "#2980b9",
Expand Down
78 changes: 39 additions & 39 deletions public/js/wn/ui/listing.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
// MIT License. See license.txt
// MIT License. See license.txt

// new re-factored Listing object
// removed rarely used functionality
Expand Down Expand Up @@ -59,7 +59,7 @@ wn.ui.Listing = Class.extend({
}
this.prepare_opts();
$.extend(this, this.opts);

$(this.parent).html(repl('\
<div class="wnlist">\
<h3 class="title hide">%(title)s</h3>\
Expand Down Expand Up @@ -101,13 +101,13 @@ wn.ui.Listing = Class.extend({
', this.opts));
this.$w = $(this.parent).find('.wnlist');
this.set_events();

if(this.appframe) {
this.$w.find('.list-toolbar-wrapper').toggle(false);
}
}

if(this.show_filters) {
this.make_filters();
this.make_filters();
}
},
add_button: function(label, click, icon) {
Expand All @@ -132,48 +132,48 @@ wn.ui.Listing = Class.extend({
},
set_events: function() {
var me = this;

// next page
this.$w.find('.btn-more').click(function() {
me.run({append: true });
});

// title
if(this.title) {
this.$w.find('h3').html(this.title).toggle(true);
}

// hide-refresh
if(!(this.hide_refresh || this.no_refresh)) {
this.add_button('Refresh', function() {
me.run();
}, 'icon-refresh');

}

// new
if(this.new_doctype) {
if(this.appframe) {
this.appframe.set_title_right("<i class='icon-plus'></i> New", function() {
this.appframe.set_title_right("<i class='icon-plus'></i> New", function() {
(me.custom_new_doc || me.make_new_doc).apply(me, [me.new_doctype]); });
}
this.add_button(wn._('New'), function() {
this.add_button(wn._('New'), function() {
(me.custom_new_doc || me.make_new_doc).apply(me, [me.new_doctype]);
}, 'icon-plus');
}
}

// hide-filter
if(me.show_filters) {
this.add_button(wn._('Filter'), function() {
me.filter_list.show_filters();
}, 'icon-search').addClass('btn-filter');
}

if(me.no_toolbar || me.hide_toolbar) {
me.$w.find('.list-toolbar-wrapper').toggle(false);
}
},

make_new_doc: function(doctype) {
var me = this;
wn.model.with_doctype(doctype, function() {
Expand All @@ -190,7 +190,7 @@ wn.ui.Listing = Class.extend({

make_filters: function() {
this.filter_list = new wn.ui.FilterList({
listobj: this,
listobj: this,
$parent: this.$w.find('.list-filters').toggle(true),
doctype: this.doctype,
filter_fields: this.filter_fields
Expand All @@ -210,15 +210,15 @@ wn.ui.Listing = Class.extend({
this.start = 0;
if(this.onreset) this.onreset();
}

if(!me.opts.no_loading)
me.set_working(true);

return wn.call({
method: this.opts.method || 'webnotes.widgets.query_builder.runquery',
type: "GET",
args: this.get_call_args(),
callback: function(r) {
callback: function(r) {
if(!me.opts.no_loading)
me.set_working(false);
me.dirty = false;
Expand All @@ -235,7 +235,7 @@ wn.ui.Listing = Class.extend({
if(!this.method) {
var query = this.get_query ? this.get_query() : this.query;
query = this.add_limits(query);
var args={
var args={
query_max: this.query_max,
as_dict: 1
}
Expand All @@ -246,19 +246,19 @@ wn.ui.Listing = Class.extend({
limit_page_length: this.page_length
}
}

// append user-defined arguments
if(this.args)
$.extend(args, this.args)

if(this.get_args) {
$.extend(args, this.get_args());
}
return args;
return args;
},
render_results: function(r) {
if(this.start===0) this.clear();

this.$w.find('.btn-more').toggle(false);

if(r.message) {
Expand All @@ -275,16 +275,16 @@ wn.ui.Listing = Class.extend({

var msg = this.get_no_result_message
? this.get_no_result_message()
: (this.no_result_message
: (this.no_result_message
? this.no_result_message
: wn._("Nothing to show"));

this.$w.find('.no-result')
.html(msg)
.toggle(true);
}
}

// callbacks
if(this.onrun) this.onrun();
if(this.callback) this.callback(r);
Expand All @@ -293,7 +293,7 @@ wn.ui.Listing = Class.extend({

get_values_from_response: function(data) {
// make dictionaries from keys and values
if(data.keys) {
if(data.keys && $.isArray(data.keys)) {
var values = [];
$.each(data.values, function(row_idx, row) {
var new_row = {};
Expand All @@ -308,28 +308,28 @@ wn.ui.Listing = Class.extend({
}
},

render_list: function(values) {
render_list: function(values) {
var m = Math.min(values.length, this.page_length);
this.data = values;
if(this.filter_list)
this.filter_values = this.filter_list.get_filters();

// render the rows
for(var i=0; i < m; i++) {
this.render_row(this.add_row(), values[i], this, i);
}
},
update_paging: function(values) {
if(values.length >= this.page_length) {
this.$w.find('.btn-more').toggle(true);
this.$w.find('.btn-more').toggle(true);
this.start += this.page_length;
}
},
add_row: function() {
return $('<div class="list-row">').appendTo(this.$w.find('.result-list')).get(0);
},
refresh: function() {
this.run();
refresh: function() {
this.run();
},
add_limits: function(query) {
query += ' LIMIT ' + this.start + ',' + (this.page_length+1);
Expand All @@ -347,7 +347,7 @@ wn.ui.Listing = Class.extend({
// second filter set for this field
if(fieldname=='_user_tags') {
// and for tags
this.filter_list.add_filter(doctype, fieldname,
this.filter_list.add_filter(doctype, fieldname,
'like', '%' + label);
} else {
// or for rest using "in"
Expand All @@ -358,11 +358,11 @@ wn.ui.Listing = Class.extend({
// no filter for this item,
// setup one
if(['_user_tags', '_comments'].indexOf(fieldname)!==-1) {
this.filter_list.add_filter(doctype, fieldname,
this.filter_list.add_filter(doctype, fieldname,
'like', '%' + label);
} else {
this.filter_list.add_filter(doctype, fieldname, '=', label);
}
}
}
});
}
});

0 comments on commit f54eb3c

Please sign in to comment.