zutils 0.4.0 → 0.4.1

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: b83f5d8d6ad65447a77d8d18cc7a9e7fde4dbd61b92a31b9034f06f23f4b702f
4
- data.tar.gz: 3b2b365d34da3b2115dad406518eb6f7d420f898de46ea22a09f36970643a49b
3
+ metadata.gz: 4b2290314f33c81d7bdaa68499ef394b9281ec5e1c375cc2b6b6656bd60bb3b2
4
+ data.tar.gz: 3997dcd75dbf932d10dae0487a72271582188fcb97cb3eaec6d24b5eb2a40f15
5
5
  SHA512:
6
- metadata.gz: 72886011e7625a2a9af5a84e044ca90b036e2164d58266f88d67a3a39dfba55cf0dfe17b7f6937d930c0d7a2d280b209e3e6b3614ed7a6dc52019f505994dba9
7
- data.tar.gz: 1e46a9037a3cdd8ba0be4f41a2020f80224c27ae8f077fd5ceb9e67565f02d576d9beff095d191cf72d523c0b5598fc3fdc7b6cecd43e0dc2352438428e98eb7
6
+ metadata.gz: b47063da1ef161bcb69abcf9341f09831a08a6b167ba0d52dedf396814236a08fbf0c0a82432fc635b64d557de4ab82bf1900a9d6059fbf5047b4947e0af05e0
7
+ data.tar.gz: '090d1baed15370f86b9dea7b3e8f1fd980c86edee3e251708e21400c04dd28d49f365357c48dffa948877187514d722086505319041ad8453605b4b8b831c0eb'
@@ -4,10 +4,12 @@
4
4
  <% sort_all ||= false %>
5
5
  <% nested_resource ||= false %>
6
6
  <% excluded_columns ||= [] %>
7
+ <% show_columns ||= [] %>
7
8
  <% additional_columns ||= [] %>
8
9
  <% additional_actions ||= [] %>
9
10
  <% box_class ||= 'primary' %>
10
11
  <% table_no_padding ||= false %>
12
+ <% table_class ||= 'datatables' %>
11
13
 
12
14
  <% hide_links ||= false %>
13
15
  <% hide_actions ||= false %>
@@ -35,18 +37,10 @@
35
37
  <% end %>
36
38
  </div>
37
39
  <% end %>
38
- <% if list.empty? %>
39
- <table class="table table-striped datatables">
40
- <tbody>
41
- <tr>
42
- <td>Nenhum registro encontrado</td>
43
- </tr>
44
- </tbody>
45
- </table>
46
- <% else %>
47
40
  <%= render 'shared/list', list: list, exceptions: exceptions, excluded_columns: excluded_columns,
48
41
  additional_columns: additional_columns, sort_fields: sort_fields, sort_all: sort_all,
49
- additional_actions: additional_actions, hide_actions: hide_actions
42
+ additional_actions: additional_actions, hide_actions: hide_actions, table_class: table_class,
43
+ show_columns: show_columns
50
44
  %>
51
45
  <% if defined? list.total_pages %>
52
46
  <div class='col-md-4'>
@@ -59,7 +53,6 @@
59
53
  <%= paginate list, window: 1 %>
60
54
  </div>
61
55
  <% end %>
62
- <% end %>
63
56
  </div>
64
57
 
65
58
  <% unless hide_links %>
@@ -5,29 +5,34 @@
5
5
  <% hide_actions ||= false %>
6
6
  <% sort_fields ||= [] %>
7
7
  <% sort_all ||= false %>
8
+ <% table_class ||= 'datatables' %>
9
+ <% show_columns ||= [] %>
8
10
 
9
- <% unless list.empty? %>
10
- <table class="table table-striped datatables">
11
+ <% if show_columns.empty? %>
12
+ <% show_columns = list.klass.column_names - exceptions - excluded_columns + additional_columns %>
13
+ <% end %>
14
+
15
+ <table class="table table-striped <%= table_class %>">
11
16
  <thead>
12
17
  <tr>
13
- <% (list.first.class.column_names - exceptions - excluded_columns + additional_columns).each do |column| %>
18
+ <% show_columns.each do |column| %>
14
19
  <% if sort_all || sort_fields.include?(column) %>
15
20
  <% if /_id$/ =~ column %>
16
- <th><%= sort_link(@q, column, list.first.class.human_attribute_name(column.split("_id")[0])) %></th>
21
+ <th><%= sort_link(@q, column, list.klass.human_attribute_name(column.split("_id")[0])) %></th>
17
22
  <% elsif /_cents$/ =~ column %>
18
- <th><%= sort_link(@q, column, list.first.class.human_attribute_name(column.split("_cents")[0])) %></th>
23
+ <th><%= sort_link(@q, column, list.klass.human_attribute_name(column.split("_cents")[0])) %></th>
19
24
  <% elsif /_currency$/ =~ column %>
20
25
  <% else %>
21
- <th><%= sort_link(@q, column, list.first.class.human_attribute_name(column)) %></th>
26
+ <th><%= sort_link(@q, column, list.klass.human_attribute_name(column)) %></th>
22
27
  <% end %>
23
28
  <% else %>
24
29
  <% if /_id$/ =~ column %>
25
- <th><%= list.first.class.human_attribute_name(column.split("_id")[0]) %></th>
30
+ <th><%= list.klass.human_attribute_name(column.split("_id")[0]) %></th>
26
31
  <% elsif /_cents$/ =~ column %>
27
- <th><%= list.first.class.human_attribute_name(column.split("_cents")[0]) %></th>
32
+ <th><%= list.klass.human_attribute_name(column.split("_cents")[0]) %></th>
28
33
  <% elsif /_currency$/ =~ column %>
29
34
  <% else %>
30
- <th><%= list.first.class.human_attribute_name(column) %></th>
35
+ <th><%= list.klass.human_attribute_name(column) %></th>
31
36
  <% end %>
32
37
  <% end %>
33
38
  <% end %>
@@ -39,7 +44,7 @@
39
44
  <tbody>
40
45
  <% list.each do |object| %>
41
46
  <tr>
42
- <% (list.first.class.column_names - exceptions - excluded_columns + additional_columns).each do |column| %>
47
+ <% show_columns.each do |column| %>
43
48
  <% next if /_currency$/ =~ column %>
44
49
  <td>
45
50
  <% if object.send(column).class == Date or
@@ -67,5 +72,4 @@
67
72
  </tr>
68
73
  <% end %>
69
74
  </tbody>
70
- </table>
71
- <% end %>
75
+ </table>
@@ -16,20 +16,20 @@
16
16
  <div class="box-header with-border">
17
17
  <h3 class="box-title"><%= object.class.model_name.human %></h3>
18
18
  <% unless hide_links %>
19
- <% if can? :edit, object %> <!--verificando se o usuario esta logado-->
19
+ <% if can? :new, object.class %> <!--verificando se o usuario esta logado-->
20
20
  <% if nested_resource %>
21
21
  <%= link_to eval_with_rescue("new_#{parent_resource.class.model_name.singular}_#{object.class.model_name.singular}_path(#{parent_resource.id})"), class: "btn btn-#{box_class} btn-xs", data: { toggle: 'tooltip', placement: 'top', title: 'Cadastrar' } do %>
22
- <i class="fa fa-plus"></i> Cadastrar
22
+ Cadastrar <i class="fa fa-plus"></i>
23
23
  <% end %>
24
24
  <% else %>
25
25
  <%= link_to eval("new_#{object.class.model_name.singular}_path"), class: "btn btn-#{box_class} btn-xs", data: { toggle: 'tooltip', placement: 'top', title: 'Cadastrar' } do %>
26
- <i class="fa fa-plus"></i> Cadastrar
26
+ Cadastrar <i class="fa fa-plus"></i>
27
27
  <% end %>
28
28
  <% end %>
29
29
  <% end %>
30
30
  <% if can? :edit, object %> <!--verificando se o usuario esta logado-->
31
31
  <%= link_to eval_with_rescue("edit_#{object.class.model_name.singular}_path(#{object.id})"), class: "btn btn-warning btn-xs", data: { toggle: 'tooltip', placement: 'top', title: 'Editar' } do %>
32
- <i class="fa fa-pencil"></i> Editar
32
+ Editar <i class="fa fa-pencil"></i>
33
33
  <% end %>
34
34
  <% end %>
35
35
  <% if nested_resource %>
@@ -1,3 +1,3 @@
1
1
  module Zutils
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zutils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ricardo Viana
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-04-19 00:00:00.000000000 Z
11
+ date: 2019-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails