smart_listing 1.1.2 → 1.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f1f5ca088a8f099afb75fbf7e1e1141d616f44ac
4
- data.tar.gz: 1f9cf4a2af47ec66b8bddc3f20a5a3dc51064e42
3
+ metadata.gz: 9e99ae401d68d2b6f4af5569bf2963fd8eafdb8f
4
+ data.tar.gz: 8469a86376223350e45927863a7d7c8096c6fc98
5
5
  SHA512:
6
- metadata.gz: 262ea9cd10b00b30dd902fe8602637b6af3413919d61bd82b6c0dbc56b23472026f00142dc4e6eec48d6613f3eb006f7ea71dd5d30efabe1983c241514361fef
7
- data.tar.gz: c37d66bf5b26b7e336c59a4d1e72f767fefa274fb439b7f10b63bd130e32cc5f5ab020bd298f6d9d72ec3b57a973fa4d60fc17b17ce7d024d979c0a813428e0b
6
+ metadata.gz: 9cf884e1df41a3417a666929c7b66796bf87dbd6089d2c35891650ee178e5c5892c7e7b32c8a8c174f413810669fad3ebca402287b4aef6dc0a0346aa895b697
7
+ data.tar.gz: 6b412d30392763ad1c5c227ec0261abd9922ffbf5f0f9c95c996b9cba745e9284b4009ffd6b27214edfaea36fef1260eece888168894f121aaee303a911b58f6
data/README.md CHANGED
@@ -180,10 +180,10 @@ New partial for user (`users/user`) may look like this:
180
180
  ```haml
181
181
  %td= user.name
182
182
  %td= user.email
183
- %td.actions= smart_listing_item_actions [{name: :edit, url: edit_user_path(user)}, {name: :destroy, url: user_path(user)}]
183
+ %td.actions= smart_listing_item_actions [{name: :show, url: user_path(user)}, {name: :edit, url: edit_user_path(user)}, {name: :destroy, url: user_path(user)}]
184
184
  ```
185
185
 
186
- `smart_listing_item_actions` renders here links that allow to edit and destroy user item. `:edit` and `:destroy` are built-in actions, you can also define your `:custom` actions. Again. `<td>`'s class `actions` is important.
186
+ `smart_listing_item_actions` renders here links that allow to edit and destroy user item. `:show`, `:edit` and `:destroy` are built-in actions, you can also define your `:custom` actions. Again. `<td>`'s class `actions` is important.
187
187
 
188
188
  Controller actions referenced by above urls are again plain Ruby on Rails actions that render JS like:
189
189
 
@@ -21,6 +21,9 @@ class window.SmartListing
21
21
  @selector: (name)->
22
22
  @options["constants"]["selectors"][name]
23
23
 
24
+ @element_template: (name)->
25
+ @options["constants"]["element_templates"][name]
26
+
24
27
  @config: Config
25
28
 
26
29
 
@@ -186,6 +189,8 @@ class window.SmartListing
186
189
  new_item_placeholder.html(content)
187
190
  new_item_placeholder.addClass(SmartListing.config.class("inline_editing"))
188
191
 
192
+ @container.trigger("smart_listing:new", new_item_placeholder)
193
+
189
194
  @fadeLoaded()
190
195
 
191
196
  create: (id, success, content) =>
@@ -196,10 +201,17 @@ class window.SmartListing
196
201
  new_item_placeholder.addClass(SmartListing.config.class("hidden"))
197
202
  new_item_action.removeClass(SmartListing.config.class("hidden"))
198
203
 
199
- new_item = $("<tr />").addClass(SmartListing.config.class("editable"))
204
+ new_item = $(SmartListing.config.element_template("row")).addClass(SmartListing.config.class("editable"))
200
205
  new_item.attr("data-#{SmartListing.config.data_attribute("id")}", id)
201
206
  new_item.html(content)
202
- new_item_placeholder.before(new_item)
207
+
208
+ if new_item_placeholder.length != 0
209
+ if new_item_placeholder.data("insert-mode") == "after"
210
+ new_item_placeholder.after(new_item)
211
+ else
212
+ new_item_placeholder.before(new_item)
213
+ else
214
+ @content.append(new_item)
203
215
 
204
216
  @container.trigger("smart_listing:create:success", new_item)
205
217
 
@@ -361,11 +373,19 @@ $.fn.smart_listing_controls = () ->
361
373
  # serialize form and merge it with smart listing params
362
374
  prms = {}
363
375
  $.each controls.serializeArray(), (i, field) ->
364
- prms[field.name] = field.value
376
+ if field.name.endsWith("[]")
377
+ field_name = field.name.slice(0, field.name.length - 2)
378
+ if Array.isArray(prms[field_name])
379
+ prms[field_name].push field.value
380
+ else
381
+ prms[field_name] = [field.value]
382
+ else
383
+ prms[field.name] = field.value
384
+
365
385
  prms = $.extend(smart_listing.params(), prms)
366
386
  smart_listing.params(prms)
367
387
 
368
- container.trigger("ajax:before")
388
+ smart_listing.fadeLoading()
369
389
  smart_listing.reload()
370
390
 
371
391
  $(this).each () ->
@@ -115,9 +115,9 @@ module SmartListing
115
115
  end
116
116
 
117
117
  # Renders the main partial (whole list)
118
- def render_list
118
+ def render_list locals = {}
119
119
  if @smart_listing.partial
120
- @template.render :partial => @smart_listing.partial, :locals => {:smart_listing => self}
120
+ @template.render :partial => @smart_listing.partial, :locals => {:smart_listing => self}.merge(locals || {})
121
121
  end
122
122
  end
123
123
 
@@ -180,6 +180,7 @@ module SmartListing
180
180
  private
181
181
 
182
182
  def sanitize_params params
183
+ params = params.permit! if params.respond_to?(:permit!)
183
184
  params.merge(UNSAFE_PARAMS)
184
185
  end
185
186
 
@@ -229,8 +230,9 @@ module SmartListing
229
230
  end
230
231
 
231
232
  def smart_listing_render name = controller_name, *args
233
+ options = args.dup.extract_options!
232
234
  smart_listing_for(name, *args) do |smart_listing|
233
- concat(smart_listing.render_list)
235
+ concat(smart_listing.render_list(options[:locals]))
234
236
  end
235
237
  end
236
238
 
@@ -328,7 +330,8 @@ module SmartListing
328
330
  smart_listing_config.data_attributes(:params) => smart_listing.all_params,
329
331
  smart_listing_config.data_attributes(:max_count) => smart_listing.max_count,
330
332
  smart_listing_config.data_attributes(:item_count) => smart_listing.count,
331
- }
333
+ },
334
+ :locals => options[:locals] || {}
332
335
  })
333
336
  end
334
337
 
@@ -1,2 +1,2 @@
1
1
  var smart_listing = $('#<%= name %>').smart_listing();
2
- smart_listing.update_list("<%= escape_javascript(render(:partial => part, :locals => {:smart_listing => smart_listing})) %>", <%= smart_listing_data.to_json.html_safe %>);
2
+ smart_listing.update_list("<%= escape_javascript(render(:partial => part, :locals => {:smart_listing => smart_listing}.merge(locals))) %>", <%= smart_listing_data.to_json.html_safe %>);
@@ -81,4 +81,8 @@ SmartListing.configure do |config|
81
81
  #:filtering_input => ".filter input",
82
82
  #:pagination_count => ".pagination-per-page .count",
83
83
  }
84
+
85
+ config.constants :element_templates, {
86
+ #:row => "<tr />",
87
+ }
84
88
  end
@@ -94,6 +94,9 @@ module SmartListing
94
94
  :filtering_icon => "button span",
95
95
  :filtering_input => ".filter input",
96
96
  :pagination_count => ".pagination-per-page .count",
97
+ },
98
+ :element_templates => {
99
+ :row => "<tr />",
97
100
  }
98
101
  }
99
102
  }.freeze
@@ -129,6 +132,10 @@ module SmartListing
129
132
  @options[:constants].try(:[], :selectors).try(:[], key) || DEFAULTS[:constants][:selectors][key]
130
133
  end
131
134
 
135
+ def element_templates key
136
+ @options[:constants].try(:[], :element_templates).try(:[], key) || DEFAULTS[:constants][:element_templates][key]
137
+ end
138
+
132
139
  def global_options value = nil
133
140
  if value && !value.empty?
134
141
  @options[:global_options] ||= {}
@@ -1,3 +1,3 @@
1
1
  module SmartListing
2
- VERSION = "1.1.2"
2
+ VERSION = "1.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_listing
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sology
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-01 00:00:00.000000000 Z
11
+ date: 2016-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - ~>
46
46
  - !ruby/object:Gem::Version
47
- version: 0.16.1
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
- version: 0.16.1
54
+ version: '0.17'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: jquery-rails
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -112,30 +112,30 @@ dependencies:
112
112
  name: capybara
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - '>='
115
+ - - ~>
116
116
  - !ruby/object:Gem::Version
117
- version: '0'
117
+ version: 2.4.4
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - '>='
122
+ - - ~>
123
123
  - !ruby/object:Gem::Version
124
- version: '0'
124
+ version: 2.4.4
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: capybara-webkit
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - '>='
129
+ - - ~>
130
130
  - !ruby/object:Gem::Version
131
- version: '0'
131
+ version: 1.3.1
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - '>='
136
+ - - ~>
137
137
  - !ruby/object:Gem::Version
138
- version: '0'
138
+ version: 1.3.1
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: database_cleaner
141
141
  requirement: !ruby/object:Gem::Requirement
@@ -158,40 +158,41 @@ executables: []
158
158
  extensions: []
159
159
  extra_rdoc_files: []
160
160
  files:
161
+ - app/assets/javascripts/smart_listing.coffee.erb
161
162
  - app/views/kaminari/smart_listing/_paginator.html.erb
162
- - app/views/kaminari/smart_listing/_gap.html.erb
163
+ - app/views/kaminari/smart_listing/_first_page.html.erb
163
164
  - app/views/kaminari/smart_listing/_page.html.erb
164
165
  - app/views/kaminari/smart_listing/_prev_page.html.erb
165
- - app/views/kaminari/smart_listing/_first_page.html.erb
166
- - app/views/kaminari/smart_listing/_next_page.html.erb
167
166
  - app/views/kaminari/smart_listing/_last_page.html.erb
168
- - app/views/smart_listing/item/_new.js.erb
169
- - app/views/smart_listing/item/_create_continue.js.erb
170
- - app/views/smart_listing/item/_edit.js.erb
171
- - app/views/smart_listing/item/_create.js.erb
172
- - app/views/smart_listing/item/_remove.js.erb
173
- - app/views/smart_listing/item/_update.js.erb
174
- - app/views/smart_listing/item/_destroy.js.erb
175
- - app/views/smart_listing/_pagination_per_page_links.html.erb
176
- - app/views/smart_listing/create.js.erb
167
+ - app/views/kaminari/smart_listing/_gap.html.erb
168
+ - app/views/kaminari/smart_listing/_next_page.html.erb
169
+ - app/views/smart_listing/destroy.js.erb
177
170
  - app/views/smart_listing/_action_custom.html.erb
178
- - app/views/smart_listing/_update_list.js.erb
171
+ - app/views/smart_listing/_item_new.html.erb
172
+ - app/views/smart_listing/_action_delete.html.erb
179
173
  - app/views/smart_listing/edit.js.erb
174
+ - app/views/smart_listing/_pagination_per_page_links.html.erb
180
175
  - app/views/smart_listing/_pagination_per_page_link.html.erb
181
- - app/views/smart_listing/update.js.erb
182
- - app/views/smart_listing/_action_delete.html.erb
183
- - app/views/smart_listing/_item_new.html.erb
184
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
+ - app/views/smart_listing/_action_edit.html.erb
185
180
  - app/views/smart_listing/new.js.erb
181
+ - app/views/smart_listing/_update_list.js.erb
186
182
  - app/views/smart_listing/_sortable.html.erb
187
- - app/views/smart_listing/_action_edit.html.erb
188
- - app/views/smart_listing/_action_show.html.erb
189
- - app/views/smart_listing/destroy.js.erb
190
- - app/assets/javascripts/smart_listing.coffee.erb
183
+ - app/views/smart_listing/create.js.erb
184
+ - app/views/smart_listing/item/_create.js.erb
185
+ - app/views/smart_listing/item/_edit.js.erb
186
+ - app/views/smart_listing/item/_destroy.js.erb
187
+ - app/views/smart_listing/item/_remove.js.erb
188
+ - app/views/smart_listing/item/_new.js.erb
189
+ - app/views/smart_listing/item/_update.js.erb
190
+ - app/views/smart_listing/item/_create_continue.js.erb
191
191
  - app/helpers/smart_listing/application_helper.rb
192
192
  - app/helpers/smart_listing/helper.rb
193
193
  - config/routes.rb
194
194
  - config/locales/en.yml
195
+ - lib/smart_listing.rb
195
196
  - lib/tasks/smart_list_tasks.rake
196
197
  - lib/smart_listing/config.rb
197
198
  - lib/smart_listing/engine.rb
@@ -199,7 +200,6 @@ files:
199
200
  - lib/generators/smart_listing/views_generator.rb
200
201
  - lib/generators/smart_listing/install_generator.rb
201
202
  - lib/generators/smart_listing/templates/initializer.rb
202
- - lib/smart_listing.rb
203
203
  - LICENSE
204
204
  - Rakefile
205
205
  - README.md
@@ -223,7 +223,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
223
223
  version: '0'
224
224
  requirements: []
225
225
  rubyforge_project:
226
- rubygems_version: 2.1.10
226
+ rubygems_version: 2.0.3
227
227
  signing_key:
228
228
  specification_version: 4
229
229
  summary: SmartListing helps creating sortable lists of ActiveRecord collections with