zutils 0.3.7 → 0.3.8

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
  SHA256:
3
- metadata.gz: 4382383457fb32821df0bced0827ce12631363dd0c3ec495ca65cf45ee021992
4
- data.tar.gz: 49f084b463c1d000b78bab90237cdfc14d0d61a031d0ee97685aa1225285f94e
3
+ metadata.gz: b7873068a2a60aa743dbdb26a1fb1c06a9f0eb1d37810502bba370b391bce2a8
4
+ data.tar.gz: 88af8504d18eec15eea620732cc5f7806662742bf88246b41a248890c8ce6a5c
5
5
  SHA512:
6
- metadata.gz: f8d5efabdba7f464fb1ca1b2401f9f5b14c1eb568629b7340fe23f6020b55266fb1286f79ca033ddcfce0ccc80d0bbcd25db881788c687ae55421cc45e9b42dd
7
- data.tar.gz: 479490d733acb8a9182f07e82274c3cf2dd0ad2c4eb00e3e8d013d17a0716c2b3e175f1414fa3046f2f9f40b9fe1bb3290480df78207c557b5a343299dd6e328
6
+ metadata.gz: 3327b7b596bd97291d0d8291982d4d844cbb9e4f5ba94be5e0d48233eba8bf60c4d03842f60f76e35c2476dbee39f4a89ed3ec9f64d2964731198a2769efcc58
7
+ data.tar.gz: dce70552ae56876fe8823d3db68bcfe164a559c21f016e7fd921ad1004a84e4f3f99bf55e96743fb7de6f337c454362780d8c2abc6520e1c7c001b7635ac37f1
@@ -78,7 +78,7 @@
78
78
  <% unless hide_table_header %>
79
79
  <thead>
80
80
  <tr>
81
- <th><%= t('field') %></th>
81
+ <th width='15%'><%= t('field') %></th>
82
82
  <th><%= t('value') %></th>
83
83
  </tr>
84
84
  </thead>
@@ -86,7 +86,7 @@
86
86
  <% (object.class.column_names - ['id', 'created_at', 'updated_at', 'deleted_at'] - excluded_columns).each do |column| %>
87
87
  <% unless /_currency$/ =~ column %>
88
88
  <tr>
89
- <th width='15%'>
89
+ <th>
90
90
  <% if /_id$/ =~ column && object.respond_to?(column.split('_id')[0]) %>
91
91
  <%= object.class.human_attribute_name(column.split("_id")[0]) %>
92
92
  <% elsif /_cents$/ =~ column %>
@@ -117,51 +117,104 @@
117
117
  </div>
118
118
  </div>
119
119
 
120
- <% if relationships.size > 0 %>
120
+ <% if relationships.any? %>
121
121
  <% relationships.each do |key, value| %>
122
- <div class="box box-<%= box_class %>">
123
- <div class="box-header with-border">
124
- <h3 class="box-title">
125
- <%= Kernel.const_get(key.to_s.singularize.camelize).model_name.human.pluralize %>
126
- </h3>
127
- </div>
128
- <div class="box-body no-padding">
129
- <table class="table table-bordered table-striped no-padding datatables">
130
- <thead>
131
- <tr>
122
+ <% if object.association(key.to_s).kind_of? ActiveRecord::Associations::BelongsToAssociation %>
123
+ <div class="box box-<%= box_class %>">
124
+ <div class="box-header with-border">
125
+ <h3 class="box-title">
126
+ <%= Kernel.const_get(key.to_s.singularize.camelize).model_name.human %>
127
+ </h3>
128
+ </div>
129
+ <div class="box-body no-padding">
130
+ <table class="table table-bordered table-striped no-padding datatables">
131
+ <% unless hide_table_header %>
132
+ <thead>
133
+ <tr>
134
+ <th width='15%'><%= t('field') %></th>
135
+ <th><%= t('value') %></th>
136
+ </tr>
137
+ </thead>
138
+ <% end %>
139
+ <tbody>
132
140
  <% value.each do |v| %>
133
- <th>
134
- <% if /_id$/ =~ v && Kernel.const_get(key.to_s.singularize.camelize).new.respond_to?(v.split('_id')[0]) %>
135
- <%= Kernel.const_get(key.to_s.singularize.camelize).human_attribute_name(v.split('_id')[0]) %>
136
- <% else %>
137
- <%= Kernel.const_get(key.to_s.singularize.camelize).human_attribute_name(v) %>
138
- <% end %>
139
- </th>
141
+ <tr>
142
+ <td>
143
+ <strong>
144
+ <% if /_id$/ =~ v && Kernel.const_get(key.to_s.singularize.camelize).new.respond_to?(v.split('_id')[0]) %>
145
+ <%= Kernel.const_get(key.to_s.singularize.camelize).human_attribute_name(v.split('_id')[0]) %>
146
+ <% elsif /_cents$/ =~ v %>
147
+ <%= Kernel.const_get(key.to_s.singularize.camelize).human_attribute_name(v.split("_cents")[0]) %>
148
+ <% else %>
149
+ <%= Kernel.const_get(key.to_s.singularize.camelize).human_attribute_name(v) %>
150
+ <% end %>
151
+ </strong>
152
+ </td>
153
+ <td>
154
+ <% if object.send(key.to_s).send(v).class == Date or
155
+ object.send(key.to_s).send(v).class == DateTime or
156
+ object.send(key.to_s).send(v).class == ActiveSupport::TimeWithZone or
157
+ object.send(key.to_s).send(v).class == Time %>
158
+ <%=l object.send(key.to_s).send(v) %>
159
+ <% elsif /_id$/ =~ v && object.send(key.to_s).respond_to?(v.split('_id')[0]) %>
160
+ <%= object.send(key.to_s).send(v.split("_id")[0])&.name %>
161
+ <% elsif /_cents$/ =~ v %>
162
+ <%= number_to_currency object.send(key.to_s).send(v.split("_cents")[0]) %>
163
+ <% else %>
164
+ <%= object.send(key.to_s).send(v) %>
165
+ <% end %>
166
+ </td>
167
+ </tr>
140
168
  <% end %>
141
- </tr>
142
- </thead>
143
- <tbody>
144
- <% object.send(key.to_s).each do |r| %>
169
+ </tbody>
170
+ </table>
171
+ </div>
172
+ </div>
173
+ <% else %>
174
+ <div class="box box-<%= box_class %>">
175
+ <div class="box-header with-border">
176
+ <h3 class="box-title">
177
+ <%= Kernel.const_get(key.to_s.singularize.camelize).model_name.human.pluralize %>
178
+ </h3>
179
+ </div>
180
+ <div class="box-body no-padding">
181
+ <table class="table table-bordered table-striped no-padding datatables">
182
+ <thead>
145
183
  <tr>
146
184
  <% value.each do |v| %>
147
- <td>
148
- <% if r.send(v).class == Date or
149
- r.send(v).class == DateTime or
150
- r.send(v).class == ActiveSupport::TimeWithZone or
151
- r.send(v).class == Time %>
152
- <%=l r.send(v) %>
153
- <% elsif /_id$/ =~ v && r.respond_to?(v.split('_id')[0]) %>
154
- <%= r.send(v.split("_id")[0])&.name %>
185
+ <th>
186
+ <% if /_id$/ =~ v && Kernel.const_get(key.to_s.singularize.camelize).new.respond_to?(v.split('_id')[0]) %>
187
+ <%= Kernel.const_get(key.to_s.singularize.camelize).human_attribute_name(v.split('_id')[0]) %>
155
188
  <% else %>
156
- <%= r.send(v) %>
189
+ <%= Kernel.const_get(key.to_s.singularize.camelize).human_attribute_name(v) %>
157
190
  <% end %>
191
+ </th>
192
+ <% end %>
193
+ </tr>
194
+ </thead>
195
+ <tbody>
196
+ <% object.send(key.to_s).each do |r| %>
197
+ <tr>
198
+ <% value.each do |v| %>
199
+ <td>
200
+ <% if r.send(v).class == Date or
201
+ r.send(v).class == DateTime or
202
+ r.send(v).class == ActiveSupport::TimeWithZone or
203
+ r.send(v).class == Time %>
204
+ <%=l r.send(v) %>
205
+ <% elsif /_id$/ =~ v && r.respond_to?(v.split('_id')[0]) %>
206
+ <%= r.send(v.split("_id")[0])&.name %>
207
+ <% else %>
208
+ <%= r.send(v) %>
209
+ <% end %>
210
+ </td>
158
211
  <% end %>
159
- </td>
212
+ </tr>
160
213
  <% end %>
161
- </tr>
162
- </tbody>
163
- </table>
214
+ </tbody>
215
+ </table>
216
+ </div>
164
217
  </div>
165
- </div>
218
+ <% end %>
166
219
  <% end %>
167
220
  <% end %>
@@ -1,3 +1,3 @@
1
1
  module Zutils
2
- VERSION = "0.3.7"
2
+ VERSION = "0.3.8"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zutils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.7
4
+ version: 0.3.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ricardo Viana