zutils 0.3.9 → 0.4.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: '049b7dcef95af7cabd8baf312bcbdcbfd978935e8565d6677690cdeb3da0cbc4'
4
- data.tar.gz: 9dc1ebb53a7e43edac16c54227c08c42e06cd207b2989b8782834e82367891ec
3
+ metadata.gz: b83f5d8d6ad65447a77d8d18cc7a9e7fde4dbd61b92a31b9034f06f23f4b702f
4
+ data.tar.gz: 3b2b365d34da3b2115dad406518eb6f7d420f898de46ea22a09f36970643a49b
5
5
  SHA512:
6
- metadata.gz: 6d67cd4e25c31fb0d775722e284788ba00d6d73d5218566a970e74a51894d13d7f157a17b0340075087677da251b102b9e2525cb4b97f648636d42638cf79855
7
- data.tar.gz: 846579a6047bd1d89467611d53bc978d3ed663a7c753a22853ad6a5b8840fb5ad6ccf627b6c100639f2b4f66083067e389309caf121656fcefa88da82e916f87
6
+ metadata.gz: 72886011e7625a2a9af5a84e044ca90b036e2164d58266f88d67a3a39dfba55cf0dfe17b7f6937d930c0d7a2d280b209e3e6b3614ed7a6dc52019f505994dba9
7
+ data.tar.gz: 1e46a9037a3cdd8ba0be4f41a2020f80224c27ae8f077fd5ceb9e67565f02d576d9beff095d191cf72d523c0b5598fc3fdc7b6cecd43e0dc2352438428e98eb7
@@ -1,11 +1,12 @@
1
1
  <% excluded_columns ||= [] %>
2
+ <% additional_columns ||= [] %>
2
3
  <% restricted_columns ||= {} %>
3
4
 
4
5
  <% form_fields ||= (object.class.respond_to?('form_fields') ? object.class.form_fields : {}) %>
5
6
  <% form_ordered_fields ||= (form_fields.empty? ? object.class.column_names : form_fields.keys) %>
6
7
 
7
8
  <div class="row">
8
- <% (form_ordered_fields - ['id', 'created_at', 'updated_at', 'deleted_at'] - excluded_columns).each do |column| %>
9
+ <% (form_ordered_fields - ['id', 'created_at', 'updated_at', 'deleted_at'] - excluded_columns + additional_columns).each do |column| %>
9
10
  <% wphtml = "col-md-#{(form_fields[column.to_sym].class == Hash ? form_fields[column.to_sym][:size] : form_fields[column.to_sym] ) || 12}" %>
10
11
  <% hint = (form_fields[column.to_sym].class == Hash ? form_fields[column.to_sym][:hint] : '') %>
11
12
  <% placeholder = (form_fields[column.to_sym].class == Hash ? form_fields[column.to_sym][:placeholder] : '') %>
@@ -13,6 +14,16 @@
13
14
  <%= f.input column, input_html: { rows: 10, cols: 20 }, wrapper_html: { class: wphtml }, hint: hint, placeholder: placeholder %>
14
15
  <% elsif [:date, :datetime].include?(object.class.column_for_attribute(column).type) %>
15
16
  <%= f.input column, html5: true, wrapper_html: { class: wphtml }, hint: hint, placeholder: placeholder %>
17
+ <% elsif object.send(column).respond_to? 'attached?' %>
18
+ <% if object.send(column).class == ActiveStorage::Attached::Many %>
19
+ <%= f.input column, wrapper_html: { class: wphtml }, hint: hint, input_html: { multiple: true, class: 'fileinput',
20
+ data: {
21
+ initial: object.send(column).map{|im| rails_blob_path(im, only_path: true)}
22
+ }
23
+ } %>
24
+ <% else %>
25
+ <%= f.input column, wrapper_html: { class: wphtml }, hint: hint, input_html: { class: 'fileinput', 'data-initial': [rails_blob_path(object.send(column))] } %>
26
+ <% end %>
16
27
  <% elsif /_id$/ =~ column && object.respond_to?(column.split('_id')[0]) %>
17
28
  <% if restricted_columns.keys.include?(column.to_sym) %>
18
29
  <%= f.association column.split("_id")[0],
@@ -1,4 +1,5 @@
1
1
  <% excluded_columns ||= [] %>
2
+ <% additional_columns ||= [] %>
2
3
  <% restricted_columns ||= {} %>
3
4
  <% nested_resource ||= false %>
4
5
  <% parent_resource ||= false %>
@@ -22,7 +23,11 @@
22
23
  </h3>
23
24
  </div>
24
25
  <div class="box-body">
25
- <%= render 'shared/fields', object: object, f: f, excluded_columns: excluded_columns, restricted_columns: restricted_columns %>
26
+ <%= render 'shared/fields', object: object, f: f,
27
+ excluded_columns: excluded_columns,
28
+ additional_columns: additional_columns,
29
+ restricted_columns: restricted_columns
30
+ %>
26
31
  </div>
27
32
  <div class="box-footer">
28
33
  <% if back_link %>
@@ -1,3 +1,3 @@
1
1
  module Zutils
2
- VERSION = "0.3.9"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zutils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.9
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ricardo Viana