ct_table_for 0.1.8.beta → 0.1.9.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fc412af2e425565111e6c532d02cfe307fd86b8e
4
- data.tar.gz: 3d6b2efb3cc3c2f2722a4f23849523be0bdc14e6
3
+ metadata.gz: 18715667af7e66131a79917e3212cc9bae3330bb
4
+ data.tar.gz: a174050bd85ba6436d4bd0c6b0de84ac97a8b97f
5
5
  SHA512:
6
- metadata.gz: fe0dbd42da97ea7d3f26d265dd8bb0b29b41388b717077358634ff180cc365e0618caf25a6fe7b0e3674a41df643fa248b1e7cb86e8dd590bad0c2b75f424b6e
7
- data.tar.gz: de7598062867f6ee45eff7b754f1feb7708f953087603a41d15c731b6659609bf6de12446085fa17755591ab6631606183f65cfeb44e4824cf85d9f609db7f32
6
+ metadata.gz: eece23729a5e9c4721e90797a7c49a44361caae2239a3f368671a68e34b651a83f05a40cdf4753ebcada81db76f4ac8dd34ee39c58a3a62bf8d26257c2dbc3d5
7
+ data.tar.gz: 0989b2dd8e6ec29e9c114a299823b5513558ace5dbeed45e8c7c5917aca255649e2ee6523facda673cb3a24564cd2d2e86666fc7ec9d81c8c538b91b86682ac3
data/README.md CHANGED
@@ -28,7 +28,7 @@ Then require the CSS in your `application.css` file:
28
28
  */
29
29
  ```
30
30
 
31
- or in sass
31
+ or in sass
32
32
 
33
33
  ```sass
34
34
  @import "table_for"
@@ -53,6 +53,9 @@ CtTableFor.setup do |config|
53
53
  config.table_for_breakpoint = "992px" # or could be done by sass
54
54
  config.table_for_icon_font = "fa"
55
55
  config.table_for_action_icons = {show: "eye", edit: "pencil", destroy: "trash"}
56
+ config.table_for_numeric_percentage_precision = 2
57
+ config.table_for_cell_for_image_image_class = "img-responsive"
58
+
56
59
  end
57
60
  ```
58
61
  You can also define the breakpoint in your `sass` before importing `table_for`:
@@ -60,7 +63,7 @@ You can also define the breakpoint in your `sass` before importing `table_for`:
60
63
  ```sass
61
64
  $table-for-breakpoint: 768px;
62
65
  @import "table_for"
63
- ```
66
+ ```
64
67
 
65
68
 
66
69
  ## Development
@@ -69,7 +72,7 @@ To develop the Gem, clone this repo and in your Rails Test application edit the
69
72
 
70
73
  ```
71
74
  gem 'table_for', path: '/home/user/path/to/table_for'
72
- ```
75
+ ```
73
76
 
74
77
 
75
78
  ## Contributing
@@ -90,4 +93,4 @@ Maintained by [CodiTramuntana](http://www.coditramuntana.com).
90
93
 
91
94
  The names and logos for CodiTramuntana are trademarks of CodiTramuntana SL.
92
95
 
93
- We love open source software!
96
+ We love open source software!
@@ -1,12 +1,12 @@
1
1
  module CtTableFor
2
2
  module ApplicationHelper
3
3
  require 'uri'
4
-
4
+
5
5
  ####################################################################################
6
6
  # RWD Table
7
7
  # use as: table_for Model, @collection, options: {}
8
8
  # options: {
9
- # actions: {
9
+ # actions: {
10
10
  # buttons: %w(show, edit)}, // Hash: with array of buttons for actions
11
11
  # premodel: [:bo, :admin], // Array: of symbols for nested namespaces/models
12
12
  # icons: true // Boolean: if true show actions as icons
@@ -46,7 +46,7 @@ module CtTableFor
46
46
  html << if defined?(Ransack) and params.include? "sortable"
47
47
  sort_link(@q, attribute, I18n.t("#{attribute}", scope: [:activerecord, :attributes, model.to_s.underscore]).capitalize )
48
48
  else
49
- model.human_attribute_name("#{attribute}").capitalize
49
+ model.human_attribute_name("#{attribute}")
50
50
  end
51
51
  html << %Q{</th>}
52
52
  end
@@ -85,7 +85,7 @@ module CtTableFor
85
85
  html = ""
86
86
  value = record.try(attribute.to_sym)
87
87
 
88
- html << %Q{<td data-title="#{model.human_attribute_name("#{attribute}").capitalize}">}
88
+ html << %Q{<td data-title="#{model.human_attribute_name("#{attribute}")}">}
89
89
  case value
90
90
  when NilClass
91
91
  html << %Q{<i class="fa fa-asterisk text-muted"></i>}
@@ -94,6 +94,8 @@ module CtTableFor
94
94
  when Numeric
95
95
  if cell_options.include? "currency"
96
96
  html << number_to_currency(value)
97
+ elsif cell_options.include? "percentage"
98
+ html << number_to_percentage(value, precision: CtTableFor.table_for_numeric_percentage_precision)
97
99
  else
98
100
  html << %Q{<code>#{value}</code>}
99
101
  end
@@ -106,7 +108,7 @@ module CtTableFor
106
108
  when ActiveRecord::Base
107
109
  if cell_options.present?
108
110
  html << %Q{#{value.send cell_options[0]}}
109
- else
111
+ else
110
112
  html << %{#{(value.try(:title) || value.try(:name))}}
111
113
  end
112
114
  when ActiveRecord::Associations::CollectionProxy
@@ -114,7 +116,7 @@ module CtTableFor
114
116
  else
115
117
  if uri?(value)
116
118
  html << link_to(value, value)
117
- elsif defined?(PaperClip) and record.is_a?(PaperClip::Attachment)
119
+ elsif defined?(Paperclip) and value.is_a?(Paperclip::Attachment)
118
120
  html << table_for_cell_for_image( record, attribute, cell_options: cell_options )
119
121
  else
120
122
  html << value.to_s.truncate(50, separator: " ")
@@ -128,7 +130,7 @@ module CtTableFor
128
130
  html = ""
129
131
  size = cell_options.select{ |opt| ["thumb", "original", "small", "medium"].include? opt }.first || "thumb"
130
132
 
131
- html << image_tag(record.send(attribute).url(size), class: 'img-fluid', style: "max-height: 100px;")
133
+ html << image_tag(record.send(attribute).url(size), class: CtTableFor.table_for_numeric_percent_precision, style: "max-height: 100px;")
132
134
  html.html_safe
133
135
  end
134
136
 
@@ -146,17 +148,17 @@ module CtTableFor
146
148
  case action.to_sym
147
149
  when :show
148
150
  if options[:actions][:icons] != false
149
- 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>}
151
+ 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>}
150
152
  end
151
153
  html << link_to(label.html_safe, polymorphic_path(nesting), class: "btn btn-primary btn-sm")
152
154
  when :edit
153
155
  if options[:actions][:icons] != false
154
- 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>}
156
+ 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>}
155
157
  end
156
158
  html << link_to(label.html_safe, edit_polymorphic_path(nesting), class: "btn btn-success btn-sm")
157
159
  when :destroy
158
160
  if options[:actions][:icons] != false
159
- 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>}
161
+ 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>}
160
162
  end
161
163
  html << link_to(label.html_safe, polymorphic_path(nesting),
162
164
  method: :delete, class: "btn btn-danger btn-sm",
@@ -5,20 +5,23 @@ module CtTableFor
5
5
  mattr_accessor :table_for_breakpoint
6
6
  mattr_accessor :table_for_icon_font_base_class
7
7
  mattr_accessor :table_for_action_icons
8
-
8
+ mattr_accessor :table_for_numeric_percentage_precision
9
+ mattr_accessor :table_for_cell_for_image_image_class
10
+
9
11
  self.table_for_wrapper_default_class = "table-responsive"
10
12
  self.table_for_default_class = "table table-striped table-bordered table-condensed table-hover"
11
13
  self.table_for_breakpoint = "992px"
12
14
  self.table_for_icon_font_base_class = "fa"
13
15
  self.table_for_action_icons = {show: "eye", edit: "pencil", destroy: "trash", custom: "gear"}
14
-
16
+ self.table_for_numeric_percentage_precision = 2
17
+ self.table_for_cell_for_image_image_class = "img-responsive"
15
18
  end
16
19
 
17
20
  # this function maps the vars from your app into your engine
18
21
  def self.setup(&block)
19
22
  yield self
20
23
  end
21
-
24
+
22
25
  class Engine < ::Rails::Engine
23
26
  isolate_namespace CtTableFor
24
27
  paths["app"]
@@ -1,3 +1,3 @@
1
1
  module CtTableFor
2
- VERSION = '0.1.8.beta'
2
+ VERSION = '0.1.9.beta'
3
3
  end
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.8.beta
4
+ version: 0.1.9.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: 2017-05-10 00:00:00.000000000 Z
13
+ date: 2017-05-23 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails