livelist-rails 0.0.8 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,26 @@
|
|
1
|
+
# 0.0.8
|
2
|
+
* make counts behave properly, along with some api changes required
|
3
|
+
to make counts work properly
|
4
|
+
|
5
|
+
# 0.0.7
|
6
|
+
* changes filters method to filter_for, and filters must be defined
|
7
|
+
in separate method calls, i.e.:
|
8
|
+
|
9
|
+
filter_for :status
|
10
|
+
filter_for :state
|
11
|
+
|
12
|
+
as opposed to:
|
13
|
+
|
14
|
+
filters :status, :state
|
15
|
+
|
16
|
+
this is necessary to allow us to pass options on a per filter
|
17
|
+
basis
|
18
|
+
|
19
|
+
* collection option for filter_for method. Passing an option called
|
20
|
+
collection to the filter_for method with the value of the option
|
21
|
+
being an array of hashes, models, etc., will override the default list
|
22
|
+
of filter options if formatted correctly
|
23
|
+
|
1
24
|
# 0.0.6
|
2
25
|
* cache counts query per filter, per request
|
3
26
|
* cache option_objects query per filter, per request
|
@@ -36,11 +36,7 @@ class window.List extends Utilities
|
|
36
36
|
|
37
37
|
$(@renderTo).bind(@eventName, (event, params) => @fetch(presets: null, page: params?.page))
|
38
38
|
|
39
|
-
|
40
|
-
if @filters.useCookies && cookie
|
41
|
-
presets = JSON.parse(cookie)
|
42
|
-
else
|
43
|
-
presets = @filters.presets
|
39
|
+
presets = @filters.presets()
|
44
40
|
@fetch(presets: presets)
|
45
41
|
|
46
42
|
displayFetchingIndication: => $(@renderTo).addClass(@fetchingIndicationClass)
|
@@ -50,55 +46,71 @@ class window.List extends Utilities
|
|
50
46
|
@data = data
|
51
47
|
@render()
|
52
48
|
@pagination.render(@data)
|
53
|
-
@filters.filters = _.pluck( @data.filters, 'filter_slug' )
|
54
49
|
@filters.render(@data)
|
55
50
|
|
56
|
-
selections: ->
|
57
|
-
filters = {}
|
58
|
-
_.each( @filters.filters, (filter) => filters[filter] = @filters.filterSelections( filter ) )
|
59
|
-
filters
|
60
|
-
|
61
51
|
fetch: (options) ->
|
62
52
|
@fetchRequest.abort() if @fetchRequest
|
63
53
|
searchTerm = @search.searchTerm()
|
64
|
-
params = {
|
54
|
+
params = {}
|
55
|
+
params.filters = @filters.setPresets(options.presets)
|
65
56
|
|
66
|
-
if
|
67
|
-
params.
|
68
|
-
|
69
|
-
|
70
|
-
else
|
71
|
-
params.filters = options.presets
|
57
|
+
if searchTerm
|
58
|
+
params.q = searchTerm
|
59
|
+
if options.page
|
60
|
+
params.page = options.page
|
72
61
|
|
73
|
-
if searchTerm then params.q = searchTerm
|
74
|
-
if options.page then params.page = options.page
|
75
62
|
@fetchRequest = $.ajax(
|
76
|
-
url: @urlPrefix
|
77
|
-
dataType: 'json'
|
78
|
-
data: params
|
79
|
-
type: @httpMethod
|
80
|
-
beforeSend: @displayFetchingIndication
|
81
|
-
success: @renderIndex
|
63
|
+
url : @urlPrefix
|
64
|
+
dataType : 'json'
|
65
|
+
data : params
|
66
|
+
type : @httpMethod
|
67
|
+
beforeSend : @displayFetchingIndication
|
68
|
+
success : @renderIndex
|
82
69
|
)
|
83
70
|
|
84
71
|
render: ->
|
85
72
|
partials = {}
|
86
73
|
partials[@resourceNameSingular] = @listItemTemplate
|
87
|
-
|
74
|
+
listHTML = Mustache.to_html(@listTemplate, @data, partials)
|
75
|
+
$(@renderTo).html( listHTML )
|
88
76
|
@removeFetchingIndication()
|
89
77
|
|
90
|
-
window.LiveList.version = '0.0.
|
78
|
+
window.LiveList.version = '0.0.4'
|
91
79
|
|
92
80
|
class window.Filters extends Utilities
|
93
81
|
constructor: (globalOptions, options = {}) ->
|
94
82
|
@setOptions(globalOptions)
|
95
83
|
@filters = if options.presets then _.keys(options.presets) else []
|
96
|
-
|
84
|
+
@initializeCookies()
|
97
85
|
@setOptions(options)
|
98
86
|
$('input.filter_option', @renderTo).live( 'change', => $(@listSelector).trigger(@eventName) )
|
99
87
|
$(@advancedOptionsToggleSelector).click(@handleAdvancedOptionsClick)
|
100
88
|
|
101
|
-
|
89
|
+
initializeCookies: ->
|
90
|
+
if jQuery.cookie && @useCookies && @cookieName
|
91
|
+
@cookieName = 'livelist_filter_presets'
|
92
|
+
|
93
|
+
presets: ->
|
94
|
+
cookie = jQuery.cookie(@cookieName) if jQuery.cookie && @useCookies
|
95
|
+
if @useCookies && cookie
|
96
|
+
JSON.parse(cookie)
|
97
|
+
else
|
98
|
+
@presets
|
99
|
+
|
100
|
+
setPresets: (presets) ->
|
101
|
+
filters = {}
|
102
|
+
if jQuery.isEmptyObject(presets)
|
103
|
+
filters = @selections()
|
104
|
+
@setCookie() if jQuery.cookie
|
105
|
+
else
|
106
|
+
filters = presets
|
107
|
+
filters
|
108
|
+
|
109
|
+
setCookie: (params_filters) ->
|
110
|
+
if not jQuery.isEmptyObject(params_filters)
|
111
|
+
jQuery.cookie(@cookieName, JSON.stringify(params_filters))
|
112
|
+
|
113
|
+
template: '''
|
102
114
|
{{#filters}}
|
103
115
|
<div class='filter'>
|
104
116
|
<h3>
|
@@ -125,8 +137,12 @@ class window.Filters extends Utilities
|
|
125
137
|
{{/filters}}
|
126
138
|
'''
|
127
139
|
|
128
|
-
|
129
|
-
|
140
|
+
selections: ->
|
141
|
+
filters = {}
|
142
|
+
_.each( @filters, (filter) =>
|
143
|
+
filters[filter] = _.pluck( $("##{filter}_filter_options input.filter_option:checked"), 'value' )
|
144
|
+
)
|
145
|
+
filters
|
130
146
|
|
131
147
|
noFiltersSelected: (data) ->
|
132
148
|
_.all( data.filters, (filter) ->
|
@@ -136,7 +152,9 @@ class window.Filters extends Utilities
|
|
136
152
|
)
|
137
153
|
|
138
154
|
render: (data) ->
|
139
|
-
|
155
|
+
@filters = _.pluck( data.filters, 'filter_slug' )
|
156
|
+
filtersHTML = Mustache.to_html(@template, data)
|
157
|
+
$(@renderTo).html( filtersHTML )
|
140
158
|
if @noFiltersSelected(data) && data[@resourceName].length > 0
|
141
159
|
$('input[type="checkbox"]', @renderTo).attr('checked', 'checked')
|
142
160
|
|
@@ -207,7 +225,8 @@ class window.Pagination extends Utilities
|
|
207
225
|
|
208
226
|
render: (data) ->
|
209
227
|
@pagination = @paginationJSON(data.pagination)
|
210
|
-
|
228
|
+
paginationHTML = Mustache.to_html(@paginationTemplate, @pagination)
|
229
|
+
$(@renderTo).html( paginationHTML )
|
211
230
|
|
212
231
|
handlePaginationLinkClick: (event) =>
|
213
232
|
event.preventDefault()
|
@@ -51,7 +51,7 @@
|
|
51
51
|
__extends(List, _super);
|
52
52
|
|
53
53
|
function List(search, filters, pagination, globalOptions, options) {
|
54
|
-
var
|
54
|
+
var presets,
|
55
55
|
_this = this;
|
56
56
|
if (options == null) options = {};
|
57
57
|
this.renderIndex = __bind(this.renderIndex, this);
|
@@ -73,14 +73,7 @@
|
|
73
73
|
page: params != null ? params.page : void 0
|
74
74
|
});
|
75
75
|
});
|
76
|
-
|
77
|
-
cookie = jQuery.cookie(this.filters.cookieName);
|
78
|
-
}
|
79
|
-
if (this.filters.useCookies && cookie) {
|
80
|
-
presets = JSON.parse(cookie);
|
81
|
-
} else {
|
82
|
-
presets = this.filters.presets;
|
83
|
-
}
|
76
|
+
presets = this.filters.presets();
|
84
77
|
this.fetch({
|
85
78
|
presets: presets
|
86
79
|
});
|
@@ -98,35 +91,15 @@
|
|
98
91
|
this.data = data;
|
99
92
|
this.render();
|
100
93
|
this.pagination.render(this.data);
|
101
|
-
this.filters.filters = _.pluck(this.data.filters, 'filter_slug');
|
102
94
|
return this.filters.render(this.data);
|
103
95
|
};
|
104
96
|
|
105
|
-
List.prototype.selections = function() {
|
106
|
-
var filters,
|
107
|
-
_this = this;
|
108
|
-
filters = {};
|
109
|
-
_.each(this.filters.filters, function(filter) {
|
110
|
-
return filters[filter] = _this.filters.filterSelections(filter);
|
111
|
-
});
|
112
|
-
return filters;
|
113
|
-
};
|
114
|
-
|
115
97
|
List.prototype.fetch = function(options) {
|
116
98
|
var params, searchTerm;
|
117
99
|
if (this.fetchRequest) this.fetchRequest.abort();
|
118
100
|
searchTerm = this.search.searchTerm();
|
119
|
-
params = {
|
120
|
-
|
121
|
-
};
|
122
|
-
if (jQuery.isEmptyObject(options.presets)) {
|
123
|
-
params.filters = this.selections();
|
124
|
-
if (jQuery.cookie && !jQuery.isEmptyObject(params.filters)) {
|
125
|
-
jQuery.cookie(this.filters.cookieName, JSON.stringify(params.filters));
|
126
|
-
}
|
127
|
-
} else {
|
128
|
-
params.filters = options.presets;
|
129
|
-
}
|
101
|
+
params = {};
|
102
|
+
params.filters = this.filters.setPresets(options.presets);
|
130
103
|
if (searchTerm) params.q = searchTerm;
|
131
104
|
if (options.page) params.page = options.page;
|
132
105
|
return this.fetchRequest = $.ajax({
|
@@ -140,10 +113,11 @@
|
|
140
113
|
};
|
141
114
|
|
142
115
|
List.prototype.render = function() {
|
143
|
-
var partials;
|
116
|
+
var listHTML, partials;
|
144
117
|
partials = {};
|
145
118
|
partials[this.resourceNameSingular] = this.listItemTemplate;
|
146
|
-
|
119
|
+
listHTML = Mustache.to_html(this.listTemplate, this.data, partials);
|
120
|
+
$(this.renderTo).html(listHTML);
|
147
121
|
return this.removeFetchingIndication();
|
148
122
|
};
|
149
123
|
|
@@ -151,7 +125,7 @@
|
|
151
125
|
|
152
126
|
})(Utilities);
|
153
127
|
|
154
|
-
window.LiveList.version = '0.0.
|
128
|
+
window.LiveList.version = '0.0.4';
|
155
129
|
|
156
130
|
window.Filters = (function(_super) {
|
157
131
|
|
@@ -163,9 +137,7 @@
|
|
163
137
|
this.handleAdvancedOptionsClick = __bind(this.handleAdvancedOptionsClick, this);
|
164
138
|
this.setOptions(globalOptions);
|
165
139
|
this.filters = options.presets ? _.keys(options.presets) : [];
|
166
|
-
|
167
|
-
this.filters.cookieName = 'livelist_filter_presets';
|
168
|
-
}
|
140
|
+
this.initializeCookies();
|
169
141
|
this.setOptions(options);
|
170
142
|
$('input.filter_option', this.renderTo).live('change', function() {
|
171
143
|
return $(_this.listSelector).trigger(_this.eventName);
|
@@ -173,14 +145,52 @@
|
|
173
145
|
$(this.advancedOptionsToggleSelector).click(this.handleAdvancedOptionsClick);
|
174
146
|
}
|
175
147
|
|
176
|
-
Filters.prototype.
|
148
|
+
Filters.prototype.initializeCookies = function() {
|
149
|
+
if (jQuery.cookie && this.useCookies && this.cookieName) {
|
150
|
+
return this.cookieName = 'livelist_filter_presets';
|
151
|
+
}
|
152
|
+
};
|
153
|
+
|
154
|
+
Filters.prototype.presets = function() {
|
155
|
+
var cookie;
|
156
|
+
if (jQuery.cookie && this.useCookies) {
|
157
|
+
cookie = jQuery.cookie(this.cookieName);
|
158
|
+
}
|
159
|
+
if (this.useCookies && cookie) {
|
160
|
+
return JSON.parse(cookie);
|
161
|
+
} else {
|
162
|
+
return this.presets;
|
163
|
+
}
|
164
|
+
};
|
177
165
|
|
178
|
-
Filters.prototype.
|
179
|
-
|
166
|
+
Filters.prototype.setPresets = function(presets) {
|
167
|
+
var filters;
|
168
|
+
filters = {};
|
169
|
+
if (jQuery.isEmptyObject(presets)) {
|
170
|
+
filters = this.selections();
|
171
|
+
if (jQuery.cookie) this.setCookie();
|
172
|
+
} else {
|
173
|
+
filters = presets;
|
174
|
+
}
|
175
|
+
return filters;
|
180
176
|
};
|
181
177
|
|
182
|
-
Filters.prototype.
|
183
|
-
|
178
|
+
Filters.prototype.setCookie = function(params_filters) {
|
179
|
+
if (!jQuery.isEmptyObject(params_filters)) {
|
180
|
+
return jQuery.cookie(this.cookieName, JSON.stringify(params_filters));
|
181
|
+
}
|
182
|
+
};
|
183
|
+
|
184
|
+
Filters.prototype.template = '{{#filters}}\n<div class=\'filter\'>\n <h3>\n {{name}}\n </h3>\n <ul id=\'{{filter_slug}}_filter_options\'>\n {{#options}}\n <label>\n <li>\n <input {{#selected}}checked=\'checked\'{{/selected}}\n class=\'left filter_option\'\n id=\'filter_{{slug}}\'\n name=\'filters[]\'\n type=\'checkbox\'\n value=\'{{value}}\' />\n <div class=\'left filter_name\'>{{name}}</div>\n <div class=\'right filter_count\'>{{count}}</div>\n <div class=\'clear\'></div>\n </li>\n </label>\n {{/options}}\n </ul>\n</div>\n{{/filters}}';
|
185
|
+
|
186
|
+
Filters.prototype.selections = function() {
|
187
|
+
var filters,
|
188
|
+
_this = this;
|
189
|
+
filters = {};
|
190
|
+
_.each(this.filters, function(filter) {
|
191
|
+
return filters[filter] = _.pluck($("#" + filter + "_filter_options input.filter_option:checked"), 'value');
|
192
|
+
});
|
193
|
+
return filters;
|
184
194
|
};
|
185
195
|
|
186
196
|
Filters.prototype.noFiltersSelected = function(data) {
|
@@ -192,7 +202,10 @@
|
|
192
202
|
};
|
193
203
|
|
194
204
|
Filters.prototype.render = function(data) {
|
195
|
-
|
205
|
+
var filtersHTML;
|
206
|
+
this.filters = _.pluck(data.filters, 'filter_slug');
|
207
|
+
filtersHTML = Mustache.to_html(this.template, data);
|
208
|
+
$(this.renderTo).html(filtersHTML);
|
196
209
|
if (this.noFiltersSelected(data) && data[this.resourceName].length > 0) {
|
197
210
|
return $('input[type="checkbox"]', this.renderTo).attr('checked', 'checked');
|
198
211
|
}
|
@@ -257,8 +270,10 @@
|
|
257
270
|
};
|
258
271
|
|
259
272
|
Pagination.prototype.render = function(data) {
|
273
|
+
var paginationHTML;
|
260
274
|
this.pagination = this.paginationJSON(data.pagination);
|
261
|
-
|
275
|
+
paginationHTML = Mustache.to_html(this.paginationTemplate, this.pagination);
|
276
|
+
return $(this.renderTo).html(paginationHTML);
|
262
277
|
};
|
263
278
|
|
264
279
|
Pagination.prototype.handlePaginationLinkClick = function(event) {
|
@@ -1 +1 @@
|
|
1
|
-
((function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b=Object.prototype.hasOwnProperty,c=function(a,c){function e(){this.constructor=a}for(var d in c)b.call(c,d)&&(a[d]=c[d]);return e.prototype=c.prototype,a.prototype=new e,a.__super__=c.prototype,a};window.Utilities=function(){function b(){this.setOptions=a(this.setOptions,this)}return b.prototype.setOptions=function(a,b){var c=this;return b==null&&(b=this),_.each(a,function(a,c){return b[c]=a})},b}(),window.LiveList=function(a){function b(a){this.globalOptions.listSelector=a.list.renderTo,this.globalOptions.eventName="livelist:"+a.global.resourceName,this.globalOptions.urlPrefix="/"+a.global.resourceName,this.setOptions(a.global,this.globalOptions),this.search=new Search(this.globalOptions,a.search),this.filters=new Filters(this.globalOptions,a.filters),this.pagination=new Pagination(this.globalOptions,a.pagination),this.list=new List(this.search,this.filters,this.pagination,this.globalOptions,a.list)}return c(b,a),b.prototype.globalOptions={data:null,resourceName:"items",resourceNameSingular:"item"},b}(Utilities),window.List=function(b){function d(b,c,d,e,f){var g,h
|
1
|
+
((function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b=Object.prototype.hasOwnProperty,c=function(a,c){function e(){this.constructor=a}for(var d in c)b.call(c,d)&&(a[d]=c[d]);return e.prototype=c.prototype,a.prototype=new e,a.__super__=c.prototype,a};window.Utilities=function(){function b(){this.setOptions=a(this.setOptions,this)}return b.prototype.setOptions=function(a,b){var c=this;return b==null&&(b=this),_.each(a,function(a,c){return b[c]=a})},b}(),window.LiveList=function(a){function b(a){this.globalOptions.listSelector=a.list.renderTo,this.globalOptions.eventName="livelist:"+a.global.resourceName,this.globalOptions.urlPrefix="/"+a.global.resourceName,this.setOptions(a.global,this.globalOptions),this.search=new Search(this.globalOptions,a.search),this.filters=new Filters(this.globalOptions,a.filters),this.pagination=new Pagination(this.globalOptions,a.pagination),this.list=new List(this.search,this.filters,this.pagination,this.globalOptions,a.list)}return c(b,a),b.prototype.globalOptions={data:null,resourceName:"items",resourceNameSingular:"item"},b}(Utilities),window.List=function(b){function d(b,c,d,e,f){var g,h=this;f==null&&(f={}),this.renderIndex=a(this.renderIndex,this),this.removeFetchingIndication=a(this.removeFetchingIndication,this),this.displayFetchingIndication=a(this.displayFetchingIndication,this),this.data=e.data,this.fetchRequest=null,this.search=b,this.filters=c,this.pagination=d,this.setOptions(e),this.listTemplate="{{#"+this.resourceName+"}}{{>"+this.resourceNameSingular+"}}{{/"+this.resourceName+"}}",this.listItemTemplate="<li>{{id}}</li>",this.fetchingIndicationClass="updating",this.setOptions(f),$(this.renderTo).bind(this.eventName,function(a,b){return h.fetch({presets:null,page:b!=null?b.page:void 0})}),g=this.filters.presets(),this.fetch({presets:g})}return c(d,b),d.prototype.displayFetchingIndication=function(){return $(this.renderTo).addClass(this.fetchingIndicationClass)},d.prototype.removeFetchingIndication=function(){return $(this.renderTo).removeClass(this.fetchingIndicationClass)},d.prototype.renderIndex=function(a,b,c){return this.data=a,this.render(),this.pagination.render(this.data),this.filters.render(this.data)},d.prototype.fetch=function(a){var b,c;return this.fetchRequest&&this.fetchRequest.abort(),c=this.search.searchTerm(),b={},b.filters=this.filters.setPresets(a.presets),c&&(b.q=c),a.page&&(b.page=a.page),this.fetchRequest=$.ajax({url:this.urlPrefix,dataType:"json",data:b,type:this.httpMethod,beforeSend:this.displayFetchingIndication,success:this.renderIndex})},d.prototype.render=function(){var a,b;return b={},b[this.resourceNameSingular]=this.listItemTemplate,a=Mustache.to_html(this.listTemplate,this.data,b),$(this.renderTo).html(a),this.removeFetchingIndication()},d}(Utilities),window.LiveList.version="0.0.4",window.Filters=function(b){function d(b,c){var d=this;c==null&&(c={}),this.handleAdvancedOptionsClick=a(this.handleAdvancedOptionsClick,this),this.setOptions(b),this.filters=c.presets?_.keys(c.presets):[],this.initializeCookies(),this.setOptions(c),$("input.filter_option",this.renderTo).live("change",function(){return $(d.listSelector).trigger(d.eventName)}),$(this.advancedOptionsToggleSelector).click(this.handleAdvancedOptionsClick)}return c(d,b),d.prototype.initializeCookies=function(){if(jQuery.cookie&&this.useCookies&&this.cookieName)return this.cookieName="livelist_filter_presets"},d.prototype.presets=function(){var a;return jQuery.cookie&&this.useCookies&&(a=jQuery.cookie(this.cookieName)),this.useCookies&&a?JSON.parse(a):this.presets},d.prototype.setPresets=function(a){var b;return b={},jQuery.isEmptyObject(a)?(b=this.selections(),jQuery.cookie&&this.setCookie()):b=a,b},d.prototype.setCookie=function(a){if(!jQuery.isEmptyObject(a))return jQuery.cookie(this.cookieName,JSON.stringify(a))},d.prototype.template="{{#filters}}\n<div class='filter'>\n <h3>\n {{name}}\n </h3>\n <ul id='{{filter_slug}}_filter_options'>\n {{#options}}\n <label>\n <li>\n <input {{#selected}}checked='checked'{{/selected}}\n class='left filter_option'\n id='filter_{{slug}}'\n name='filters[]'\n type='checkbox'\n value='{{value}}' />\n <div class='left filter_name'>{{name}}</div>\n <div class='right filter_count'>{{count}}</div>\n <div class='clear'></div>\n </li>\n </label>\n {{/options}}\n </ul>\n</div>\n{{/filters}}",d.prototype.selections=function(){var a,b=this;return a={},_.each(this.filters,function(b){return a[b]=_.pluck($("#"+b+"_filter_options input.filter_option:checked"),"value")}),a},d.prototype.noFiltersSelected=function(a){return _.all(a.filters,function(a){return _.all(a.options,function(a){return!a.selected})})},d.prototype.render=function(a){var b;this.filters=_.pluck(a.filters,"filter_slug"),b=Mustache.to_html(this.template,a),$(this.renderTo).html(b);if(this.noFiltersSelected(a)&&a[this.resourceName].length>0)return $('input[type="checkbox"]',this.renderTo).attr("checked","checked")},d.prototype.handleAdvancedOptionsClick=function(a){return a.preventDefault(),$(this.renderTo).slideToggle()},d}(Utilities),window.Pagination=function(b){function d(b,c){c==null&&(c={}),this.handlePaginationLinkClick=a(this.handlePaginationLinkClick,this),this.pagination=null,this.maxPages=30,this.setOptions(b),this.emptyListMessage="<p>No "+this.resourceName+" matched your filter criteria</p>",this.setOptions(c),$(""+this.renderTo+" a").live("click",this.handlePaginationLinkClick)}return c(d,b),d.prototype.paginationTemplate="{{#isEmpty}}\n {{{emptyListMessage}}}\n{{/isEmpty}}\n{{^isEmpty}}\n{{#previousPage}}\n <a href='{{urlPrefix}}?page={{previousPage}}' data-page='{{previousPage}}'>← Previous</a>\n{{/previousPage}}\n{{^previousPage}}\n <span>← Previous</span>\n{{/previousPage}}\n{{#pages}}\n {{#currentPage}}\n <span>{{page}}</span>\n {{/currentPage}}\n {{^currentPage}}\n <a href='{{urlPrefix}}?page={{page}}' data-page='{{page}}'>{{page}}</a>\n {{/currentPage}}\n{{/pages}}\n{{#nextPage}}\n <a href='{{urlPrefix}}?page={{nextPage}}' data-page='{{nextPage}}'>Next →</a>\n{{/nextPage}}\n{{^nextPage}}\n <span>Next →</span>\n{{/nextPage}}\n{{/isEmpty}}",d.prototype.pagesJSON=function(a,b){var c,d,e,f,g,h;return d=this.maxPages/2,c=a<d?1:a-d,f=c+d*2-1,e=f>=b?b:f,_.map(function(){h=[];for(var a=c;c<=e?a<=e:a>=e;c<=e?a++:a--)h.push(a);return h}.apply(this),function(b){return{page:b,currentPage:function(){return a===b}}})},d.prototype.paginationJSON=function(a){return{isEmpty:a.total_pages===0,emptyListMessage:this.emptyListMessage,currentPage:a.current_page,nextPage:a.next_page,previousPage:a.previous_page,urlPrefix:this.urlPrefix,pages:this.pagesJSON(a.current_page,a.total_pages)}},d.prototype.render=function(a){var b;return this.pagination=this.paginationJSON(a.pagination),b=Mustache.to_html(this.paginationTemplate,this.pagination),$(this.renderTo).html(b)},d.prototype.handlePaginationLinkClick=function(a){return a.preventDefault(),$(this.listSelector).trigger(this.eventName,{page:$(a.target).data("page")})},d}(Utilities),window.Search=function(b){function d(b,c){var d=this;c==null&&(c={}),this.handleSearchFormSubmit=a(this.handleSearchFormSubmit,this),this.setOptions(b),this.setOptions(c),$(this.formSelector).submit(function(a){return d.handleSearchFormSubmit(a)})}return c(d,b),d.prototype.searchTerm=function(){var a;return a=$(this.searchTextInputSelector).val(),!a||a===""?null:a},d.prototype.handleSearchFormSubmit=function(a){return a.preventDefault(),$(this.listSelector).trigger(this.eventName)},d}(Utilities)})).call(this);
|
@@ -24,8 +24,9 @@ module Livelist
|
|
24
24
|
|
25
25
|
def filter_relation(filter_params)
|
26
26
|
relation = scoped
|
27
|
-
|
28
|
-
|
27
|
+
@@filter_slugs.each do |filter_slug|
|
28
|
+
values = filter_params[filter_slug.to_s]
|
29
|
+
relation = relation.send("#{filter_slug}_relation", values) unless filter_params.empty?
|
29
30
|
end
|
30
31
|
relation
|
31
32
|
end
|
@@ -92,7 +93,7 @@ module Livelist
|
|
92
93
|
query = scoped.except(:order)
|
93
94
|
@@filter_slugs.each do |slug|
|
94
95
|
query = query.send("#{slug}_join")
|
95
|
-
query = query.send("#{slug}_where", @@filter_params[slug]) unless slug.to_s == filter_slug
|
96
|
+
query = query.send("#{slug}_where", @@filter_params[slug]) unless @@filter_params[filter_slug].nil? || (slug.to_s == filter_slug)
|
96
97
|
end
|
97
98
|
group_by = send("#{filter_slug}_counts_group_by")
|
98
99
|
query.group(group_by).count
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: livelist-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-01
|
12
|
+
date: 2012-02-01 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &16423600 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *16423600
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: activerecord
|
27
|
-
requirement: &
|
27
|
+
requirement: &16423180 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *16423180
|
36
36
|
description: ! 'livelist-rails is a Rails 3.1 Engine/Extensiont incorporating the
|
37
37
|
following javascript libraries: Mustache.js, underscore.js, jQuery and livelist.js,
|
38
38
|
and providing ActiveRecord filtering extenstions.'
|
@@ -84,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
84
|
version: '0'
|
85
85
|
requirements: []
|
86
86
|
rubyforge_project: livelist-rails
|
87
|
-
rubygems_version: 1.8.
|
87
|
+
rubygems_version: 1.8.15
|
88
88
|
signing_key:
|
89
89
|
specification_version: 3
|
90
90
|
summary: A Rails Engine/Extension Incorporating Livelist.js
|