grapple 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +0 -0
  3. data/README.md +0 -0
  4. data/Rakefile +0 -0
  5. data/app/assets/images/grapple/arrow-down.png +0 -0
  6. data/app/assets/images/grapple/arrow-up.png +0 -0
  7. data/app/assets/images/grapple/loading-bar.gif +0 -0
  8. data/app/assets/images/grapple/minus.png +0 -0
  9. data/app/assets/images/grapple/plus.png +0 -0
  10. data/app/assets/javascripts/grapple-history.js +0 -0
  11. data/app/assets/javascripts/grapple-jquery.js +0 -0
  12. data/app/assets/javascripts/grapple.js +0 -0
  13. data/app/assets/stylesheets/grapple.css +0 -0
  14. data/config/locales/en.yml +0 -0
  15. data/lib/grapple.rb +0 -0
  16. data/lib/grapple/ajax_data_grid_builder.rb +0 -0
  17. data/lib/grapple/base_table_builder.rb +0 -0
  18. data/lib/grapple/components.rb +0 -0
  19. data/lib/grapple/components/actions.rb +0 -0
  20. data/lib/grapple/components/base_component.rb +0 -0
  21. data/lib/grapple/components/column_headings.rb +0 -0
  22. data/lib/grapple/components/html_body.rb +0 -0
  23. data/lib/grapple/components/html_caption.rb +0 -0
  24. data/lib/grapple/components/html_colgroup.rb +0 -0
  25. data/lib/grapple/components/html_component.rb +7 -1
  26. data/lib/grapple/components/html_footer.rb +0 -0
  27. data/lib/grapple/components/html_header.rb +0 -0
  28. data/lib/grapple/components/html_row.rb +0 -0
  29. data/lib/grapple/components/kaminari_infobar.rb +40 -0
  30. data/lib/grapple/components/kaminari_pagination.rb +40 -0
  31. data/lib/grapple/components/search_form.rb +0 -0
  32. data/lib/grapple/components/search_query_field.rb +0 -0
  33. data/lib/grapple/components/search_submit.rb +0 -0
  34. data/lib/grapple/components/toolbar.rb +0 -0
  35. data/lib/grapple/components/will_paginate_infobar.rb +0 -0
  36. data/lib/grapple/components/will_paginate_pagination.rb +0 -0
  37. data/lib/grapple/data_grid_builder.rb +0 -0
  38. data/lib/grapple/engine.rb +0 -0
  39. data/lib/grapple/helpers.rb +0 -0
  40. data/lib/grapple/helpers/table_helper.rb +0 -0
  41. data/lib/grapple/html_table_builder.rb +0 -0
  42. data/spec/builders/ajax_data_grid_builder_spec.rb +0 -0
  43. data/spec/builders/base_table_builder_spec.rb +0 -0
  44. data/spec/builders/data_grid_builder_spec.rb +0 -0
  45. data/spec/builders/html_table_builder_spec.rb +0 -0
  46. data/spec/components/actions_spec.rb +0 -0
  47. data/spec/components/column_headings_spec.rb +0 -0
  48. data/spec/components/html_body_spec.rb +0 -0
  49. data/spec/components/html_colgroup_spec.rb +0 -0
  50. data/spec/components/html_footer_spec.rb +0 -0
  51. data/spec/components/search_form_spec.rb +0 -0
  52. data/spec/components/toolbar_spec.rb +0 -0
  53. data/spec/components/will_paginate_spec.rb +0 -0
  54. data/spec/fixtures/schema.rb +0 -0
  55. data/spec/fixtures/users.yml +0 -0
  56. data/spec/spec_helper.rb +0 -0
  57. data/spec/support/test_environment.rb +0 -0
  58. metadata +5 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 29fe6d42cf2c20b787701ae4129775f325a3a67a
4
- data.tar.gz: 274443c21e688445641107e68db1a937baa4848f
3
+ metadata.gz: fba23ec15fa15e3af330adb21135aa01d7fc086b
4
+ data.tar.gz: a1400867677c6d2aaf42f960be45cc3a43290882
5
5
  SHA512:
6
- metadata.gz: 86634330ca55fc613cff43012798c0ab8a5f0e6742c9301e836c20bcc32355c5c43e0a76677c1ffd8cfd6d8936f4ec2eb323ccb17f90e62ece6ddbb7ff9856a8
7
- data.tar.gz: 362d5d6e62826ae54ef5dc6759e964a75f2b05e0486b01799e0c7dac0b5b6f84db1d684ec0a34cb025e1388c60508bd7d87aef7c2e4454f81f50e081e7248476
6
+ metadata.gz: c34626569e41eb3064454c449b39c6bf789addcf65e67891b2adade034e62666dbadc8ef5aec741cbd86466a2f30a0ce148b87e3f2aebc2ccb75756b0e23683b
7
+ data.tar.gz: c7209519dd827357fa63d1d582ab050cfbd1b83345dbc24ea994c591f969b8d16fd0d39735b8328acbf4dd809e10cf1d661ada5d44bf34672d26125501e2851e
data/LICENSE CHANGED
File without changes
data/README.md CHANGED
File without changes
data/Rakefile CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
data/lib/grapple.rb CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -16,7 +16,13 @@ module Grapple
16
16
  if options[:sort] == params[:sort]
17
17
  options[:dir] = (params[:dir] == 'desc') ? 'asc' : 'desc'
18
18
  end
19
- url_params = params.stringify_keys().merge(options.stringify_keys())
19
+ # Convert ActionController::Parameters to a Hash
20
+ p = if params.respond_to?(:to_unsafe_h)
21
+ params.to_unsafe_h
22
+ else
23
+ params.to_h
24
+ end
25
+ url_params = p.stringify_keys().merge(options.stringify_keys())
20
26
  if @builder.namespace
21
27
  tmp = {}
22
28
  url_params.each do |key, value|
File without changes
File without changes
File without changes
@@ -0,0 +1,40 @@
1
+ module Grapple
2
+ module Components
3
+ class KaminariInfobar < HtmlComponent
4
+
5
+ setting :message, "Displaying %s - %s of %s results"
6
+ setting :estimate_message, "Displaying %s - %s of about %s results"
7
+ setting :no_results_message, "0 results"
8
+
9
+ def render
10
+ estimate = false
11
+ begin
12
+ # total_count will throw an error if without_count is being used
13
+ total_count = records.total_count
14
+ rescue Exception => e
15
+ estimate = true
16
+ total_count = ActiveRecord::Base.connection.execute(
17
+ "SELECT reltuples AS approximate_row_count FROM pg_class WHERE relname = '#{records.table_name}'"
18
+ ).first["approximate_row_count"].to_i
19
+ end
20
+
21
+ if total_count > 0
22
+ offset = (records.current_page - 1) * records.current_per_page
23
+ start_range = offset + 1
24
+ end_range = [offset + records.current_per_page, total_count].min
25
+
26
+ start_range = ActiveSupport::NumberHelper.number_to_delimited(start_range)
27
+ end_range = ActiveSupport::NumberHelper.number_to_delimited(end_range)
28
+ total = ActiveSupport::NumberHelper.number_to_delimited(total_count)
29
+
30
+ html = sprintf((estimate ? estimate_message : message), start_range, end_range, total)
31
+ else
32
+ html = no_results_message
33
+ end
34
+
35
+ builder.row "<th colspan=\"#{num_columns}\">#{html}</th>", :class => 'infobar'
36
+ end
37
+
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,40 @@
1
+ module Grapple
2
+ module Components
3
+ # Generates paging links using will_paginate.
4
+ #
5
+ # @example
6
+ # <%= table_for(columns, Post.paginate(page: 2)) do |t| %>
7
+ # <%= t.footer do %>
8
+ # <%= t.pagination %>
9
+ # <% end %>
10
+ # <% end %>
11
+ #
12
+ class KaminariPagination < HtmlComponent
13
+
14
+ setting :no_results_message, :no_search_results
15
+ setting :renderer, nil
16
+
17
+ def render(paginate_parameters = {})
18
+ td_class = ""
19
+ if records.instance_of?(Array)
20
+ html = '&nbsp;'
21
+ elsif !params[:query].blank? and records.empty?
22
+ html = h(t(no_results_message))
23
+ td_class = "class='text-left'"
24
+ else
25
+ begin
26
+ # paginate helper will throw an error if without_count is being used
27
+ html = template.paginate(records)
28
+ rescue Exception => e
29
+ html = template.link_to_prev_page(records, "Previous Page") || ""
30
+ html += " " if html
31
+ html += template.link_to_next_page(records, "Next Page") || ""
32
+ end
33
+ end
34
+
35
+ builder.row "<td colspan=\"#{num_columns}\" #{td_class}>#{html}</td>"
36
+ end
37
+
38
+ end
39
+ end
40
+ end
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
data/spec/spec_helper.rb CHANGED
File without changes
File without changes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grapple
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edward Potocko
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-03-16 00:00:00.000000000 Z
13
+ date: 2018-02-23 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: actionpack
@@ -157,6 +157,8 @@ files:
157
157
  - lib/grapple/components/html_footer.rb
158
158
  - lib/grapple/components/html_header.rb
159
159
  - lib/grapple/components/html_row.rb
160
+ - lib/grapple/components/kaminari_infobar.rb
161
+ - lib/grapple/components/kaminari_pagination.rb
160
162
  - lib/grapple/components/search_form.rb
161
163
  - lib/grapple/components/search_query_field.rb
162
164
  - lib/grapple/components/search_submit.rb
@@ -205,7 +207,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
205
207
  version: '0'
206
208
  requirements: []
207
209
  rubyforge_project:
208
- rubygems_version: 2.4.8
210
+ rubygems_version: 2.5.1
209
211
  signing_key:
210
212
  specification_version: 4
211
213
  summary: Customizable data grid for Rails