grapple 0.0.2 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/grapple/ajax_data_grid_builder.rb +6 -6
- data/lib/grapple/base_table_builder.rb +6 -6
- data/lib/grapple/components/html_caption.rb +12 -0
- data/lib/grapple/components/html_colgroup.rb +3 -3
- data/lib/grapple/components/html_component.rb +5 -5
- data/lib/grapple/components.rb +2 -1
- data/lib/grapple/data_grid_builder.rb +8 -8
- data/lib/grapple/helpers/table_helper.rb +10 -9
- data/lib/grapple/html_table_builder.rb +10 -9
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dbc0c19f5351b685a28eb3cccbf18aa71418fd0d
|
4
|
+
data.tar.gz: f7a5a428ead03812a503ec79c04cf8eaae98fcf9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86a7d8935dfff0004548900811f161d8e44329f3c97cc4092f989b16f346b2599e584dce0ee1dc4aead5e6b5d616addd5a8b9ee32175bcb9f082970fc0ab3186
|
7
|
+
data.tar.gz: f5f9b9bc3512489b545230d45bdf574690ecd1aa10902505cf9f24b96433021c1e674a71f38e6acb942402434786e9449e6e7bb56d13b5fb4a47b7f0f5c72ff1
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module Grapple
|
2
2
|
class AjaxDataGridBuilder < DataGridBuilder
|
3
|
-
|
3
|
+
|
4
4
|
CONTAINER_CLASSES = 'grapple grapple-ajax grapple-ajax-loading'
|
5
|
-
|
5
|
+
|
6
6
|
@@next_id = 1000
|
7
7
|
|
8
8
|
def self.container_attributes(template, options)
|
@@ -10,17 +10,17 @@ module Grapple
|
|
10
10
|
options[:id] ||= "grapple_ajax_table_#{@@next_id}"
|
11
11
|
css = CONTAINER_CLASSES
|
12
12
|
css += " #{options[:container_class]}" unless options[:container_class].nil?
|
13
|
-
|
13
|
+
|
14
14
|
data = {
|
15
15
|
"grapple-ajax-url" => options[:url] || template.url_for(action: 'table'),
|
16
|
-
# History is disabled by default, override container_attributes
|
16
|
+
# History is disabled by default, override container_attributes
|
17
17
|
# in an initializer to enable it by default
|
18
18
|
"grapple-ajax-history" => options[:history] == true ? '1' : '0'
|
19
19
|
}
|
20
20
|
|
21
21
|
return {
|
22
22
|
:id => options[:id],
|
23
|
-
:class => css,
|
23
|
+
:class => css,
|
24
24
|
:data => data
|
25
25
|
}
|
26
26
|
end
|
@@ -29,7 +29,7 @@ module Grapple
|
|
29
29
|
style = 'background-image: url(' + template.image_path("grapple/loading-bar.gif") + ')'
|
30
30
|
template.content_tag :div, '', :class => 'loading-overlay', :style => style
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
def self.after_container(template, options)
|
34
34
|
selector = '#' + options[:id]
|
35
35
|
js = "$(#{selector.to_json}).grapple();"
|
@@ -11,7 +11,7 @@ module Grapple
|
|
11
11
|
define_singleton_method(:"class_for_#{name}") { klass }
|
12
12
|
define_singleton_method(:"settings_for_#{name}") { settings }
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
# Update settings for a helper
|
16
16
|
def self.configure(helper_name, *options)
|
17
17
|
settings = options[0] || {}
|
@@ -34,17 +34,17 @@ module Grapple
|
|
34
34
|
@options = options[0] || {}
|
35
35
|
@helper_instances = {}
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
def before_table
|
39
39
|
''
|
40
40
|
end
|
41
|
-
|
41
|
+
|
42
42
|
def after_table
|
43
43
|
''
|
44
44
|
end
|
45
45
|
|
46
46
|
protected
|
47
|
-
|
47
|
+
|
48
48
|
def invoke_helper(name, *arguments, &block)
|
49
49
|
unless @helper_instances.has_key?(name)
|
50
50
|
klass = self.class.send(:"class_for_#{name}")
|
@@ -53,6 +53,6 @@ module Grapple
|
|
53
53
|
end
|
54
54
|
@helper_instances[name].send(:render, *arguments, &block)
|
55
55
|
end
|
56
|
-
|
56
|
+
|
57
57
|
end
|
58
|
-
end
|
58
|
+
end
|
@@ -1,14 +1,14 @@
|
|
1
1
|
module Grapple
|
2
2
|
module Components
|
3
3
|
class HtmlColgroup < HtmlComponent
|
4
|
-
|
4
|
+
|
5
5
|
def render
|
6
6
|
cols = columns.collect do |col|
|
7
7
|
indent + (col[:width].nil? ? "<col>" : "<col width=\"#{col[:width]}\">")
|
8
8
|
end
|
9
9
|
"<colgroup>\n#{cols.join("\n")}\n</colgroup>\n".html_safe
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
end
|
13
13
|
end
|
14
|
-
end
|
14
|
+
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module Grapple
|
2
2
|
module Components
|
3
3
|
class HtmlComponent < BaseComponent
|
4
|
-
|
4
|
+
|
5
5
|
setting :indent, "\t"
|
6
|
-
|
6
|
+
|
7
7
|
protected
|
8
8
|
|
9
9
|
include ERB::Util
|
@@ -11,14 +11,14 @@ module Grapple
|
|
11
11
|
def content_tag(name, content_or_options_with_block = nil, options = nil, escape = true, &block)
|
12
12
|
template.content_tag(name, content_or_options_with_block, options, escape, &block)
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
def table_url(options)
|
16
16
|
if options[:sort] == params[:sort]
|
17
17
|
options[:dir] = (params[:dir] == 'desc') ? 'asc' : 'desc'
|
18
18
|
end
|
19
19
|
template.url_for params.stringify_keys().merge(options.stringify_keys())
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
end
|
23
23
|
end
|
24
|
-
end
|
24
|
+
end
|
data/lib/grapple/components.rb
CHANGED
@@ -9,6 +9,7 @@ module Grapple
|
|
9
9
|
autoload :HtmlBody
|
10
10
|
autoload :HtmlFooter
|
11
11
|
autoload :HtmlColgroup
|
12
|
+
autoload :HtmlCaption
|
12
13
|
autoload :ColumnHeadings
|
13
14
|
autoload :WillPaginate
|
14
15
|
autoload :Toolbar
|
@@ -20,4 +21,4 @@ module Grapple
|
|
20
21
|
autoload :WillPaginateInfobar
|
21
22
|
|
22
23
|
end
|
23
|
-
end
|
24
|
+
end
|
@@ -1,24 +1,24 @@
|
|
1
1
|
module Grapple
|
2
2
|
class DataGridBuilder < HtmlTableBuilder
|
3
3
|
|
4
|
-
helper :infobar, Grapple::Components::WillPaginateInfobar
|
4
|
+
helper :infobar, Grapple::Components::WillPaginateInfobar
|
5
5
|
|
6
|
-
# Toolbar
|
6
|
+
# Toolbar
|
7
7
|
helper :search_submit, Grapple::Components::SearchSubmit
|
8
|
-
helper :search_query_field, Grapple::Components::SearchQueryField
|
8
|
+
helper :search_query_field, Grapple::Components::SearchQueryField
|
9
9
|
helper :search_form, Grapple::Components::SearchForm
|
10
10
|
helper :actions, Grapple::Components::Actions
|
11
11
|
helper :toolbar, Grapple::Components::Toolbar, components: [:search_form, :actions]
|
12
12
|
|
13
13
|
# Sortable column headings
|
14
14
|
helper :column_headings, Grapple::Components::ColumnHeadings
|
15
|
-
|
16
|
-
configure :header, components: [:infobar, :toolbar, :column_headings]
|
17
|
-
|
15
|
+
|
16
|
+
configure :header, components: [:infobar, :toolbar, :column_headings]
|
17
|
+
|
18
18
|
# Paging
|
19
19
|
helper :pagination, Grapple::Components::WillPaginatePagination
|
20
|
-
|
20
|
+
|
21
21
|
configure :footer, components: [:pagination]
|
22
22
|
|
23
23
|
end
|
24
|
-
end
|
24
|
+
end
|
@@ -5,6 +5,15 @@ module Grapple
|
|
5
5
|
@@builder = Grapple::DataGridBuilder
|
6
6
|
mattr_accessor :builder
|
7
7
|
|
8
|
+
def table_for(columns, records, *args, &block)
|
9
|
+
options = args[0] || {}
|
10
|
+
table_html_attributes = options[:html] || {}
|
11
|
+
builder_class = options[:builder] || @@builder
|
12
|
+
builder = builder_class.new(self, columns, records, params, options)
|
13
|
+
output = capture(builder, &block)
|
14
|
+
(builder.before_table + builder.table(output, table_html_attributes) + builder.after_table).html_safe
|
15
|
+
end
|
16
|
+
|
8
17
|
def grapple_container(*args, &block)
|
9
18
|
options = args[0] || {}
|
10
19
|
builder_class = options[:builder] || @@builder
|
@@ -17,15 +26,7 @@ module Grapple
|
|
17
26
|
html << builder_class.after_container(self, options)
|
18
27
|
return html.html_safe
|
19
28
|
end
|
20
|
-
|
21
|
-
def table_for(columns, records, *args, &block)
|
22
|
-
options = args[0] || {}
|
23
|
-
builder_class = options[:builder] || @@builder
|
24
|
-
builder = builder_class.new(self, columns, records, params, options)
|
25
|
-
output = capture(builder, &block)
|
26
|
-
(builder.before_table + builder.table(output) + builder.after_table).html_safe
|
27
|
-
end
|
28
|
-
|
29
|
+
|
29
30
|
end
|
30
31
|
end
|
31
32
|
end
|
@@ -2,31 +2,32 @@ module Grapple
|
|
2
2
|
|
3
3
|
class HtmlTableBuilder < BaseTableBuilder
|
4
4
|
|
5
|
+
# Standard HTML table elements
|
6
|
+
helper :caption, Grapple::Components::HtmlCaption
|
5
7
|
helper :row, Grapple::Components::HtmlRow
|
6
8
|
helper :colgroup, Grapple::Components::HtmlColgroup
|
7
9
|
helper :header, Grapple::Components::HtmlHeader
|
8
10
|
helper :body, Grapple::Components::HtmlBody
|
9
11
|
helper :footer, Grapple::Components::HtmlFooter
|
10
12
|
|
11
|
-
def table(content)
|
12
|
-
#
|
13
|
-
"<table>#{content}</table>\n".html_safe
|
13
|
+
def table(content, attributes = {})
|
14
|
+
"#{template.content_tag('table', content, attributes)}\n".html_safe
|
14
15
|
end
|
15
|
-
|
16
|
+
|
16
17
|
def self.container_attributes(template, options)
|
17
18
|
return {
|
18
|
-
:class => 'grapple'
|
19
|
+
:class => 'grapple'
|
19
20
|
}
|
20
21
|
end
|
21
|
-
|
22
|
+
|
22
23
|
def self.before_container(template, options)
|
23
24
|
''
|
24
25
|
end
|
25
|
-
|
26
|
+
|
26
27
|
def self.after_container(template, options)
|
27
28
|
''
|
28
29
|
end
|
29
|
-
|
30
|
+
|
30
31
|
end
|
31
32
|
|
32
|
-
end
|
33
|
+
end
|
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.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Edward Potocko
|
@@ -150,6 +150,7 @@ files:
|
|
150
150
|
- lib/grapple/components/base_component.rb
|
151
151
|
- lib/grapple/components/column_headings.rb
|
152
152
|
- lib/grapple/components/html_body.rb
|
153
|
+
- lib/grapple/components/html_caption.rb
|
153
154
|
- lib/grapple/components/html_colgroup.rb
|
154
155
|
- lib/grapple/components/html_component.rb
|
155
156
|
- lib/grapple/components/html_footer.rb
|