grapple 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +0 -0
- data/README.md +0 -0
- data/Rakefile +0 -0
- data/app/assets/images/grapple/arrow-down.png +0 -0
- data/app/assets/images/grapple/arrow-up.png +0 -0
- data/app/assets/images/grapple/loading-bar.gif +0 -0
- data/app/assets/images/grapple/minus.png +0 -0
- data/app/assets/images/grapple/plus.png +0 -0
- data/app/assets/javascripts/grapple-history.js +0 -0
- data/app/assets/javascripts/grapple-jquery.js +0 -0
- data/app/assets/javascripts/grapple.js +0 -0
- data/app/assets/stylesheets/grapple.css +0 -0
- data/config/locales/en.yml +0 -0
- data/lib/grapple.rb +0 -0
- data/lib/grapple/ajax_data_grid_builder.rb +0 -0
- data/lib/grapple/base_table_builder.rb +0 -0
- data/lib/grapple/components.rb +0 -0
- data/lib/grapple/components/actions.rb +0 -0
- data/lib/grapple/components/base_component.rb +0 -0
- data/lib/grapple/components/column_headings.rb +0 -0
- data/lib/grapple/components/html_body.rb +0 -0
- data/lib/grapple/components/html_caption.rb +0 -0
- data/lib/grapple/components/html_colgroup.rb +0 -0
- data/lib/grapple/components/html_component.rb +7 -1
- data/lib/grapple/components/html_footer.rb +0 -0
- data/lib/grapple/components/html_header.rb +0 -0
- data/lib/grapple/components/html_row.rb +0 -0
- data/lib/grapple/components/kaminari_infobar.rb +40 -0
- data/lib/grapple/components/kaminari_pagination.rb +40 -0
- data/lib/grapple/components/search_form.rb +0 -0
- data/lib/grapple/components/search_query_field.rb +0 -0
- data/lib/grapple/components/search_submit.rb +0 -0
- data/lib/grapple/components/toolbar.rb +0 -0
- data/lib/grapple/components/will_paginate_infobar.rb +0 -0
- data/lib/grapple/components/will_paginate_pagination.rb +0 -0
- data/lib/grapple/data_grid_builder.rb +0 -0
- data/lib/grapple/engine.rb +0 -0
- data/lib/grapple/helpers.rb +0 -0
- data/lib/grapple/helpers/table_helper.rb +0 -0
- data/lib/grapple/html_table_builder.rb +0 -0
- data/spec/builders/ajax_data_grid_builder_spec.rb +0 -0
- data/spec/builders/base_table_builder_spec.rb +0 -0
- data/spec/builders/data_grid_builder_spec.rb +0 -0
- data/spec/builders/html_table_builder_spec.rb +0 -0
- data/spec/components/actions_spec.rb +0 -0
- data/spec/components/column_headings_spec.rb +0 -0
- data/spec/components/html_body_spec.rb +0 -0
- data/spec/components/html_colgroup_spec.rb +0 -0
- data/spec/components/html_footer_spec.rb +0 -0
- data/spec/components/search_form_spec.rb +0 -0
- data/spec/components/toolbar_spec.rb +0 -0
- data/spec/components/will_paginate_spec.rb +0 -0
- data/spec/fixtures/schema.rb +0 -0
- data/spec/fixtures/users.yml +0 -0
- data/spec/spec_helper.rb +0 -0
- data/spec/support/test_environment.rb +0 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fba23ec15fa15e3af330adb21135aa01d7fc086b
|
4
|
+
data.tar.gz: a1400867677c6d2aaf42f960be45cc3a43290882
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/config/locales/en.yml
CHANGED
File without changes
|
data/lib/grapple.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
data/lib/grapple/components.rb
CHANGED
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
|
-
|
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 = ' '
|
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
|
data/lib/grapple/engine.rb
CHANGED
File without changes
|
data/lib/grapple/helpers.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
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/spec/fixtures/schema.rb
CHANGED
File without changes
|
data/spec/fixtures/users.yml
CHANGED
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.
|
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:
|
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.
|
210
|
+
rubygems_version: 2.5.1
|
209
211
|
signing_key:
|
210
212
|
specification_version: 4
|
211
213
|
summary: Customizable data grid for Rails
|