zutils 3.0.7 → 4.0.0

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.
@@ -1,94 +1,149 @@
1
- <% size ||= "md" %>
1
+ <% size ||= "sm" %>
2
2
  <% labels ||= false %>
3
3
  <% hide ||= [] %>
4
- <% new_color ||= 'primary' %>
5
- <% edit_color ||= 'warning' %>
6
- <% delete_color ||= 'danger' %>
7
- <div class="row align-items-center">
8
- <div class="col text-nowrap">
9
- <% if can? :show, object %>
10
- <% unless hide.include? "show" %>
11
- <%= link_to object, class: "btn btn-#{size} btn-default",
12
- data: { "bs-toggle": "tooltip", "bs-placement": "top", "bs-title": "Visualizar" } do %>
4
+ <% extra_actions ||= {} %>
5
+
6
+ <% back_color ||= 'btn-link' %>
7
+ <% show_color ||= 'btn-outline-secondary' %>
8
+ <% new_color ||= 'btn-primary' %>
9
+ <% edit_color ||= 'btn-warning' %>
10
+ <% delete_color ||= 'btn-danger' %>
11
+
12
+ <% default_actions = {
13
+
14
+ back: {
15
+ icon: "fa-arrow-left",
16
+ label: "Voltar",
17
+ class: back_color,
18
+ side: :left,
19
+ path: -> { polymorphic_path(object.class) },
20
+ method: :get
21
+ },
22
+
23
+ show: {
24
+ icon: "fa-eye",
25
+ label: "Ver",
26
+ class: show_color,
27
+ side: :right,
28
+ path: -> { object },
29
+ method: :get
30
+ },
31
+
32
+ edit: {
33
+ icon: "fa-pen",
34
+ label: "Editar",
35
+ class: edit_color,
36
+ side: :right,
37
+ path: -> { edit_polymorphic_path(object) },
38
+ method: :get
39
+ },
40
+
41
+ new: {
42
+ icon: "fa-plus",
43
+ label: "Cadastrar",
44
+ class: new_color,
45
+ side: :right,
46
+ path: -> { new_polymorphic_path(object.class) },
47
+ method: :get
48
+ },
49
+
50
+ delete: {
51
+ icon: "fa-trash",
52
+ label: "Apagar",
53
+ class: delete_color,
54
+ side: :right,
55
+ path: -> { object },
56
+ method: :delete,
57
+ form: { data: { turbo_confirm: "Tem certeza?" } }
58
+ }
59
+
60
+ } %>
61
+
62
+ <% actions = default_actions.merge(extra_actions) %>
63
+
64
+ <% left_actions = actions.select { |k,v| v[:side] == :left } %>
65
+ <% right_actions = actions.select { |k,v| v[:side] != :left } %>
66
+
67
+ <div class="d-flex justify-content-between align-items-center gap-2">
68
+ <!-- LEFT -->
69
+ <div class="d-flex gap-1">
70
+ <% left_actions.each do |name, config| %>
71
+ <% next if hide.include?(name.to_s) %>
72
+
73
+ <% ability = (name == :delete ? :destroy : name) %>
74
+ <% next unless (can?(ability, object) rescue true) %>
75
+
76
+ <% path = begin
77
+ config[:path].respond_to?(:call) ? config[:path].call : config[:path]
78
+ rescue StandardError
79
+ next
80
+ end %>
81
+ <% method = (config[:method] || :get).to_sym %>
82
+
83
+ <% if method == :get %>
84
+ <%= link_to path,
85
+ class: "btn btn-#{size} #{config[:class]}",
86
+ data: { "bs-toggle": "tooltip", "bs-title": config[:label] } do %>
87
+ <i class="fa-solid <%= config[:icon] %>"></i>
88
+
13
89
  <% if labels %>
14
- <div class="d-none d-sm-inline-block">
15
- Ver
16
- </div>
90
+ <span class="ms-1 d-none d-md-inline"><%= config[:label] %></span>
17
91
  <% end %>
18
- <i class="fa fa-fw fa-eye"></i>
19
92
  <% end %>
20
- <% end %>
21
- <% end %>
22
- <% if can? :new, object %>
23
- <% unless hide.include? "new" %>
24
- <%= link_to eval_with_rescue("new_#{[object].flatten.map{|x| x.class.to_s.underscore}.join("_")}_path"),
25
- class: "btn btn-#{size} btn-#{new_color}", data: { "bs-toggle": "tooltip", "bs-placement": "top", "bs-title": "Cadastrar" } do %>
93
+ <% else %>
94
+ <%= button_to path,
95
+ method: method,
96
+ form: config[:form],
97
+ class: "btn btn-#{size} #{config[:class]}",
98
+ data: { "bs-toggle": "tooltip", "bs-title": config[:label] } do %>
99
+ <i class="fa-solid <%= config[:icon] %>"></i>
100
+
26
101
  <% if labels %>
27
- <div class="d-none d-sm-inline-block">
28
- Cadastrar
29
- </div>
102
+ <span class="ms-1 d-none d-md-inline"><%= config[:label] %></span>
30
103
  <% end %>
31
- <i class="fa fa-fw fa-plus"></i>
32
104
  <% end %>
33
105
  <% end %>
34
106
  <% end %>
35
- <% if can? :edit, object %>
36
- <% unless hide.include? "edit" %>
37
- <%= link_to eval_with_rescue("edit_#{[object].flatten.map{|x| x.class.to_s.underscore}.join("_")}_path(#{object.id})"),
38
- class: "btn btn-#{size} btn-#{edit_color}", data: { "bs-toggle": "tooltip", "bs-placement": "top", "bs-title": "Editar" } do %>
39
- <% if labels %>
40
- <div class="d-none d-sm-inline-block">
41
- Editar
42
- </div>
43
- <% end %>
44
- <i class="fa fa-fw fa-pen"></i>
45
- <% end %>
46
- <% end %>
47
- <% unless hide.include? "back" %>
48
- <%= link_to eval_with_rescue("#{[object].flatten.map{|x| x.class.to_s.underscore.pluralize}.join("_")}_path"),
49
- class: "btn btn-#{size}", data: { "bs-toggle": "tooltip", "bs-placement": "top", "bs-title": "Voltar" } do %>
107
+ </div>
108
+
109
+ <!-- RIGHT -->
110
+ <div class="d-flex align-items-center gap-1">
111
+ <% right_actions.each do |name, config| %>
112
+ <% next if hide.include?(name.to_s) %>
113
+
114
+ <% ability = (name == :delete ? :destroy : name) %>
115
+ <% next unless (can?(ability, object) rescue true) %>
116
+
117
+ <% path = begin
118
+ config[:path].respond_to?(:call) ? config[:path].call : config[:path]
119
+ rescue StandardError
120
+ next
121
+ end %>
122
+ <% method = (config[:method] || :get).to_sym %>
123
+
124
+ <% if method == :get %>
125
+ <%= link_to path,
126
+ class: "btn btn-#{size} #{config[:class]}",
127
+ data: { "bs-toggle": "tooltip", "bs-title": config[:label] } do %>
128
+ <i class="fa-solid <%= config[:icon] %>"></i>
129
+
50
130
  <% if labels %>
51
- <div class="d-none d-sm-inline-block">
52
- Voltar
53
- </div>
131
+ <span class="ms-1 d-none d-md-inline"><%= config[:label] %></span>
54
132
  <% end %>
55
- <i class="fa fa-fw fa-arrow-left"></i>
56
133
  <% end %>
57
- <% end %>
58
- <% end %>
59
- <% if can? :destroy, object %>
60
- <% unless hide.include? "delete" %>
61
- <%= button_to object, method: :delete, form: { data: { turbo_confirm: 'Tem certeza?' }, class: 'd-inline'},
62
- data: { "bs-toggle": "tooltip", "bs-placement": "top", "bs-title": "Apagar" },
63
- class: "btn btn-#{size} btn-#{delete_color}" do %>
134
+ <% else %>
135
+ <%= button_to path,
136
+ method: method,
137
+ form: config[:form],
138
+ class: "btn btn-#{size} #{config[:class]}",
139
+ data: { "bs-toggle": "tooltip", "bs-title": config[:label] } do %>
140
+ <i class="fa-solid <%= config[:icon] %>"></i>
141
+
64
142
  <% if labels %>
65
- <div class="d-none d-sm-inline-block">
66
- Apagar
67
- </div>
143
+ <span class="ms-1 d-none d-md-inline"><%= config[:label] %></span>
68
144
  <% end %>
69
- <i class="fa fa-fw fa-trash"></i>
70
145
  <% end %>
71
146
  <% end %>
72
147
  <% end %>
73
- <!-- adicionar menus via bloco -->
74
- <% if block_given? %>
75
- <%= yield %>
76
- <% end %>
77
148
  </div>
78
- <% unless hide.include? "delete_right" %>
79
- <% if can? :destroy, object %>
80
- <div class="col col-auto text-right">
81
- <%= button_to object, method: :delete, form: { data: { turbo_confirm: 'Tem certeza?' }, class: 'd-inline'},
82
- data: { "bs-toggle": "tooltip", "bs-placement": "top", "bs-title": "Apagar" },
83
- class: "btn btn-#{size} btn-#{delete_color}" do %>
84
- <% if labels %>
85
- <div class="d-none d-sm-inline-block">
86
- Apagar
87
- </div>
88
- <% end %>
89
- <i class="fa fa-fw fa-trash"></i>
90
- <% end %>
91
- </div>
92
- <% end %>
93
- <% end %>
94
- </div>
149
+ </div>
@@ -1,56 +1,23 @@
1
- <% exceptions ||= ['created_at', 'updated_at', 'deleted_at'] %>
2
- <% show_columns ||= [] %>
3
- <% card_class ||= 'primary' %>
4
- <% sort_all ||= false %>
5
1
  <% hide_new ||= false %>
6
- <% sort_fields ||= [] %>
7
- <% table_class ||= 'bootstrap-table' %>
2
+ <% show_new ||= !hide_new %>
8
3
 
9
- <% hide ||= %w[new back delete_right] %>
10
- <% size ||= "xs" %>
11
- <% controller ||= "bootstrap-table" %>
12
-
13
- <% hide_actions ||= false %>
14
-
15
- <% if show_columns.empty? %>
16
- <% show_columns = list.klass.column_names - exceptions %>
17
- <% end %>
18
-
19
- <div class="card card-outline card-<%= card_class %>" data-controller="<%= controller %>">
20
- <div class="card-header with-border">
21
- <h3 class="card-title">
22
- <strong>
23
- <i class="fa fa-<%= list.klass.icon %>"></i>
24
- Listagem de
25
- <%= list.klass.model_name.human.pluralize %>
26
- </strong>
27
- <% unless hide_new %>
28
- <%= link_to eval("new_#{list.klass.model_name.singular}_path"), class: "btn btn-xs btn-#{card_class}" do %>
29
- Cadastar <i class="fa fa-plus"></i>
30
- <% end %>
31
- <% end %>
32
- <div class="text-muted text-xs">
33
- <%= page_entries_info list, entry_name: '' %>
34
- </div>
35
- </h3>
36
- <div class='card-tools'>
37
- <%= paginate list, window: 1 %>
38
- </div>
39
- </div>
40
- <%= render 'shared/list', list: list, show_columns: show_columns, card_class: card_class, table_class: table_class,
41
- exceptions: exceptions, sort_all: sort_all, sort_fields: sort_fields, hide: hide, size: size, hide_actions: hide_actions
42
- %>
43
- </div>
44
- <div class="row">
45
- <div class="col" >
46
- <div class="text-muted text-xs">
47
- <%= page_entries_info list, entry_name: '' %>
48
- </div>
49
- </div>
50
- <div class="col">
51
- <div class="float-right">
52
- <%= paginate list, window: 1 %>
53
- </div>
54
- </div>
55
- </div>
56
- <br>
4
+ <%= render "shared/index",
5
+ list: list,
6
+ show_columns: (show_columns if defined?(show_columns)),
7
+ exceptions: (exceptions if defined?(exceptions)),
8
+ excluded_columns: (excluded_columns if defined?(excluded_columns)),
9
+ additional_columns: (additional_columns if defined?(additional_columns)),
10
+ additional_actions: (additional_actions if defined?(additional_actions)),
11
+ sort_all: (sort_all if defined?(sort_all)),
12
+ sort_fields: (sort_fields if defined?(sort_fields)),
13
+ card_color: (card_color if defined?(card_color)),
14
+ card_class: (card_class if defined?(card_class)),
15
+ card_margin: (card_margin if defined?(card_margin)),
16
+ table_class: (table_class if defined?(table_class)),
17
+ hide: (hide if defined?(hide)),
18
+ size: (size if defined?(size)),
19
+ controller: (controller if defined?(controller)),
20
+ hide_actions: (hide_actions if defined?(hide_actions)),
21
+ pagy: (pagy if defined?(pagy)),
22
+ show_new: show_new
23
+ %>
@@ -0,0 +1,95 @@
1
+ <% size ||= "sm" %>
2
+ <% hide ||= [] %>
3
+ <% position ||= "end" %>
4
+ <% theme ||= "dark" %>
5
+
6
+ <div data-controller="dropdown" class="d-inline-block">
7
+ <button type="button" class="btn btn-<%= size %> border-0">
8
+ <i class="fa-fw fas fa-ellipsis-v"></i>
9
+ </button>
10
+
11
+ <template data-dropdown-target="template">
12
+ <ul class="border-0 dropdown-menu show position-static p-0">
13
+ <% if block_given? %>
14
+ <%= yield %>
15
+ <% end %>
16
+
17
+ <%# BACK LINK %>
18
+ <% unless hide.include?("back") %>
19
+ <% back_path = eval_with_rescue("#{[object].flatten.map{|x| x.class.to_s.underscore.pluralize}.join("_")}_path") %>
20
+ <li>
21
+ <%= link_to back_path,
22
+ class: "dropdown-item",
23
+ tabindex: "0",
24
+ data: { turbo_frame: "_top" } do %>
25
+ <i class="fa-fw fas fa-arrow-left me-2" aria-hidden="true"></i>
26
+ <%= content_tag(:span, "Voltar") %>
27
+ <% end %>
28
+ </li>
29
+ <% end %>
30
+
31
+ <%# SHOW %>
32
+ <% if can?(:show, object) && !hide.include?("show") %>
33
+ <li>
34
+ <%= link_to object,
35
+ class: "dropdown-item",
36
+ data: { turbo_frame: "_top" },
37
+ title: "Visualizar" do %>
38
+ <i class="fa-fw fas fa-eye me-2" aria-hidden="true"></i>
39
+ <%= content_tag(:span, "Ver") %>
40
+ <% end %>
41
+ </li>
42
+ <% end %>
43
+
44
+ <%# NEW %>
45
+ <% if can?(:new, object) && !hide.include?("new") %>
46
+ <% new_path = eval_with_rescue("new_#{[object].flatten.map{|x| x.class.to_s.underscore}.join("_")}_path") %>
47
+ <li>
48
+ <%= link_to new_path,
49
+ class: "dropdown-item",
50
+ data: { turbo_frame: "_top" },
51
+ title: "Cadastrar novo" do %>
52
+ <i class="fa-fw fas fa-plus me-2" aria-hidden="true"></i>
53
+ <%= content_tag(:span, "Cadastrar") %>
54
+ <% end %>
55
+ </li>
56
+ <% end %>
57
+
58
+ <%# EDIT %>
59
+ <% if can?(:edit, object) && !hide.include?("edit") %>
60
+ <% edit_path = eval_with_rescue("edit_#{[object].flatten.map{|x| x.class.to_s.underscore}.join("_")}_path(#{object.id})") %>
61
+ <li>
62
+ <%= link_to edit_path,
63
+ data: { turbo_frame: "_top" },
64
+ class: "dropdown-item",
65
+ title: "Editar" do %>
66
+ <i class="fa-fw fas fa-pen me-2" aria-hidden="true"></i>
67
+ <%= content_tag(:span, "Editar") %>
68
+ <% end %>
69
+ </li>
70
+ <% end %>
71
+
72
+ <%# DIVIDER %>
73
+ <% if can?(:destroy, object) && !hide.include?("delete") %>
74
+ <li><hr class="dropdown-divider"></li>
75
+ <% end %>
76
+
77
+ <%# DELETE %>
78
+ <% if can?(:destroy, object) && !hide.include?("delete") %>
79
+ <li>
80
+ <%= link_to object,
81
+ class: "dropdown-item text-danger fw-semibold",
82
+ title: "Apagar permanentemente",
83
+ data: {
84
+ turbo_frame: "_top",
85
+ turbo_method: :delete,
86
+ turbo_confirm: "Tem certeza que deseja apagar este item?\nEsta ação não pode ser desfeita."
87
+ } do %>
88
+ <i class="fa-fw fas fa-trash-can me-2" aria-hidden="true"></i>
89
+ <%= content_tag(:span, "Apagar") %>
90
+ <% end %>
91
+ </li>
92
+ <% end %>
93
+ </ul>
94
+ </template>
95
+ </div>
@@ -0,0 +1,15 @@
1
+ <div
2
+ class="text-center py-2 border border-dashed rounded-3 mb-2 list-empty-state"
3
+ style="border-style: dashed !important; border-color: #dee2e6;"
4
+ >
5
+ <div class="mt-1">
6
+ <i
7
+ class="<%= local_assigns[:icon] || 'far fa-circle-xmark' %> text-muted"
8
+ style="font-size: 1.2rem;"
9
+ ></i>
10
+ </div>
11
+
12
+ <p class="small text-muted mb-0" style="font-size: 0.75rem;">
13
+ <%= local_assigns[:message] || "Nenhum registro encontrado" %>
14
+ </p>
15
+ </div>
@@ -0,0 +1,29 @@
1
+ <% title ||= "" %>
2
+ <% message ||= "" %>
3
+ <% icon ||= "fa fa-inbox" %>
4
+ <% btn_title ||= "Criar" %>
5
+ <% btn_url ||= "" %>
6
+ <% btn_icon ||= "fa-plus" %>
7
+ <% btn_color ||= "btn-primary" %>
8
+ <% icon_style ||= "" %>
9
+ <% border_color ||= "" %>
10
+
11
+ <div class="my-4 py-5 px-4 text-center rounded-4 border border-2 border-dashed <%= border_color.present? ? border_color : "" %> bg-light shadow-sm">
12
+ <div class="d-inline-flex align-items-center justify-content-center bg-white rounded-circle shadow-sm mb-4" style="width: 100px; height: 100px;">
13
+ <i class="<%= icon %> display-3 <%= icon_style.present? ? icon_style : "text-muted opacity-50" %>"></i>
14
+ </div>
15
+
16
+ <div class="mx-auto" style="max-width: 480px;">
17
+ <h3 class="fw-bold text-dark"><%= title %></h3>
18
+ <p class="text-muted mb-4 lead" style="font-size: 1rem;"><%= message %></p>
19
+
20
+ <% if btn_url.present? %>
21
+ <div class="d-grid gap-2 d-sm-flex justify-content-sm-center">
22
+ <%= link_to btn_url, class: "btn #{btn_color} btn-lg px-4 rounded-pill fw-bold shadow-sm" do %>
23
+ <i class="<%= btn_icon %> me-2"></i>
24
+ <%= btn_title %>
25
+ <% end %>
26
+ </div>
27
+ <% end %>
28
+ </div>
29
+ </div>
@@ -1,47 +1,48 @@
1
- <% excluded_columns ||= [] %>
2
- <% additional_columns ||= [] %>
3
- <% restricted_columns ||= {} %>
4
- <% show_columns ||= [] %>
5
-
6
- <% form_fields ||= (object.class.respond_to?('form_fields') ? object.class.form_fields : {}) %>
7
- <% form_ordered_fields ||= (form_fields.empty? ? object.class.column_names : form_fields.keys) %>
8
-
9
- <% if show_columns.empty? %>
10
- <% show_columns = form_ordered_fields - ['id', 'created_at', 'updated_at', 'deleted_at'] - excluded_columns + additional_columns %>
11
- <% end %>
12
-
13
- <div class="row">
14
- <% show_columns.each do |column| %>
15
- <% wphtml = "col-md-#{(form_fields[column.to_sym].class == Hash ? form_fields[column.to_sym][:size] : form_fields[column.to_sym] ) || 12}" %>
16
- <% hint = (form_fields[column.to_sym].class == Hash ? form_fields[column.to_sym][:hint] : nil) %>
17
- <% placeholder = (form_fields[column.to_sym].class == Hash ? form_fields[column.to_sym][:placeholder] : nil) %>
18
- <% if object.class.column_for_attribute(column).type == :text %>
19
- <%= f.input column, input_html: { rows: 10, cols: 20 }, wrapper_html: { class: wphtml }, hint: hint, placeholder: placeholder %>
20
- <% elsif [:date, :datetime].include?(object.class.column_for_attribute(column).type) %>
21
- <%= f.input column, html5: true, wrapper_html: { class: wphtml }, hint: hint, placeholder: placeholder %>
22
- <% elsif object.send(column).respond_to? 'attached?' %>
23
- <% if object.send(column).class == ActiveStorage::Attached::Many %>
24
- <%= f.input column, wrapper_html: { class: wphtml }, hint: hint, input_html: { multiple: true, class: 'fileinput',
25
- data: {
26
- initial: object.send(column).map{|im| rails_blob_path(im, only_path: true)}
27
- }
28
- } %>
29
- <% else %>
30
- <%= f.input column, wrapper_html: { class: wphtml }, hint: hint, input_html: { class: 'fileinput', 'data-initial': [rails_blob_path(object.send(column))] } %>
31
- <% end %>
32
- <% elsif /_id$/ =~ column && object.respond_to?(column.split('_id')[0]) %>
33
- <% if restricted_columns.keys.include?(column.to_sym) %>
34
- <%= f.association column.split("_id")[0],
35
- label: restricted_columns[column.to_sym][:label],
36
- collection: restricted_columns[column.to_sym][:collection],
37
- wrapper_html: { class: wphtml },
38
- hint: hint, placeholder: placeholder
39
- %>
40
- <% else %>
41
- <%= f.association column.split("_id")[0], wrapper_html: { class: wphtml }, hint: hint, placeholder: placeholder %>
42
- <% end %>
43
- <% else %>
44
- <%= f.input column, wrapper_html: { class: wphtml }, hint: hint, placeholder: placeholder %>
45
- <% end %>
46
- <% end %>
47
- </div>
1
+ <% excluded_columns ||= [] %>
2
+ <% additional_columns ||= [] %>
3
+ <% restricted_columns ||= {} %>
4
+ <% show_columns ||= [] %>
5
+
6
+ <% form_fields ||= (object.class.respond_to?('form_fields') ? object.class.form_fields : {}) %>
7
+ <% form_ordered_fields ||= (form_fields.empty? ? object.class.column_names : form_fields.keys) %>
8
+
9
+ <% if show_columns.empty? %>
10
+ <% show_columns = form_ordered_fields - ['id', 'created_at', 'updated_at', 'deleted_at'] - excluded_columns + additional_columns %>
11
+ <% end %>
12
+
13
+ <div class="row g-3">
14
+ <% show_columns.each do |column| %>
15
+ <% wphtml = "col-md-#{(form_fields[column.to_sym].class == Hash ? form_fields[column.to_sym][:size] : form_fields[column.to_sym]) || 12}" %>
16
+ <% hint = (form_fields[column.to_sym].class == Hash ? form_fields[column.to_sym][:hint] : nil) %>
17
+ <% placeholder = (form_fields[column.to_sym].class == Hash ? form_fields[column.to_sym][:placeholder] : nil) %>
18
+
19
+ <% if object.class.column_for_attribute(column).type == :text %>
20
+ <%= f.input column, as: :text, input_html: { rows: 10, cols: 20 }, wrapper_html: { class: wphtml }, hint: hint, placeholder: placeholder %>
21
+ <% elsif [:date, :datetime].include?(object.class.column_for_attribute(column).type) %>
22
+ <%= f.input column, html5: true, wrapper_html: { class: wphtml }, hint: hint, placeholder: placeholder %>
23
+ <% elsif object.send(column).respond_to? 'attached?' %>
24
+ <% if object.send(column).class == ActiveStorage::Attached::Many %>
25
+ <%= f.input column, wrapper_html: { class: wphtml }, hint: hint, input_html: { multiple: true, class: 'fileinput',
26
+ data: {
27
+ initial: object.send(column).map { |im| rails_blob_path(im, only_path: true) }
28
+ }
29
+ } %>
30
+ <% else %>
31
+ <%= f.input column, wrapper_html: { class: wphtml }, hint: hint, input_html: { class: 'fileinput', 'data-initial': [rails_blob_path(object.send(column))] } %>
32
+ <% end %>
33
+ <% elsif /_id$/ =~ column && object.respond_to?(column.split('_id')[0]) %>
34
+ <% if restricted_columns.keys.include?(column.to_sym) %>
35
+ <%= f.association column.split("_id")[0],
36
+ label: restricted_columns[column.to_sym][:label],
37
+ collection: restricted_columns[column.to_sym][:collection],
38
+ wrapper_html: { class: wphtml },
39
+ hint: hint, placeholder: placeholder
40
+ %>
41
+ <% else %>
42
+ <%= f.association column.split("_id")[0], wrapper_html: { class: wphtml }, hint: hint, placeholder: placeholder %>
43
+ <% end %>
44
+ <% else %>
45
+ <%= f.input column, wrapper_html: { class: wphtml }, hint: hint, placeholder: placeholder %>
46
+ <% end %>
47
+ <% end %>
48
+ </div>
@@ -0,0 +1,23 @@
1
+ <% label ||= "" %>
2
+ <% required ||= false %>
3
+ <% wrapper_html ||= { class: "" } %>
4
+ <% kind ||= "pdffileinput" %>
5
+
6
+ <% unless f.object.nil? %>
7
+ <div class="<%= wrapper_html[:class] %>" data-controller="fileinput">
8
+ <%= f.label attribute, label %>
9
+ <%= f.hidden_field attribute, value: f.object.send(attribute).signed_id if f.object.send(attribute).attached? %>
10
+
11
+ <div class="<%= "is-invalid" if f.object.errors[attribute].present? %>">
12
+ <%= f.file_field attribute, class: kind, direct_upload: true,
13
+ data: {
14
+ url: (url_for(f.object.send(attribute)) if f.object.send(attribute).attached?),
15
+ filename: f.object.send(attribute).filename if f.object.send(attribute).attached?
16
+ } %>
17
+ </div>
18
+
19
+ <% if f.object.errors[attribute].present? %>
20
+ <div class="invalid-feedback"><%= f.object.errors[attribute].join(", ") %></div>
21
+ <% end %>
22
+ </div>
23
+ <% end %>
@@ -0,0 +1,3 @@
1
+ <div id="flash_messages" class="d-none" data-controller="toastr">
2
+ <%= bootstrap_flash %>
3
+ </div>
@@ -6,47 +6,58 @@
6
6
  <% back_link ||= false %>
7
7
  <% card_color ||= 'primary' %>
8
8
  <% show_columns ||= [] %>
9
+
9
10
  <% form_fields ||= (object.class.respond_to?('form_fields') ? object.class.form_fields : {}) %>
10
11
  <% form_ordered_fields ||= (form_fields.empty? ? object.class.column_names : form_fields.keys) %>
12
+
11
13
  <% if show_columns.empty? %>
12
14
  <% show_columns = form_ordered_fields - ['id', 'created_at', 'updated_at', 'deleted_at'] - excluded_columns + additional_columns %>
13
15
  <% end %>
16
+
14
17
  <%= simple_form_for(nested_resource ? [parent_resource, object] : object) do |f| %>
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>
18
+ <div class="card border-0 border-top border-4 border-<%= card_color %> shadow-sm">
19
+ <div class="card-header bg-body-tertiary border-0">
20
+ <h5 class="mb-0 fw-semibold">
21
+ <i class="<%= object.class.icon %> me-2"></i>
19
22
  Dados do <%= object.class.model_name.human %>
20
- </h3>
23
+ </h5>
21
24
  </div>
25
+
22
26
  <div class="card-body">
23
- <%= render 'shared/fields', object: object, f: f,
27
+ <%= render 'shared/fields',
28
+ object: object,
29
+ f: f,
24
30
  excluded_columns: excluded_columns,
25
- additional_columns: additional_columns,
31
+ additional_columns: additional_columns,
26
32
  restricted_columns: restricted_columns,
27
- show_columns: show_columns
28
- %>
33
+ show_columns: show_columns %>
29
34
  </div>
30
35
  </div>
31
- <div class="text-right">
36
+
37
+ <div class="d-flex justify-content-end align-items-center gap-2 mt-3">
32
38
  <% if back_link %>
33
- <%= link_to 'Cancelar', "javascript:history.back()", class: "btn" %>
39
+ <%= link_to "javascript:history.back()",
40
+ class: "btn" do %>
41
+ Cancelar
42
+ <% end %>
34
43
  <% else %>
35
44
  <% if parent_resource %>
36
- <%= link_to eval_with_rescue("#{parent_resource.class.model_name.to_s.downcase}_#{controller_name}_path(#{parent_resource.id})"), class: "btn" do %>
45
+ <%= link_to eval_with_rescue("#{parent_resource.class.model_name.to_s.downcase}_#{controller_name}_path(#{parent_resource.id})"),
46
+ class: "btn" do %>
37
47
  Cancelar
38
- <i class="fa fa-cancel fa-fw"></i>
39
48
  <% end %>
40
49
  <% else %>
41
- <%= link_to eval_with_rescue("#{controller_name}_path"), class: "btn" do %>
50
+ <%= link_to eval_with_rescue("#{controller_name}_path"),
51
+ class: "btn" do %>
42
52
  Cancelar
43
- <i class="fa fa-cancel fa-fw"></i>
44
53
  <% end %>
45
54
  <% end %>
46
55
  <% end %>
47
- <%= button_tag type: :submit, class: "btn btn-#{card_color}" do %>
56
+
57
+ <%= button_tag type: :submit,
58
+ class: "btn btn-#{card_color}" do %>
59
+ <i class="fa fa-save me-1"></i>
48
60
  Salvar
49
- <i class="fa fa-fw fa-save"></i>
50
61
  <% end %>
51
62
  </div>
52
63
  <% end %>