zutils 2.0.1 → 3.0.0

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: 4f4676ffa4289aaa630608de27b2156473f7337c0c850598e3f7bb79fb7397ba
4
- data.tar.gz: 7c0294692a429bc75b007bbc845b1deaf88164b1384adcc9667ea33baaf266f2
3
+ metadata.gz: 8d324c51d55fbc3c4b4b504b566b4cfcec75add45d14ed79995c1613f010fdc1
4
+ data.tar.gz: 7c582d7a7ea2a95368fb69ed3c4c7db3758abe1ef3b07aacb30919c19d01ed7a
5
5
  SHA512:
6
- metadata.gz: 1c28a400899038fa78a122d3b14e4d029b2ee139cd603d8448d59c9cd1597abe3d1f1a6b64f7ecdf25f480a9d0acb71f02fb7f2d8508164c8600fcc53918cd2b
7
- data.tar.gz: 3f3c5ab944e70a2fa4d287c7e6ab3fe7e75b4789a712956cf994efdfa6076d5e5901a4efbc14f71608c750b1440778c2b9b995f7dd4471dfdfbed408f25b774e
6
+ metadata.gz: 1931449bd2e9cfaad73a415c1cded45c8fd30c0d9ba0cede4008cddc6ee4866bd33380765e74aef22003c54ef3baa75611ed06c2b2a48441ee22a18672cda24b
7
+ data.tar.gz: d8d96656c6bc5713ca863b717f040814538ed8f84c96e0ef5e6b3915dfe71f4d52ae69c5a282147330114496e4d3863b0baf986e9773a0ebf7066cfc203c7044
@@ -0,0 +1,81 @@
1
+ <% size ||= "md" %>
2
+ <% labels ||= false %>
3
+ <% hide ||= [] %>
4
+ <div class="row">
5
+ <div class="col text-nowrap">
6
+ <% unless hide.include? "show" %>
7
+ <%= link_to object, class: "mb-1 btn btn-#{size} btn-default",
8
+ data: { "bs-toggle": "tooltip", "bs-placement": "top", "bs-title": "Visualizar" } do %>
9
+ <% if labels %>
10
+ <div class="d-none d-sm-inline-block">
11
+ Ver
12
+ </div>
13
+ <% end %>
14
+ <i class="fa fa-fw fa-eye"></i>
15
+ <% end %>
16
+ <% end %>
17
+ <% unless hide.include? "new" %>
18
+ <%= link_to eval_with_rescue("new_#{[object].flatten.map{|x| x.class.to_s.underscore}.join("_")}_path"),
19
+ class: "mb-1 btn btn-#{size} btn-danger", data: { "bs-toggle": "tooltip", "bs-placement": "top", "bs-title": "Cadastrar" } do %>
20
+ <% if labels %>
21
+ <div class="d-none d-sm-inline-block">
22
+ Cadastrar
23
+ </div>
24
+ <% end %>
25
+ <i class="fa fa-fw fa-plus"></i>
26
+ <% end %>
27
+ <% end %>
28
+ <% unless hide.include? "edit" %>
29
+ <%= link_to eval_with_rescue("edit_#{[object].flatten.map{|x| x.class.to_s.underscore}.join("_")}_path(#{object.id})"),
30
+ class: "mb-1 btn btn-#{size} btn-warning", data: { "bs-toggle": "tooltip", "bs-placement": "top", "bs-title": "Editar" } do %>
31
+ <% if labels %>
32
+ <div class="d-none d-sm-inline-block">
33
+ Editar
34
+ </div>
35
+ <% end %>
36
+ <i class="fa fa-fw fa-pen"></i>
37
+ <% end %>
38
+ <% end %>
39
+ <% unless hide.include? "back" %>
40
+ <%= link_to eval_with_rescue("#{[object].flatten.map{|x| x.class.to_s.underscore.pluralize}.join("_")}_path"),
41
+ class: "mb-1 btn btn-#{size}", data: { "bs-toggle": "tooltip", "bs-placement": "top", "bs-title": "Voltar" } do %>
42
+ <% if labels %>
43
+ <div class="d-none d-sm-inline-block">
44
+ Voltar
45
+ </div>
46
+ <% end %>
47
+ <i class="fa fa-fw fa-arrow-left"></i>
48
+ <% end %>
49
+ <% end %>
50
+ <% unless hide.include? "delete" %>
51
+ <%= button_to object, method: :delete, form: { data: { turbo_confirm: 'Tem certeza?' }, class: 'd-inline'},
52
+ data: { "bs-toggle": "tooltip", "bs-placement": "top", "bs-title": "Apagar" },
53
+ class: "mb-1 btn btn-#{size} btn-dark" do %>
54
+ <% if labels %>
55
+ <div class="d-none d-sm-inline-block">
56
+ Apagar
57
+ </div>
58
+ <% end %>
59
+ <i class="fa fa-fw fa-trash"></i>
60
+ <% end %>
61
+ <% end %>
62
+ </div>
63
+ <% unless hide.include? "delete_right" %>
64
+ <div class="col col-auto text-right">
65
+ <%= button_to object, method: :delete, form: { data: { turbo_confirm: 'Tem certeza?' }, class: 'd-inline'},
66
+ data: { "bs-toggle": "tooltip", "bs-placement": "top", "bs-title": "Apagar" },
67
+ class: "mb-1 btn btn-#{size} btn-dark" do %>
68
+ <% if labels %>
69
+ <div class="d-none d-sm-inline-block">
70
+ Apagar
71
+ </div>
72
+ <% end %>
73
+ <i class="fa fa-fw fa-trash"></i>
74
+ <% end %>
75
+ </div>
76
+ <% end %>
77
+ <!-- adicionar menus via bloco -->
78
+ <% if block_given? %>
79
+ <%= yield %>
80
+ <% end %>
81
+ </div>
@@ -1,10 +1,13 @@
1
1
  <% exceptions ||= ['created_at', 'updated_at', 'deleted_at'] %>
2
2
  <% show_columns ||= [] %>
3
- <% table_class ||= 'datatables styletable' %>
4
- <% card_class ||= 'primary' %>
3
+ <% card_color ||= 'danger' %>
5
4
  <% sort_all ||= false %>
6
- <% show_new &&= true %>
7
5
  <% sort_fields ||= [] %>
6
+ <% table_class ||= 'bootstrap-table' %>
7
+
8
+ <% hide ||= %w[new back delete_right] %>
9
+ <% size ||= "xs" %>
10
+ <% controller ||= "bootstrap-table" %>
8
11
 
9
12
  <% hide_actions ||= false %>
10
13
 
@@ -12,18 +15,22 @@
12
15
  <% show_columns = list.klass.column_names - exceptions %>
13
16
  <% end %>
14
17
 
15
- <div class="card card-outline card-<%= card_class %>">
18
+ <div class="card card-outline card-<%= card_color %>" data-controller="<%= controller %>">
16
19
  <div class="card-header with-border">
17
20
  <h3 class="card-title">
18
21
  <strong>
19
- <i class="fa fa-list"></i>
20
- Listagem
22
+ <i class="fa fa-<%= list.klass.icon %>"></i>
23
+ Listagem de
24
+ <%= list.klass.model_name.human.pluralize %>
21
25
  </strong>
22
- <% if show_new %>
23
- <%= link_to eval("new_#{list.klass.model_name.singular}_path"), class: "btn btn-xs btn-#{card_class}" do %>
26
+ <% unless hide.include? "header_new" %>
27
+ <%= link_to eval("new_#{list.klass.model_name.singular}_path"), class: "btn btn-xs btn-#{card_color}" do %>
24
28
  Cadastar <i class="fa fa-plus"></i>
25
29
  <% end %>
26
30
  <% end %>
31
+ <% if block_given? %>
32
+ <%= yield %>
33
+ <% end %>
27
34
  <div class="text-muted text-xs">
28
35
  <%= page_entries_info list, entry_name: '' %>
29
36
  </div>
@@ -33,12 +40,21 @@
33
40
  </div>
34
41
  </div>
35
42
  <div class="card-body p-0">
36
- <%= render 'shared/list', list: list, show_columns: show_columns, box_class: card_class,
37
- table_class: table_class, exceptions: exceptions, sort_all: sort_all, sort_fields: sort_fields,
38
- hide_actions: hide_actions
43
+ <%= render 'shared/list', list: list, show_columns: show_columns, card_color: card_color, table_class: table_class,
44
+ exceptions: exceptions, sort_all: sort_all, sort_fields: sort_fields, hide: hide, size: size, hide_actions: hide_actions
39
45
  %>
40
46
  </div>
41
- <div class="pagination justify-content-center pt-3">
42
- <%= paginate list %>
47
+ </div>
48
+ <div class="row">
49
+ <div class="col" >
50
+ <div class="text-muted text-xs">
51
+ <%= page_entries_info list, entry_name: '' %>
52
+ </div>
53
+ </div>
54
+ <div class="col">
55
+ <div class="float-right">
56
+ <%= paginate list, window: 1 %>
57
+ </div>
43
58
  </div>
44
- </div>
59
+ </div>
60
+ <br>
@@ -0,0 +1,3 @@
1
+ <div id="flash_messages" data-controller="toastr">
2
+ <%= bootstrap_flash %>
3
+ </div>
@@ -4,30 +4,22 @@
4
4
  <% nested_resource ||= false %>
5
5
  <% parent_resource ||= false %>
6
6
  <% back_link ||= false %>
7
- <% box_class ||= 'primary' %>
7
+ <% card_color ||= 'primary' %>
8
8
  <% show_columns ||= [] %>
9
-
10
9
  <% form_fields ||= (object.class.respond_to?('form_fields') ? object.class.form_fields : {}) %>
11
10
  <% form_ordered_fields ||= (form_fields.empty? ? object.class.column_names : form_fields.keys) %>
12
-
13
11
  <% if show_columns.empty? %>
14
12
  <% show_columns = form_ordered_fields - ['id', 'created_at', 'updated_at', 'deleted_at'] - excluded_columns + additional_columns %>
15
13
  <% end %>
16
-
17
14
  <%= simple_form_for(nested_resource ? [parent_resource, object] : object) do |f| %>
18
- <div class="box box-<%= box_class %> card card-outline card-<%= box_class %>">
19
- <div class="box-header with-border card-header">
20
- <h3 class="box-title card-title">
15
+ <div class="card card-outline card-<%= card_color %>">
16
+ <div class="card-header">
17
+ <h3 class="card-title">
18
+ <i class="fa-fw <%= object.class.icon %>"></i>
21
19
  Dados do <%= object.class.model_name.human %>
22
- <% if parent_resource %>
23
- <%= link_to 'Cancelar', eval_with_rescue("#{parent_resource.class.model_name.to_s.downcase}_#{controller_name}_path(#{parent_resource.id})"), class: "btn btn-default btn-xs" %>
24
- <% else %>
25
- <%= link_to 'Cancelar', eval_with_rescue("#{controller_name}_path"), class: "btn btn-default btn-xs" %>
26
- <% end %>
27
- <%= f.submit 'Salvar', class: "btn btn-#{box_class} btn-xs" %>
28
20
  </h3>
29
21
  </div>
30
- <div class="box-body card-body">
22
+ <div class="card-body">
31
23
  <%= render 'shared/fields', object: object, f: f,
32
24
  excluded_columns: excluded_columns,
33
25
  additional_columns: additional_columns,
@@ -35,18 +27,26 @@
35
27
  show_columns: show_columns
36
28
  %>
37
29
  </div>
38
- <div class="box-footer card-footer">
30
+ <div class="card-footer text-right">
39
31
  <% if back_link %>
40
- <%= link_to 'Cancelar', "javascript:history.back()", class: "btn btn-default" %>
32
+ <%= link_to 'Cancelar', "javascript:history.back()", class: "btn" %>
41
33
  <% else %>
42
34
  <% if parent_resource %>
43
- <%= link_to 'Cancelar', eval_with_rescue("#{parent_resource.class.model_name.to_s.downcase}_#{controller_name}_path(#{parent_resource.id})"), class: "btn btn-default" %>
35
+ <%= link_to eval_with_rescue("#{parent_resource.class.model_name.to_s.downcase}_#{controller_name}_path(#{parent_resource.id})"), class: "btn" do %>
36
+ Cancelar
37
+ <i class="fa fa-cancel fa-fw"></i>
38
+ <% end %>
44
39
  <% else %>
45
- <%= link_to 'Cancelar', eval_with_rescue("#{controller_name}_path"), class: "btn btn-default" %>
40
+ <%= link_to eval_with_rescue("#{controller_name}_path"), class: "btn" do %>
41
+ Cancelar
42
+ <i class="fa fa-cancel fa-fw"></i>
43
+ <% end %>
46
44
  <% end %>
47
45
  <% end %>
48
-
49
- <%= f.submit class: "btn btn-#{box_class}" %>
46
+ <%= button_tag type: :submit, class: "btn btn-#{card_color}" do %>
47
+ Salvar
48
+ <i class="fa fa-fw fa-save"></i>
49
+ <% end %>
50
50
  </div>
51
51
  </div>
52
52
  <% end %>
@@ -1,5 +1,4 @@
1
1
  <% exceptions ||= ['created_at', 'updated_at', 'deleted_at'] %>
2
- <% search_fields ||= [] %>
3
2
  <% sort_fields ||= [] %>
4
3
  <% sort_all ||= false %>
5
4
  <% nested_resource ||= false %>
@@ -7,83 +6,59 @@
7
6
  <% show_columns ||= [] %>
8
7
  <% additional_columns ||= [] %>
9
8
  <% additional_actions ||= [] %>
10
- <% box_class ||= 'primary' %>
11
- <% table_no_padding ||= false %>
12
- <% table_class ||= 'datatables' %>
9
+ <% card_color ||= 'danger' %>
10
+ <% table_padding ||= false %>
11
+ <% table_class ||= 'bootstrap-table' %>
13
12
 
14
- <% hide_links ||= false %>
15
- <% hide_actions ||= false %>
16
- <% hide_header ||= false %>
17
- <% hide_footer ||= false %>
13
+ <% hide ||= %w[new back delete_right] %>
14
+ <% size ||= "xs" %>
15
+ <% controller ||= "bootstrap-table" %>
18
16
 
19
- <% hide_read_action ||= false %>
20
- <% hide_new_action ||= false %>
21
- <% hide_edit_action ||= false %>
22
- <% hide_destroy_action ||= false %>
17
+ <% hide_actions ||= false %>
23
18
 
24
- <div class='box box-<%= box_class %> card card-outline card-<%= box_class %>'>
25
- <% unless hide_header %>
26
- <div class="box-header with-border card-header">
27
- <h3 class="box-title card-title">
19
+ <div class="card card-outline card-<%= card_color %>" data-controller="<%= controller %>">
20
+ <% unless hide.include? 'header' %>
21
+ <div class="card-header with-border">
22
+ <h3 class="card-title">
28
23
  <strong>
24
+ <i class="fa fa-<%= list.klass.icon %>"></i>
25
+ Listagem de
29
26
  <%= list.klass.model_name.human.pluralize %>
30
27
  </strong>
31
- </h3>
32
- <% if block_given? %>
33
- <%= yield %>
34
- <% end %>
35
- </div>
36
- <% end %>
37
- <div class="box-body card-body <%= 'no-padding' if table_no_padding %> <%= 'p-0' if table_no_padding %>">
38
- <% unless search_fields.empty? %>
39
- <div class="row">
40
- <%= search_form_for @q, url: eval(nested_resource ? "#{parent_resource}_#{controller_name}_path" : "#{controller_name}_path") do |f| %>
41
- <% search_fields.each do |sf| %>
42
- <%= f.input sf[:field], label: sf[:label], required: false, as: sf[:as], collection: sf[:collection], wrapper_html: { class: 'col-md-3' } %>
28
+ <% unless hide.include? "header_new" %>
29
+ <%= link_to eval("new_#{list.klass.model_name.singular}_path"), class: "btn btn-xs btn-#{card_color}" do %>
30
+ Cadastar <i class="fa fa-plus"></i>
43
31
  <% end %>
44
- <div class="col-md-3 top-25 ">
45
- <%= f.submit "Pesquisar", class: "btn btn-#{box_class}" %>
46
- </div>
47
32
  <% end %>
33
+ <% if block_given? %>
34
+ <%= yield %>
35
+ <% end %>
36
+ <div class="text-muted text-xs">
37
+ <%= page_entries_info list, entry_name: '' %>
38
+ </div>
39
+ </h3>
40
+ <div class='card-tools'>
41
+ <%= paginate list, window: 1 %>
48
42
  </div>
49
- <% end %>
43
+ </div>
44
+ <% end %>
45
+ <div class="card-body <%= 'p-0' unless table_padding %>">
50
46
  <%= render 'shared/list', list: list, exceptions: exceptions, excluded_columns: excluded_columns,
51
47
  additional_columns: additional_columns, sort_fields: sort_fields, sort_all: sort_all,
52
48
  additional_actions: additional_actions, hide_actions: hide_actions, table_class: table_class,
53
- show_columns: show_columns, hide_read_action: hide_read_action, hide_edit_action: hide_edit_action,
54
- hide_destroy_action: hide_destroy_action, box_class: box_class
49
+ show_columns: show_columns, hide: hide, size: size, card_color: card_color, controller: controller
55
50
  %>
56
- <% if defined? list.total_pages %>
57
- <div class='col-md-4'>
58
- <%= page_entries_info list, entry_name: 'resultado(s)' %>
59
- </div>
60
- <div class='col-md-8 text-right hidden-xs'>
61
- <%= paginate list, window: 4 %>
62
- </div>
63
- <div class='col-md-8 text-center visible-xs'>
64
- <%= paginate list, window: 1 %>
65
- </div>
66
- <% end %>
67
51
  </div>
68
-
69
- <% unless hide_links %>
70
- <% unless controller_name == 'users' %>
71
- <div class="box-footer card-footer">
72
- <% if !hide_new_action && can?(:new, list.klass) %>
73
- <% if nested_resource == true %>
74
- <% if parent_resource %>
75
- <%= 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 %>
76
- <%= t('.new', default: t("helpers.links.new")) %> <%= list.klass.model_name.human %> <i class='fa fa-plus'></i>
77
- <% end %>
78
- <% end %>
79
- <% else %>
80
- <%= link_to eval("new_#{list.klass.model_name.singular}_path"), class: "btn btn-#{box_class}" do %>
81
- <%= t('.new', default: t("helpers.links.new")) %> <%= list.klass.model_name.human %> <i class='fa fa-plus'></i>
82
- <% end %>
83
- <% end %>
84
- <% end %>
85
- </div>
86
- <% end %>
87
- <% end %>
88
-
89
52
  </div>
53
+ <div class="row">
54
+ <div class="col" >
55
+ <div class="text-muted text-xs">
56
+ <%= page_entries_info list, entry_name: '' %>
57
+ </div>
58
+ </div>
59
+ <div class="col">
60
+ <div class="float-right">
61
+ <%= paginate list, window: 1 %>
62
+ </div>
63
+ </div>
64
+ </div>
@@ -2,25 +2,23 @@
2
2
  <% excluded_columns ||= [] %>
3
3
  <% additional_columns ||= [] %>
4
4
  <% additional_actions ||= [] %>
5
- <% hide_actions ||= false %>
6
5
  <% sort_fields ||= [] %>
7
6
  <% sort_all ||= false %>
8
- <% table_class ||= 'datatables styletable' %>
9
7
 
10
- <% box_class ||= 'primary' %>
11
- <% card_class ||= 'primary' %>
8
+ <% card_color ||= 'primary' %>
9
+ <% table_class ||= 'table table-striped bootstrap-table' %>
12
10
 
13
11
  <% show_columns ||= [] %>
14
12
 
15
- <% hide_read_action ||= false %>
16
- <% hide_edit_action ||= false %>
17
- <% hide_destroy_action ||= false %>
13
+ <% hide_actions ||= false %>
14
+ <% hide ||= %w[new back delete_right] %>
15
+ <% size ||= "xs" %>
18
16
 
19
17
  <% if show_columns.empty? %>
20
18
  <% show_columns = list.klass.column_names - exceptions - excluded_columns + additional_columns %>
21
19
  <% end %>
22
20
 
23
- <table class="table table-striped <%= table_class %>">
21
+ <table class="<%= table_class %>">
24
22
  <thead>
25
23
  <tr>
26
24
  <% show_columns.each do |column| %>
@@ -32,6 +30,7 @@
32
30
  <% column_name = column[:attribute] %>
33
31
  <% column_method = column[:method] %>
34
32
  <% column_align = column[:align] %>
33
+ <% column_title = column[:title] %>
35
34
  <% end %>
36
35
 
37
36
  <% next if /_currency$/ =~ column_name %>
@@ -43,38 +42,38 @@
43
42
  <% cname = column_name.split('.')[-1] %>
44
43
  <% model = Kernel.const_get(mname) %>
45
44
  <%= sort_link(@q, column_name.split('.').join('_'),
46
- "#{model.model_name.human} (#{model.human_attribute_name(cname)})")
45
+ column_title || "#{model.model_name.human} (#{model.human_attribute_name(cname)})")
47
46
  %>
48
47
  <% elsif /_id$/ =~ column_name %>
49
- <%= sort_link(@q, column_name, list.klass.human_attribute_name(column_name.split("_id")[0])) %>
48
+ <%= sort_link(@q, column_name, column_title || list.klass.human_attribute_name(column_name.split("_id")[0])) %>
50
49
  <% elsif /_cents$/ =~ column_name %>
51
- <%= sort_link(@q, column_name, list.klass.human_attribute_name(column_name.split("_cents")[0])) %>
50
+ <%= sort_link(@q, column_name, column_title || list.klass.human_attribute_name(column_name.split("_cents")[0])) %>
52
51
  <% elsif /_currency$/ =~ column_name %>
53
52
  <!-- faz nada -->
54
53
  <% elsif column_name == 'id' %>
55
- <%= sort_link(@q, column_name, '#') %>
54
+ <%= sort_link(@q, column_name, column_title || '#') %>
56
55
  <% else %>
57
- <%= sort_link(@q, column_name, list.klass.human_attribute_name(column_name)) %>
56
+ <%= sort_link(@q, column_name, column_title || list.klass.human_attribute_name(column_name)) %>
58
57
  <% end %>
59
58
  <% else %>
60
59
  <% if column_name.include?('.') %>
61
- <% s_name = column_method || column_name %>
60
+ <% s_name = column_title || column_method || column_name %>
62
61
  <%= "#{s_name.split('.')[-2]&.camelize} (#{s_name.split('.')[-1]})" %>
63
62
  <% elsif /_id$/ =~ column_name %>
64
- <%= list.klass.human_attribute_name(column_name.split("_id")[0]) %>
63
+ <%= column_title || list.klass.human_attribute_name(column_name.split("_id")[0]) %>
65
64
  <% elsif /_cents$/ =~ column_name %>
66
- <%= list.klass.human_attribute_name(column_name.split("_cents")[0]) %>
65
+ <%= column_title || list.klass.human_attribute_name(column_name.split("_cents")[0]) %>
67
66
  <% elsif /_currency$/ =~ column_name %>
68
67
  <% elsif column_name == 'id' %>
69
- #
68
+ <%= column_title || "#" %>
70
69
  <% else %>
71
- <%= list.klass.human_attribute_name(column_name) %>
70
+ <%= column_title || list.klass.human_attribute_name(column_name) %>
72
71
  <% end %>
73
72
  <% end %>
74
73
  </th>
75
74
  <% end %>
76
75
  <% unless hide_actions %>
77
- <th>Ações</th>
76
+ <th data-align="center">Ações</th>
78
77
  <% end %>
79
78
  </tr>
80
79
  </thead>
@@ -88,6 +87,7 @@
88
87
  <% if column.class == Hash %>
89
88
  <% column_name = column[:attribute] %>
90
89
  <% column_method = column[:method] %>
90
+ <% column_format = column[:format] %>
91
91
  <% end %>
92
92
 
93
93
  <% next if /_currency$/ =~ column_name %>
@@ -105,11 +105,15 @@
105
105
  object.send(column_name).class == DateTime or
106
106
  object.send(column_name).class == ActiveSupport::TimeWithZone or
107
107
  object.send(column_name).class == Time %>
108
- <%=l object.send(column_name) %>
108
+ <% if column_format %>
109
+ <%= l(object.send(column_name), format: (column_format.is_a?(Symbol) ? column_format : column_format.to_sym)) %>
110
+ <% else %>
111
+ <%=l object.send(column_name) %>
112
+ <% end %>
109
113
  <% elsif object.send(column_name).respond_to? 'attached?' %>
110
114
  <% if object.send(column_name).class == ActiveStorage::Attached::One %>
111
115
  <% if object.send(column_name).attached? %>
112
- <%= link_to rails_blob_path(object.send(column_name)), class: "btn btn-#{box_class} #{card_class} btn-xs", target: '_blank' do %>
116
+ <%= link_to rails_blob_path(object.send(column_name)), class: "btn btn-#{card_color} btn-xs", target: '_blank' do %>
113
117
  <i class="fa fa-file-o"></i> Arquivo
114
118
  <% end %>
115
119
  <% end %>
@@ -131,12 +135,10 @@
131
135
  <% end %>
132
136
  <% unless hide_actions %>
133
137
  <td>
134
- <%= render 'shared/action_links', object: object, additional_actions: additional_actions,
135
- hide_read_action: hide_read_action, hide_edit_action: hide_edit_action, hide_destroy_action: hide_destroy_action
136
- %>
138
+ <%= render 'shared/btn_action_links', object: object, additional_actions: additional_actions, hide: hide, size: size %>
137
139
  </td>
138
140
  <% end %>
139
141
  </tr>
140
142
  <% end %>
141
143
  </tbody>
142
- </table>
144
+ </table>
@@ -4,11 +4,10 @@
4
4
 
5
5
  <% nested_resource ||= false %>
6
6
  <% relationships ||= {} %>
7
- <% box_class ||= 'primary' %>
8
- <% hide_links ||= false %>
9
- <% show_actions ||= ['new', 'edit', 'index'] %>
10
- <% hide_header ||= false %>
11
- <% hide_table_header ||= false %>
7
+
8
+ <% card_color ||= 'danger' %>
9
+ <% hide ||= %w[show delete] %>
10
+ <% size ||= "xs" %>
12
11
 
13
12
  <% if show_columns.empty? %>
14
13
  <% form_fields ||= (object.class.respond_to?('form_fields') ? object.class.form_fields : {}) %>
@@ -16,218 +15,195 @@
16
15
  <% show_columns = form_ordered_fields - ['id', 'created_at', 'updated_at', 'deleted_at'] - excluded_columns + additional_columns %>
17
16
  <% end %>
18
17
 
19
- <div class="box box-<%= box_class %> card card-outline card-<%= box_class %>">
20
- <% unless hide_header %>
21
- <div class="box-header with-border card-header">
22
- <h3 class="box-title card-title">
23
- <%= object.class.model_name.human %>
24
- <% unless hide_links %>
25
- <% if show_actions.include?('new') && can?(:new, object.class) %>
26
- <% if nested_resource %>
27
- <%= 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 %>
28
- Cadastrar <i class="fa fa-plus"></i>
29
- <% end %>
30
- <% else %>
31
- <%= 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 %>
32
- Cadastrar <i class="fa fa-plus"></i>
33
- <% end %>
34
- <% end %>
35
- <% end %>
36
- <% if show_actions.include?('edit') && can?(:edit, object) %>
37
- <% if nested_resource %>
38
- <%= link_to eval_with_rescue("edit_#{parent_resource.class.model_name.singular}_#{object.class.model_name.singular}_path(#{parent_resource.id},#{object.id})"), class: "btn btn-#{box_class} btn-xs", data: { toggle: 'tooltip', placement: 'top', title: 'Editar' } do %>
39
- Editar <i class="fa fa-pencil fa-pen"></i>
40
- <% end %>
41
- <% else %>
42
- <%= 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 %>
43
- Editar <i class="fa fa-pencil fa-pen"></i>
44
- <% end %>
45
- <% end %>
46
- <% end %>
47
- <% if show_actions.include?('index') %>
48
- <% if nested_resource %>
49
- <%= link_to eval_with_rescue("#{parent_resource.class.model_name.singular}_#{object.class.model_name.plural}_path(#{parent_resource.id})"), class: "btn btn-default btn-xs", data: { toggle: 'tooltip', placement: 'top', title: 'Listagem' } do %>
50
- Listagem <i class="fa fa-bars"></i>
51
- <% end %>
52
- <% else %>
53
- <%= link_to eval_with_rescue("#{object.class.model_name.plural}_path"), class: "btn btn-default btn-xs", data: { toggle: 'tooltip', placement: 'top', title: 'Listagem' } do %>
54
- Listagem <i class="fa fa-bars"></i>
55
- <% end %>
56
- <% end %>
57
- <% end %>
58
- <% end %>
59
- <% if block_given? %>
60
- <%= yield %>
18
+ <div class="card card-outline card-<%= card_color %>">
19
+ <div class="card-header">
20
+ <div class="row align-items-center">
21
+ <div class="col-12 col-md-auto">
22
+ <h3 class="card-title">
23
+ <strong>
24
+ <i class="fa fa<%= object.class.icon %>"></i>
25
+ Visualizar <%=t object.class.model_name.human %>
26
+ </strong>
27
+ </h3>
28
+ </div>
29
+ <div class="col-12 col-md mr-auto">
30
+ <% if can? :manage, object %>
31
+ <%= render "shared/btn_action_links", size: "xs", object: object, labels: true, hide: hide %>
61
32
  <% end %>
62
- </h3>
33
+ </div>
63
34
  </div>
64
- <% end %>
65
- <div class="box-body no-padding">
66
- <table class="table table-bordered table-striped no-padding datatables">
67
- <% unless hide_table_header %>
35
+ </div>
36
+ </div>
37
+ <% if lookup_context.find_all("#{object.class.model_name.plural}/_#{object.class.model_name.singular}").any? %>
38
+ <%= render object %>
39
+ <% else %>
40
+ <div class="card card-outline card-<%= card_color %>">
41
+ <div class="card-body p-0">
42
+ <table class="table table-bordered table-striped p-0">
68
43
  <thead>
69
44
  <tr>
70
- <th width='15%'><%= t('field') %></th>
71
- <th><%= t('value') %></th>
45
+ <th width='15%'>Campo</th>
46
+ <th>Valor</th>
72
47
  </tr>
73
48
  </thead>
74
- <% end %>
75
- <% show_columns.each do |column| %>
76
- <% unless /_currency$/ =~ column %>
77
- <tr>
78
- <th>
79
- <% if /_id$/ =~ column && object.respond_to?(column.split('_id')[0]) %>
80
- <%= object.class.human_attribute_name(column.split("_id")[0]) %>
81
- <% elsif /_cents$/ =~ column %>
82
- <%= object.class.human_attribute_name(column.split("_cents")[0]) %>
83
- <% else %>
84
- <%= object.class.human_attribute_name(column) %>
85
- <% end %>
86
- </th>
87
- <td>
88
- <% if column.to_s.include?('.') %>
89
- <% o = object %>
90
- <% column.split('.').each{|m| o = o.send(m) if o } %>
91
- <%= o %>
92
- <% elsif object.send(column).class == Date or
93
- object.send(column).class == DateTime or
94
- object.send(column).class == ActiveSupport::TimeWithZone or
95
- object.send(column).class == Time %>
96
- <%=l object.send(column) %>
97
- <% elsif object.send(column).respond_to? 'attached?' %>
98
- <% if object.send(column).class == ActiveStorage::Attached::One %>
99
- <% if object.send(column).attached? %>
100
- <%= link_to rails_blob_path(object.send(column)), class: "btn btn-#{box_class} btn-xs", target: '_blank' do %>
101
- <i class="fa fa-file-o"></i> Arquivo
49
+ <% show_columns.each do |column| %>
50
+ <% unless /_currency$/ =~ column %>
51
+ <tr>
52
+ <th>
53
+ <% if /_id$/ =~ column && object.respond_to?(column.split('_id')[0]) %>
54
+ <%= object.class.human_attribute_name(column.split("_id")[0]) %>
55
+ <% elsif /_cents$/ =~ column %>
56
+ <%= object.class.human_attribute_name(column.split("_cents")[0]) %>
57
+ <% else %>
58
+ <%= object.class.human_attribute_name(column) %>
59
+ <% end %>
60
+ </th>
61
+ <td>
62
+ <% if column.to_s.include?('.') %>
63
+ <% o = object %>
64
+ <% column.split('.').each{|m| o = o.send(m) if o } %>
65
+ <%= o %>
66
+ <% elsif object.send(column).class == Date or
67
+ object.send(column).class == DateTime or
68
+ object.send(column).class == ActiveSupport::TimeWithZone or
69
+ object.send(column).class == Time %>
70
+ <%=l object.send(column) %>
71
+ <% elsif object.send(column).respond_to? 'attached?' %>
72
+ <% if object.send(column).class == ActiveStorage::Attached::One %>
73
+ <% if object.send(column).attached? %>
74
+ <%= link_to rails_blob_path(object.send(column)), class: "btn btn-#{card_color} btn-xs", target: '_blank' do %>
75
+ <i class="fa fa-file-o"></i> Arquivo
76
+ <% end %>
102
77
  <% end %>
103
78
  <% end %>
79
+ <% elsif /_id$/ =~ column && object.respond_to?(column.split('_id')[0]) %>
80
+ <%= object.send(column.split("_id")[0])&.name %>
81
+ <% elsif /_cents$/ =~ column %>
82
+ <%= number_to_currency object.send(column.split("_cents")[0]) %>
83
+ <% else %>
84
+ <%= object.send(column) %>
104
85
  <% end %>
105
- <% elsif /_id$/ =~ column && object.respond_to?(column.split('_id')[0]) %>
106
- <%= object.send(column.split("_id")[0])&.name %>
107
- <% elsif /_cents$/ =~ column %>
108
- <%= number_to_currency object.send(column.split("_cents")[0]) %>
109
- <% else %>
110
- <%= object.send(column) %>
111
- <% end %>
112
- </td>
113
- </tr>
86
+ </td>
87
+ </tr>
88
+ <% end %>
114
89
  <% end %>
115
- <% end %>
116
- </table>
90
+ </table>
91
+ </div>
117
92
  </div>
118
- </div>
119
93
 
120
- <% if relationships.any? %>
121
- <% relationships.each do |key, value| %>
122
- <% if object.association(key.to_s).kind_of?(ActiveRecord::Associations::BelongsToAssociation) ||
123
- object.association(key.to_s).kind_of?(ActiveRecord::Associations::HasOneAssociation) %>
124
- <div class="box box-<%= box_class %>">
125
- <div class="box-header with-border">
126
- <h3 class="box-title">
127
- <%= Kernel.const_get(key.to_s.singularize.camelize).model_name.human %>
128
- </h3>
94
+ <% if relationships.any? %>
95
+ <% relationships.each do |key, value| %>
96
+ <% if object.association(key.to_s).kind_of?(ActiveRecord::Associations::BelongsToAssociation) ||
97
+ object.association(key.to_s).kind_of?(ActiveRecord::Associations::HasOneAssociation) %>
98
+ <div class="box card-<%= card_color %>">
99
+ <div class="card-header with-border">
100
+ <h3 class="card-title">
101
+ <%= Kernel.const_get(key.to_s.singularize.camelize).model_name.human %>
102
+ </h3>
103
+ </div>
104
+ <div class="card-body p-0">
105
+ <table class="table table-bordered table-striped p-0">
106
+ <% unless hide_table_header %>
107
+ <thead>
108
+ <tr>
109
+ <th width='15%'><%= t('field') %></th>
110
+ <th><%= t('value') %></th>
111
+ </tr>
112
+ </thead>
113
+ <% end %>
114
+ <tbody>
115
+ <% value.each do |v| %>
116
+ <tr>
117
+ <td>
118
+ <strong>
119
+ <% if /_id$/ =~ v && Kernel.const_get(key.to_s.singularize.camelize).new.respond_to?(v.split('_id')[0]) %>
120
+ <%= Kernel.const_get(key.to_s.singularize.camelize).human_attribute_name(v.split('_id')[0]) %>
121
+ <% elsif /_cents$/ =~ v %>
122
+ <%= Kernel.const_get(key.to_s.singularize.camelize).human_attribute_name(v.split("_cents")[0]) %>
123
+ <% else %>
124
+ <%= Kernel.const_get(key.to_s.singularize.camelize).human_attribute_name(v) %>
125
+ <% end %>
126
+ </strong>
127
+ </td>
128
+ <td>
129
+ <% if object.send(key.to_s).send(v).class == Date or
130
+ object.send(key.to_s).send(v).class == DateTime or
131
+ object.send(key.to_s).send(v).class == ActiveSupport::TimeWithZone or
132
+ object.send(key.to_s).send(v).class == Time %>
133
+ <%=l object.send(key.to_s).send(v) %>
134
+ <% elsif /_id$/ =~ v && object.send(key.to_s).respond_to?(v.split('_id')[0]) %>
135
+ <%= object.send(key.to_s).send(v.split("_id")[0])&.name %>
136
+ <% elsif /_cents$/ =~ v %>
137
+ <%= number_to_currency object.send(key.to_s).send(v.split("_cents")[0]) %>
138
+ <% else %>
139
+ <%= object.send(key.to_s).send(v) %>
140
+ <% end %>
141
+ </td>
142
+ </tr>
143
+ <% end %>
144
+ </tbody>
145
+ </table>
146
+ </div>
129
147
  </div>
130
- <div class="box-body no-padding">
131
- <table class="table table-bordered table-striped no-padding datatables">
132
- <% unless hide_table_header %>
148
+ <% else %>
149
+ <div class="box card-<%= card_color %>">
150
+ <div class="card-header with-border">
151
+ <h3 class="card-title">
152
+ <%= Kernel.const_get(key.to_s.singularize.camelize).model_name.human.pluralize %>
153
+ </h3>
154
+ </div>
155
+ <div class="card-body p-0">
156
+ <table class="table table-bordered table-striped p-0">
133
157
  <thead>
134
158
  <tr>
135
- <th width='15%'><%= t('field') %></th>
136
- <th><%= t('value') %></th>
137
- </tr>
138
- </thead>
139
- <% end %>
140
- <tbody>
141
- <% value.each do |v| %>
142
- <tr>
143
- <td>
144
- <strong>
159
+ <% value.each do |v| %>
160
+ <th>
145
161
  <% if /_id$/ =~ v && Kernel.const_get(key.to_s.singularize.camelize).new.respond_to?(v.split('_id')[0]) %>
146
162
  <%= Kernel.const_get(key.to_s.singularize.camelize).human_attribute_name(v.split('_id')[0]) %>
147
- <% elsif /_cents$/ =~ v %>
148
- <%= Kernel.const_get(key.to_s.singularize.camelize).human_attribute_name(v.split("_cents")[0]) %>
149
163
  <% else %>
150
164
  <%= Kernel.const_get(key.to_s.singularize.camelize).human_attribute_name(v) %>
151
165
  <% end %>
152
- </strong>
153
- </td>
154
- <td>
155
- <% if object.send(key.to_s).send(v).class == Date or
156
- object.send(key.to_s).send(v).class == DateTime or
157
- object.send(key.to_s).send(v).class == ActiveSupport::TimeWithZone or
158
- object.send(key.to_s).send(v).class == Time %>
159
- <%=l object.send(key.to_s).send(v) %>
160
- <% elsif /_id$/ =~ v && object.send(key.to_s).respond_to?(v.split('_id')[0]) %>
161
- <%= object.send(key.to_s).send(v.split("_id")[0])&.name %>
162
- <% elsif /_cents$/ =~ v %>
163
- <%= number_to_currency object.send(key.to_s).send(v.split("_cents")[0]) %>
164
- <% else %>
165
- <%= object.send(key.to_s).send(v) %>
166
- <% end %>
167
- </td>
166
+ </th>
167
+ <% end %>
168
168
  </tr>
169
- <% end %>
170
- </tbody>
171
- </table>
172
- </div>
173
- </div>
174
- <% else %>
175
- <div class="box box-<%= box_class %>">
176
- <div class="box-header with-border">
177
- <h3 class="box-title">
178
- <%= Kernel.const_get(key.to_s.singularize.camelize).model_name.human.pluralize %>
179
- </h3>
180
- </div>
181
- <div class="box-body no-padding">
182
- <table class="table table-bordered table-striped no-padding datatables">
183
- <thead>
184
- <tr>
185
- <% value.each do |v| %>
186
- <th>
187
- <% if /_id$/ =~ v && Kernel.const_get(key.to_s.singularize.camelize).new.respond_to?(v.split('_id')[0]) %>
188
- <%= Kernel.const_get(key.to_s.singularize.camelize).human_attribute_name(v.split('_id')[0]) %>
189
- <% else %>
190
- <%= Kernel.const_get(key.to_s.singularize.camelize).human_attribute_name(v) %>
191
- <% end %>
192
- </th>
193
- <% end %>
194
- </tr>
195
- </thead>
196
- <tbody>
197
- <% object.send(key.to_s).each do |r| %>
198
- <tr>
199
- <% value.each do |v| %>
200
- <td>
201
- <% if v.include?('.') %>
202
- <% o = r %>
203
- <% v.split('.').each{|m| o = o.send(m) if o } %>
204
- <%= o %>
205
- <% elsif r.send(v).class == Date or
206
- r.send(v).class == DateTime or
207
- r.send(v).class == ActiveSupport::TimeWithZone or
208
- r.send(v).class == Time %>
209
- <%=l r.send(v) %>
210
- <% elsif r.send(v).respond_to? 'attached?' %>
211
- <% if r.send(v).class == ActiveStorage::Attached::One %>
212
- <% if r.send(v).attached? %>
213
- <%= link_to rails_blob_path(r.send(v)), class: "btn btn-#{box_class} btn-xs", target: '_blank' do %>
214
- <i class="fa fa-file-o"></i> Arquivo
169
+ </thead>
170
+ <tbody>
171
+ <% object.send(key.to_s).each do |r| %>
172
+ <tr>
173
+ <% value.each do |v| %>
174
+ <td>
175
+ <% if v.include?('.') %>
176
+ <% o = r %>
177
+ <% v.split('.').each{|m| o = o.send(m) if o } %>
178
+ <%= o %>
179
+ <% elsif r.send(v).class == Date or
180
+ r.send(v).class == DateTime or
181
+ r.send(v).class == ActiveSupport::TimeWithZone or
182
+ r.send(v).class == Time %>
183
+ <%=l r.send(v) %>
184
+ <% elsif r.send(v).respond_to? 'attached?' %>
185
+ <% if r.send(v).class == ActiveStorage::Attached::One %>
186
+ <% if r.send(v).attached? %>
187
+ <%= link_to rails_blob_path(r.send(v)), class: "btn btn-#{card_color} btn-xs", target: '_blank' do %>
188
+ <i class="fa fa-file-o"></i> Arquivo
189
+ <% end %>
215
190
  <% end %>
216
191
  <% end %>
192
+ <% elsif /_id$/ =~ v && r.respond_to?(v.split('_id')[0]) %>
193
+ <%= r.send(v.split("_id")[0])&.name %>
194
+ <% else %>
195
+ <%= r.send(v) %>
217
196
  <% end %>
218
- <% elsif /_id$/ =~ v && r.respond_to?(v.split('_id')[0]) %>
219
- <%= r.send(v.split("_id")[0])&.name %>
220
- <% else %>
221
- <%= r.send(v) %>
222
- <% end %>
223
- </td>
224
- <% end %>
225
- </tr>
226
- <% end %>
227
- </tbody>
228
- </table>
197
+ </td>
198
+ <% end %>
199
+ </tr>
200
+ <% end %>
201
+ </tbody>
202
+ </table>
203
+ </div>
229
204
  </div>
230
- </div>
205
+ <% end %>
231
206
  <% end %>
232
207
  <% end %>
233
208
  <% end %>
209
+ <%= render "shared/btn_action_links", object: object, labels: true, hide: hide %>
@@ -1,3 +1,3 @@
1
1
  module Zutils
2
- VERSION = "2.0.1"
2
+ VERSION = "3.0.0"
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: 2.0.1
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ricardo Viana
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-06-20 00:00:00.000000000 Z
11
+ date: 2024-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -68,8 +68,10 @@ files:
68
68
  - app/assets/javascripts/zutils.js
69
69
  - app/assets/stylesheets/zutils.scss
70
70
  - app/views/shared/_action_links.html.erb
71
+ - app/views/shared/_btn_action_links.html.erb
71
72
  - app/views/shared/_card_list.html.erb
72
73
  - app/views/shared/_fields.html.erb
74
+ - app/views/shared/_flash.html.erb
73
75
  - app/views/shared/_form.html.erb
74
76
  - app/views/shared/_index.html.erb
75
77
  - app/views/shared/_list.html.erb
@@ -85,7 +87,7 @@ homepage: http://gitlab.tjpi.jus.br/
85
87
  licenses:
86
88
  - MIT
87
89
  metadata: {}
88
- post_install_message:
90
+ post_install_message:
89
91
  rdoc_options: []
90
92
  require_paths:
91
93
  - lib
@@ -100,8 +102,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
102
  - !ruby/object:Gem::Version
101
103
  version: '0'
102
104
  requirements: []
103
- rubygems_version: 3.3.7
104
- signing_key:
105
+ rubygems_version: 3.5.18
106
+ signing_key:
105
107
  specification_version: 4
106
108
  summary: Utilidades gerais para aplicações rails
107
109
  test_files: []