zutils 2.0.2 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/views/shared/_btn_action_links.html.erb +81 -0
- data/app/views/shared/_card_list.html.erb +17 -11
- data/app/views/shared/_flash.html.erb +3 -0
- data/app/views/shared/_form.html.erb +20 -20
- data/app/views/shared/_index.html.erb +41 -66
- data/app/views/shared/_list.html.erb +10 -14
- data/app/views/shared/_show.html.erb +168 -192
- data/lib/zutils/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d324c51d55fbc3c4b4b504b566b4cfcec75add45d14ed79995c1613f010fdc1
|
4
|
+
data.tar.gz: 7c582d7a7ea2a95368fb69ed3c4c7db3758abe1ef3b07aacb30919c19d01ed7a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
<%
|
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-<%=
|
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
|
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
|
-
<%
|
23
|
-
<%= link_to eval("new_#{list.klass.model_name.singular}_path"), class: "btn btn-xs btn-#{
|
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,9 +40,8 @@
|
|
33
40
|
</div>
|
34
41
|
</div>
|
35
42
|
<div class="card-body p-0">
|
36
|
-
<%= render 'shared/list', list: list, show_columns: show_columns,
|
37
|
-
|
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
47
|
</div>
|
@@ -4,30 +4,22 @@
|
|
4
4
|
<% nested_resource ||= false %>
|
5
5
|
<% parent_resource ||= false %>
|
6
6
|
<% back_link ||= false %>
|
7
|
-
<%
|
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="
|
19
|
-
<div class="
|
20
|
-
<h3 class="
|
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="
|
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="
|
30
|
+
<div class="card-footer text-right">
|
39
31
|
<% if back_link %>
|
40
|
-
<%= link_to 'Cancelar', "javascript:history.back()", class: "btn
|
32
|
+
<%= link_to 'Cancelar', "javascript:history.back()", class: "btn" %>
|
41
33
|
<% else %>
|
42
34
|
<% if parent_resource %>
|
43
|
-
<%= link_to
|
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
|
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
|
-
|
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
|
-
<%
|
11
|
-
<%
|
12
|
-
<% table_class ||= '
|
9
|
+
<% card_color ||= 'danger' %>
|
10
|
+
<% table_padding ||= false %>
|
11
|
+
<% table_class ||= 'bootstrap-table' %>
|
13
12
|
|
14
|
-
<%
|
15
|
-
<%
|
16
|
-
<%
|
17
|
-
<% hide_footer ||= false %>
|
13
|
+
<% hide ||= %w[new back delete_right] %>
|
14
|
+
<% size ||= "xs" %>
|
15
|
+
<% controller ||= "bootstrap-table" %>
|
18
16
|
|
19
|
-
<%
|
20
|
-
<% hide_new_action ||= false %>
|
21
|
-
<% hide_edit_action ||= false %>
|
22
|
-
<% hide_destroy_action ||= false %>
|
17
|
+
<% hide_actions ||= false %>
|
23
18
|
|
24
|
-
<div class=
|
25
|
-
<% unless
|
26
|
-
<div class="
|
27
|
-
<h3 class="
|
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
|
-
|
32
|
-
|
33
|
-
|
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
|
-
|
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,
|
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
|
-
<%
|
11
|
-
<%
|
8
|
+
<% card_color ||= 'primary' %>
|
9
|
+
<% table_class ||= 'table table-striped bootstrap-table' %>
|
12
10
|
|
13
11
|
<% show_columns ||= [] %>
|
14
12
|
|
15
|
-
<%
|
16
|
-
<%
|
17
|
-
<%
|
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="
|
21
|
+
<table class="<%= table_class %>">
|
24
22
|
<thead>
|
25
23
|
<tr>
|
26
24
|
<% show_columns.each do |column| %>
|
@@ -75,7 +73,7 @@
|
|
75
73
|
</th>
|
76
74
|
<% end %>
|
77
75
|
<% unless hide_actions %>
|
78
|
-
<th>Ações</th>
|
76
|
+
<th data-align="center">Ações</th>
|
79
77
|
<% end %>
|
80
78
|
</tr>
|
81
79
|
</thead>
|
@@ -115,7 +113,7 @@
|
|
115
113
|
<% elsif object.send(column_name).respond_to? 'attached?' %>
|
116
114
|
<% if object.send(column_name).class == ActiveStorage::Attached::One %>
|
117
115
|
<% if object.send(column_name).attached? %>
|
118
|
-
<%= link_to rails_blob_path(object.send(column_name)), class: "btn btn-#{
|
116
|
+
<%= link_to rails_blob_path(object.send(column_name)), class: "btn btn-#{card_color} btn-xs", target: '_blank' do %>
|
119
117
|
<i class="fa fa-file-o"></i> Arquivo
|
120
118
|
<% end %>
|
121
119
|
<% end %>
|
@@ -137,12 +135,10 @@
|
|
137
135
|
<% end %>
|
138
136
|
<% unless hide_actions %>
|
139
137
|
<td>
|
140
|
-
<%= render 'shared/
|
141
|
-
hide_read_action: hide_read_action, hide_edit_action: hide_edit_action, hide_destroy_action: hide_destroy_action
|
142
|
-
%>
|
138
|
+
<%= render 'shared/btn_action_links', object: object, additional_actions: additional_actions, hide: hide, size: size %>
|
143
139
|
</td>
|
144
140
|
<% end %>
|
145
141
|
</tr>
|
146
142
|
<% end %>
|
147
143
|
</tbody>
|
148
|
-
</table>
|
144
|
+
</table>
|
@@ -4,11 +4,10 @@
|
|
4
4
|
|
5
5
|
<% nested_resource ||= false %>
|
6
6
|
<% relationships ||= {} %>
|
7
|
-
|
8
|
-
<%
|
9
|
-
<%
|
10
|
-
<%
|
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="
|
20
|
-
|
21
|
-
<div class="
|
22
|
-
<
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
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
|
-
</
|
33
|
+
</div>
|
63
34
|
</div>
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
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%'
|
71
|
-
<th
|
45
|
+
<th width='15%'>Campo</th>
|
46
|
+
<th>Valor</th>
|
72
47
|
</tr>
|
73
48
|
</thead>
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
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
|
-
|
106
|
-
|
107
|
-
|
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
|
-
|
116
|
-
</
|
90
|
+
</table>
|
91
|
+
</div>
|
117
92
|
</div>
|
118
|
-
</div>
|
119
93
|
|
120
|
-
<% if relationships.any? %>
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
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
|
-
|
131
|
-
|
132
|
-
|
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
|
-
|
136
|
-
|
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
|
-
</
|
153
|
-
|
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
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
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
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
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
|
-
|
205
|
+
<% end %>
|
231
206
|
<% end %>
|
232
207
|
<% end %>
|
233
208
|
<% end %>
|
209
|
+
<%= render "shared/btn_action_links", object: object, labels: true, hide: hide %>
|
data/lib/zutils/version.rb
CHANGED
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:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ricardo Viana
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
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
|
@@ -100,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
102
|
- !ruby/object:Gem::Version
|
101
103
|
version: '0'
|
102
104
|
requirements: []
|
103
|
-
rubygems_version: 3.
|
105
|
+
rubygems_version: 3.5.18
|
104
106
|
signing_key:
|
105
107
|
specification_version: 4
|
106
108
|
summary: Utilidades gerais para aplicações rails
|