grapple 0.1.9 → 0.1.10
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/ajax_data_grid_builder.rb +0 -0
- data/lib/grapple/base_table_builder.rb +30 -1
- data/lib/grapple/components/actions.rb +17 -0
- data/lib/grapple/components/base_component.rb +10 -3
- data/lib/grapple/components/column_headings.rb +2 -2
- 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 +0 -0
- data/lib/grapple/components/html_footer.rb +0 -0
- data/lib/grapple/components/html_header.rb +1 -0
- data/lib/grapple/components/html_row.rb +0 -0
- data/lib/grapple/components/kaminari_pagination.rb +2 -2
- 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_pagination.rb +2 -1
- data/lib/grapple/components.rb +0 -0
- data/lib/grapple/data_grid_builder.rb +0 -0
- data/lib/grapple/engine.rb +0 -0
- data/lib/grapple/helpers/table_helper.rb +10 -0
- data/lib/grapple/helpers.rb +0 -0
- data/lib/grapple/html_table_builder.rb +0 -0
- data/lib/grapple.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 +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68bba465bb61d6a8343e0029923b398fe5ef5569
|
4
|
+
data.tar.gz: ff37c6cc6d79e153795c6d74cd2a418101f856d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b41a77f3d07dadd2502b0561a5889d4347c415f9c372d159d7114d12f6e1aa9fedbab7a65592658a8b59aee33f82303997a861adcdb2f6bd168c65cf4161f257
|
7
|
+
data.tar.gz: 3b1a4b251d8300697f1084d7fdf538ca3b1f27f83f959b862ea158e074e08185e8a710d8b827b8c650df3e3f72ef63b5189e3491a230cee82f8af3ee09afe438
|
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
|
File without changes
|
@@ -2,6 +2,12 @@ module Grapple
|
|
2
2
|
class BaseTableBuilder
|
3
3
|
|
4
4
|
# Create a helper
|
5
|
+
# @param name [Symbol]
|
6
|
+
# The name of the helper
|
7
|
+
# @param klass [Grapple::Components::BaseComponent]
|
8
|
+
# The component class
|
9
|
+
# @param settings [Hash]
|
10
|
+
# Settings for the component
|
5
11
|
def self.helper(name, klass, settings = {})
|
6
12
|
class_eval <<-RUBY_EVAL
|
7
13
|
def #{name}(*arguments, &block)
|
@@ -13,6 +19,10 @@ module Grapple
|
|
13
19
|
end
|
14
20
|
|
15
21
|
# Update settings for a helper
|
22
|
+
# @param helper_name [Symbol]
|
23
|
+
# The name of the helper
|
24
|
+
# @param options [Hash]
|
25
|
+
# Settings to update for the component
|
16
26
|
def self.configure(helper_name, *options)
|
17
27
|
settings = options[0] || {}
|
18
28
|
method = :"settings_for_#{helper_name}"
|
@@ -24,7 +34,22 @@ module Grapple
|
|
24
34
|
define_singleton_method(method) { settings }
|
25
35
|
end
|
26
36
|
|
27
|
-
|
37
|
+
# An Array of columns
|
38
|
+
# @return [Array<Hash>]
|
39
|
+
attr_reader :columns
|
40
|
+
|
41
|
+
# An Array, ActiveRecord::Collection or Enumerable of records to be displayed in the table
|
42
|
+
# @return [Enumerable]
|
43
|
+
attr_reader :records
|
44
|
+
|
45
|
+
# @return [ActionView::Base]
|
46
|
+
attr_reader :template
|
47
|
+
|
48
|
+
# Request parameters
|
49
|
+
attr_reader :params
|
50
|
+
|
51
|
+
# @return [String] namespace for the grapple table
|
52
|
+
attr_reader :namespace
|
28
53
|
|
29
54
|
def initialize(template, columns, records, params = {}, *options)
|
30
55
|
@template = template
|
@@ -37,14 +62,18 @@ module Grapple
|
|
37
62
|
@helper_instances = {}
|
38
63
|
end
|
39
64
|
|
65
|
+
# Default options for the component
|
66
|
+
# @return [Hash]
|
40
67
|
def default_options
|
41
68
|
{ }
|
42
69
|
end
|
43
70
|
|
71
|
+
# HTML to insert before the <table> tag
|
44
72
|
def before_table
|
45
73
|
''
|
46
74
|
end
|
47
75
|
|
76
|
+
# HTML to insert after the </table> tag
|
48
77
|
def after_table
|
49
78
|
''
|
50
79
|
end
|
@@ -1,5 +1,22 @@
|
|
1
1
|
module Grapple
|
2
2
|
module Components
|
3
|
+
|
4
|
+
# Render links that apply to the table
|
5
|
+
# @example
|
6
|
+
# <%
|
7
|
+
# actions = [
|
8
|
+
# { label: :new_user, url: new_user_path },
|
9
|
+
# { label: :export_users, url: export_users_path }
|
10
|
+
# ]
|
11
|
+
# %>
|
12
|
+
# <%= table_for(columns, @users) do |t| %>
|
13
|
+
# <%= t.header do %>
|
14
|
+
# <%= t.toolbar do %>
|
15
|
+
# <%= t.actions actions %>
|
16
|
+
# <% end %>
|
17
|
+
# <%= t.column_headings %>
|
18
|
+
# <% end %>
|
19
|
+
# <% end %>
|
3
20
|
class Actions < HtmlComponent
|
4
21
|
|
5
22
|
setting :link_to_helper, :link_to
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module Grapple
|
2
2
|
module Components
|
3
|
+
|
4
|
+
# Base class for components
|
3
5
|
class BaseComponent
|
4
6
|
|
5
7
|
cattr_accessor :default_settings
|
@@ -11,8 +13,12 @@ module Grapple
|
|
11
13
|
@@default_settings[self.name][name] = default
|
12
14
|
end
|
13
15
|
|
14
|
-
attr_reader :columns
|
15
|
-
|
16
|
+
attr_reader :columns
|
17
|
+
attr_reader :records
|
18
|
+
attr_reader :template
|
19
|
+
attr_reader :params
|
20
|
+
attr_reader :builder
|
21
|
+
|
16
22
|
def initialize(columns, records, template, params, builder, settings = {})
|
17
23
|
@template = template
|
18
24
|
@columns = columns
|
@@ -23,7 +29,7 @@ module Grapple
|
|
23
29
|
self.send(:"#{name}=", value)
|
24
30
|
end
|
25
31
|
end
|
26
|
-
|
32
|
+
|
27
33
|
def render(*options, &block)
|
28
34
|
raise StandardError.new("Component must override render method")
|
29
35
|
end
|
@@ -71,6 +77,7 @@ module Grapple
|
|
71
77
|
template.with_output_buffer(&block).html_safe
|
72
78
|
end
|
73
79
|
|
80
|
+
# Renders a block if present, otherwise renders the components with options
|
74
81
|
def block_or_components(components, options, &block)
|
75
82
|
block.nil? ? render_components(components, options, &block).join : capture_block(&block)
|
76
83
|
end
|
@@ -33,9 +33,9 @@ module Grapple
|
|
33
33
|
else
|
34
34
|
content = label
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
if column[:class]
|
38
|
-
column[:class].split(" ").each{|c| cell_classes << c
|
38
|
+
column[:class].split(" ").each{|c| cell_classes << c}
|
39
39
|
end
|
40
40
|
|
41
41
|
cell_classes = ' class="' + cell_classes.join(' ') + '"'
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module Grapple
|
2
2
|
module Components
|
3
|
-
# Generates paging links using
|
3
|
+
# Generates paging links using Kaminari.
|
4
4
|
#
|
5
5
|
# @example
|
6
|
-
# <%= table_for(columns, Post.
|
6
|
+
# <%= table_for(columns, Post.page(2)) do |t| %>
|
7
7
|
# <%= t.footer do %>
|
8
8
|
# <%= t.pagination %>
|
9
9
|
# <% end %>
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -16,9 +16,10 @@ module Grapple
|
|
16
16
|
|
17
17
|
def render(paginate_parameters = {})
|
18
18
|
td_class = ""
|
19
|
+
|
19
20
|
if records.instance_of?(Array)
|
20
21
|
html = ' '
|
21
|
-
elsif
|
22
|
+
elsif params.has_key?(:query) && records.empty?
|
22
23
|
html = h(t(no_results_message))
|
23
24
|
td_class = "class='text-left'"
|
24
25
|
else
|
data/lib/grapple/components.rb
CHANGED
File without changes
|
File without changes
|
data/lib/grapple/engine.rb
CHANGED
File without changes
|
@@ -5,6 +5,16 @@ module Grapple
|
|
5
5
|
@@builder = Grapple::DataGridBuilder
|
6
6
|
mattr_accessor :builder
|
7
7
|
|
8
|
+
# Render a grapple table
|
9
|
+
# @param columns [Enumerable]
|
10
|
+
# @param records [Enumerable]
|
11
|
+
# @option args :container [Boolean]
|
12
|
+
# If true the table will be rendered with a container div around it
|
13
|
+
# @option args :html [Hash]
|
14
|
+
# HTML attributes for the `<table>` element
|
15
|
+
# @option args :builder [Grapple::BaseTableBuilder]
|
16
|
+
# The table builder to use to render the table
|
17
|
+
# @option args :params
|
8
18
|
def table_for(columns, records, *args, &block)
|
9
19
|
options = args[0] || {}
|
10
20
|
# Don't render the container for AJAX requests by default
|
data/lib/grapple/helpers.rb
CHANGED
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
|
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.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Edward Potocko
|
@@ -207,7 +207,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
207
207
|
version: '0'
|
208
208
|
requirements: []
|
209
209
|
rubyforge_project:
|
210
|
-
rubygems_version: 2.
|
210
|
+
rubygems_version: 2.6.14.1
|
211
211
|
signing_key:
|
212
212
|
specification_version: 4
|
213
213
|
summary: Customizable data grid for Rails
|