zutils 0.5.1 → 1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2fb99d41fe0ffcf9bc92c4af427ff166a3b51aee5d16a513bb61786af245ab8b
4
- data.tar.gz: deecc20864d40807f2e5613c90752fa88cba0ec890a7342c66735e41595220c8
3
+ metadata.gz: c149d9195250f9f394b8cfda619c8df775cdb7dd9a7853cae66b7cc19b53f2f6
4
+ data.tar.gz: 836a4930072fd3a696052a857c782c18411393a9e710c3215815bcce614fb7e6
5
5
  SHA512:
6
- metadata.gz: 7dcd4e480c21b92aa23014b0cc5f125ceddc18bc4d15fe3f818eebf5fca147389f0deb928b4e107824803cee5a82fe86503cb929aae181d2ebc5a37640e7619a
7
- data.tar.gz: 97042c9f956abefaab9761d9bd9ce587598b2e2f0be86e3ee9b9f00fa944b7eeac5244f00fc502d54e2c9fac5d18b911cbc24b4d2f6ee67e3a5b5cd055728001
6
+ metadata.gz: ad38bf5c390df6cd13bf980479aa2c5af6c659420395dd05231822481c7625b5a557f383352006823c32b051388195efb9384fd28b787424a61bfc0045cd1453
7
+ data.tar.gz: 634890763235592646345f705bf28c18f41d10bf7f48029bc449819c25fdb817fca70cd32301d862781af4b02ad925911d11eb2987ef101c2fb802cf6d10e25a
@@ -5,7 +5,7 @@
5
5
  <% hide_destroy_action ||= false %>
6
6
 
7
7
  <div class="btn-group">
8
- <button type="button" class="btn btn-xs btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
8
+ <button type="button" class="btn btn-sm btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
9
9
  Ações
10
10
  <span class="caret"></span>
11
11
  <span class="sr-only">Toggle Dropdown</span>
@@ -13,7 +13,7 @@
13
13
  <ul class="dropdown-menu" role="menu">
14
14
  <% if !hide_read_action && can?(:read, (object.class == Array ? object.last.class : object.class)) %>
15
15
  <li>
16
- <%= link_to object, data: { toggle: 'tooltip', placement: 'top', title: 'Visualizar' } do %>
16
+ <%= link_to object, class: 'dropdown-item', data: { toggle: 'tooltip', placement: 'top', title: 'Visualizar' } do %>
17
17
  <i class="fa fa-eye"></i> Visualizar
18
18
  <% end %>
19
19
  <% end %>
@@ -21,11 +21,11 @@
21
21
  <% if !hide_edit_action && can?(:edit, (object.class == Array ? object.last.class : object.class)) %>
22
22
  <li>
23
23
  <% if object.class == Array %>
24
- <%= link_to eval_with_rescue("edit_#{[object].flatten.map{|x| x.class.to_s.underscore}.join("_")}_path(#{object[0].id}, #{object[1].id})"), data: { toggle: 'tooltip', placement: 'top', title: 'Editar' } do %>
24
+ <%= link_to eval_with_rescue("edit_#{[object].flatten.map{|x| x.class.to_s.underscore}.join("_")}_path(#{object[0].id}, #{object[1].id})"), class: 'dropdown-item', data: { toggle: 'tooltip', placement: 'top', title: 'Editar' } do %>
25
25
  <i class="fa fa-pencil fa-edit"></i> Editar
26
26
  <% end %>
27
27
  <% else %>
28
- <%= link_to eval_with_rescue("edit_#{[object].flatten.map{|x| x.class.to_s.underscore}.join("_")}_path(#{object.id})"), data: { toggle: 'tooltip', placement: 'top', title: 'Editar' } do %>
28
+ <%= link_to eval_with_rescue("edit_#{[object].flatten.map{|x| x.class.to_s.underscore}.join("_")}_path(#{object.id})"), class: 'dropdown-item', data: { toggle: 'tooltip', placement: 'top', title: 'Editar' } do %>
29
29
  <i class="fa fa-pencil fa-edit"></i> Editar
30
30
  <% end %>
31
31
  <% end %>
@@ -33,7 +33,7 @@
33
33
  <% end %>
34
34
  <% if !hide_destroy_action && can?(:destroy, (object.class == Array ? object.last.class : object.class)) %>
35
35
  <li>
36
- <%= link_to object, method: :delete, data: { confirm: 'Tem certeza?', toggle: 'tooltip', placement: 'top', title: 'Apagar' } do %>
36
+ <%= link_to object, method: :delete, class: 'dropdown-item', data: { confirm: 'Tem certeza?', toggle: 'tooltip', placement: 'top', title: 'Apagar' } do %>
37
37
  <i class="fa fa-trash"></i> Apagar
38
38
  <% end %>
39
39
  </li>
@@ -42,7 +42,7 @@
42
42
  <% additional_actions.each do |key, value| %>
43
43
  <% if can? key, (object.class == Array ? object.last.class : object.class) %>
44
44
  <li>
45
- <%= link_to eval_with_rescue("#{value[:link]}(#{object.id})"), value[:options] do %>
45
+ <%= link_to eval_with_rescue("#{value[:link]}(#{object.id})"), value[:options], class: 'dropdown-item' do %>
46
46
  <i class="fa fa-<%= value[:icon] %>"></i> <%= value[:title] %>
47
47
  <% end %>
48
48
  </li>
@@ -1,15 +1,20 @@
1
1
  <% excluded_columns ||= [] %>
2
2
  <% additional_columns ||= [] %>
3
3
  <% restricted_columns ||= {} %>
4
+ <% show_columns ||= [] %>
4
5
 
5
6
  <% form_fields ||= (object.class.respond_to?('form_fields') ? object.class.form_fields : {}) %>
6
7
  <% form_ordered_fields ||= (form_fields.empty? ? object.class.column_names : form_fields.keys) %>
7
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
+
8
13
  <div class="row">
9
- <% (form_ordered_fields - ['id', 'created_at', 'updated_at', 'deleted_at'] - excluded_columns + additional_columns).each do |column| %>
14
+ <% show_columns.each do |column| %>
10
15
  <% wphtml = "col-md-#{(form_fields[column.to_sym].class == Hash ? form_fields[column.to_sym][:size] : form_fields[column.to_sym] ) || 12}" %>
11
- <% hint = (form_fields[column.to_sym].class == Hash ? form_fields[column.to_sym][:hint] : '') %>
12
- <% placeholder = (form_fields[column.to_sym].class == Hash ? form_fields[column.to_sym][:placeholder] : '') %>
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) %>
13
18
  <% if object.class.column_for_attribute(column).type == :text %>
14
19
  <%= f.input column, input_html: { rows: 10, cols: 20 }, wrapper_html: { class: wphtml }, hint: hint, placeholder: placeholder %>
15
20
  <% elsif [:date, :datetime].include?(object.class.column_for_attribute(column).type) %>
@@ -5,14 +5,19 @@
5
5
  <% parent_resource ||= false %>
6
6
  <% back_link ||= false %>
7
7
  <% box_class ||= 'primary' %>
8
+ <% show_columns ||= [] %>
8
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) %>
11
12
 
13
+ <% if show_columns.empty? %>
14
+ <% show_columns = form_ordered_fields - ['id', 'created_at', 'updated_at', 'deleted_at'] - excluded_columns + additional_columns %>
15
+ <% end %>
16
+
12
17
  <%= simple_form_for(nested_resource ? [parent_resource, object] : object) do |f| %>
13
- <div class="box box-<%= box_class %>">
14
- <div class="box-header with-border">
15
- <h3 class="box-title">
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">
16
21
  Dados do <%= object.class.model_name.human %>
17
22
  <% if parent_resource %>
18
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" %>
@@ -22,14 +27,15 @@
22
27
  <%= f.submit 'Salvar', class: "btn btn-#{box_class} btn-xs" %>
23
28
  </h3>
24
29
  </div>
25
- <div class="box-body">
30
+ <div class="box-body card-body">
26
31
  <%= render 'shared/fields', object: object, f: f,
27
32
  excluded_columns: excluded_columns,
28
33
  additional_columns: additional_columns,
29
- restricted_columns: restricted_columns
34
+ restricted_columns: restricted_columns,
35
+ show_columns: show_columns
30
36
  %>
31
37
  </div>
32
- <div class="box-footer">
38
+ <div class="box-footer card-footer">
33
39
  <% if back_link %>
34
40
  <%= link_to 'Cancelar', "javascript:history.back()", class: "btn btn-default" %>
35
41
  <% else %>
@@ -9,7 +9,7 @@
9
9
  <% additional_actions ||= [] %>
10
10
  <% box_class ||= 'primary' %>
11
11
  <% table_no_padding ||= false %>
12
- <% table_class ||= 'datatables' %>
12
+ <% table_class ||= 'datatables styletable' %>
13
13
 
14
14
  <% hide_links ||= false %>
15
15
  <% hide_actions ||= false %>
@@ -20,25 +20,27 @@
20
20
  <% hide_edit_action ||= false %>
21
21
  <% hide_destroy_action ||= false %>
22
22
 
23
- <div class='box box-<%= box_class %>'>
23
+ <div class='box box-<%= box_class %> card card-outline card-<%= box_class %>'>
24
24
  <% unless hide_header %>
25
- <div class="box-header with-border">
26
- <h3 class="box-title">
27
- <%= list.klass.model_name.human.pluralize %>
25
+ <div class="box-header with-border card-header">
26
+ <h3 class="box-title card-title">
27
+ <strong>
28
+ <%= list.klass.model_name.human.pluralize %>
29
+ </strong>
28
30
  </h3>
29
31
  <% if block_given? %>
30
32
  <%= yield %>
31
33
  <% end %>
32
34
  </div>
33
35
  <% end %>
34
- <div class="box-body <%= 'no-padding' if table_no_padding %>">
36
+ <div class="box-body card-body <%= 'no-padding' if table_no_padding %> <%= 'p-0' if table_no_padding %>">
35
37
  <% unless search_fields.empty? %>
36
38
  <div class="row">
37
39
  <%= search_form_for @q, url: eval(nested_resource ? "#{parent_resource}_#{controller_name}_path" : "#{controller_name}_path") do |f| %>
38
40
  <% search_fields.each do |sf| %>
39
41
  <%= f.input sf[:field], label: sf[:label], required: false, as: sf[:as], collection: sf[:collection], wrapper_html: { class: 'col-md-3' } %>
40
42
  <% end %>
41
- <div class="col-md-3 top-25">
43
+ <div class="col-md-3 top-25 ">
42
44
  <%= f.submit "Pesquisar", class: "btn btn-#{box_class}" %>
43
45
  </div>
44
46
  <% end %>
@@ -65,7 +67,7 @@
65
67
 
66
68
  <% unless hide_links %>
67
69
  <% unless controller_name == 'users' %>
68
- <div class="box-footer">
70
+ <div class="box-footer card-footer">
69
71
  <% if can? :new, list.klass %>
70
72
  <% if nested_resource == true %>
71
73
  <% if parent_resource %>
@@ -5,7 +5,7 @@
5
5
  <% hide_actions ||= false %>
6
6
  <% sort_fields ||= [] %>
7
7
  <% sort_all ||= false %>
8
- <% table_class ||= 'datatables' %>
8
+ <% table_class ||= 'datatables styletable' %>
9
9
  <% box_class ||= 'primary' %>
10
10
  <% show_columns ||= [] %>
11
11
 
@@ -17,7 +17,7 @@
17
17
  <% show_columns = list.klass.column_names - exceptions - excluded_columns + additional_columns %>
18
18
  <% end %>
19
19
 
20
- <table class="table table-striped <%= table_class %>">
20
+ <table class="table table-striped <%= table_class %> table-bordered">
21
21
  <thead>
22
22
  <tr>
23
23
  <% show_columns.each do |column| %>
@@ -16,42 +16,44 @@
16
16
  <% show_columns = form_ordered_fields - ['id', 'created_at', 'updated_at', 'deleted_at'] - excluded_columns + additional_columns %>
17
17
  <% end %>
18
18
 
19
- <div class="box box-<%= box_class %>">
19
+ <div class="box box-<%= box_class %> card card-outline card-<%= box_class %>">
20
20
  <% unless hide_header %>
21
- <div class="box-header with-border">
22
- <h3 class="box-title"><%= object.class.model_name.human %></h3>
23
- <% unless hide_links %>
24
- <% if show_actions.include?('new') && can?(:new, object.class) %>
25
- <% if nested_resource %>
26
- <%= 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 %>
27
- Cadastrar <i class="fa fa-plus"></i>
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 %>
28
34
  <% end %>
29
- <% else %>
30
- <%= 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 %>
31
- Cadastrar <i class="fa fa-plus"></i>
35
+ <% end %>
36
+ <% if show_actions.include?('edit') && can?(:edit, object) %>
37
+ <%= 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 %>
38
+ Editar <i class="fa fa-pencil fa-pen"></i>
32
39
  <% end %>
33
40
  <% end %>
34
- <% end %>
35
- <% if show_actions.include?('edit') && can?(:edit, object) %>
36
- <%= 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 %>
37
- Editar <i class="fa fa-pencil"></i>
41
+ <% if show_actions.include?('index') %>
42
+ <% if nested_resource %>
43
+ <%= link_to 'Listagem', eval_with_rescue("#{parent_resource.class.model_name.singular}_#{object.class.model_name.plural}_path(#{parent_resource.id})"), class: "btn btn-default btn-xs", data: { toggle: 'tooltip', placement: 'top', title: 'Listagem' } %>
44
+ <% else %>
45
+ <%= link_to 'Listagem', eval_with_rescue("#{object.class.model_name.plural}_path"), class: "btn btn-default btn-xs", data: { toggle: 'tooltip', placement: 'top', title: 'Listagem' } %>
46
+ <% end %>
38
47
  <% end %>
39
48
  <% end %>
40
- <% if show_actions.include?('index') %>
41
- <% if nested_resource %>
42
- <%= link_to 'Listagem', eval_with_rescue("#{parent_resource.class.model_name.singular}_#{object.class.model_name.plural}_path(#{parent_resource.id})"), class: "btn btn-default btn-xs" %>
43
- <% else %>
44
- <%= link_to 'Listagem', eval_with_rescue("#{object.class.model_name.plural}_path"), class: "btn btn-default btn-xs" %>
45
- <% end %>
49
+ <% if block_given? %>
50
+ <%= yield %>
46
51
  <% end %>
47
- <% end %>
48
- <% if block_given? %>
49
- <%= yield %>
50
- <% end %>
52
+ </h3>
51
53
  </div>
52
54
  <% end %>
53
- <div class="box-body no-padding">
54
- <table class="table table-bordered table-striped no-padding datatables">
55
+ <div class="box-body card-body p-0 no-padding">
56
+ <table class="table table-bordered table-striped datatables styletable">
55
57
  <% unless hide_table_header %>
56
58
  <thead>
57
59
  <tr>
@@ -109,14 +111,14 @@
109
111
  <% relationships.each do |key, value| %>
110
112
  <% if object.association(key.to_s).kind_of?(ActiveRecord::Associations::BelongsToAssociation) ||
111
113
  object.association(key.to_s).kind_of?(ActiveRecord::Associations::HasOneAssociation) %>
112
- <div class="box box-<%= box_class %>">
113
- <div class="box-header with-border">
114
- <h3 class="box-title">
114
+ <div class="box box-<%= box_class %> card card-outline card-<%= box_class %>">
115
+ <div class="box-header with-border card-header">
116
+ <h3 class="box-title card-title">
115
117
  <%= Kernel.const_get(key.to_s.singularize.camelize).model_name.human %>
116
118
  </h3>
117
119
  </div>
118
- <div class="box-body no-padding">
119
- <table class="table table-bordered table-striped no-padding datatables">
120
+ <div class="box-body card-body p-0 no-padding">
121
+ <table class="table table-bordered table-striped datatables styletable">
120
122
  <% unless hide_table_header %>
121
123
  <thead>
122
124
  <tr>
@@ -160,14 +162,14 @@
160
162
  </div>
161
163
  </div>
162
164
  <% else %>
163
- <div class="box box-<%= box_class %>">
164
- <div class="box-header with-border">
165
- <h3 class="box-title">
165
+ <div class="box box-<%= box_class %> card card-outline card-<%= box_class %>">
166
+ <div class="box-header with-border card-header">
167
+ <h3 class="box-title card-title">
166
168
  <%= Kernel.const_get(key.to_s.singularize.camelize).model_name.human.pluralize %>
167
169
  </h3>
168
170
  </div>
169
- <div class="box-body no-padding">
170
- <table class="table table-bordered table-striped no-padding datatables">
171
+ <div class="box-body no-padding card-body p-0">
172
+ <table class="table table-bordered table-striped datatables styletable">
171
173
  <thead>
172
174
  <tr>
173
175
  <% value.each do |v| %>
@@ -1,3 +1,3 @@
1
1
  module Zutils
2
- VERSION = "0.5.1"
2
+ VERSION = "1.0.0"
3
3
  end
data/zutils.gemspec CHANGED
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
32
32
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
33
33
  spec.require_paths = ["lib"]
34
34
 
35
- spec.add_dependency 'rails', '~> 5.0'
35
+ spec.add_dependency 'rails', '~> 6.0'
36
36
 
37
37
  spec.add_development_dependency "bundler", "~> 1.16"
38
38
  spec.add_development_dependency "rake", "~> 10.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zutils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 1.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: 2019-10-21 00:00:00.000000000 Z
11
+ date: 2020-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '5.0'
19
+ version: '6.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '5.0'
26
+ version: '6.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement