zutils 0.3.4 → 0.3.5

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: 160377b52e19d0d783a832a833e6d1b650f9f5b9c627e708555f55803ccda183
4
- data.tar.gz: 1acfa0727db0c49be6ffc58f0668677396941faf375760a6b8769a7ef68aa3f6
3
+ metadata.gz: 03053f0f54df36cd364d503549a97fa7f5125a250cf84b5b031a237a098a7b59
4
+ data.tar.gz: 3cc44ed720cc7eb10e9e8c6419154d346cd621b81fb4da74976bfbe472038c38
5
5
  SHA512:
6
- metadata.gz: 82f3ee65bd3fc78f4f24de539f09d9037c6d7b9e358fcad0328fe92ef7eff30b7e874f40014938e1f5a5ef23412761a9bc77a931f1d2ebb49137dd9adeb11ce5
7
- data.tar.gz: f8eda3f402e0417e08b804274c816542db33aad21c27d5b22f569d5de0345419fc4f66bddec48dcd0438d086851bff245a0daff56e6d7e8aed665f840e6f1c6c
6
+ metadata.gz: 5b55b90d928c7c7598c06012cd50e00f49d3033cd62c6c2c611e44513696c6e36fedce993b29ab6751d65069b36999736d08ffb0ce0b2a8348b89bcc9fee300b
7
+ data.tar.gz: fb328aa9f9e0008a5913321a424cffe0a4b550daaae8b45cad3a9a215130eaeeb152c25b00a20ff84077cef59da14fd56bcd1fa775b662d804a3e617c7f7d7bd
@@ -7,14 +7,22 @@
7
7
  <% additional_columns ||= [] %>
8
8
  <% additional_actions ||= [] %>
9
9
  <% box_class ||= 'primary' %>
10
+ <% table_no_padding ||= false %>
11
+
12
+ <% hide_links ||= false %>
13
+ <% hide_actions ||= false %>
14
+ <% hide_header ||= false %>
15
+ <% hide_footer ||= false %>
10
16
 
11
17
  <div class='box box-<%= box_class %>'>
12
- <div class="box-header with-border">
13
- <h3 class="box-title">
14
- <%= list.klass.model_name.human.pluralize %>
15
- </h3>
16
- </div>
17
- <div class="box-body">
18
+ <% unless hide_header %>
19
+ <div class="box-header with-border">
20
+ <h3 class="box-title">
21
+ <%= list.klass.model_name.human.pluralize %>
22
+ </h3>
23
+ </div>
24
+ <% end %>
25
+ <div class="box-body <%= 'no-padding' if table_no_padding %>">
18
26
  <% unless search_fields.empty? %>
19
27
  <div class="row">
20
28
  <%= search_form_for @q, url: eval(nested_resource ? "#{parent_resource}_#{controller_name}_path" : "#{controller_name}_path") do |f| %>
@@ -38,7 +46,7 @@
38
46
  <% else %>
39
47
  <%= render 'shared/list', list: list, exceptions: exceptions, excluded_columns: excluded_columns,
40
48
  additional_columns: additional_columns, sort_fields: sort_fields, sort_all: sort_all,
41
- additional_actions: additional_actions
49
+ additional_actions: additional_actions, hide_actions: hide_actions
42
50
  %>
43
51
  <% if defined? list.total_pages %>
44
52
  <div class='col-md-4'>
@@ -54,22 +62,24 @@
54
62
  <% end %>
55
63
  </div>
56
64
 
57
- <% unless controller_name == 'users' %>
58
- <div class="box-footer">
59
- <% if can? :new, controller_name.singularize %>
60
- <% if nested_resource == true %>
61
- <% if parent_resource %>
62
- <%= link_to eval("new_#{parent_resource.class.model_name.singular}_#{list.klass.model_name.singular}_path(#{parent_resource.id})"), class: "btn btn-#{box_class}" do %>
65
+ <% unless hide_links %>
66
+ <% unless controller_name == 'users' %>
67
+ <div class="box-footer">
68
+ <% if can? :new, controller_name.singularize %>
69
+ <% if nested_resource == true %>
70
+ <% if parent_resource %>
71
+ <%= link_to eval("new_#{parent_resource.class.model_name.singular}_#{list.klass.model_name.singular}_path(#{parent_resource.id})"), class: "btn btn-#{box_class}" do %>
72
+ <%= t('.new', default: t("helpers.links.new")) %> <%= list.klass.model_name.human %> <i class='fa fa-plus'></i>
73
+ <% end %>
74
+ <% end %>
75
+ <% else %>
76
+ <%= link_to eval("new_#{list.klass.model_name.singular}_path"), class: "btn btn-#{box_class}" do %>
63
77
  <%= t('.new', default: t("helpers.links.new")) %> <%= list.klass.model_name.human %> <i class='fa fa-plus'></i>
64
78
  <% end %>
65
79
  <% end %>
66
- <% else %>
67
- <%= link_to eval("new_#{list.klass.model_name.singular}_path"), class: "btn btn-#{box_class}" do %>
68
- <%= t('.new', default: t("helpers.links.new")) %> <%= list.klass.model_name.human %> <i class='fa fa-plus'></i>
69
- <% end %>
70
80
  <% end %>
71
- <% end %>
72
- </div>
81
+ </div>
82
+ <% end %>
73
83
  <% end %>
74
84
 
75
85
  </div>
@@ -51,6 +51,7 @@
51
51
  <%= object.send(column.split("_id")[0])&.name %>
52
52
  <% elsif /_cents$/ =~ column %>
53
53
  <%= number_to_currency object.send(column.split("_cents")[0]) %>
54
+ <% elsif /_currency$/ =~ column %>
54
55
  <% elsif column == 'id' %>
55
56
  <%= link_to object.id, object %>
56
57
  <% else %>
@@ -3,35 +3,41 @@
3
3
  <% relationships ||= {} %>
4
4
  <% box_class ||= 'primary' %>
5
5
  <% display_mode ||= 'table' %>
6
+ <% hide_links ||= false %>
7
+ <% hide_header ||= false %>
6
8
 
7
9
  <% form_fields ||= (object.class.respond_to?('form_fields') ? object.class.form_fields : {}) %>
8
10
  <% form_ordered_fields ||= (form_fields.empty? ? object.class.column_names : form_fields.keys) %>
9
11
 
10
12
  <div class="box box-<%= box_class %>">
11
- <div class="box-header with-border">
12
- <h3 class="box-title"><%= object.class.model_name.human %></h3>
13
- <% if can? :edit, object %> <!--verificando se o usuario esta logado-->
14
- <% if nested_resource %>
15
- <%= 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 %>
16
- <i class="fa fa-plus"></i> Cadastrar
13
+ <% unless hide_header %>
14
+ <div class="box-header with-border">
15
+ <h3 class="box-title"><%= object.class.model_name.human %></h3>
16
+ <% unless hide_links %>
17
+ <% if can? :edit, object %> <!--verificando se o usuario esta logado-->
18
+ <% if nested_resource %>
19
+ <%= 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 %>
20
+ <i class="fa fa-plus"></i> Cadastrar
21
+ <% end %>
22
+ <% else %>
23
+ <%= 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 %>
24
+ <i class="fa fa-plus"></i> Cadastrar
25
+ <% end %>
26
+ <% end %>
17
27
  <% end %>
18
- <% else %>
19
- <%= 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 %>
20
- <i class="fa fa-plus"></i> Cadastrar
28
+ <% if can? :edit, object %> <!--verificando se o usuario esta logado-->
29
+ <%= 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 %>
30
+ <i class="fa fa-pencil"></i> Editar
31
+ <% end %>
32
+ <% end %>
33
+ <% if nested_resource %>
34
+ <%= link_to 'Listagem', eval_with_rescue("#{parent_resource.class.model_name.singular}_#{object.class.model_name.plural}_path(#{parent_resource.id})"), class: "btn btn-default btn-xs" %>
35
+ <% else %>
36
+ <%= link_to 'Listagem', eval_with_rescue("#{object.class.model_name.plural}_path"), class: "btn btn-default btn-xs" %>
21
37
  <% end %>
22
38
  <% end %>
23
- <% end %>
24
- <% if can? :edit, object %> <!--verificando se o usuario esta logado-->
25
- <%= 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 %>
26
- <i class="fa fa-pencil"></i> Editar
27
- <% end %>
28
- <% end %>
29
- <% if nested_resource %>
30
- <%= link_to 'Listagem', eval_with_rescue("#{parent_resource.class.model_name.singular}_#{object.class.model_name.plural}_path(#{parent_resource.id})"), class: "btn btn-default btn-xs" %>
31
- <% else %>
32
- <%= link_to 'Listagem', eval_with_rescue("#{object.class.model_name.plural}_path"), class: "btn btn-default btn-xs" %>
33
- <% end %>
34
- </div>
39
+ </div>
40
+ <% end %>
35
41
  <div class="box-body <%= 'no-padding' if display_mode == 'table' %>">
36
42
  <% if display_mode == 'dt' %>
37
43
  <div class="row">
@@ -69,27 +75,33 @@
69
75
  <% if display_mode == 'table' %>
70
76
  <table class="table table-bordered table-striped no-padding datatables">
71
77
  <% (object.class.column_names - ['id', 'created_at', 'updated_at', 'deleted_at'] - excluded_columns).each do |column| %>
72
- <tr>
73
- <th width='15%'>
74
- <% if /_id$/ =~ column && object.respond_to?(column.split('_id')[0]) %>
75
- <%= object.class.human_attribute_name(column.split("_id")[0]) %>
76
- <% else %>
77
- <%= object.class.human_attribute_name(column) %>
78
- <% end %>
79
- </th>
80
- <td>
81
- <% if object.send(column).class == Date or
82
- object.send(column).class == DateTime or
83
- object.send(column).class == ActiveSupport::TimeWithZone or
84
- object.send(column).class == Time %>
85
- <%=l object.send(column) %>
86
- <% elsif /_id$/ =~ column && object.respond_to?(column.split('_id')[0]) %>
87
- <%= object.send(column.split("_id")[0])&.name %>
88
- <% else %>
89
- <%= object.send(column) %>
90
- <% end %>
91
- </td>
92
- </tr>
78
+ <% unless /_currency$/ =~ column %>
79
+ <tr>
80
+ <th width='15%'>
81
+ <% if /_id$/ =~ column && object.respond_to?(column.split('_id')[0]) %>
82
+ <%= object.class.human_attribute_name(column.split("_id")[0]) %>
83
+ <% elsif /_cents$/ =~ column %>
84
+ <%= object.class.human_attribute_name(column.split("_cents")[0]) %>
85
+ <% else %>
86
+ <%= object.class.human_attribute_name(column) %>
87
+ <% end %>
88
+ </th>
89
+ <td>
90
+ <% if object.send(column).class == Date or
91
+ object.send(column).class == DateTime or
92
+ object.send(column).class == ActiveSupport::TimeWithZone or
93
+ object.send(column).class == Time %>
94
+ <%=l object.send(column) %>
95
+ <% elsif /_id$/ =~ column && object.respond_to?(column.split('_id')[0]) %>
96
+ <%= object.send(column.split("_id")[0])&.name %>
97
+ <% elsif /_cents$/ =~ column %>
98
+ <%= number_to_currency object.send(column.split("_cents")[0]) %>
99
+ <% else %>
100
+ <%= object.send(column) %>
101
+ <% end %>
102
+ </td>
103
+ </tr>
104
+ <% end %>
93
105
  <% end %>
94
106
  </table>
95
107
  <% end %>
@@ -1,3 +1,3 @@
1
1
  module Zutils
2
- VERSION = "0.3.4"
2
+ VERSION = "0.3.5"
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.3.4
4
+ version: 0.3.5
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-03-21 00:00:00.000000000 Z
11
+ date: 2019-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails