compony 0.1.1 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/CHANGELOG.md +23 -0
- data/Gemfile.lock +107 -72
- data/app/controllers/compony_controller.rb +3 -1
- data/compony.gemspec +5 -5
- data/config/locales/fr.yml +33 -0
- data/lib/compony/component.rb +0 -5
- data/lib/compony/component_mixins/default/standalone/resourceful_verb_dsl.rb +1 -1
- data/lib/compony/component_mixins/default/standalone/standalone_dsl.rb +14 -3
- data/lib/compony/component_mixins/default/standalone/verb_dsl.rb +14 -5
- data/lib/compony/component_mixins/default/standalone.rb +6 -3
- data/lib/compony/components/form.rb +9 -6
- data/lib/compony/components/with_form.rb +13 -1
- data/lib/compony/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8c73b93a2181fc65daa7d813741776da0426bb8f17bdfee660d8e94626f1676
|
4
|
+
data.tar.gz: 70715489017a96b9fd638a75c48666fc8157971af5b6f15f80a202ce774c14e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f18b01d899380afbcba59880d0ef3bf827228ca410f67bcd2a8d70900cf32004442e4ae60cce6a6a2ca00801225cc8f760e0988e3a1903bda7969263ded700d
|
7
|
+
data.tar.gz: 0f9896f5d968a90f20c4c2323a41b205915a57f05b10cdb80d3968192b4af9c700635f22ed1057c5ba4850449c8d6f6c796c61f6f774418c2620a13e5fda0505
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.
|
1
|
+
3.2.2
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,26 @@
|
|
1
|
+
# 0.2.1
|
2
|
+
|
3
|
+
- Fix a bug where the app crashed on HEAD verb
|
4
|
+
- Show more details about failing authorization block
|
5
|
+
- Implement `submit_path` DSL call for WithForm
|
6
|
+
- Add French translation
|
7
|
+
- Implement `skip_autofocus` in Form
|
8
|
+
- Allow partial override of standalone verb configs. Example:
|
9
|
+
```ruby
|
10
|
+
verb :get do
|
11
|
+
authorize { true }
|
12
|
+
end
|
13
|
+
verb :post do
|
14
|
+
authorize { true }
|
15
|
+
# Parent class implements more logic here, which will no longer be overwritten by calling `verb :post`.
|
16
|
+
end
|
17
|
+
```
|
18
|
+
|
19
|
+
# 0.2.0
|
20
|
+
|
21
|
+
- Cleanup old code
|
22
|
+
- Remove `check_config!` that was barely used
|
23
|
+
|
1
24
|
# 0.1.1
|
2
25
|
|
3
26
|
- Support and force Rails 7.1.2
|
data/Gemfile.lock
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
compony (0.1.
|
4
|
+
compony (0.1.2.edge)
|
5
5
|
anchormodel (~> 0.1.2)
|
6
6
|
cancancan (~> 3.4.0)
|
7
7
|
dslblend (>= 0.0.3)
|
8
8
|
dyny (>= 0.0.3)
|
9
|
+
rails (>= 7.1.2)
|
9
10
|
request_store (>= 1.5)
|
10
11
|
schemacop (>= 3.0.17)
|
11
12
|
simple_form (>= 5.1.0)
|
@@ -13,79 +14,93 @@ PATH
|
|
13
14
|
GEM
|
14
15
|
remote: https://rubygems.org/
|
15
16
|
specs:
|
16
|
-
actioncable (7.
|
17
|
-
actionpack (= 7.
|
18
|
-
activesupport (= 7.
|
17
|
+
actioncable (7.1.2)
|
18
|
+
actionpack (= 7.1.2)
|
19
|
+
activesupport (= 7.1.2)
|
19
20
|
nio4r (~> 2.0)
|
20
21
|
websocket-driver (>= 0.6.1)
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
zeitwerk (~> 2.6)
|
23
|
+
actionmailbox (7.1.2)
|
24
|
+
actionpack (= 7.1.2)
|
25
|
+
activejob (= 7.1.2)
|
26
|
+
activerecord (= 7.1.2)
|
27
|
+
activestorage (= 7.1.2)
|
28
|
+
activesupport (= 7.1.2)
|
27
29
|
mail (>= 2.7.1)
|
28
30
|
net-imap
|
29
31
|
net-pop
|
30
32
|
net-smtp
|
31
|
-
actionmailer (7.
|
32
|
-
actionpack (= 7.
|
33
|
-
actionview (= 7.
|
34
|
-
activejob (= 7.
|
35
|
-
activesupport (= 7.
|
33
|
+
actionmailer (7.1.2)
|
34
|
+
actionpack (= 7.1.2)
|
35
|
+
actionview (= 7.1.2)
|
36
|
+
activejob (= 7.1.2)
|
37
|
+
activesupport (= 7.1.2)
|
36
38
|
mail (~> 2.5, >= 2.5.4)
|
37
39
|
net-imap
|
38
40
|
net-pop
|
39
41
|
net-smtp
|
40
|
-
rails-dom-testing (~> 2.
|
41
|
-
actionpack (7.
|
42
|
-
actionview (= 7.
|
43
|
-
activesupport (= 7.
|
44
|
-
|
42
|
+
rails-dom-testing (~> 2.2)
|
43
|
+
actionpack (7.1.2)
|
44
|
+
actionview (= 7.1.2)
|
45
|
+
activesupport (= 7.1.2)
|
46
|
+
nokogiri (>= 1.8.5)
|
47
|
+
racc
|
48
|
+
rack (>= 2.2.4)
|
49
|
+
rack-session (>= 1.0.1)
|
45
50
|
rack-test (>= 0.6.3)
|
46
|
-
rails-dom-testing (~> 2.
|
47
|
-
rails-html-sanitizer (~> 1.
|
48
|
-
actiontext (7.
|
49
|
-
actionpack (= 7.
|
50
|
-
activerecord (= 7.
|
51
|
-
activestorage (= 7.
|
52
|
-
activesupport (= 7.
|
51
|
+
rails-dom-testing (~> 2.2)
|
52
|
+
rails-html-sanitizer (~> 1.6)
|
53
|
+
actiontext (7.1.2)
|
54
|
+
actionpack (= 7.1.2)
|
55
|
+
activerecord (= 7.1.2)
|
56
|
+
activestorage (= 7.1.2)
|
57
|
+
activesupport (= 7.1.2)
|
53
58
|
globalid (>= 0.6.0)
|
54
59
|
nokogiri (>= 1.8.5)
|
55
|
-
actionview (7.
|
56
|
-
activesupport (= 7.
|
60
|
+
actionview (7.1.2)
|
61
|
+
activesupport (= 7.1.2)
|
57
62
|
builder (~> 3.1)
|
58
|
-
erubi (~> 1.
|
59
|
-
rails-dom-testing (~> 2.
|
60
|
-
rails-html-sanitizer (~> 1.
|
61
|
-
activejob (7.
|
62
|
-
activesupport (= 7.
|
63
|
+
erubi (~> 1.11)
|
64
|
+
rails-dom-testing (~> 2.2)
|
65
|
+
rails-html-sanitizer (~> 1.6)
|
66
|
+
activejob (7.1.2)
|
67
|
+
activesupport (= 7.1.2)
|
63
68
|
globalid (>= 0.3.6)
|
64
|
-
activemodel (7.
|
65
|
-
activesupport (= 7.
|
66
|
-
activerecord (7.
|
67
|
-
activemodel (= 7.
|
68
|
-
activesupport (= 7.
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
69
|
+
activemodel (7.1.2)
|
70
|
+
activesupport (= 7.1.2)
|
71
|
+
activerecord (7.1.2)
|
72
|
+
activemodel (= 7.1.2)
|
73
|
+
activesupport (= 7.1.2)
|
74
|
+
timeout (>= 0.4.0)
|
75
|
+
activestorage (7.1.2)
|
76
|
+
actionpack (= 7.1.2)
|
77
|
+
activejob (= 7.1.2)
|
78
|
+
activerecord (= 7.1.2)
|
79
|
+
activesupport (= 7.1.2)
|
74
80
|
marcel (~> 1.0)
|
75
|
-
|
76
|
-
|
81
|
+
activesupport (7.1.2)
|
82
|
+
base64
|
83
|
+
bigdecimal
|
77
84
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
85
|
+
connection_pool (>= 2.2.5)
|
86
|
+
drb
|
78
87
|
i18n (>= 1.6, < 2)
|
79
88
|
minitest (>= 5.1)
|
89
|
+
mutex_m
|
80
90
|
tzinfo (~> 2.0)
|
81
|
-
anchormodel (0.1.
|
91
|
+
anchormodel (0.1.3)
|
82
92
|
rails (~> 7.0)
|
83
93
|
ast (2.4.2)
|
94
|
+
base64 (0.2.0)
|
95
|
+
bigdecimal (3.1.4)
|
84
96
|
builder (3.2.4)
|
85
97
|
cancancan (3.4.0)
|
86
98
|
concurrent-ruby (1.2.2)
|
99
|
+
connection_pool (2.4.1)
|
87
100
|
crass (1.0.6)
|
88
101
|
date (3.3.3)
|
102
|
+
drb (2.2.0)
|
103
|
+
ruby2_keywords
|
89
104
|
dslblend (0.0.3)
|
90
105
|
dyny (0.0.3)
|
91
106
|
rails
|
@@ -94,6 +109,10 @@ GEM
|
|
94
109
|
activesupport (>= 5.0)
|
95
110
|
i18n (1.13.0)
|
96
111
|
concurrent-ruby (~> 1.0)
|
112
|
+
io-console (0.6.0)
|
113
|
+
irb (1.9.1)
|
114
|
+
rdoc
|
115
|
+
reline (>= 0.3.8)
|
97
116
|
json (2.6.3)
|
98
117
|
loofah (2.21.3)
|
99
118
|
crass (~> 1.0.2)
|
@@ -104,9 +123,9 @@ GEM
|
|
104
123
|
net-pop
|
105
124
|
net-smtp
|
106
125
|
marcel (1.0.2)
|
107
|
-
method_source (1.0.0)
|
108
126
|
mini_mime (1.1.2)
|
109
127
|
minitest (5.18.0)
|
128
|
+
mutex_m (0.2.0)
|
110
129
|
net-imap (0.3.4)
|
111
130
|
date
|
112
131
|
net-protocol
|
@@ -122,39 +141,53 @@ GEM
|
|
122
141
|
parallel (1.23.0)
|
123
142
|
parser (3.2.2.1)
|
124
143
|
ast (~> 2.4.1)
|
144
|
+
psych (5.1.1.1)
|
145
|
+
stringio
|
125
146
|
racc (1.6.2)
|
126
147
|
rack (2.2.7)
|
148
|
+
rack-session (1.0.1)
|
149
|
+
rack (< 3)
|
127
150
|
rack-test (2.1.0)
|
128
151
|
rack (>= 1.3)
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
152
|
+
rackup (1.0.0)
|
153
|
+
rack (< 3)
|
154
|
+
webrick
|
155
|
+
rails (7.1.2)
|
156
|
+
actioncable (= 7.1.2)
|
157
|
+
actionmailbox (= 7.1.2)
|
158
|
+
actionmailer (= 7.1.2)
|
159
|
+
actionpack (= 7.1.2)
|
160
|
+
actiontext (= 7.1.2)
|
161
|
+
actionview (= 7.1.2)
|
162
|
+
activejob (= 7.1.2)
|
163
|
+
activemodel (= 7.1.2)
|
164
|
+
activerecord (= 7.1.2)
|
165
|
+
activestorage (= 7.1.2)
|
166
|
+
activesupport (= 7.1.2)
|
141
167
|
bundler (>= 1.15.0)
|
142
|
-
railties (= 7.
|
143
|
-
rails-dom-testing (2.0
|
144
|
-
activesupport (>=
|
168
|
+
railties (= 7.1.2)
|
169
|
+
rails-dom-testing (2.2.0)
|
170
|
+
activesupport (>= 5.0.0)
|
171
|
+
minitest
|
145
172
|
nokogiri (>= 1.6)
|
146
|
-
rails-html-sanitizer (1.
|
147
|
-
loofah (~> 2.
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
173
|
+
rails-html-sanitizer (1.6.0)
|
174
|
+
loofah (~> 2.21)
|
175
|
+
nokogiri (~> 1.14)
|
176
|
+
railties (7.1.2)
|
177
|
+
actionpack (= 7.1.2)
|
178
|
+
activesupport (= 7.1.2)
|
179
|
+
irb
|
180
|
+
rackup (>= 1.0.0)
|
152
181
|
rake (>= 12.2)
|
153
|
-
thor (~> 1.0)
|
154
|
-
zeitwerk (~> 2.
|
182
|
+
thor (~> 1.0, >= 1.2.2)
|
183
|
+
zeitwerk (~> 2.6)
|
155
184
|
rainbow (3.1.1)
|
156
185
|
rake (13.0.6)
|
186
|
+
rdoc (6.6.0)
|
187
|
+
psych (>= 4.0.0)
|
157
188
|
regexp_parser (2.8.0)
|
189
|
+
reline (0.4.0)
|
190
|
+
io-console (~> 0.5)
|
158
191
|
request_store (1.5.1)
|
159
192
|
rack (>= 1.4)
|
160
193
|
rexml (3.2.5)
|
@@ -182,11 +215,13 @@ GEM
|
|
182
215
|
simple_form (5.2.0)
|
183
216
|
actionpack (>= 5.2)
|
184
217
|
activemodel (>= 5.2)
|
218
|
+
stringio (3.0.9)
|
185
219
|
thor (1.2.2)
|
186
|
-
timeout (0.
|
220
|
+
timeout (0.4.1)
|
187
221
|
tzinfo (2.0.6)
|
188
222
|
concurrent-ruby (~> 1.0)
|
189
223
|
unicode-display_width (2.4.2)
|
224
|
+
webrick (1.8.1)
|
190
225
|
websocket-driver (0.7.5)
|
191
226
|
websocket-extensions (>= 0.1.0)
|
192
227
|
websocket-extensions (0.1.5)
|
@@ -15,7 +15,9 @@ class ComponyController < ApplicationController
|
|
15
15
|
|
16
16
|
# Define controller action for each standalone config
|
17
17
|
define_method(standalone_config.rails_action_name) do
|
18
|
-
|
18
|
+
translated_verb = request.raw_request_method.downcase.to_sym
|
19
|
+
translated_verb = :get if translated_verb == :head # Rails transparently converts HEAD to GET, so we must do the same for fetching the config.
|
20
|
+
verb_config = standalone_config.verbs[translated_verb]
|
19
21
|
Compony.comp_class_for!(comp_cst, family_cst).new.on_standalone_access(verb_config, self)
|
20
22
|
end
|
21
23
|
|
data/compony.gemspec
CHANGED
@@ -2,19 +2,19 @@
|
|
2
2
|
# This file is auto-generated via: 'rake gemspec'.
|
3
3
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: compony 0.
|
5
|
+
# stub: compony 0.2.1 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "compony".freeze
|
9
|
-
s.version = "0.
|
9
|
+
s.version = "0.2.1".freeze
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib".freeze]
|
13
13
|
s.authors = ["Sandro Kalbermatter".freeze, "contributors".freeze]
|
14
|
-
s.date = "
|
15
|
-
s.files = [".gitignore".freeze, ".ruby-version".freeze, ".yardopts".freeze, "CHANGELOG.md".freeze, "Gemfile".freeze, "Gemfile.lock".freeze, "LICENSE".freeze, "README.md".freeze, "Rakefile".freeze, "app/controllers/compony_controller.rb".freeze, "compony.gemspec".freeze, "config/locales/de.yml".freeze, "config/locales/en.yml".freeze, "config/routes.rb".freeze, "doc/resourceful_lifecycle.graphml".freeze, "doc/resourceful_lifecycle.pdf".freeze, "lib/compony.rb".freeze, "lib/compony/component.rb".freeze, "lib/compony/component_mixins/default/labelling.rb".freeze, "lib/compony/component_mixins/default/standalone.rb".freeze, "lib/compony/component_mixins/default/standalone/resourceful_verb_dsl.rb".freeze, "lib/compony/component_mixins/default/standalone/standalone_dsl.rb".freeze, "lib/compony/component_mixins/default/standalone/verb_dsl.rb".freeze, "lib/compony/component_mixins/resourceful.rb".freeze, "lib/compony/components/button.rb".freeze, "lib/compony/components/destroy.rb".freeze, "lib/compony/components/edit.rb".freeze, "lib/compony/components/form.rb".freeze, "lib/compony/components/new.rb".freeze, "lib/compony/components/with_form.rb".freeze, "lib/compony/controller_mixin.rb".freeze, "lib/compony/engine.rb".freeze, "lib/compony/method_accessible_hash.rb".freeze, "lib/compony/model_fields/anchormodel.rb".freeze, "lib/compony/model_fields/association.rb".freeze, "lib/compony/model_fields/attachment.rb".freeze, "lib/compony/model_fields/base.rb".freeze, "lib/compony/model_fields/boolean.rb".freeze, "lib/compony/model_fields/color.rb".freeze, "lib/compony/model_fields/currency.rb".freeze, "lib/compony/model_fields/date.rb".freeze, "lib/compony/model_fields/datetime.rb".freeze, "lib/compony/model_fields/decimal.rb".freeze, "lib/compony/model_fields/email.rb".freeze, "lib/compony/model_fields/float.rb".freeze, "lib/compony/model_fields/integer.rb".freeze, "lib/compony/model_fields/percentage.rb".freeze, "lib/compony/model_fields/phone.rb".freeze, "lib/compony/model_fields/rich_text.rb".freeze, "lib/compony/model_fields/string.rb".freeze, "lib/compony/model_fields/text.rb".freeze, "lib/compony/model_fields/time.rb".freeze, "lib/compony/model_fields/url.rb".freeze, "lib/compony/model_mixin.rb".freeze, "lib/compony/request_context.rb".freeze, "lib/compony/version.rb".freeze, "lib/compony/view_helpers.rb".freeze, "lib/generators/component/USAGE".freeze, "lib/generators/component/component_generator.rb".freeze, "lib/generators/component/templates/component.rb.erb".freeze, "lib/generators/component/templates/destroy.rb.erb".freeze, "lib/generators/component/templates/edit.rb.erb".freeze, "lib/generators/component/templates/form.rb.erb".freeze, "lib/generators/component/templates/new.rb.erb".freeze, "lib/generators/components/USAGE".freeze, "lib/generators/components/components_generator.rb".freeze]
|
14
|
+
s.date = "2024-01-22"
|
15
|
+
s.files = [".gitignore".freeze, ".ruby-version".freeze, ".yardopts".freeze, "CHANGELOG.md".freeze, "Gemfile".freeze, "Gemfile.lock".freeze, "LICENSE".freeze, "README.md".freeze, "Rakefile".freeze, "app/controllers/compony_controller.rb".freeze, "compony.gemspec".freeze, "config/locales/de.yml".freeze, "config/locales/en.yml".freeze, "config/locales/fr.yml".freeze, "config/routes.rb".freeze, "doc/resourceful_lifecycle.graphml".freeze, "doc/resourceful_lifecycle.pdf".freeze, "lib/compony.rb".freeze, "lib/compony/component.rb".freeze, "lib/compony/component_mixins/default/labelling.rb".freeze, "lib/compony/component_mixins/default/standalone.rb".freeze, "lib/compony/component_mixins/default/standalone/resourceful_verb_dsl.rb".freeze, "lib/compony/component_mixins/default/standalone/standalone_dsl.rb".freeze, "lib/compony/component_mixins/default/standalone/verb_dsl.rb".freeze, "lib/compony/component_mixins/resourceful.rb".freeze, "lib/compony/components/button.rb".freeze, "lib/compony/components/destroy.rb".freeze, "lib/compony/components/edit.rb".freeze, "lib/compony/components/form.rb".freeze, "lib/compony/components/new.rb".freeze, "lib/compony/components/with_form.rb".freeze, "lib/compony/controller_mixin.rb".freeze, "lib/compony/engine.rb".freeze, "lib/compony/method_accessible_hash.rb".freeze, "lib/compony/model_fields/anchormodel.rb".freeze, "lib/compony/model_fields/association.rb".freeze, "lib/compony/model_fields/attachment.rb".freeze, "lib/compony/model_fields/base.rb".freeze, "lib/compony/model_fields/boolean.rb".freeze, "lib/compony/model_fields/color.rb".freeze, "lib/compony/model_fields/currency.rb".freeze, "lib/compony/model_fields/date.rb".freeze, "lib/compony/model_fields/datetime.rb".freeze, "lib/compony/model_fields/decimal.rb".freeze, "lib/compony/model_fields/email.rb".freeze, "lib/compony/model_fields/float.rb".freeze, "lib/compony/model_fields/integer.rb".freeze, "lib/compony/model_fields/percentage.rb".freeze, "lib/compony/model_fields/phone.rb".freeze, "lib/compony/model_fields/rich_text.rb".freeze, "lib/compony/model_fields/string.rb".freeze, "lib/compony/model_fields/text.rb".freeze, "lib/compony/model_fields/time.rb".freeze, "lib/compony/model_fields/url.rb".freeze, "lib/compony/model_mixin.rb".freeze, "lib/compony/request_context.rb".freeze, "lib/compony/version.rb".freeze, "lib/compony/view_helpers.rb".freeze, "lib/generators/component/USAGE".freeze, "lib/generators/component/component_generator.rb".freeze, "lib/generators/component/templates/component.rb.erb".freeze, "lib/generators/component/templates/destroy.rb.erb".freeze, "lib/generators/component/templates/edit.rb.erb".freeze, "lib/generators/component/templates/form.rb.erb".freeze, "lib/generators/component/templates/new.rb.erb".freeze, "lib/generators/components/USAGE".freeze, "lib/generators/components/components_generator.rb".freeze]
|
16
16
|
s.required_ruby_version = Gem::Requirement.new(">= 3.0.0".freeze)
|
17
|
-
s.rubygems_version = "3.4.
|
17
|
+
s.rubygems_version = "3.4.22".freeze
|
18
18
|
s.summary = "Needs summary".freeze
|
19
19
|
|
20
20
|
s.specification_version = 4
|
@@ -0,0 +1,33 @@
|
|
1
|
+
fr:
|
2
|
+
compony:
|
3
|
+
cancel: 'Annuler'
|
4
|
+
filtered: '[Filtré]' # Not translated as this appears in log
|
5
|
+
boolean:
|
6
|
+
true: 'Oui'
|
7
|
+
false: 'Non'
|
8
|
+
feasibility:
|
9
|
+
has_dependent_models: 'il existe des %{dependent_class} dépendants'
|
10
|
+
model_fields:
|
11
|
+
attachment:
|
12
|
+
download: 'Télécharger'
|
13
|
+
components:
|
14
|
+
form:
|
15
|
+
submit: 'Envoyer'
|
16
|
+
cancel: 'Annuler'
|
17
|
+
edit:
|
18
|
+
label:
|
19
|
+
long: 'Modifier %{data_label}'
|
20
|
+
short: 'Modifier'
|
21
|
+
data_was_updated: '%{data_label} a été enregistré.'
|
22
|
+
new:
|
23
|
+
label:
|
24
|
+
long: 'Créer %{data_class}'
|
25
|
+
short: 'Nouveau'
|
26
|
+
data_was_created: '%{data_label} a été créé.'
|
27
|
+
destroy:
|
28
|
+
label:
|
29
|
+
long: 'Supprimer %{data_label}'
|
30
|
+
short: 'Supprimer'
|
31
|
+
confirm_question: 'Voulez-vous vraiment supprimer %{data_label} ?'
|
32
|
+
confirm_button: 'Oui, supprimer'
|
33
|
+
data_was_destroyed: '%{data_label} a été supprimé.'
|
data/lib/compony/component.rb
CHANGED
@@ -37,7 +37,6 @@ module Compony
|
|
37
37
|
setup_blocks.each do |setup_block|
|
38
38
|
instance_exec(&setup_block)
|
39
39
|
end
|
40
|
-
check_config!
|
41
40
|
end
|
42
41
|
|
43
42
|
def inspect
|
@@ -228,9 +227,5 @@ module Compony
|
|
228
227
|
def resourceful?
|
229
228
|
return false
|
230
229
|
end
|
231
|
-
|
232
|
-
protected
|
233
|
-
|
234
|
-
def check_config!; end
|
235
230
|
end
|
236
231
|
end
|
@@ -14,7 +14,7 @@ module Compony
|
|
14
14
|
end
|
15
15
|
|
16
16
|
# For internal usage only, processes the block and returns a config hash.
|
17
|
-
def to_conf(&)
|
17
|
+
def to_conf(provide_defaults:, &)
|
18
18
|
return super.deep_merge({
|
19
19
|
load_data_block: @load_data_block,
|
20
20
|
assign_attributes_block: @assign_attributes_block,
|
@@ -4,11 +4,13 @@ module Compony
|
|
4
4
|
module Standalone
|
5
5
|
# @api description
|
6
6
|
# Wrapper and DSL helper for component's standalone config
|
7
|
+
# Pass `provide_defaults` true if this is the first standalone DSL of a component. Pass false if it is a subsequent one (e.g. if subclassed comp)
|
7
8
|
class StandaloneDsl < Dslblend::Base
|
8
|
-
def initialize(component, name = nil, path: nil)
|
9
|
+
def initialize(component, name = nil, provide_defaults:, path: nil)
|
9
10
|
super()
|
10
11
|
@component = component
|
11
12
|
@name = name&.to_sym
|
13
|
+
@provide_defaults = provide_defaults
|
12
14
|
@path = path
|
13
15
|
@verbs = {}
|
14
16
|
@skip_authentication = false
|
@@ -38,8 +40,17 @@ module Compony
|
|
38
40
|
def verb(verb, *args, **nargs, &)
|
39
41
|
verb = verb.to_sym
|
40
42
|
verb_dsl_class = @component.resourceful? ? ResourcefulVerbDsl : VerbDsl
|
41
|
-
@verbs[verb]
|
42
|
-
|
43
|
+
if @verbs[verb]
|
44
|
+
@verbs[verb].deep_merge! verb_dsl_class.new(@component, verb, *args, **nargs).to_conf(provide_defaults: false, &)
|
45
|
+
else
|
46
|
+
# Note about provide_defaults:
|
47
|
+
# - We must pass false if this is the second time `standalone` was called for this component -> see @provide_defaults
|
48
|
+
# - We musst pass false if this is the second time `verb` was called for this component -> handled by the if statement (other branch)
|
49
|
+
# - We must pass true otherwise (handled by this branch)
|
50
|
+
@verbs[verb] = Compony::MethodAccessibleHash.new(
|
51
|
+
verb_dsl_class.new(@component, verb, *args, **nargs).to_conf(provide_defaults: @provide_defaults, &)
|
52
|
+
)
|
53
|
+
end
|
43
54
|
end
|
44
55
|
|
45
56
|
# DSL
|
@@ -17,18 +17,19 @@ module Compony
|
|
17
17
|
|
18
18
|
@component = component
|
19
19
|
@verb = verb
|
20
|
-
@respond_blocks = {
|
20
|
+
@respond_blocks = {}
|
21
21
|
@authorize_block = nil
|
22
22
|
end
|
23
23
|
|
24
24
|
# For internal usage only, processes the block and returns a config hash.
|
25
|
-
def to_conf(&)
|
25
|
+
def to_conf(provide_defaults:, &)
|
26
26
|
evaluate(&) if block_given?
|
27
|
-
|
27
|
+
base_config = provide_defaults ? default_config : {}
|
28
|
+
return base_config.deep_merge({
|
28
29
|
verb: @verb,
|
29
|
-
authorize_block: @authorize_block
|
30
|
+
authorize_block: @authorize_block,
|
30
31
|
respond_blocks: @respond_blocks
|
31
|
-
}.compact
|
32
|
+
}.compact)
|
32
33
|
end
|
33
34
|
|
34
35
|
protected
|
@@ -45,6 +46,14 @@ module Compony
|
|
45
46
|
def respond(format = nil, &block)
|
46
47
|
@respond_blocks[format&.to_sym] = block
|
47
48
|
end
|
49
|
+
|
50
|
+
# Internal, do not use
|
51
|
+
def default_config
|
52
|
+
return {
|
53
|
+
authorize_block: proc { can?(comp_name.to_sym, family_name.to_sym) },
|
54
|
+
respond_blocks: { nil => proc { render_standalone(controller) } }
|
55
|
+
}
|
56
|
+
end
|
48
57
|
end
|
49
58
|
end
|
50
59
|
end
|
@@ -57,7 +57,7 @@ module Compony
|
|
57
57
|
end
|
58
58
|
|
59
59
|
# TODO: Make much prettier, providing message, action, subject and conditions
|
60
|
-
fail CanCan::AccessDenied, inspect unless request_context.evaluate(&verb_config.authorize_block)
|
60
|
+
fail CanCan::AccessDenied, [inspect, verb_config.authorize_block.inspect].join(', ') unless request_context.evaluate(&verb_config.authorize_block)
|
61
61
|
|
62
62
|
if verb_config.store_data_block
|
63
63
|
request_context.evaluate_with_backfire(&verb_config.store_data_block)
|
@@ -107,8 +107,11 @@ module Compony
|
|
107
107
|
def standalone(name = nil, *args, **nargs, &block)
|
108
108
|
block = proc {} unless block_given? # If called without a block, must default to an empty block to provide a binding to the DSL.
|
109
109
|
name = name&.to_sym # nil name is the most common case
|
110
|
-
@standalone_configs[name]
|
111
|
-
|
110
|
+
if @standalone_configs[name]
|
111
|
+
@standalone_configs[name].deep_merge! StandaloneDsl.new(self, name, *args, provide_defaults: false, **nargs).to_conf(&block)
|
112
|
+
else
|
113
|
+
@standalone_configs[name] = Compony::MethodAccessibleHash.new(StandaloneDsl.new(self, name, *args, provide_defaults: true, **nargs).to_conf(&block))
|
114
|
+
end
|
112
115
|
end
|
113
116
|
|
114
117
|
# Undoes previous standalone calls
|
@@ -8,13 +8,11 @@ module Compony
|
|
8
8
|
super
|
9
9
|
end
|
10
10
|
|
11
|
-
def check_config!
|
12
|
-
super
|
13
|
-
fail "#{inspect} requires config.form_fields do ..." if @form_fields.blank?
|
14
|
-
end
|
15
|
-
|
16
11
|
setup do
|
17
12
|
before_render do
|
13
|
+
# Make sure the error message is going to be nice if form_fields were not implemented
|
14
|
+
fail "#{component.inspect} requires config.form_fields do ..." if @form_fields.nil?
|
15
|
+
|
18
16
|
# Must render the buttons now as the rendering within simple form breaks the form
|
19
17
|
@submit_button = Compony.button_component_class.new(
|
20
18
|
label: @submit_label || I18n.t('compony.components.form.submit'), icon: 'arrow-right', type: :submit
|
@@ -88,7 +86,7 @@ module Compony
|
|
88
86
|
if hidden
|
89
87
|
return model_field.simpleform_input_hidden(@simpleform, self, **input_opts)
|
90
88
|
else
|
91
|
-
unless @focus_given
|
89
|
+
unless @focus_given || @skip_autofocus
|
92
90
|
input_opts[:autofocus] = true unless input_opts.key? :autofocus
|
93
91
|
@focus_given = true
|
94
92
|
end
|
@@ -138,6 +136,11 @@ module Compony
|
|
138
136
|
fail 'schema requires a block to be given'
|
139
137
|
end
|
140
138
|
end
|
139
|
+
|
140
|
+
# DSL method, skips adding autofocus to the first field
|
141
|
+
def skip_autofocus
|
142
|
+
@skip_autofocus = true
|
143
|
+
end
|
141
144
|
end
|
142
145
|
end
|
143
146
|
end
|
@@ -4,6 +4,11 @@ module Compony
|
|
4
4
|
# This component is destined to take a sub-component that is a form component.
|
5
5
|
# It can be called via :get or via `submit_verb` depending on whether its form should be shown or submitted.
|
6
6
|
class WithForm < Component
|
7
|
+
def initialize(...)
|
8
|
+
@submit_path_block = ->(controller) { controller.helpers.send("#{Compony.path_helper_name(comp_name, family_name)}_path") }
|
9
|
+
super
|
10
|
+
end
|
11
|
+
|
7
12
|
# Returns an instance of the form component responsible for rendering the form.
|
8
13
|
# Feel free to override this in subclasses.
|
9
14
|
def form_comp
|
@@ -11,7 +16,7 @@ module Compony
|
|
11
16
|
self,
|
12
17
|
submit_verb:,
|
13
18
|
# If applicable, Rails adds the route keys automatically, thus, e.g. :id does not need to be passed here, as it comes from the request.
|
14
|
-
submit_path:
|
19
|
+
submit_path: @submit_path_block
|
15
20
|
)
|
16
21
|
end
|
17
22
|
|
@@ -32,6 +37,13 @@ module Compony
|
|
32
37
|
def form_comp_class(new_form_comp_class = nil)
|
33
38
|
@form_comp_class ||= new_form_comp_class
|
34
39
|
end
|
40
|
+
|
41
|
+
# DSL method
|
42
|
+
# Overrides the submit path which would otherwise default to this component
|
43
|
+
# This takes a block that will be called and given a controller
|
44
|
+
def submit_path(&new_submit_path_block)
|
45
|
+
@submit_path_block = new_submit_path_block
|
46
|
+
end
|
35
47
|
end
|
36
48
|
end
|
37
49
|
end
|
data/lib/compony/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: compony
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sandro Kalbermatter
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2024-01-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: yard
|
@@ -184,6 +184,7 @@ files:
|
|
184
184
|
- compony.gemspec
|
185
185
|
- config/locales/de.yml
|
186
186
|
- config/locales/en.yml
|
187
|
+
- config/locales/fr.yml
|
187
188
|
- config/routes.rb
|
188
189
|
- doc/resourceful_lifecycle.graphml
|
189
190
|
- doc/resourceful_lifecycle.pdf
|