zutils 0.1.2 → 0.1.3

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: a84d686582748295669bb5830b58cc288c8f2d49f60766411631418762096215
4
- data.tar.gz: 0c30009b666d29da85c8b6bf112113328f100d67434d03f8ded1978654708208
3
+ metadata.gz: 54a91acee1737d98173875c8a52aea2427ba8d02fab7cbc86d9d6afcb125ddab
4
+ data.tar.gz: 0b075a541cfc30e88473ce2c349704fb2624ab30a2dc9a314cf0172bc0b8ff7e
5
5
  SHA512:
6
- metadata.gz: cd3b6d08c8c0d3530b1bd676b1f4005e01c66f02a0fa92bc90378883d54ee521a600e04743ad445b10f38607e18ba7832c149e7a42895d308770bd9951c637da
7
- data.tar.gz: d16d39ffaaa633989aea79dbb7820619e8f535c93bfb6886ef82920749842a9f16b7d457121e92d787b4582974b1801262962de1c7c6d0f8ac0bed015c005ef7
6
+ metadata.gz: '09a8297d560a01f474369b7b1733803def3f4e8c8b548f3213f15d58ec5a039c092f17c2a47d616996f71902256c773bf14b6ba27b742048c4495d622dc3499e'
7
+ data.tar.gz: 8006f6d324b2592edd8f3927b057ad6c5a3410f1c07a74eae072919d9d18286d717ee2033b397ed2e496a964d2c78b559319fb7f2fd71da42b77b413a35906dd
@@ -18,7 +18,7 @@
18
18
  <% else %>
19
19
  <%= link_to 'Cancelar', eval_with_rescue("#{controller_name}_path"), class: "btn btn-default btn-xs" %>
20
20
  <% end %>
21
- <%= f.submit 'Salvar', class: 'btn btn-primary btn-xs' %>
21
+ <%= f.submit 'Salvar', class: "btn btn-#{box_class} btn-xs" %>
22
22
  </h3>
23
23
  </div>
24
24
  <div class="box-body">
@@ -56,7 +56,7 @@
56
56
  <% end %>
57
57
  <% end %>
58
58
 
59
- <%= f.submit class: "btn btn-primary" %>
59
+ <%= f.submit class: "btn btn-#{box_class}" %>
60
60
  </div>
61
61
  </div>
62
62
  <% end %>
@@ -19,7 +19,7 @@
19
19
  <%= f.input sf[:field], label: sf[:label], required: false, as: sf[:as], collection: sf[:collection], wrapper_html: { class: 'col-md-3' } %>
20
20
  <% end %>
21
21
  <div class="col-md-3 top-25">
22
- <%= f.submit "Pesquisar", class: 'btn btn-primary' %>
22
+ <%= f.submit "Pesquisar", class: "btn btn-#{box_class}" %>
23
23
  </div>
24
24
  <% end %>
25
25
  </div>
@@ -54,12 +54,12 @@
54
54
  <% if can? :new, controller_name.singularize %>
55
55
  <% if nested_resource == true %>
56
56
  <% if parent_resource %>
57
- <%= link_to eval("new_#{parent_resource}_#{controller_name.singularize}_path"), class: "btn btn-primary" do %>
57
+ <%= link_to eval("new_#{parent_resource}_#{controller_name.singularize}_path"), class: "btn btn-<%= box_class %>" do %>
58
58
  <%= t('.new', default: t("helpers.links.new")) %> <%= Kernel.const_get(controller_name.singularize.camelize).model_name.human %> <i class='fa fa-plus'></i>
59
59
  <% end %>
60
60
  <% end %>
61
61
  <% else %>
62
- <%= link_to eval("new_#{controller_name.singularize}_path"), class: "btn btn-primary" do %>
62
+ <%= link_to eval("new_#{controller_name.singularize}_path"), class: "btn btn-#{box_class}" do %>
63
63
  <%= t('.new', default: t("helpers.links.new")) %> <%= Kernel.const_get(controller_name.singularize.camelize).model_name.human %> <i class='fa fa-plus'></i>
64
64
  <% end %>
65
65
  <% end %>
@@ -21,7 +21,13 @@
21
21
  <table class="table table-bordered table-striped no-padding datatables">
22
22
  <% (object.class.column_names - ['id', 'created_at', 'updated_at', 'deleted_at'] - excluded_columns).each do |column| %>
23
23
  <tr>
24
- <th width='15%'><%= object.class.human_attribute_name(column) %></th>
24
+ <th width='15%'>
25
+ <% if /_id$/ =~ column && object.respond_to?(column.split('_id')[0]) %>
26
+ <%= object.class.human_attribute_name(column.split("_id")[0]) %>
27
+ <% else %>
28
+ <%= object.class.human_attribute_name(column) %>
29
+ <% end %>
30
+ </th>
25
31
  <td>
26
32
  <% if object.send(column).class == Date or
27
33
  object.send(column).class == DateTime or
@@ -48,7 +54,13 @@
48
54
  <thead>
49
55
  <tr>
50
56
  <% value.each do |v| %>
51
- <th><%= Kernel.const_get(key.to_s.singularize.camelize).human_attribute_name(v) %></th>
57
+ <th>
58
+ <% if /_id$/ =~ v && Kernel.const_get(key.to_s.singularize.camelize).new.respond_to?(v.split('_id')[0]) %>
59
+ <%= Kernel.const_get(key.to_s.singularize.camelize).human_attribute_name(v.split('_id')[0]) %>
60
+ <% else %>
61
+ <%= Kernel.const_get(key.to_s.singularize.camelize).human_attribute_name(v) %>
62
+ <% end %>
63
+ </th>
52
64
  <% end %>
53
65
  </tr>
54
66
  </thead>
@@ -56,10 +68,21 @@
56
68
  <% object.send(key.to_s).each do |r| %>
57
69
  <tr>
58
70
  <% value.each do |v| %>
59
- <td><%= r.send(v) %></td>
60
- <% end %>
61
- </tr>
62
- <% end %>
71
+ <td>
72
+ <% if r.send(v).class == Date or
73
+ r.send(v).class == DateTime or
74
+ r.send(v).class == ActiveSupport::TimeWithZone or
75
+ r.send(v).class == Time %>
76
+ <%=l r.send(v) %>
77
+ <% elsif /_id$/ =~ v && r.respond_to?(v.split('_id')[0]) %>
78
+ <%= r.send(v.split("_id")[0]).name %>
79
+ <% else %>
80
+ <%= r.send(v) %>
81
+ <% end %>
82
+ <% end %>
83
+ </td>
84
+ <% end %>
85
+ </tr>
63
86
  </tbody>
64
87
  </table>
65
88
  <% end %>
@@ -1,3 +1,3 @@
1
1
  module Zutils
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
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.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ricardo Viana