html_tables 0.0.11 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/html_tables/config.rb +19 -0
- data/lib/html_tables/data_table_helper.rb +5 -3
- data/lib/html_tables/version.rb +1 -1
- data/lib/html_tables.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e0bae9b4cbf7907485ab3be3a13d8ca01682a9b
|
4
|
+
data.tar.gz: e525363a740bf4af8a7e8b865a4c3a37ae1c3d0a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f69ca9e6d5df648a5bbfe1482424714d6971364cb050afa59f106275ae107201f893d5334c741c126eacda5375aa6022594fa833df34d3a11a2e985b49d44c9
|
7
|
+
data.tar.gz: c8af413fa4c711a9e16f235392ce79d0b72f2633f45f9014003e0d7bbcc98e928d7a2af3897107ac8cc973262d8f3ad4a6c497a50bf4b7a7192afd25b9c10e67
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'singleton'
|
2
|
+
|
3
|
+
module HtmlTables
|
4
|
+
def self.setup
|
5
|
+
yield Configuration.instance
|
6
|
+
end
|
7
|
+
|
8
|
+
class Configuration
|
9
|
+
include Singleton
|
10
|
+
|
11
|
+
attr_accessor :use_entity_shortcuts, :url_generator_proc, :default_table_classes
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
@use_entity_shortcuts = ::Rails.env.development?
|
15
|
+
@url_generator_proc = -> obj { url_for(obj) }
|
16
|
+
@default_table_classes = %w(table table-striped table-bordered)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -3,6 +3,8 @@
|
|
3
3
|
module HtmlTables
|
4
4
|
module DataTableHelper
|
5
5
|
def data_table_for(collection, options = {})
|
6
|
+
config = HtmlTables::Configuration.instance
|
7
|
+
|
6
8
|
t = DataTable.new(self, collection, options)
|
7
9
|
if block_given?
|
8
10
|
yield t.object_to_yield
|
@@ -10,7 +12,7 @@ module HtmlTables
|
|
10
12
|
t.auto_generate_columns!
|
11
13
|
end
|
12
14
|
|
13
|
-
cls =
|
15
|
+
cls = config.default_table_classes.dup
|
14
16
|
cls << 'table-condensed' if options[:condensed]
|
15
17
|
cls << options[:class] if options[:class]
|
16
18
|
table_html_options = { class: cls }
|
@@ -98,9 +100,9 @@ module HtmlTables
|
|
98
100
|
tmp
|
99
101
|
end
|
100
102
|
|
101
|
-
if
|
103
|
+
if config.use_entity_shortcuts && v.is_a?(ActiveRecord::Base)
|
102
104
|
btn = content_tag(:div, class: 'entity-shortcut') do
|
103
|
-
link_to(
|
105
|
+
link_to(config.url_generator_proc.(v), class: 'btn btn-small') do
|
104
106
|
content_tag(:i, nil, class: 'icon-share')
|
105
107
|
end
|
106
108
|
end rescue nil
|
data/lib/html_tables/version.rb
CHANGED
data/lib/html_tables.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: html_tables
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fábio David Batista
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|
@@ -81,6 +81,7 @@ files:
|
|
81
81
|
- Rakefile
|
82
82
|
- html_tables.gemspec
|
83
83
|
- lib/html_tables.rb
|
84
|
+
- lib/html_tables/config.rb
|
84
85
|
- lib/html_tables/data_table.rb
|
85
86
|
- lib/html_tables/data_table_helper.rb
|
86
87
|
- lib/html_tables/format_for_output.rb
|