smart_listing 0.9.3 → 0.9.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ed162afb1635a06affeb6c2bb0f3bc0d539b7cad
4
- data.tar.gz: 9cae821c8260b22a3782daf452008b1da9822e54
3
+ metadata.gz: 34f2ebadeaeafd444b806b6392bd706ebd298d24
4
+ data.tar.gz: dd9ebe392e5a3976e2c69183d32cb90c6cf67e2d
5
5
  SHA512:
6
- metadata.gz: 1ee4da5ad5023f269936c615dd547c2710c13925ab6e892fc28dad1bb86c2d2e54aacabe4ce8b241b7c9c2847fe1353539f06a2def7c381cdd5355684d4c556d
7
- data.tar.gz: 56fb50e405e8afdee3f471f1e565dd3e764197a183c8113b02321c7edf5756ed40c3bdcca01e5978209a49d1b42d75760812c730f76c183f167de5d99669db25
6
+ metadata.gz: 6cc5d0d352c80b62fcd0526ce62385a2c58e0eda3563131d56748d2a8cc235e0144c078f8b9e5aa01cc5ea2b14b4c930489b2986de40e7f51e04a7d008542646
7
+ data.tar.gz: 239bdd2c28d6f113c864ef5054135a5a7b65fcf83e2dc482da3a162eb610e34a4e2a73c6c1a2064a403eb0868bec9c1411d648bf8ebf61b6e7da0d9c482573c2
@@ -54,6 +54,7 @@ class SmartListing
54
54
  $(confirmation_elem).click()
55
55
  $(confirmation_elem).popover('destroy')
56
56
  )
57
+ .append(" ")
57
58
  .append($('<button/>').html('No').addClass('btn btn-small').click (event) =>
58
59
  editable = $(event.currentTarget).closest('.editable')
59
60
  $(confirmation_elem).popover('destroy')
@@ -86,8 +87,8 @@ class SmartListing
86
87
  @cancelEdit(editable)
87
88
  else
88
89
  # Cancel new record
89
- @container.find('.new_item_placeholder').addClass('disabled')
90
- @container.find('.new_item_action').removeClass('disabled')
90
+ @container.find('.new_item_placeholder').addClass('hidden')
91
+ @container.find('.new_item_action').removeClass('hidden')
91
92
  false
92
93
 
93
94
  @container.on 'click', '.actions a[data-confirmation]', (event) =>
@@ -95,7 +96,7 @@ class SmartListing
95
96
  if(@confirmed != event.currentTarget)
96
97
  # We need confirmation
97
98
  @container.find('.actions a').popover('destroy')
98
- $(event.currentTarget).popover(content: createPopover(event.currentTarget, $(event.currentTarget).data('confirmation')), html: true, trigger: 'manual')
99
+ $(event.currentTarget).popover(content: createPopover(event.currentTarget, $(event.currentTarget).data('confirmation')), html: true, trigger: 'manual', title: null)
99
100
  $(event.currentTarget).popover('show')
100
101
  false
101
102
  else
@@ -106,6 +107,17 @@ class SmartListing
106
107
  @container.on 'click', 'input[type=text].autoselect', (event) ->
107
108
  $(this).select()
108
109
 
110
+ @container.on 'change', '.callback', (event) =>
111
+ checkbox = $(event.currentTarget)
112
+ id = checkbox.closest("tr").data("id")
113
+ data = {}
114
+ data[checkbox.val()] = checkbox.is(":checked")
115
+ $.ajax({
116
+ url: @container.data("callback-href"),
117
+ type: "POST",
118
+ data: data,
119
+ })
120
+
109
121
  fadeLoading: =>
110
122
  @content.stop(true).fadeTo(500, 0.2)
111
123
  @loading.show()
@@ -152,11 +164,11 @@ class SmartListing
152
164
  if @maxCount()
153
165
  if @itemCount() >= @maxCount()
154
166
  if @itemCount()
155
- @container.find('.new_item_action').addClass('disabled')
156
- @container.find('.new_item_action .btn').addClass('disabled')
167
+ @container.find('.new_item_action').addClass('hidden')
168
+ @container.find('.new_item_action .btn').addClass('hidden')
157
169
  else
158
- @container.find('.new_item_action').removeClass('disabled')
159
- @container.find('.new_item_action .btn').removeClass('disabled')
170
+ @container.find('.new_item_action').removeClass('hidden')
171
+ @container.find('.new_item_action .btn').removeClass('hidden')
160
172
 
161
173
  @status.each (index, status) =>
162
174
  $(status).find('.smart_listing_limit').html(@maxCount() - @itemCount())
@@ -177,13 +189,13 @@ class SmartListing
177
189
 
178
190
  new_item: (content) =>
179
191
  new_item_action = @container.find('.new_item_action')
180
- new_item_placeholder = @container.find('.new_item_placeholder').addClass('disabled')
192
+ new_item_placeholder = @container.find('.new_item_placeholder').addClass('hidden')
181
193
 
182
194
  @container.find('.editable').each (i, v) =>
183
195
  @cancelEdit($(v))
184
196
 
185
- new_item_action.addClass('disabled')
186
- new_item_placeholder.removeClass('disabled')
197
+ new_item_action.addClass('hidden')
198
+ new_item_placeholder.removeClass('hidden')
187
199
  new_item_placeholder.html(content)
188
200
  new_item_placeholder.addClass('info')
189
201
 
@@ -194,8 +206,8 @@ class SmartListing
194
206
  new_item_placeholder = @container.find('.new_item_placeholder')
195
207
 
196
208
  if success
197
- new_item_placeholder.addClass('disabled')
198
- new_item_action.removeClass('disabled')
209
+ new_item_placeholder.addClass('hidden')
210
+ new_item_action.removeClass('hidden')
199
211
 
200
212
  new_item = $('<tr />').addClass('editable')
201
213
  new_item.attr('data-id', id)
@@ -212,8 +224,8 @@ class SmartListing
212
224
  edit: (id, content) =>
213
225
  @container.find('.editable').each (i, v) =>
214
226
  @cancelEdit($(v))
215
- @container.find('.new_item_placeholder').addClass('disabled')
216
- @container.find('.new_item_action').removeClass('disabled')
227
+ @container.find('.new_item_placeholder').addClass('hidden')
228
+ @container.find('.new_item_action').removeClass('hidden')
217
229
 
218
230
  editable = @container.find(".editable[data-id=#{id}]")
219
231
  editable.data('smart_listing_edit_backup', editable.html())
@@ -265,6 +277,7 @@ $.fn.handleSmartListingControls = () ->
265
277
  $(this).each () ->
266
278
  controls = $(this)
267
279
  smart_listing = $("##{controls.data('smart-listing')}")
280
+ reset = controls.find(".reset")
268
281
 
269
282
  controls.submit ->
270
283
  # Merges smart list params with the form action url before submitting.
@@ -296,18 +309,18 @@ $.fn.handleSmartListingFilter = () ->
296
309
 
297
310
  field.observeField(
298
311
  onFilled: ->
299
- icon.removeClass('icon-search')
300
- icon.addClass('icon-remove')
312
+ icon.removeClass('glyphicon-search')
313
+ icon.addClass('glyphicon-remove')
301
314
  button.removeClass('disabled')
302
315
  onEmpty: ->
303
- icon.addClass('icon-search')
304
- icon.removeClass('icon-remove')
316
+ icon.addClass('glyphicon-search')
317
+ icon.removeClass('glyphicon-remove')
305
318
  button.addClass('disabled')
306
319
  onChange: ->
307
320
  form.submit()
308
321
  )
309
322
 
310
- button.click ->
323
+ icon.click ->
311
324
  if field.val().length > 0
312
325
  field.val('')
313
326
  field.trigger('keydown')
@@ -40,7 +40,7 @@ module SmartListing
40
40
 
41
41
  def pagination_per_page_links options = {}
42
42
  container_classes = ["pagination_per_page"]
43
- container_classes << "disabled" if empty?
43
+ container_classes << "hidden" if empty?
44
44
 
45
45
  per_page_sizes = @smart_listing.page_sizes.clone
46
46
  per_page_sizes.push(0) if @smart_listing.unlimited_per_page?
@@ -113,15 +113,15 @@ module SmartListing
113
113
 
114
114
  # Add new item button & placeholder to list
115
115
  def item_new options = {}
116
- new_item_action_classes = %{new_item_action}
117
- new_item_action_classes << "disabled" if !empty? && max_count?
118
- no_records_classes = %{no_records}
119
- no_records_classes << "disabled" unless empty?
116
+ new_item_action_classes = %w{new_item_action}
117
+ new_item_action_classes << "hidden" if !empty? && max_count?
118
+ no_records_classes = %w{no_records}
119
+ no_records_classes << "hidden" unless empty?
120
120
  new_item_button_classes = []
121
- new_item_button_classes << "disabled" if max_count?
121
+ new_item_button_classes << "hidden" if max_count?
122
122
 
123
123
  locals = {
124
- :placeholder_classes => %w{new_item_placeholder disabled},
124
+ :placeholder_classes => %w{new_item_placeholder hidden},
125
125
  :new_item_action_classes => new_item_action_classes,
126
126
  :colspan => options.delete(:colspan),
127
127
  :no_items_classes => no_records_classes,
@@ -132,7 +132,6 @@ module SmartListing
132
132
  }
133
133
 
134
134
  @template.render(:partial => 'smart_listing/item_new', :locals => default_locals.merge(locals))
135
- nil
136
135
  end
137
136
 
138
137
  # Check if smart list is empty
@@ -171,6 +170,7 @@ module SmartListing
171
170
  data = {}
172
171
  data['max-count'] = @smart_listings[name].max_count if @smart_listings[name].max_count && @smart_listings[name].max_count > 0
173
172
  data['href'] = @smart_listings[name].href if @smart_listings[name].href
173
+ data['callback_href'] = @smart_listings[name].callback_href if @smart_listings[name].callback_href
174
174
  data.merge!(options[:data]) if options[:data]
175
175
 
176
176
  if bare
@@ -12,15 +12,15 @@
12
12
  new_item_button_text
13
13
  -%>
14
14
 
15
- <%= content_tag(:tr, '', :class => placeholder_classes.merge(%{info})) %>
16
- <%= content_tag(:tr, :class => new_item_action_classes.merge(%{info})) do %>
15
+ <%= content_tag(:tr, '', :class => placeholder_classes + %w{info}) %>
16
+ <%= content_tag(:tr, :class => new_item_action_classes + %w{info}) do %>
17
17
  <%= content_tag(:td, :colspan => colspan) do %>
18
- <%= content_tag(:p, :class => no_items_classes.merge(%{pull-left})) do %>
18
+ <%= content_tag(:h5, :class => no_items_classes + %w{pull-left}) do %>
19
19
  <%= no_items_text %>
20
20
  <% end %>
21
- <%= link_to(new_item_button_url, :remote => true, :class => new_item_button_classes.merge(%{btn pull-right})) do %>
21
+ <%= link_to(new_item_button_url, :remote => true, :class => new_item_button_classes + %w{btn pull-right}) do %>
22
22
  <%= content_tag(:i, '', :class => "glyphicon glyphicon-plus") %>
23
- <%= new_item_text %>
23
+ <%= new_item_button_text %>
24
24
  <% end %>
25
25
  <% end %>
26
26
  <% end %>
@@ -9,4 +9,4 @@
9
9
  -%>
10
10
 
11
11
  <% name = page == 0 ? t('views.pagination.unlimited') : page %>
12
- <%= url ? link_to(name, url) : content_tag(:span, name) %>
12
+ <%= url ? link_to(name, url, :remote => true) : content_tag(:span, name) %>
@@ -1,3 +1,3 @@
1
1
  module SmartListing
2
- VERSION = "0.9.3"
2
+ VERSION = "0.9.4"
3
3
  end
data/lib/smart_listing.rb CHANGED
@@ -28,6 +28,7 @@ module SmartListing
28
28
  :sort => true, # allow sorting
29
29
  :paginate => true, # allow pagination
30
30
  :href => nil, # set smart list target url (in case when different than current url)
31
+ :callback_href => nil, # set smart list callback url (in case when different than current url)
31
32
  :default_sort_attr => nil, # default sort by
32
33
  :memorize_per_page => false,
33
34
  :page_sizes => DEFAULT_PAGE_SIZES, # set available page sizes array
@@ -52,6 +53,12 @@ module SmartListing
52
53
 
53
54
  @count = @collection.size
54
55
 
56
+ # Reset @page if greater than total number of pages
57
+ no_pages = (@count.to_f / @per_page.to_f).ceil.to_i
58
+ if @page.to_i > no_pages
59
+ @page = no_pages
60
+ end
61
+
55
62
  if @options[:array]
56
63
  @collection = @collection.sort do |x, y|
57
64
  xval = x
@@ -107,6 +114,10 @@ module SmartListing
107
114
  @options[:href]
108
115
  end
109
116
 
117
+ def callback_href
118
+ @options[:callback_href]
119
+ end
120
+
110
121
  def page_sizes
111
122
  @options[:page_sizes]
112
123
  end
metadata CHANGED
@@ -1,69 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_listing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 0.9.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sology
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-30 00:00:00.000000000 Z
11
+ date: 2014-02-14 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'
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'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: sqlite3
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: :development
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
  description:
@@ -73,36 +73,36 @@ executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
- - app/views/smart_listing/item/_new.js.erb
77
- - app/views/smart_listing/item/_edit.js.erb
78
- - app/views/smart_listing/item/_create.js.erb
79
- - app/views/smart_listing/item/_remove.js.erb
80
- - app/views/smart_listing/item/_update.js.erb
81
- - app/views/smart_listing/item/_destroy.js.erb
82
- - app/views/smart_listing/_pagination_per_page_links.html.erb
76
+ - LICENSE
77
+ - README.md
78
+ - Rakefile
79
+ - app/assets/javascripts/smart_listing/application.js
80
+ - app/assets/javascripts/smart_listing/smart_listing.coffee
81
+ - app/assets/stylesheets/smart_listing/application.css
82
+ - app/helpers/smart_listing/application_helper.rb
83
+ - app/helpers/smart_listing/helper.rb
83
84
  - app/views/smart_listing/_action_custom.html.erb
84
- - app/views/smart_listing/_action_inactive.html.erb
85
- - app/views/smart_listing/_update_list.js.erb
86
- - app/views/smart_listing/_pagination_per_page_link.html.erb
87
85
  - app/views/smart_listing/_action_delete.html.erb
86
+ - app/views/smart_listing/_action_edit.html.erb
87
+ - app/views/smart_listing/_action_inactive.html.erb
88
88
  - app/views/smart_listing/_item_new.html.erb
89
+ - app/views/smart_listing/_pagination_per_page_link.html.erb
90
+ - app/views/smart_listing/_pagination_per_page_links.html.erb
89
91
  - app/views/smart_listing/_sortable.html.erb
90
- - app/views/smart_listing/_action_edit.html.erb
91
- - app/assets/stylesheets/smart_listing/application.css
92
- - app/assets/javascripts/smart_listing/smart_listing.coffee
93
- - app/assets/javascripts/smart_listing/application.js
94
- - app/helpers/smart_listing/application_helper.rb
95
- - app/helpers/smart_listing/helper.rb
96
- - config/routes.rb
92
+ - app/views/smart_listing/_update_list.js.erb
93
+ - app/views/smart_listing/item/_create.js.erb
94
+ - app/views/smart_listing/item/_destroy.js.erb
95
+ - app/views/smart_listing/item/_edit.js.erb
96
+ - app/views/smart_listing/item/_new.js.erb
97
+ - app/views/smart_listing/item/_remove.js.erb
98
+ - app/views/smart_listing/item/_update.js.erb
97
99
  - config/locales/en.yml
98
- - lib/tasks/smart_list_tasks.rake
99
- - lib/smart_listing/engine.rb
100
- - lib/smart_listing/version.rb
100
+ - config/routes.rb
101
101
  - lib/generators/smart_listing/views_generator.rb
102
102
  - lib/smart_listing.rb
103
- - LICENSE
104
- - Rakefile
105
- - README.md
103
+ - lib/smart_listing/engine.rb
104
+ - lib/smart_listing/version.rb
105
+ - lib/tasks/smart_list_tasks.rake
106
106
  homepage: https://github.com/Sology/smart_listing
107
107
  licenses:
108
108
  - MIT
@@ -113,17 +113,17 @@ require_paths:
113
113
  - lib
114
114
  required_ruby_version: !ruby/object:Gem::Requirement
115
115
  requirements:
116
- - - '>='
116
+ - - ">="
117
117
  - !ruby/object:Gem::Version
118
118
  version: '0'
119
119
  required_rubygems_version: !ruby/object:Gem::Requirement
120
120
  requirements:
121
- - - '>='
121
+ - - ">="
122
122
  - !ruby/object:Gem::Version
123
123
  version: '0'
124
124
  requirements: []
125
125
  rubyforge_project:
126
- rubygems_version: 2.0.14
126
+ rubygems_version: 2.2.0
127
127
  signing_key:
128
128
  specification_version: 4
129
129
  summary: SmartListing helps creating sortable lists of ActiveRecord collections with