base_editing_bootstrap 0.1.2 → 0.2.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 +53 -3
- data/README.md +28 -6
- data/app/helpers/utilities/enum_helper.rb +4 -1
- data/app/helpers/utilities/form_helper.rb +9 -3
- data/app/views/base_editing/form_field/_enum.html.erb +2 -0
- data/base_editing_bootstrap.gemspec +1 -1
- data/cog.toml +8 -2
- data/lib/base_editing_bootstrap/VERSION +1 -0
- data/lib/base_editing_bootstrap/version.rb +1 -1
- data/lib/base_editing_bootstrap.rb +5 -0
- data/spec/support/external_shared/base_editing_controller_helpers.rb +10 -10
- metadata +5 -4
- data/app/helpers/utilities/modal_helper.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f935f929fda6d975ddd3d969fe03d639e0c523a19824733227bec64865e982e
|
4
|
+
data.tar.gz: 12448bdc9765b31fe9660d9116092cd5ff3e61bd160b8d0cfc0d699b56a85212
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f86e276eb409edff874465dfdea52e44f581d5db4ab47d0d44bd33f0b7b24c0a871125f4807371eb0f199b5bf8a56edd6768f1787d66f8fae314e4d77fc1b16b
|
7
|
+
data.tar.gz: cbb77961f4f3df339a474472a6669039505ffbe2e31aa37abea4a7eae02481ea02e459f2f47fe0e802a6ef579d4bbcb81c3058c84ad9e12636462b3a28617f22
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,55 @@
|
|
1
|
-
|
1
|
+
# Changelog
|
2
|
+
All notable changes to this project will be documented in this file. See [conventional commits](https://www.conventionalcommits.org/) for commit guidelines.
|
3
|
+
|
4
|
+
- - -
|
5
|
+
## 0.2.0 - 2024-04-23
|
6
|
+
#### Documentation
|
7
|
+
- Add documntation for installation - (b528daa) - Marino Bonetti
|
8
|
+
- Fix documentation - (28e2e0b) - Marino Bonetti
|
9
|
+
#### Features
|
10
|
+
- Add Automatic Enum editing - (aab85a5) - Marino Bonetti
|
11
|
+
#### Miscellaneous Chores
|
12
|
+
- Remove code - (e07516a) - Marino Bonetti
|
13
|
+
- Fix Cog hooks - (2045412) - Marino Bonetti
|
14
|
+
#### Refactoring
|
15
|
+
- Rewrite helpers for base request editing - (1a08528) - Marino Bonetti
|
16
|
+
#### Tests
|
17
|
+
- Add test for enum helper - (4f48b48) - Marino Bonetti
|
18
|
+
|
19
|
+
- - -
|
20
|
+
|
21
|
+
## 0.1.4 - 2024-04-21
|
22
|
+
#### Miscellaneous Chores
|
23
|
+
- Fix Cog hooks - (ebd2d77) - Marino Bonetti
|
24
|
+
- Fix Version read - (ead56ca) - Marino Bonetti
|
25
|
+
|
26
|
+
- - -
|
27
|
+
|
28
|
+
## 0.1.3 - 2024-04-21
|
29
|
+
#### Miscellaneous Chores
|
30
|
+
- Set Version - (2c384f4) - Marino Bonetti
|
31
|
+
|
32
|
+
- - -
|
33
|
+
|
34
|
+
## 0.1.2 - 2024-04-21
|
35
|
+
#### Continuous Integration
|
36
|
+
- Test - (b05a41b) - Marino Bonetti
|
37
|
+
- Assets precompile - (036f22e) - Marino Bonetti
|
38
|
+
- Assets precompile - (e8e44ea) - Marino Bonetti
|
39
|
+
- Assets precompile - (1e3f959) - Marino Bonetti
|
40
|
+
#### Documentation
|
41
|
+
- Documentation form search form - (346da14) - Marino Bonetti
|
42
|
+
- Typo - (b83e829) - Marino Bonetti
|
43
|
+
#### Miscellaneous Chores
|
44
|
+
- Upgrade CHANGELOG.md - (3004ebd) - Marino Bonetti
|
45
|
+
- Prepare to push - (4a94d82) - Marino Bonetti
|
46
|
+
- Add cog cfg - (636b3ee) - Marino Bonetti
|
47
|
+
- Correct Ruby Ver Dependency - (0a05fba) - Marino Bonetti
|
48
|
+
- Add lost Dockerfile - (1318ee0) - Marino Bonetti
|
49
|
+
- Completa predisposizione gemma per iniziare lo sviluppo - (d83204c) - Marino Bonetti
|
50
|
+
#### Refactoring
|
51
|
+
- Rename fields - (b43d8f1) - Marino Bonetti
|
52
|
+
#### Tests
|
53
|
+
- Add Spec to search fields - (6822edb) - Marino Bonetti
|
2
54
|
|
3
|
-
## [0.1.0] - 2024-04-06
|
4
55
|
|
5
|
-
- Initial release
|
data/README.md
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
# BaseEditingBootstrap
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/base_editing_bootstrap.svg)](https://badge.fury.io/rb/base_editing_bootstrap)
|
3
|
+
|
2
4
|
WIP
|
3
5
|
|
4
6
|
## Installation
|
@@ -42,10 +44,26 @@ config.generators do |g|
|
|
42
44
|
g.factory_bot dir: 'spec/factories'
|
43
45
|
end
|
44
46
|
```
|
47
|
+
### Initializers
|
48
|
+
E' possibile configurare BaseEditingBootstrap con alcune impostazioni:
|
49
|
+
```ruby
|
50
|
+
BaseEditingBootstrap.configure do |config|
|
51
|
+
##
|
52
|
+
# Controller da cui derivare poi il BaseEditingController da cui derivano
|
53
|
+
# tutti i controller sottostanti
|
54
|
+
# @default "ApplicationController"
|
55
|
+
# config.inherited_controller = 'ApplicationController'
|
56
|
+
end
|
57
|
+
|
58
|
+
```
|
59
|
+
|
45
60
|
## Usage
|
46
61
|
Utilizzo per modello base, in questo esempio prendiamo come modello Post come esempio del dummy.
|
47
62
|
|
48
|
-
- Creare il Modello ed includere
|
63
|
+
- Creare il Modello ed includere
|
64
|
+
```ruby
|
65
|
+
include BaseEditingBootstrap::BaseModel
|
66
|
+
```
|
49
67
|
- Creare Controller:
|
50
68
|
```ruby
|
51
69
|
class PostsController < BaseEditingController
|
@@ -99,11 +117,15 @@ Utilizzo per modello base, in questo esempio prendiamo come modello Post come es
|
|
99
117
|
- updated_at => timestamps.html.erb
|
100
118
|
- default => base.html.erb
|
101
119
|
**Form Field**
|
102
|
-
- Integer
|
103
|
-
- Float
|
104
|
-
- Decimal
|
105
|
-
- DateTime
|
106
|
-
- Date
|
120
|
+
- Integer => _integer.html.erb
|
121
|
+
- Float => _decimal.html.erb
|
122
|
+
- Decimal => _decimal.html.erb
|
123
|
+
- DateTime => _detetime.html.erb
|
124
|
+
- Date => _date.html.erb
|
125
|
+
- Enum => _enum.html.erb
|
126
|
+
Per gli enum, le traduzioni dei labels di ogni valore provvengono da i18n
|
127
|
+
attraverso l'helper: `Utilities::EnumHelper#enum_translation`
|
128
|
+
il quale utilizza il nome dell'attributo con
|
107
129
|
- Default/String => _base.html.erb
|
108
130
|
|
109
131
|
In futuro si prevede di aggiungere automatismi per renderizzare senza
|
@@ -18,7 +18,10 @@ module Utilities
|
|
18
18
|
def enum_translation(model, attribute, value, variant = nil)
|
19
19
|
return '' if value.nil?
|
20
20
|
variant = "_#{variant}" unless variant.nil?
|
21
|
-
model.human_attribute_name(
|
21
|
+
model.human_attribute_name(
|
22
|
+
"#{attribute}.#{value}#{variant}",
|
23
|
+
default: model.human_attribute_name("#{attribute}.#{value}")
|
24
|
+
)
|
22
25
|
end
|
23
26
|
end
|
24
27
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module Utilities
|
2
2
|
module FormHelper
|
3
3
|
include TemplateHelper
|
4
|
+
include EnumHelper
|
4
5
|
##
|
5
6
|
# Metodo su cui eseguire override per i campi specifici rispetto all'oggetto gestito dal controller
|
6
7
|
# @deprecated Utilizza form_print_field(form, field) senza sovrascriverlo
|
@@ -17,7 +18,8 @@ module Utilities
|
|
17
18
|
# @param [Symbol] field
|
18
19
|
def form_print_field(form, field)
|
19
20
|
locals = {form:, field:}
|
20
|
-
|
21
|
+
type = form.object.class.type_for_attribute(field).type
|
22
|
+
case type
|
21
23
|
when :datetime
|
22
24
|
generic_field = "datetime"
|
23
25
|
when :date
|
@@ -31,7 +33,11 @@ module Utilities
|
|
31
33
|
when :integer
|
32
34
|
generic_field = "integer"
|
33
35
|
else
|
34
|
-
|
36
|
+
if form.object.class.defined_enums.key?(field.to_s)
|
37
|
+
generic_field = "enum"
|
38
|
+
else
|
39
|
+
generic_field = "base"
|
40
|
+
end
|
35
41
|
end
|
36
42
|
|
37
43
|
template = find_template_with_fallbacks(
|
@@ -40,7 +46,7 @@ module Utilities
|
|
40
46
|
"form_field",
|
41
47
|
generic_field
|
42
48
|
)
|
43
|
-
Rails.logger.debug { "#{template}->#{ locals.inspect}" }
|
49
|
+
Rails.logger.debug { "#{type}->#{generic_field}->#{template}->#{ locals.inspect}" }
|
44
50
|
render template, **locals
|
45
51
|
end
|
46
52
|
|
@@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
|
|
13
13
|
|
14
14
|
spec.metadata["homepage_uri"] = spec.homepage
|
15
15
|
spec.metadata["source_code_uri"] = "https://github.com/oniram88/BaseEditingBootstrap"
|
16
|
-
spec.metadata["changelog_uri"] = "https://github.com/oniram88/BaseEditingBootstrap/CHANGELOG"
|
16
|
+
spec.metadata["changelog_uri"] = "https://github.com/oniram88/BaseEditingBootstrap/blob/main/CHANGELOG.md"
|
17
17
|
|
18
18
|
# Specify which files should be added to the gem when it is released.
|
19
19
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
data/cog.toml
CHANGED
@@ -5,10 +5,16 @@ generate_mono_repository_global_tag = true
|
|
5
5
|
branch_whitelist = []
|
6
6
|
skip_ci = "[skip ci]"
|
7
7
|
skip_untracked = false
|
8
|
-
pre_bump_hooks = [
|
8
|
+
pre_bump_hooks = [
|
9
|
+
"echo '{{version}}' > lib/base_editing_bootstrap/VERSION",
|
10
|
+
"docker compose run app bundle"
|
11
|
+
]
|
9
12
|
post_bump_hooks = [
|
10
13
|
"git push",
|
11
|
-
"git push origin {{version}}"
|
14
|
+
"git push origin {{version}}",
|
15
|
+
"docker compose run app gem build base_editing_bootstrap.gemspec",
|
16
|
+
"docker compose run app gem push base_editing_bootstrap-{{version}}.gem",
|
17
|
+
"rm -fr base_editing_bootstrap-{{version}}.gem"
|
12
18
|
]
|
13
19
|
pre_package_bump_hooks = []
|
14
20
|
post_package_bump_hooks = []
|
@@ -0,0 +1 @@
|
|
1
|
+
0.2.0
|
@@ -15,6 +15,11 @@ loader.setup
|
|
15
15
|
|
16
16
|
module BaseEditingBootstrap
|
17
17
|
include ActiveSupport::Configurable
|
18
|
+
|
19
|
+
##
|
20
|
+
# Controller da cui derivare poi il BaseEditingController da cui derivano
|
21
|
+
# tutti i controller sottostanti
|
22
|
+
# @default "ApplicationController"
|
18
23
|
config_accessor :inherited_controller, default: "ApplicationController"
|
19
24
|
|
20
25
|
def self.deprecator
|
@@ -23,13 +23,13 @@ RSpec.shared_examples "base editing controller" do |factory: nil, only: [], exce
|
|
23
23
|
##
|
24
24
|
# Possibili override per la costruzione delle path
|
25
25
|
#
|
26
|
-
let(:url_for_new) { [model.new, action: :new] }
|
26
|
+
let(:url_for_new) { url_for([model.new, action: :new]) }
|
27
27
|
let(:url_for_index) { url_for(model) }
|
28
|
-
let(:url_for_create) {
|
28
|
+
let(:url_for_create) { url_for(model.new) }
|
29
29
|
let(:url_for_succ_delete) { url_for(model) }
|
30
30
|
let(:url_for_fail_delete) { url_for_succ_delete }
|
31
|
-
let(:url_for_edit) { [persisted_instance, action: :edit] }
|
32
|
-
let(:url_for_update) {
|
31
|
+
let(:url_for_edit) { url_for([persisted_instance, action: :edit]) }
|
32
|
+
let(:url_for_update) { url_for(persisted_instance) }
|
33
33
|
## non sempre abbiamo l'index nelle action disponibili, dobbiamo quindi avere modo di eseguire un override
|
34
34
|
let(:url_for_unauthorized) { url_for_index }
|
35
35
|
##
|
@@ -69,7 +69,7 @@ RSpec.shared_examples "base editing controller" do |factory: nil, only: [], exce
|
|
69
69
|
if check_if_should_execute(only, except, :new)
|
70
70
|
describe "new" do
|
71
71
|
it "response" do
|
72
|
-
get
|
72
|
+
get url_for_new
|
73
73
|
expect(response).to have_http_status(:ok)
|
74
74
|
expect(assigns[:object]).to be_an_instance_of(model)
|
75
75
|
end
|
@@ -79,7 +79,7 @@ RSpec.shared_examples "base editing controller" do |factory: nil, only: [], exce
|
|
79
79
|
if check_if_should_execute(only, except, :edit)
|
80
80
|
describe "edit" do
|
81
81
|
it "response" do
|
82
|
-
get
|
82
|
+
get url_for_edit
|
83
83
|
expect(response).to have_http_status(:ok)
|
84
84
|
expect(assigns[:object]).to be_an_instance_of(model)
|
85
85
|
end
|
@@ -89,14 +89,14 @@ RSpec.shared_examples "base editing controller" do |factory: nil, only: [], exce
|
|
89
89
|
if check_if_should_execute(only, except, :update)
|
90
90
|
describe "update" do
|
91
91
|
it "response" do
|
92
|
-
put
|
92
|
+
put url_for_update, params: {param_key => valid_attributes}
|
93
93
|
expect(assigns[:object]).to be_an_instance_of(model)
|
94
94
|
expect(response).to have_http_status(:see_other)
|
95
95
|
end
|
96
96
|
|
97
97
|
unless skip_invalid_checks
|
98
98
|
it "not valid" do
|
99
|
-
put
|
99
|
+
put url_for_update, params: {param_key => invalid_attributes}
|
100
100
|
expect(response).to have_http_status(:unprocessable_entity)
|
101
101
|
end
|
102
102
|
end
|
@@ -106,14 +106,14 @@ RSpec.shared_examples "base editing controller" do |factory: nil, only: [], exce
|
|
106
106
|
if check_if_should_execute(only, except, :create)
|
107
107
|
describe "create" do
|
108
108
|
it "response" do
|
109
|
-
post
|
109
|
+
post url_for_create, params: {param_key => valid_attributes}
|
110
110
|
expect(assigns[:object]).to be_an_instance_of(model)
|
111
111
|
expect(response).to have_http_status(:see_other)
|
112
112
|
end
|
113
113
|
|
114
114
|
unless skip_invalid_checks
|
115
115
|
it "not valid" do
|
116
|
-
post
|
116
|
+
post url_for_create, params: {param_key => invalid_attributes}
|
117
117
|
expect(response).to have_http_status(:unprocessable_entity)
|
118
118
|
end
|
119
119
|
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: 0.
|
4
|
+
version: 0.2.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: 2024-04-
|
11
|
+
date: 2024-04-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -121,7 +121,6 @@ files:
|
|
121
121
|
- app/helpers/base_editing_helper.rb
|
122
122
|
- app/helpers/utilities/enum_helper.rb
|
123
123
|
- app/helpers/utilities/form_helper.rb
|
124
|
-
- app/helpers/utilities/modal_helper.rb
|
125
124
|
- app/helpers/utilities/page_helper.rb
|
126
125
|
- app/helpers/utilities/search_helper.rb
|
127
126
|
- app/helpers/utilities/template_helper.rb
|
@@ -155,6 +154,7 @@ files:
|
|
155
154
|
- app/views/base_editing/form_field/_date.html.erb
|
156
155
|
- app/views/base_editing/form_field/_datetime.html.erb
|
157
156
|
- app/views/base_editing/form_field/_decimal.html.erb
|
157
|
+
- app/views/base_editing/form_field/_enum.html.erb
|
158
158
|
- app/views/base_editing/form_field/_integer.html.erb
|
159
159
|
- app/views/base_editing/index.html.erb
|
160
160
|
- app/views/base_editing/new.html.erb
|
@@ -173,6 +173,7 @@ files:
|
|
173
173
|
- config/routes.rb
|
174
174
|
- docker-compose.yml
|
175
175
|
- lib/base_editing_bootstrap.rb
|
176
|
+
- lib/base_editing_bootstrap/VERSION
|
176
177
|
- lib/base_editing_bootstrap/base_model.rb
|
177
178
|
- lib/base_editing_bootstrap/engine.rb
|
178
179
|
- lib/base_editing_bootstrap/forms/base.rb
|
@@ -191,7 +192,7 @@ licenses:
|
|
191
192
|
metadata:
|
192
193
|
homepage_uri: https://github.com/oniram88/BaseEditingBootstrap
|
193
194
|
source_code_uri: https://github.com/oniram88/BaseEditingBootstrap
|
194
|
-
changelog_uri: https://github.com/oniram88/BaseEditingBootstrap/CHANGELOG
|
195
|
+
changelog_uri: https://github.com/oniram88/BaseEditingBootstrap/blob/main/CHANGELOG.md
|
195
196
|
post_install_message:
|
196
197
|
rdoc_options: []
|
197
198
|
require_paths:
|
@@ -1,11 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Utilities::ModalHelper
|
4
|
-
##
|
5
|
-
# Metodo speciale per l'inclusione del contenuto nelle modal, forzando il flush in modo da poter utilizzare
|
6
|
-
# più modal contemporaneamente
|
7
|
-
def content_for_modal(*args, &block)
|
8
|
-
opts = args.extract_options!
|
9
|
-
content_for(*args, opts.merge(flush: true), &block)
|
10
|
-
end
|
11
|
-
end
|