smart_listing 1.2.1 → 1.2.2
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.
- checksums.yaml +5 -5
- data/README.md +6 -0
- data/app/assets/javascripts/smart_listing.coffee.erb +7 -0
- data/app/helpers/smart_listing/helper.rb +6 -12
- data/app/views/smart_listing/_sortable.html.erb +1 -1
- data/lib/generators/smart_listing/templates/initializer.rb +0 -1
- data/lib/smart_listing.rb +6 -1
- data/lib/smart_listing/config.rb +1 -0
- data/lib/smart_listing/version.rb +1 -1
- metadata +84 -56
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d094a24f3cf879ec07471fa78e42f6d7923476971f03f0b3d0ffdc4243488e28
|
4
|
+
data.tar.gz: 44f9ec23a184ff3c3df4fa2af4e053115dc78830036fba5f5584733c38b03977
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c71f8202ab047e5727f8f0ca04aaa7d940aaf1f304758690905cc4be8f96ecb32cd3de1e616d5e355c9e21773b57d7ace88987c0ced8d7e09599fa3d700c627
|
7
|
+
data.tar.gz: 7c7377b916ab03f30a4992f7fa37241f474033a8aa38320e27e454ebbd01617d49ac480a4879b8f2f88c38023633a66b155939e8dfff000389096d50d745ce9c
|
data/README.md
CHANGED
@@ -24,6 +24,12 @@ Also, you need to add SmartListing to your asset pipeline:
|
|
24
24
|
//= require smart_listing
|
25
25
|
```
|
26
26
|
|
27
|
+
__Rails >= 5.1 users__: Rails 5.1 has dropped jQuery dependency from the default stack in favour of `rails-ujs`. SmartListing still requires jQuery so make sure that you use `jquery_ujs` from `jquery-rails` gem and have following requires in your asset pipeline before `smart_listing`:
|
28
|
+
```
|
29
|
+
//= require jquery
|
30
|
+
//= require jquery_ujs
|
31
|
+
```
|
32
|
+
|
27
33
|
### Initializer
|
28
34
|
|
29
35
|
Optionally you can also install some configuration initializer:
|
@@ -1,3 +1,10 @@
|
|
1
|
+
# endsWith polyfill
|
2
|
+
if !String::endsWith
|
3
|
+
String::endsWith = (search, this_len) ->
|
4
|
+
if this_len == undefined or this_len > @length
|
5
|
+
this_len = @length
|
6
|
+
@substring(this_len - (search.length), this_len) == search
|
7
|
+
|
1
8
|
# Useful when SmartListing target url is different than current one
|
2
9
|
$.rails.href = (element) ->
|
3
10
|
element.attr("href") || element.data("<%= SmartListing.config.data_attributes(:href) %>") || window.location.pathname
|
@@ -33,8 +33,6 @@ module SmartListing
|
|
33
33
|
end
|
34
34
|
|
35
35
|
class Builder
|
36
|
-
# Params that should not be visible in pagination links (pages, per-page, sorting, etc.)
|
37
|
-
UNSAFE_PARAMS = {:authenticity_token => nil, :utf8 => nil}
|
38
36
|
|
39
37
|
class_attribute :smart_listing_helpers
|
40
38
|
|
@@ -48,7 +46,7 @@ module SmartListing
|
|
48
46
|
|
49
47
|
def paginate options = {}
|
50
48
|
if @smart_listing.collection.respond_to? :current_page
|
51
|
-
@template.paginate @smart_listing.collection, {:remote => @smart_listing.remote?, :param_name => @smart_listing.param_name(:page)
|
49
|
+
@template.paginate @smart_listing.collection, {:remote => @smart_listing.remote?, :param_name => @smart_listing.param_name(:page)}.merge(@smart_listing.kaminari_options)
|
52
50
|
end
|
53
51
|
end
|
54
52
|
|
@@ -78,7 +76,7 @@ module SmartListing
|
|
78
76
|
|
79
77
|
def pagination_per_page_link page
|
80
78
|
if @smart_listing.per_page.to_i != page
|
81
|
-
url = @template.url_for(
|
79
|
+
url = @template.url_for(@smart_listing.params.merge(@smart_listing.all_params(:per_page => page, :page => 1)))
|
82
80
|
end
|
83
81
|
|
84
82
|
locals = {
|
@@ -100,10 +98,11 @@ module SmartListing
|
|
100
98
|
|
101
99
|
locals = {
|
102
100
|
:order => @smart_listing.sort_order(attribute),
|
103
|
-
:url => @template.url_for(
|
101
|
+
:url => @template.url_for(@smart_listing.params.merge(@smart_listing.all_params(:sort => sort_params))),
|
104
102
|
:container_classes => [@template.smart_listing_config.classes(:sortable)],
|
105
103
|
:attribute => attribute,
|
106
|
-
:title => title
|
104
|
+
:title => title,
|
105
|
+
:remote => @smart_listing.remote?
|
107
106
|
}
|
108
107
|
|
109
108
|
@template.render(:partial => 'smart_listing/sortable', :locals => default_locals.merge(locals))
|
@@ -180,11 +179,6 @@ module SmartListing
|
|
180
179
|
|
181
180
|
private
|
182
181
|
|
183
|
-
def sanitize_params params
|
184
|
-
params = params.permit! if params.respond_to?(:permit!)
|
185
|
-
params.merge(UNSAFE_PARAMS)
|
186
|
-
end
|
187
|
-
|
188
182
|
def default_locals
|
189
183
|
{:smart_listing => @smart_listing, :builder => self}
|
190
184
|
end
|
@@ -318,7 +312,7 @@ module SmartListing
|
|
318
312
|
smart_listing = @smart_listings[name]
|
319
313
|
|
320
314
|
# don't update list if params are missing (prevents interfering with other lists)
|
321
|
-
if params.keys.select{|k| k.include?("smart_listing")}.
|
315
|
+
if params.keys.select{|k| k.include?("smart_listing")}.present? && !params[smart_listing.base_param]
|
322
316
|
return unless options[:force]
|
323
317
|
end
|
324
318
|
|
@@ -11,7 +11,7 @@
|
|
11
11
|
builder: current builder instance
|
12
12
|
-%>
|
13
13
|
|
14
|
-
<%= link_to url, :class => container_classes, :data => {:attr => attribute}, :remote =>
|
14
|
+
<%= link_to url, :class => container_classes, :data => {:attr => attribute}, :remote => remote do %>
|
15
15
|
<%= title %>
|
16
16
|
<% if order %>
|
17
17
|
<span class="<%= order == "asc" ? smart_listing_config.classes(:icon_sort_up) : smart_listing_config.classes(:icon_sort_down) %>"></span>
|
data/lib/smart_listing.rb
CHANGED
@@ -21,7 +21,9 @@ end
|
|
21
21
|
|
22
22
|
module SmartListing
|
23
23
|
class Base
|
24
|
-
attr_reader :name, :collection, :options, :per_page, :sort, :page, :partial, :count
|
24
|
+
attr_reader :name, :collection, :options, :per_page, :sort, :page, :partial, :count, :params
|
25
|
+
# Params that should not be visible in pagination links (pages, per-page, sorting, etc.)
|
26
|
+
UNSAFE_PARAMS = [:authenticity_token, :commit, :utf8, :_method, :script_name].freeze
|
25
27
|
|
26
28
|
def initialize name, collection, options = {}
|
27
29
|
@name = name
|
@@ -46,6 +48,9 @@ module SmartListing
|
|
46
48
|
|
47
49
|
def setup params, cookies
|
48
50
|
@params = params
|
51
|
+
@params = @params.to_unsafe_h if @params.respond_to?(:to_unsafe_h)
|
52
|
+
@params = @params.with_indifferent_access
|
53
|
+
@params.except!(*UNSAFE_PARAMS)
|
49
54
|
|
50
55
|
@page = get_param :page
|
51
56
|
@per_page = !get_param(:per_page) || get_param(:per_page).empty? ? (@options[:memorize_per_page] && get_param(:per_page, cookies).to_i > 0 ? get_param(:per_page, cookies).to_i : page_sizes.first) : get_param(:per_page).to_i
|
data/lib/smart_listing/config.rb
CHANGED
@@ -31,6 +31,7 @@ module SmartListing
|
|
31
31
|
:page_sizes => DEFAULT_PAGE_SIZES.dup, # set available page sizes array
|
32
32
|
:kaminari_options => {:theme => "smart_listing"}, # Kaminari's paginate helper options
|
33
33
|
:sort_dirs => [nil, "asc", "desc"], # Default sorting directions cycle of sortables
|
34
|
+
:remote => true, # Default remote mode
|
34
35
|
},
|
35
36
|
:constants => {
|
36
37
|
:classes => {
|
metadata
CHANGED
@@ -1,153 +1,181 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smart_listing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sology
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '3.2'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '3.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: coffee-rails
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: kaminari
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0.17'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0.17'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: jquery-rails
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: bootstrap-sass
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: sqlite3
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: rspec-rails
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: guard-rspec
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: byebug
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
109
137
|
- !ruby/object:Gem::Version
|
110
138
|
version: '0'
|
111
139
|
- !ruby/object:Gem::Dependency
|
112
140
|
name: capybara
|
113
141
|
requirement: !ruby/object:Gem::Requirement
|
114
142
|
requirements:
|
115
|
-
- -
|
143
|
+
- - "<"
|
116
144
|
- !ruby/object:Gem::Version
|
117
|
-
version: 2.
|
145
|
+
version: '2.14'
|
118
146
|
type: :development
|
119
147
|
prerelease: false
|
120
148
|
version_requirements: !ruby/object:Gem::Requirement
|
121
149
|
requirements:
|
122
|
-
- -
|
150
|
+
- - "<"
|
123
151
|
- !ruby/object:Gem::Version
|
124
|
-
version: 2.
|
152
|
+
version: '2.14'
|
125
153
|
- !ruby/object:Gem::Dependency
|
126
154
|
name: capybara-webkit
|
127
155
|
requirement: !ruby/object:Gem::Requirement
|
128
156
|
requirements:
|
129
|
-
- - ~>
|
157
|
+
- - "~>"
|
130
158
|
- !ruby/object:Gem::Version
|
131
|
-
version: 1.
|
159
|
+
version: '1.14'
|
132
160
|
type: :development
|
133
161
|
prerelease: false
|
134
162
|
version_requirements: !ruby/object:Gem::Requirement
|
135
163
|
requirements:
|
136
|
-
- - ~>
|
164
|
+
- - "~>"
|
137
165
|
- !ruby/object:Gem::Version
|
138
|
-
version: 1.
|
166
|
+
version: '1.14'
|
139
167
|
- !ruby/object:Gem::Dependency
|
140
168
|
name: database_cleaner
|
141
169
|
requirement: !ruby/object:Gem::Requirement
|
142
170
|
requirements:
|
143
|
-
- -
|
171
|
+
- - ">="
|
144
172
|
- !ruby/object:Gem::Version
|
145
173
|
version: '0'
|
146
174
|
type: :development
|
147
175
|
prerelease: false
|
148
176
|
version_requirements: !ruby/object:Gem::Requirement
|
149
177
|
requirements:
|
150
|
-
- -
|
178
|
+
- - ">="
|
151
179
|
- !ruby/object:Gem::Version
|
152
180
|
version: '0'
|
153
181
|
description: Ruby on Rails data listing gem with built-in sorting, filtering and in-place
|
@@ -158,51 +186,51 @@ executables: []
|
|
158
186
|
extensions: []
|
159
187
|
extra_rdoc_files: []
|
160
188
|
files:
|
189
|
+
- LICENSE
|
190
|
+
- README.md
|
191
|
+
- Rakefile
|
161
192
|
- app/assets/javascripts/smart_listing.coffee.erb
|
162
|
-
- app/
|
193
|
+
- app/helpers/smart_listing/application_helper.rb
|
194
|
+
- app/helpers/smart_listing/helper.rb
|
163
195
|
- app/views/kaminari/smart_listing/_first_page.html.erb
|
164
|
-
- app/views/kaminari/smart_listing/_page.html.erb
|
165
|
-
- app/views/kaminari/smart_listing/_prev_page.html.erb
|
166
|
-
- app/views/kaminari/smart_listing/_last_page.html.erb
|
167
196
|
- app/views/kaminari/smart_listing/_gap.html.erb
|
197
|
+
- app/views/kaminari/smart_listing/_last_page.html.erb
|
168
198
|
- app/views/kaminari/smart_listing/_next_page.html.erb
|
169
|
-
- app/views/smart_listing/
|
199
|
+
- app/views/kaminari/smart_listing/_page.html.erb
|
200
|
+
- app/views/kaminari/smart_listing/_paginator.html.erb
|
201
|
+
- app/views/kaminari/smart_listing/_prev_page.html.erb
|
170
202
|
- app/views/smart_listing/_action_custom.html.erb
|
171
|
-
- app/views/smart_listing/_item_new.html.erb
|
172
203
|
- app/views/smart_listing/_action_delete.html.erb
|
173
|
-
- app/views/smart_listing/edit.js.erb
|
174
|
-
- app/views/smart_listing/_pagination_per_page_links.html.erb
|
175
|
-
- app/views/smart_listing/_pagination_per_page_link.html.erb
|
176
|
-
- app/views/smart_listing/index.js.erb
|
177
|
-
- app/views/smart_listing/_action_show.html.erb
|
178
|
-
- app/views/smart_listing/update.js.erb
|
179
204
|
- app/views/smart_listing/_action_edit.html.erb
|
180
|
-
- app/views/smart_listing/
|
181
|
-
- app/views/smart_listing/
|
205
|
+
- app/views/smart_listing/_action_show.html.erb
|
206
|
+
- app/views/smart_listing/_item_new.html.erb
|
207
|
+
- app/views/smart_listing/_pagination_per_page_link.html.erb
|
208
|
+
- app/views/smart_listing/_pagination_per_page_links.html.erb
|
182
209
|
- app/views/smart_listing/_sortable.html.erb
|
210
|
+
- app/views/smart_listing/_update_list.js.erb
|
183
211
|
- app/views/smart_listing/create.js.erb
|
212
|
+
- app/views/smart_listing/destroy.js.erb
|
213
|
+
- app/views/smart_listing/edit.js.erb
|
214
|
+
- app/views/smart_listing/index.js.erb
|
184
215
|
- app/views/smart_listing/item/_create.js.erb
|
185
|
-
- app/views/smart_listing/item/
|
216
|
+
- app/views/smart_listing/item/_create_continue.js.erb
|
186
217
|
- app/views/smart_listing/item/_destroy.js.erb
|
187
|
-
- app/views/smart_listing/item/
|
218
|
+
- app/views/smart_listing/item/_edit.js.erb
|
188
219
|
- app/views/smart_listing/item/_new.js.erb
|
220
|
+
- app/views/smart_listing/item/_remove.js.erb
|
189
221
|
- app/views/smart_listing/item/_update.js.erb
|
190
|
-
- app/views/smart_listing/
|
191
|
-
- app/
|
192
|
-
- app/helpers/smart_listing/helper.rb
|
193
|
-
- config/routes.rb
|
222
|
+
- app/views/smart_listing/new.js.erb
|
223
|
+
- app/views/smart_listing/update.js.erb
|
194
224
|
- config/locales/en.yml
|
225
|
+
- config/routes.rb
|
226
|
+
- lib/generators/smart_listing/install_generator.rb
|
227
|
+
- lib/generators/smart_listing/templates/initializer.rb
|
228
|
+
- lib/generators/smart_listing/views_generator.rb
|
195
229
|
- lib/smart_listing.rb
|
196
|
-
- lib/tasks/smart_list_tasks.rake
|
197
230
|
- lib/smart_listing/config.rb
|
198
231
|
- lib/smart_listing/engine.rb
|
199
232
|
- lib/smart_listing/version.rb
|
200
|
-
- lib/
|
201
|
-
- lib/generators/smart_listing/install_generator.rb
|
202
|
-
- lib/generators/smart_listing/templates/initializer.rb
|
203
|
-
- LICENSE
|
204
|
-
- Rakefile
|
205
|
-
- README.md
|
233
|
+
- lib/tasks/smart_list_tasks.rake
|
206
234
|
homepage: https://github.com/Sology/smart_listing
|
207
235
|
licenses:
|
208
236
|
- MIT
|
@@ -213,17 +241,17 @@ require_paths:
|
|
213
241
|
- lib
|
214
242
|
required_ruby_version: !ruby/object:Gem::Requirement
|
215
243
|
requirements:
|
216
|
-
- -
|
244
|
+
- - ">="
|
217
245
|
- !ruby/object:Gem::Version
|
218
246
|
version: '0'
|
219
247
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
220
248
|
requirements:
|
221
|
-
- -
|
249
|
+
- - ">="
|
222
250
|
- !ruby/object:Gem::Version
|
223
251
|
version: '0'
|
224
252
|
requirements: []
|
225
253
|
rubyforge_project:
|
226
|
-
rubygems_version: 2.
|
254
|
+
rubygems_version: 2.7.3
|
227
255
|
signing_key:
|
228
256
|
specification_version: 4
|
229
257
|
summary: SmartListing helps creating sortable lists of ActiveRecord collections with
|