ct_table_for 0.1.13.beta → 0.1.14.beta
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 +5 -5
- data/README.md +2 -0
- data/app/helpers/ct_table_for/application_helper.rb +17 -6
- data/lib/ct_table_for/engine.rb +4 -0
- data/lib/ct_table_for/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 041f6baa92ac9afa0958cc533634b04a227375a78ad0112e04443c918769960a
|
4
|
+
data.tar.gz: 106b8f09e6c614d19de6063cb0beaed28ce8d8751a2c126f300070ab00460907
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db5fee74fd15bd4ce79e9afd1ab1bf17d2e54664f6db63f34ba0fea0e1749302175e59413dfd8976298e6cc7a11574258d33575918e4d3ffed0badd02c8fe476
|
7
|
+
data.tar.gz: d123e433841e73634945b587f7e398a46ef70c6349e50e4a9923b5bb9816c911997d95cdd76b49baf659c6b5aa0c8387d665470b354e79b4a3c826a76b5e8c18
|
data/README.md
CHANGED
@@ -74,6 +74,8 @@ Create config variables in your app's /config/initializers/ct_table_for.rb
|
|
74
74
|
CtTableFor.setup do |config|
|
75
75
|
config.table_for_wrapper_default_class = "table-responsive"
|
76
76
|
config.table_for_default_class = "table table-striped table-bordered table-condensed table-hover"
|
77
|
+
config.table_for_default_action_base_class = "btn btn-sm"
|
78
|
+
config.table_for_action_class = {show: "btn-primary", edit: "btn-success", destroy: "btn-danger", other: "btn-default"}
|
77
79
|
config.table_for_breakpoint = "992px" # or could be done by sass
|
78
80
|
config.table_for_icon_font = "fa"
|
79
81
|
config.table_for_action_icons = {show: "eye", edit: "pencil", destroy: "trash"}
|
@@ -18,6 +18,10 @@ module CtTableFor
|
|
18
18
|
# id: "my-id", // String: adds custom id to <table> element
|
19
19
|
# class: "my-custom-css", // String: add custom class to <table> element
|
20
20
|
# tr_class: "my-custom-css" // String: add custom class to <tr> element
|
21
|
+
# btn_class: { // Hash: add custom class to action buttons
|
22
|
+
# show: "my-custom-css",
|
23
|
+
# edit: "my-custom-css"
|
24
|
+
# }
|
21
25
|
# clickable: true || Array // Boolean or Array of nested resources for polymorphic_url
|
22
26
|
#}
|
23
27
|
####################################################################################
|
@@ -94,12 +98,18 @@ module CtTableFor
|
|
94
98
|
|
95
99
|
def table_for_cell model, record, attribute, cell_options: {}
|
96
100
|
html = ""
|
97
|
-
value = record.
|
101
|
+
value = if record.respond_to?(attribute.to_sym)
|
102
|
+
record.send(attribute.to_sym)
|
103
|
+
elsif self.respond_to?(attribute.to_sym)
|
104
|
+
self.send(attribute.to_sym, record)
|
105
|
+
else
|
106
|
+
nil
|
107
|
+
end
|
98
108
|
|
99
109
|
html << %Q{<td data-title="#{model.human_attribute_name("#{attribute}")}">}
|
100
110
|
case value
|
101
111
|
when NilClass
|
102
|
-
html << %Q{<i class="fa fa-
|
112
|
+
html << %Q{<i class="fa fa-minus text-muted"></i>}
|
103
113
|
when TrueClass, FalseClass
|
104
114
|
html << %Q{<i class="fa #{value ? "fa-check text-success" : "fa-times text-danger"}"></i>}
|
105
115
|
when Numeric
|
@@ -170,24 +180,25 @@ module CtTableFor
|
|
170
180
|
buttons.each do |action|
|
171
181
|
return "" if defined?(CanCanCan) and cannot?(action, record)
|
172
182
|
label = I18n.t(action.to_sym, scope: [:table_for, :buttons]).capitalize
|
183
|
+
custom_action_class = %Q{#{CtTableFor.table_for_default_action_base_class} #{options.dig(:btn_class, action.to_sym) || CtTableFor.table_for_action_class[action.to_sym]}}
|
173
184
|
case action.to_sym
|
174
185
|
when :show
|
175
186
|
if options[:actions][:icons] != false
|
176
187
|
label = %Q{<i class="#{CtTableFor.table_for_icon_font_base_class} #{CtTableFor.table_for_icon_font_base_class}-#{CtTableFor.table_for_action_icons[:show]}"></i>}
|
177
188
|
end
|
178
|
-
html << link_to(label.html_safe, polymorphic_path(nesting), class:
|
189
|
+
html << link_to(label.html_safe, polymorphic_path(nesting), class: custom_action_class)
|
179
190
|
when :edit
|
180
191
|
if options[:actions][:icons] != false
|
181
192
|
label = %Q{<i class="#{CtTableFor.table_for_icon_font_base_class} #{CtTableFor.table_for_icon_font_base_class}-#{CtTableFor.table_for_action_icons[:edit]}"></i>}
|
182
193
|
end
|
183
|
-
html << link_to(label.html_safe, edit_polymorphic_path(nesting), class:
|
194
|
+
html << link_to(label.html_safe, edit_polymorphic_path(nesting), class: custom_action_class)
|
184
195
|
when :destroy
|
185
196
|
if options[:actions][:icons] != false
|
186
197
|
label = %Q{<i class="#{CtTableFor.table_for_icon_font_base_class} #{CtTableFor.table_for_icon_font_base_class}-#{CtTableFor.table_for_action_icons[:destroy]}"></i>}
|
187
198
|
end
|
188
199
|
html << link_to(label.html_safe, polymorphic_path(nesting),
|
189
|
-
method: :delete, class:
|
190
|
-
data: { confirm: I18n.t('are_you_sure').capitalize })
|
200
|
+
method: :delete, class: custom_action_class,
|
201
|
+
data: { confirm: I18n.t('table_for.messages.are_you_sure').capitalize })
|
191
202
|
else
|
192
203
|
# TODO:
|
193
204
|
# nesting_custom = nesting + btn_options[0]
|
data/lib/ct_table_for/engine.rb
CHANGED
@@ -2,6 +2,8 @@ module CtTableFor
|
|
2
2
|
class << self
|
3
3
|
mattr_accessor :table_for_default_class
|
4
4
|
mattr_accessor :table_for_wrapper_default_class
|
5
|
+
mattr_accessor :table_for_default_action_base_class
|
6
|
+
mattr_accessor :table_for_action_class
|
5
7
|
mattr_accessor :table_for_breakpoint
|
6
8
|
mattr_accessor :table_for_icon_font_base_class
|
7
9
|
mattr_accessor :table_for_action_icons
|
@@ -13,6 +15,8 @@ module CtTableFor
|
|
13
15
|
|
14
16
|
self.table_for_wrapper_default_class = "table-responsive"
|
15
17
|
self.table_for_default_class = "table table-striped table-bordered table-condensed table-hover"
|
18
|
+
self.table_for_default_action_base_class = "btn btn-sm"
|
19
|
+
self.table_for_action_class = {show: "btn-primary", edit: "btn-success", destroy: "btn-danger", other: "btn-default"}
|
16
20
|
self.table_for_breakpoint = "992px"
|
17
21
|
self.table_for_icon_font_base_class = "fa"
|
18
22
|
self.table_for_action_icons = {show: "eye", edit: "pencil", destroy: "trash", custom: "gear"}
|
data/lib/ct_table_for/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ct_table_for
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.14.beta
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Agustí B.R.
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2018-11-13 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
@@ -68,7 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
68
68
|
version: 1.3.1
|
69
69
|
requirements: []
|
70
70
|
rubyforge_project:
|
71
|
-
rubygems_version: 2.
|
71
|
+
rubygems_version: 2.7.6
|
72
72
|
signing_key:
|
73
73
|
specification_version: 4
|
74
74
|
summary: Rails table builder that makes it easy to do responsive tables ActiveRecord
|