zutils 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 72badd3ec764154e313471360dafcabe600d6153df08ea630ae3ce425aeea926
4
- data.tar.gz: fba001c4d9484e97a8c66564c6a96c810b1e3ee82215cbabda1e1b86771adb72
3
+ metadata.gz: 87774d0b4bade17dbfbf691b7fdbbf66605bd3d154598f28f7d650f2ec10bd2c
4
+ data.tar.gz: ee5cb78bbb9e22450155327e43bf37c5bb857aab83a3d807ad9a9f21bc97326f
5
5
  SHA512:
6
- metadata.gz: 6354ac15798e6bd9213a560fc74747da7138d97b2765fb17e9147f9869051eef6e37db19e4a9e00f3204ebbc4ce9334e640cf839d10bc83396f59695bf164d64
7
- data.tar.gz: 2c49a5c5fd612a0bbc38b9a582581bd53c62aae44e0717bf68bdd4e52dcaaab46a0e526f1e546fa09e72d0c9f4a3e6db19495d06e534dbfb086b5700bb94eb07
6
+ metadata.gz: '04683de51005f1081a62816385b693b62e956e71d64da67807c03e4a8bc9ef56f3834fa3c7978e920762726561831ecf419f7e6cd854efcd58b09c2df857230b'
7
+ data.tar.gz: b88db9d689fc9318ace4f9a7cfc2d399af965c73ce677742b7c17f7fef95012fd5f07235eef34b401672a039874b1008a9700ef509d4ee4e021febf0d511d9f1
@@ -2,6 +2,10 @@
2
2
  <% nested_resource ||= false %>
3
3
  <% relationships ||= {} %>
4
4
  <% box_class ||= 'primary' %>
5
+ <% display_mode ||= 'table' %>
6
+
7
+ <% form_fields ||= (object.class.respond_to?('form_fields') ? object.class.form_fields : {}) %>
8
+ <% form_ordered_fields ||= (form_fields.empty? ? object.class.column_names : form_fields.keys) %>
5
9
 
6
10
  <div class="box box-<%= box_class %>">
7
11
  <div class="box-header with-border">
@@ -17,40 +21,80 @@
17
21
  <%= link_to 'Listagem', eval_with_rescue("#{controller_name}_path"), class: "btn btn-default btn-xs" %>
18
22
  <% end %>
19
23
  </div>
20
- <div class="box-body no-padding">
21
- <table class="table table-bordered table-striped no-padding datatables">
22
- <% (object.class.column_names - ['id', 'created_at', 'updated_at', 'deleted_at'] - excluded_columns).each do |column| %>
23
- <tr>
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>
31
- <td>
32
- <% if object.send(column).class == Date or
33
- object.send(column).class == DateTime or
34
- object.send(column).class == ActiveSupport::TimeWithZone or
35
- object.send(column).class == Time %>
36
- <%=l object.send(column) %>
37
- <% elsif /_id$/ =~ column && object.respond_to?(column.split('_id')[0]) %>
38
- <%= object.send(column.split("_id")[0])&.name %>
39
- <% else %>
40
- <%= object.send(column) %>
41
- <% end %>
42
- </td>
43
- </tr>
44
- <% end %>
45
- </table>
46
- <% if relationships.size > 0 %>
47
- <% relationships.each do |key, value| %>
24
+ <div class="box-body <%= 'no-padding' if display_mode == 'table' %>">
25
+ <% if display_mode == 'dt' %>
26
+ <div class="row">
27
+ <dl>
28
+ <% (form_ordered_fields - ['id', 'created_at', 'updated_at', 'deleted_at'] - excluded_columns).each do |column| %>
29
+ <% wphtml = "col-md-#{(form_fields[column.to_sym].class == Hash ? form_fields[column.to_sym][:size] : form_fields[column.to_sym] ) || 12}" %>
30
+ <% icon = (form_fields[column.to_sym].class == Hash ? form_fields[column.to_sym][:icon] : 'id-card-o') %>
31
+ <div class="<%= wphtml %>">
32
+ <dt>
33
+ <i class="fa fa-<%= icon %> margin-r-5"></i>
34
+ <% if /_id$/ =~ column && object.respond_to?(column.split('_id')[0]) %>
35
+ <%= object.class.human_attribute_name(column.split("_id")[0]) %>
36
+ <% else %>
37
+ <%= object.class.human_attribute_name(column) %>
38
+ <% end %>
39
+ </dt>
40
+ <dd>
41
+ <% if object.send(column).class == Date or
42
+ object.send(column).class == DateTime or
43
+ object.send(column).class == ActiveSupport::TimeWithZone or
44
+ object.send(column).class == Time %>
45
+ <%=l object.send(column) %>
46
+ <% elsif /_id$/ =~ column && object.respond_to?(column.split('_id')[0]) %>
47
+ <%= object.send(column.split("_id")[0])&.name %>
48
+ <% else %>
49
+ <%= object.send(column) %>
50
+ <% end %>
51
+ &nbsp;
52
+ </dd>
53
+ </div>
54
+ <% end %>
55
+ </dl>
56
+ </div>
57
+ <% end %>
58
+ <% if display_mode == 'table' %>
59
+ <table class="table table-bordered table-striped no-padding datatables">
60
+ <% (object.class.column_names - ['id', 'created_at', 'updated_at', 'deleted_at'] - excluded_columns).each do |column| %>
61
+ <tr>
62
+ <th width='15%'>
63
+ <% if /_id$/ =~ column && object.respond_to?(column.split('_id')[0]) %>
64
+ <%= object.class.human_attribute_name(column.split("_id")[0]) %>
65
+ <% else %>
66
+ <%= object.class.human_attribute_name(column) %>
67
+ <% end %>
68
+ </th>
69
+ <td>
70
+ <% if object.send(column).class == Date or
71
+ object.send(column).class == DateTime or
72
+ object.send(column).class == ActiveSupport::TimeWithZone or
73
+ object.send(column).class == Time %>
74
+ <%=l object.send(column) %>
75
+ <% elsif /_id$/ =~ column && object.respond_to?(column.split('_id')[0]) %>
76
+ <%= object.send(column.split("_id")[0])&.name %>
77
+ <% else %>
78
+ <%= object.send(column) %>
79
+ <% end %>
80
+ </td>
81
+ </tr>
82
+ <% end %>
83
+ </table>
84
+ <% end %>
85
+ </div>
86
+ </div>
87
+
88
+ <% if relationships.size > 0 %>
89
+ <% relationships.each do |key, value| %>
90
+ <div class="box box-<%= box_class %>">
91
+ <div class="box-header with-border">
92
+ <h3 class="box-title">
93
+ <%=t Kernel.const_get(key.to_s.singularize.camelize).model_name.human.pluralize %>
94
+ </h3>
95
+ </div>
96
+ <div class="box-body no-padding">
48
97
  <table class="table table-bordered table-striped no-padding datatables">
49
- <caption>
50
- <strong>
51
- <%=t Kernel.const_get(key.to_s.singularize.camelize).model_name.human.pluralize %>
52
- </strong>
53
- </caption>
54
98
  <thead>
55
99
  <tr>
56
100
  <% value.each do |v| %>
@@ -85,9 +129,12 @@
85
129
  </tr>
86
130
  </tbody>
87
131
  </table>
88
- <% end %>
89
- <% end %>
90
- </div>
132
+ </div>
133
+ </div>
134
+ <% end %>
135
+ <% end %>
136
+
137
+ <div class="box box-<%= box_class %>">
91
138
  <div class="box-footer">
92
139
  <% if can? :edit, object %> <!--verificando se o usuario esta logado-->
93
140
  <%= link_to eval_with_rescue("edit_#{controller_name.singularize}_path(#{object.id})"), class: "btn btn-warning", data: { toggle: 'tooltip', placement: 'top', title: 'Editar' } do %>
@@ -1,3 +1,3 @@
1
1
  module Zutils
2
- VERSION = "0.1.8"
2
+ VERSION = "0.1.9"
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.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ricardo Viana