base_editing_bootstrap 1.3.2 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +2 -0
- data/app/helpers/utilities/form_helper.rb +9 -0
- data/app/views/base_editing/_form_field.html.erb +2 -0
- data/app/views/base_editing/form_field/_has_one_attachment.html.erb +31 -0
- data/base_editing_bootstrap.gemspec +3 -1
- data/lib/base_editing_bootstrap/VERSION +1 -1
- data/lib/generators/base_editing_bootstrap/scaffold/templates/policy.rb.tt +4 -4
- metadata +34 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec2173d4ede7597e31056daba4097d643b427878115e0e2898e5e43c09d80d80
|
4
|
+
data.tar.gz: 6e8325daa90163681e969003f1a32612eab37e0bcc40fac78618b5f79cf24d35
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ce5b95dd4da6535fbe6e3388d7dbc65b4ec11ea1c304b4141f7c299a2974d3a30b72ce65fb2d000216fb92cc028c24ef4b2c4bdd4819c033bc50696ea8ce801
|
7
|
+
data.tar.gz: d923d2daed952f049ad97b13e723d6c5343639fce7b873d923aee776bfca3f3021e78d45db4c199c524a9a4a8ebd1bd5a6c5ea509c0a14ba5bbd9644b546c0e8
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
All notable changes to this project will be documented in this file. See [conventional commits](https://www.conventionalcommits.org/) for commit guidelines.
|
3
3
|
|
4
4
|
- - -
|
5
|
+
## 1.4.0 - 2025-01-13
|
6
|
+
#### Bug Fixes
|
7
|
+
- Correct generator for values - (a83f07a) - Marino Bonetti
|
8
|
+
#### Features
|
9
|
+
- Has one attached automatic file_field - (fd32678) - Marino Bonetti
|
10
|
+
|
11
|
+
- - -
|
12
|
+
|
5
13
|
## 1.3.2 - 2025-01-10
|
6
14
|
#### Bug Fixes
|
7
15
|
- Fields in form inside layout - (a2e1d42) - Marino Bonetti
|
data/README.md
CHANGED
@@ -25,6 +25,8 @@ Then run installer:
|
|
25
25
|
$ bundle exec rails g base_editing_bootstrap:install
|
26
26
|
```
|
27
27
|
|
28
|
+
**Si presume quindi che ActiveStorage sia correttamente installato, completo del javascript per il direct upload**
|
29
|
+
|
28
30
|
### Generators
|
29
31
|
Then Install dependency (if you run base_editing_bootstrap:install you are good to go):
|
30
32
|
```bash
|
@@ -2,6 +2,7 @@ module Utilities
|
|
2
2
|
module FormHelper
|
3
3
|
include TemplateHelper
|
4
4
|
include EnumHelper
|
5
|
+
include IconHelper
|
5
6
|
##
|
6
7
|
# Metodo su cui eseguire override per i campi specifici rispetto all'oggetto gestito dal controller
|
7
8
|
# @deprecated Utilizza form_print_field(form, field) senza sovrascriverlo
|
@@ -23,9 +24,15 @@ module Utilities
|
|
23
24
|
else
|
24
25
|
if form.object.class.respond_to?(:type_for_attribute)
|
25
26
|
type = form.object.class.type_for_attribute(field).type
|
27
|
+
|
28
|
+
# Se non abbiamo ancora il type tentiamo di capire se è di tipo attachment SINGOLO
|
29
|
+
if type.nil? and form.object.respond_to?(:"#{field}_attachment")
|
30
|
+
type = :has_one_attachment
|
31
|
+
end
|
26
32
|
else
|
27
33
|
type = :string
|
28
34
|
end
|
35
|
+
|
29
36
|
case type
|
30
37
|
when :datetime
|
31
38
|
generic_field = "datetime"
|
@@ -41,6 +48,8 @@ module Utilities
|
|
41
48
|
generic_field = "integer"
|
42
49
|
when :boolean
|
43
50
|
generic_field = "boolean"
|
51
|
+
when :has_one_attachment
|
52
|
+
generic_field = "has_one_attachment"
|
44
53
|
else
|
45
54
|
generic_field = "base"
|
46
55
|
end
|
@@ -30,3 +30,5 @@
|
|
30
30
|
<%= error_messages_for(form.object, form_field) %>
|
31
31
|
<% end %>
|
32
32
|
<%= render partial: "editing_form_help_text", locals: {object: form.object, field: form_field} %>
|
33
|
+
<%= content_for :form_field_ending %>
|
34
|
+
<% content_for :form_field_ending, "", flush: true #RESET altrimenti ce lo troviamo nel successivo campo %>
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<%# locals: (form:, field:) -%>
|
2
|
+
<%
|
3
|
+
is_attached = form.object.send(field).attached?
|
4
|
+
hidden_field_id = dom_id(form.object, "hidden_#{field}")
|
5
|
+
preview_image_id = dom_id(form.object, "preview_image_#{field}")
|
6
|
+
filename_id = dom_id(form.object, "filename_#{field}")
|
7
|
+
|
8
|
+
javascript_clear_event = <<~JAVASCRIPT
|
9
|
+
try{document.getElementById('#{hidden_field_id}').value = ''}catch{};
|
10
|
+
try{document.getElementById('#{preview_image_id}').remove()}catch{};
|
11
|
+
try{document.getElementById('#{filename_id}').remove()}catch{};
|
12
|
+
return false
|
13
|
+
JAVASCRIPT
|
14
|
+
|
15
|
+
%>
|
16
|
+
<%= form.hidden_field field, value: form.object.send(field).signed_id, id: hidden_field_id if is_attached %>
|
17
|
+
|
18
|
+
<%= form.file_field field, direct_upload: true %>
|
19
|
+
|
20
|
+
<% if is_attached %>
|
21
|
+
<%= content_tag :span, form.object.send(field).attachment.blob.filename, class: "input-group-text", id: filename_id %>
|
22
|
+
<%= content_tag :button, icon(:trash),
|
23
|
+
onclick: javascript_clear_event,
|
24
|
+
class: "btn btn-outline-secondary rounded-0" %>
|
25
|
+
<%= link_to icon(:download), form.object.send(field), class: "btn btn-outline-secondary", target: :_blank %>
|
26
|
+
<% if form.object.send(field).representable? %>
|
27
|
+
<% content_for :form_field_ending,flush:true do %>
|
28
|
+
<%= content_tag :div, image_tag(form.object.send(field).representation(resize_to_limit: [100, 100])), id: preview_image_id %>
|
29
|
+
<% end %>
|
30
|
+
<% end %>
|
31
|
+
<% end %>
|
@@ -43,7 +43,9 @@ Gem::Specification.new do |spec|
|
|
43
43
|
spec.add_development_dependency 'faker', '~> 3.3'
|
44
44
|
spec.add_development_dependency "puma", '~> 6.4'
|
45
45
|
spec.add_development_dependency "sqlite3"
|
46
|
-
spec.add_development_dependency "
|
46
|
+
spec.add_development_dependency "propshaft", '~> 1.1.0'
|
47
|
+
spec.add_development_dependency 'importmap-rails', '~> 2.1.0'
|
48
|
+
spec.add_development_dependency "image_processing", "~> 1.2"
|
47
49
|
spec.add_development_dependency 'rails-i18n'
|
48
50
|
spec.add_development_dependency "i18n-debug", '~> 1.2'
|
49
51
|
spec.add_development_dependency "cssbundling-rails", '~> 1.4'
|
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.4.0
|
@@ -1,8 +1,8 @@
|
|
1
1
|
class <%= class_name %>Policy < BaseModelPolicy
|
2
2
|
|
3
|
-
def editable_attributes = %
|
4
|
-
def permitted_attributes = %
|
5
|
-
def search_result_fields = %
|
3
|
+
def editable_attributes = %i[<%= attributes_names.join(" ") %>]
|
4
|
+
def permitted_attributes = %i[<%= attributes_names.join(" ") %>]
|
5
|
+
def search_result_fields = %i[<%= attributes_names.join(" ") %>]
|
6
6
|
<%- if @search_attrs.any? -%>
|
7
7
|
def search_fields
|
8
8
|
%i[<%= @search_attrs.join(" ") %>]
|
@@ -11,7 +11,7 @@ class <%= class_name %>Policy < BaseModelPolicy
|
|
11
11
|
<%- if @permitted_attributes.any? -%>
|
12
12
|
# TODO check if correct with search_fields
|
13
13
|
def permitted_attributes_for_ransack
|
14
|
-
%
|
14
|
+
%i[<%= @permitted_attributes.join(" ") %>]
|
15
15
|
end
|
16
16
|
<%- end -%>
|
17
17
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: base_editing_bootstrap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marino Bonetti
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-01-
|
11
|
+
date: 2025-01-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -175,19 +175,47 @@ dependencies:
|
|
175
175
|
- !ruby/object:Gem::Version
|
176
176
|
version: '0'
|
177
177
|
- !ruby/object:Gem::Dependency
|
178
|
-
name:
|
178
|
+
name: propshaft
|
179
179
|
requirement: !ruby/object:Gem::Requirement
|
180
180
|
requirements:
|
181
181
|
- - "~>"
|
182
182
|
- !ruby/object:Gem::Version
|
183
|
-
version:
|
183
|
+
version: 1.1.0
|
184
184
|
type: :development
|
185
185
|
prerelease: false
|
186
186
|
version_requirements: !ruby/object:Gem::Requirement
|
187
187
|
requirements:
|
188
188
|
- - "~>"
|
189
189
|
- !ruby/object:Gem::Version
|
190
|
-
version:
|
190
|
+
version: 1.1.0
|
191
|
+
- !ruby/object:Gem::Dependency
|
192
|
+
name: importmap-rails
|
193
|
+
requirement: !ruby/object:Gem::Requirement
|
194
|
+
requirements:
|
195
|
+
- - "~>"
|
196
|
+
- !ruby/object:Gem::Version
|
197
|
+
version: 2.1.0
|
198
|
+
type: :development
|
199
|
+
prerelease: false
|
200
|
+
version_requirements: !ruby/object:Gem::Requirement
|
201
|
+
requirements:
|
202
|
+
- - "~>"
|
203
|
+
- !ruby/object:Gem::Version
|
204
|
+
version: 2.1.0
|
205
|
+
- !ruby/object:Gem::Dependency
|
206
|
+
name: image_processing
|
207
|
+
requirement: !ruby/object:Gem::Requirement
|
208
|
+
requirements:
|
209
|
+
- - "~>"
|
210
|
+
- !ruby/object:Gem::Version
|
211
|
+
version: '1.2'
|
212
|
+
type: :development
|
213
|
+
prerelease: false
|
214
|
+
version_requirements: !ruby/object:Gem::Requirement
|
215
|
+
requirements:
|
216
|
+
- - "~>"
|
217
|
+
- !ruby/object:Gem::Version
|
218
|
+
version: '1.2'
|
191
219
|
- !ruby/object:Gem::Dependency
|
192
220
|
name: rails-i18n
|
193
221
|
requirement: !ruby/object:Gem::Requirement
|
@@ -343,6 +371,7 @@ files:
|
|
343
371
|
- app/views/base_editing/form_field/_datetime.html.erb
|
344
372
|
- app/views/base_editing/form_field/_decimal.html.erb
|
345
373
|
- app/views/base_editing/form_field/_enum.html.erb
|
374
|
+
- app/views/base_editing/form_field/_has_one_attachment.html.erb
|
346
375
|
- app/views/base_editing/form_field/_integer.html.erb
|
347
376
|
- app/views/base_editing/header_field/_base.html.erb
|
348
377
|
- app/views/base_editing/index.html.erb
|