compony 0.0.1 → 0.0.2

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: 85db41ccf7cece62891a703bb4e79c1e4e4a5a14fd87cc5ea0955df633184d60
4
- data.tar.gz: 15bbcb498d877f9b9932c77b867f3ae28215f21b37db213a05e6073752674f8a
3
+ metadata.gz: 9c333fb952f7e7d0014f3a8b076f8f902bb253ca2696b0fe8bec7a59b6f9b2eb
4
+ data.tar.gz: 816afcdeeba74972d758eef0b93824b605925b4e9e8f07bb140dac2621c94df2
5
5
  SHA512:
6
- metadata.gz: b84a06879a6e6c85682f92bfdfd0afd3243614312231e12b3c8f201b75799eb4b077a953b945f3da8c581011e9d0a3e9a27721b5ffe3087a4d6aca1831940e9a
7
- data.tar.gz: 403aaad21bb3853be4cfd8ed19c571910e6fac0a1e27193fc4e9177f48d9a313d6adac2339dd8e4ec530e064f8262e1de75283117583e8ef83292bdc0c1188bf
6
+ metadata.gz: bcf8622372086feb57f31c5e9024576a7c7e27ece17f42d4a225aba8051a9f500730cc2eb872305e02b2189651817ffddd9bf8fd6c618cd3d56b482917d80239
7
+ data.tar.gz: ebd6da5daf161538e755dc0a1c7bd59d8d14db81cd7253c419e719665e40f4a276909a4c2546977b6371dd5f61841eeafebdba8ece3f3162671fbb0fe734b18b
data/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ # 0.0.2
2
+
3
+ - Add new model field `Attachment`
4
+ - Slightly extend documentation
5
+ - Update `Gemfile.lock`
6
+
7
+ # 0.0.1
8
+
9
+ First version
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- compony (0.0.1.edge)
4
+ compony (0.0.1)
5
5
  anchormodel (~> 0.1.2)
6
6
  cancancan (~> 3.4.0)
7
7
  dslblend (>= 0.0.3)
@@ -13,67 +13,67 @@ PATH
13
13
  GEM
14
14
  remote: https://rubygems.org/
15
15
  specs:
16
- actioncable (7.0.4.2)
17
- actionpack (= 7.0.4.2)
18
- activesupport (= 7.0.4.2)
16
+ actioncable (7.0.4.3)
17
+ actionpack (= 7.0.4.3)
18
+ activesupport (= 7.0.4.3)
19
19
  nio4r (~> 2.0)
20
20
  websocket-driver (>= 0.6.1)
21
- actionmailbox (7.0.4.2)
22
- actionpack (= 7.0.4.2)
23
- activejob (= 7.0.4.2)
24
- activerecord (= 7.0.4.2)
25
- activestorage (= 7.0.4.2)
26
- activesupport (= 7.0.4.2)
21
+ actionmailbox (7.0.4.3)
22
+ actionpack (= 7.0.4.3)
23
+ activejob (= 7.0.4.3)
24
+ activerecord (= 7.0.4.3)
25
+ activestorage (= 7.0.4.3)
26
+ activesupport (= 7.0.4.3)
27
27
  mail (>= 2.7.1)
28
28
  net-imap
29
29
  net-pop
30
30
  net-smtp
31
- actionmailer (7.0.4.2)
32
- actionpack (= 7.0.4.2)
33
- actionview (= 7.0.4.2)
34
- activejob (= 7.0.4.2)
35
- activesupport (= 7.0.4.2)
31
+ actionmailer (7.0.4.3)
32
+ actionpack (= 7.0.4.3)
33
+ actionview (= 7.0.4.3)
34
+ activejob (= 7.0.4.3)
35
+ activesupport (= 7.0.4.3)
36
36
  mail (~> 2.5, >= 2.5.4)
37
37
  net-imap
38
38
  net-pop
39
39
  net-smtp
40
40
  rails-dom-testing (~> 2.0)
41
- actionpack (7.0.4.2)
42
- actionview (= 7.0.4.2)
43
- activesupport (= 7.0.4.2)
41
+ actionpack (7.0.4.3)
42
+ actionview (= 7.0.4.3)
43
+ activesupport (= 7.0.4.3)
44
44
  rack (~> 2.0, >= 2.2.0)
45
45
  rack-test (>= 0.6.3)
46
46
  rails-dom-testing (~> 2.0)
47
47
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
48
- actiontext (7.0.4.2)
49
- actionpack (= 7.0.4.2)
50
- activerecord (= 7.0.4.2)
51
- activestorage (= 7.0.4.2)
52
- activesupport (= 7.0.4.2)
48
+ actiontext (7.0.4.3)
49
+ actionpack (= 7.0.4.3)
50
+ activerecord (= 7.0.4.3)
51
+ activestorage (= 7.0.4.3)
52
+ activesupport (= 7.0.4.3)
53
53
  globalid (>= 0.6.0)
54
54
  nokogiri (>= 1.8.5)
55
- actionview (7.0.4.2)
56
- activesupport (= 7.0.4.2)
55
+ actionview (7.0.4.3)
56
+ activesupport (= 7.0.4.3)
57
57
  builder (~> 3.1)
58
58
  erubi (~> 1.4)
59
59
  rails-dom-testing (~> 2.0)
60
60
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
61
- activejob (7.0.4.2)
62
- activesupport (= 7.0.4.2)
61
+ activejob (7.0.4.3)
62
+ activesupport (= 7.0.4.3)
63
63
  globalid (>= 0.3.6)
64
- activemodel (7.0.4.2)
65
- activesupport (= 7.0.4.2)
66
- activerecord (7.0.4.2)
67
- activemodel (= 7.0.4.2)
68
- activesupport (= 7.0.4.2)
69
- activestorage (7.0.4.2)
70
- actionpack (= 7.0.4.2)
71
- activejob (= 7.0.4.2)
72
- activerecord (= 7.0.4.2)
73
- activesupport (= 7.0.4.2)
64
+ activemodel (7.0.4.3)
65
+ activesupport (= 7.0.4.3)
66
+ activerecord (7.0.4.3)
67
+ activemodel (= 7.0.4.3)
68
+ activesupport (= 7.0.4.3)
69
+ activestorage (7.0.4.3)
70
+ actionpack (= 7.0.4.3)
71
+ activejob (= 7.0.4.3)
72
+ activerecord (= 7.0.4.3)
73
+ activesupport (= 7.0.4.3)
74
74
  marcel (~> 1.0)
75
75
  mini_mime (>= 1.1.0)
76
- activesupport (7.0.4.2)
76
+ activesupport (7.0.4.3)
77
77
  concurrent-ruby (~> 1.0, >= 1.0.2)
78
78
  i18n (>= 1.6, < 2)
79
79
  minitest (>= 5.1)
@@ -92,12 +92,12 @@ GEM
92
92
  erubi (1.12.0)
93
93
  globalid (1.1.0)
94
94
  activesupport (>= 5.0)
95
- i18n (1.12.0)
95
+ i18n (1.13.0)
96
96
  concurrent-ruby (~> 1.0)
97
97
  json (2.6.3)
98
- loofah (2.19.1)
98
+ loofah (2.21.3)
99
99
  crass (~> 1.0.2)
100
- nokogiri (>= 1.5.9)
100
+ nokogiri (>= 1.12.0)
101
101
  mail (2.8.1)
102
102
  mini_mime (>= 0.1.1)
103
103
  net-imap
@@ -116,84 +116,82 @@ GEM
116
116
  timeout
117
117
  net-smtp (0.3.3)
118
118
  net-protocol
119
- nio4r (2.5.8)
120
- nokogiri (1.14.2-x86_64-linux)
119
+ nio4r (2.5.9)
120
+ nokogiri (1.15.0-x86_64-linux)
121
121
  racc (~> 1.4)
122
- parallel (1.22.1)
123
- parser (3.2.1.1)
122
+ parallel (1.23.0)
123
+ parser (3.2.2.1)
124
124
  ast (~> 2.4.1)
125
125
  racc (1.6.2)
126
- rack (2.2.6.3)
127
- rack-test (2.0.2)
126
+ rack (2.2.7)
127
+ rack-test (2.1.0)
128
128
  rack (>= 1.3)
129
- rails (7.0.4.2)
130
- actioncable (= 7.0.4.2)
131
- actionmailbox (= 7.0.4.2)
132
- actionmailer (= 7.0.4.2)
133
- actionpack (= 7.0.4.2)
134
- actiontext (= 7.0.4.2)
135
- actionview (= 7.0.4.2)
136
- activejob (= 7.0.4.2)
137
- activemodel (= 7.0.4.2)
138
- activerecord (= 7.0.4.2)
139
- activestorage (= 7.0.4.2)
140
- activesupport (= 7.0.4.2)
129
+ rails (7.0.4.3)
130
+ actioncable (= 7.0.4.3)
131
+ actionmailbox (= 7.0.4.3)
132
+ actionmailer (= 7.0.4.3)
133
+ actionpack (= 7.0.4.3)
134
+ actiontext (= 7.0.4.3)
135
+ actionview (= 7.0.4.3)
136
+ activejob (= 7.0.4.3)
137
+ activemodel (= 7.0.4.3)
138
+ activerecord (= 7.0.4.3)
139
+ activestorage (= 7.0.4.3)
140
+ activesupport (= 7.0.4.3)
141
141
  bundler (>= 1.15.0)
142
- railties (= 7.0.4.2)
142
+ railties (= 7.0.4.3)
143
143
  rails-dom-testing (2.0.3)
144
144
  activesupport (>= 4.2.0)
145
145
  nokogiri (>= 1.6)
146
146
  rails-html-sanitizer (1.5.0)
147
147
  loofah (~> 2.19, >= 2.19.1)
148
- railties (7.0.4.2)
149
- actionpack (= 7.0.4.2)
150
- activesupport (= 7.0.4.2)
148
+ railties (7.0.4.3)
149
+ actionpack (= 7.0.4.3)
150
+ activesupport (= 7.0.4.3)
151
151
  method_source
152
152
  rake (>= 12.2)
153
153
  thor (~> 1.0)
154
154
  zeitwerk (~> 2.5)
155
155
  rainbow (3.1.1)
156
156
  rake (13.0.6)
157
- regexp_parser (2.7.0)
157
+ regexp_parser (2.8.0)
158
158
  request_store (1.5.1)
159
159
  rack (>= 1.4)
160
160
  rexml (3.2.5)
161
- rubocop (1.48.0)
161
+ rubocop (1.51.0)
162
162
  json (~> 2.3)
163
163
  parallel (~> 1.10)
164
164
  parser (>= 3.2.0.0)
165
165
  rainbow (>= 2.2.2, < 4.0)
166
166
  regexp_parser (>= 1.8, < 3.0)
167
167
  rexml (>= 3.2.5, < 4.0)
168
- rubocop-ast (>= 1.26.0, < 2.0)
168
+ rubocop-ast (>= 1.28.0, < 2.0)
169
169
  ruby-progressbar (~> 1.7)
170
170
  unicode-display_width (>= 2.4.0, < 3.0)
171
- rubocop-ast (1.27.0)
171
+ rubocop-ast (1.28.1)
172
172
  parser (>= 3.2.1.0)
173
- rubocop-rails (2.18.0)
173
+ rubocop-rails (2.19.1)
174
174
  activesupport (>= 4.2.0)
175
175
  rack (>= 1.1)
176
176
  rubocop (>= 1.33.0, < 2.0)
177
177
  ruby-progressbar (1.13.0)
178
178
  ruby2_keywords (0.0.4)
179
- schemacop (3.0.22)
179
+ schemacop (3.0.24)
180
180
  activesupport (>= 4.0)
181
181
  ruby2_keywords (= 0.0.4)
182
182
  simple_form (5.2.0)
183
183
  actionpack (>= 5.2)
184
184
  activemodel (>= 5.2)
185
- thor (1.2.1)
185
+ thor (1.2.2)
186
186
  timeout (0.3.2)
187
187
  tzinfo (2.0.6)
188
188
  concurrent-ruby (~> 1.0)
189
189
  unicode-display_width (2.4.2)
190
- webrick (1.7.0)
191
190
  websocket-driver (0.7.5)
192
191
  websocket-extensions (>= 0.1.0)
193
192
  websocket-extensions (0.1.5)
194
- yard (0.9.28)
195
- webrick (~> 1.7.0)
196
- zeitwerk (2.6.7)
193
+ yard (0.9.34)
194
+ zeitwerk (2.6.8)
197
195
 
198
196
  PLATFORMS
199
197
  x86_64-linux
@@ -205,4 +203,4 @@ DEPENDENCIES
205
203
  yard (>= 0.9.28)
206
204
 
207
205
  BUNDLED WITH
208
- 2.3.26
206
+ 2.4.13
data/compony.gemspec CHANGED
@@ -2,31 +2,31 @@
2
2
  # This file is auto-generated via: 'rake gemspec'.
3
3
 
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: compony 0.0.1 ruby lib
5
+ # stub: compony 0.0.2 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "compony".freeze
9
- s.version = "0.0.1"
9
+ s.version = "0.0.2".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 = "2023-05-12"
15
- s.files = [".gitignore".freeze, ".ruby-version".freeze, ".yardopts".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/form.rb".freeze, "lib/compony/components/resourceful/destroy.rb".freeze, "lib/compony/components/resourceful/edit.rb".freeze, "lib/compony/components/resourceful/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/base.rb".freeze, "lib/compony/model_fields/boolean.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/float.rb".freeze, "lib/compony/model_fields/integer.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_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]
14
+ s.date = "2024-03-25"
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/form.rb".freeze, "lib/compony/components/resourceful/destroy.rb".freeze, "lib/compony/components/resourceful/edit.rb".freeze, "lib/compony/components/resourceful/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/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/float.rb".freeze, "lib/compony/model_fields/integer.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_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]
16
16
  s.required_ruby_version = Gem::Requirement.new(">= 3.0.0".freeze)
17
- s.rubygems_version = "3.4.10".freeze
17
+ s.rubygems_version = "3.5.6".freeze
18
18
  s.summary = "Needs summary".freeze
19
19
 
20
20
  s.specification_version = 4
21
21
 
22
- s.add_development_dependency(%q<yard>.freeze, [">= 0.9.28"])
23
- s.add_development_dependency(%q<rubocop>.freeze, [">= 1.48"])
24
- s.add_development_dependency(%q<rubocop-rails>.freeze, [">= 2.18.0"])
25
- s.add_runtime_dependency(%q<request_store>.freeze, [">= 1.5"])
26
- s.add_runtime_dependency(%q<dyny>.freeze, [">= 0.0.3"])
27
- s.add_runtime_dependency(%q<schemacop>.freeze, [">= 3.0.17"])
28
- s.add_runtime_dependency(%q<simple_form>.freeze, [">= 5.1.0"])
29
- s.add_runtime_dependency(%q<dslblend>.freeze, [">= 0.0.3"])
30
- s.add_runtime_dependency(%q<anchormodel>.freeze, ["~> 0.1.2"])
31
- s.add_runtime_dependency(%q<cancancan>.freeze, ["~> 3.4.0"])
22
+ s.add_development_dependency(%q<yard>.freeze, [">= 0.9.28".freeze])
23
+ s.add_development_dependency(%q<rubocop>.freeze, [">= 1.48".freeze])
24
+ s.add_development_dependency(%q<rubocop-rails>.freeze, [">= 2.18.0".freeze])
25
+ s.add_runtime_dependency(%q<request_store>.freeze, [">= 1.5".freeze])
26
+ s.add_runtime_dependency(%q<dyny>.freeze, [">= 0.0.3".freeze])
27
+ s.add_runtime_dependency(%q<schemacop>.freeze, [">= 3.0.17".freeze])
28
+ s.add_runtime_dependency(%q<simple_form>.freeze, [">= 5.1.0".freeze])
29
+ s.add_runtime_dependency(%q<dslblend>.freeze, [">= 0.0.3".freeze])
30
+ s.add_runtime_dependency(%q<anchormodel>.freeze, ["~> 0.1.2".freeze])
31
+ s.add_runtime_dependency(%q<cancancan>.freeze, ["~> 3.4.0".freeze])
32
32
  end
@@ -6,6 +6,9 @@ de:
6
6
  false: 'Nein'
7
7
  feasibility:
8
8
  has_dependent_models: 'es gibt abhängige %{dependent_class}'
9
+ model_fields:
10
+ attachment:
11
+ download: 'Herunterladen'
9
12
  components:
10
13
  form:
11
14
  submit: 'Senden'
@@ -6,6 +6,9 @@ en:
6
6
  no: 'No'
7
7
  feasibility:
8
8
  has_dependent_models: 'there are dependent %{dependent_class}'
9
+ model_fields:
10
+ attachment:
11
+ download: 'Download'
9
12
  components:
10
13
  form:
11
14
  submit: 'Submit'
@@ -3,13 +3,24 @@ require 'active_support/concern'
3
3
  module Compony
4
4
  module ComponentMixins
5
5
  module Default
6
- # This module contains all methods for Component that concern labelling and look
6
+ # api description
7
+ # This module contains all methods for Component that concern labelling and look.
7
8
  module Labelling
8
9
  extend ActiveSupport::Concern
9
10
 
10
- # DSL method and accessor
11
- # When assigning via DSL, pass format as first parameter.
12
- # When accessing the value, pass foramt as named parameter
11
+ # DSL method and accessor When assigning via DSL, pass format as first
12
+ # parameter. When accessing the value, pass format as named parameter
13
+ # (e.g. `format: :short`). <br/> A component either generates labels
14
+ # without data (e.g. "New user") or with data (e.g. "Edit John Doe").
15
+ # This needs to be consistent across all formats. If the block generates
16
+ # labels with data, the label block must take exactly one argument,
17
+ # otherwise none. Label blocks with data are given the data as argument.
18
+ # The block is expected to return the label in the given format. <br/>
19
+ # Examples:
20
+ # - Setting a block with data: `label(:short){ |data| "Edit #{data.label}" }`
21
+ # - Setting a block without data: `label(:short){ 'New user' }`
22
+ # - Reading a component's label with data: `comp.label(User.first, format: :short)`
23
+ # - Reading a component's label without data: `comp.label(format: :short)`
13
24
  def label(data_or_format = nil, format: :long, &block)
14
25
  format = data_or_format if block_given?
15
26
  format ||= :long
@@ -42,7 +53,8 @@ module Compony
42
53
  end
43
54
  end
44
55
 
45
- # DSL method and accessor
56
+ # DSL method and accessor for an icon.
57
+ # While this is not used in Compony directly, this is useful if your front-end uses an icon library such as fontawesome.
46
58
  def icon(&block)
47
59
  if block_given?
48
60
  @icon_block = block
@@ -52,6 +64,7 @@ module Compony
52
64
  end
53
65
 
54
66
  # DSL method and accessor
67
+ # While this is not used in Compony directly, this is useful if you use a custom button component class that supports colors.
55
68
  def color(&block)
56
69
  if block_given?
57
70
  @color_block = block
@@ -2,6 +2,10 @@ module Compony
2
2
  module ComponentMixins
3
3
  module Default
4
4
  module Standalone
5
+ # @api description
6
+ # Verb DSL override specifically for resourceful components
7
+ # @see Compony::ComponentMixins::Default::Standalone::VerbDsl
8
+ # @see Compony::ComponentMixins::Resourceful
5
9
  class ResourcefulVerbDsl < VerbDsl
6
10
  def initialize(...)
7
11
  # All resourceful components have a load_data_block, which defaults to the one defined in Resource, defaulting to finding the record.
@@ -9,6 +13,7 @@ module Compony
9
13
  super
10
14
  end
11
15
 
16
+ # For internal usage only, processes the block and returns a config hash.
12
17
  def to_conf(&)
13
18
  return super.deep_merge({
14
19
  load_data_block: @load_data_block,
@@ -15,6 +15,7 @@ module Compony
15
15
  @layout = true # can be overriden by false or a string
16
16
  end
17
17
 
18
+ # For internal usage only, processes the block and returns a config hash.
18
19
  def to_conf(&block)
19
20
  evaluate(&block)
20
21
  @component = block.binding.eval('self') # Fetches the component holding this DSL call (via the block)
@@ -31,7 +32,9 @@ module Compony
31
32
 
32
33
  protected
33
34
 
34
- # DSL
35
+ # DSL call for defining a config for a verb. The block runs within the verb DSL, positional and named arguments are passed to the verb DSL.
36
+ # @param verb [Symbol] The HTTP verb the config is for (e.g. :get, :post etc.)
37
+ # @see Compony::ComponentMixins::Default::Standalone::VerbDsl
35
38
  def verb(verb, *args, **nargs, &)
36
39
  verb = verb.to_sym
37
40
  verb_dsl_class = @component.resourceful? ? ResourcefulVerbDsl : VerbDsl
@@ -40,12 +43,15 @@ module Compony
40
43
  end
41
44
 
42
45
  # DSL
46
+ # Defines that for this component, no authentication should be performed.
43
47
  def skip_authentication!
44
48
  @skip_authentication = true
45
49
  end
46
50
 
47
51
  # DSL
48
- # Defaults to Rails' default (layouts/application)
52
+ # Speficies the Rails layout (under `app/views/layouts`) that should be used to render this component.
53
+ # Defaults to Rails' default (`layouts/application`) if the method is never called.
54
+ # @param layout [String] name of the layout as you would give it to a Rails controller's `render` method
49
55
  def layout(layout)
50
56
  @layout = layout.to_s
51
57
  end
@@ -2,6 +2,10 @@ module Compony
2
2
  module ComponentMixins
3
3
  module Default
4
4
  module Standalone
5
+ # @api description
6
+ # DSL for speficying verb configs within a standalone config.
7
+ # @see Compony::ComponentMixins::Default::Standalone::VerbDsl for the verb DSL for resourceful components
8
+ # @see Compony::ComponentMixins::Default::Standalone::StandaloneDsl
5
9
  class VerbDsl < Dslblend::Base
6
10
  AVAILABLE_VERBS = %i[get head post put delete connect options trace patch].freeze
7
11
 
@@ -17,6 +21,7 @@ module Compony
17
21
  @authorize_block = nil
18
22
  end
19
23
 
24
+ # For internal usage only, processes the block and returns a config hash.
20
25
  def to_conf(&)
21
26
  evaluate(&) if block_given?
22
27
  return {
@@ -1,7 +1,8 @@
1
1
  module Compony
2
2
  module ComponentMixins
3
3
  module Default
4
- # This contains all default component logic concerning standalone functionality
4
+ # @api description
5
+ # This contains all default component logic concerning standalone functionality. The module is included in every component.
5
6
  module Standalone
6
7
  extend ActiveSupport::Concern
7
8
 
@@ -12,8 +13,11 @@ module Compony
12
13
  attr_reader :standalone_configs
13
14
  end
14
15
 
15
- # Called by fab_controller when a request is issued.
16
+ # Called by compony_controller when a request is issued.
16
17
  # This is the entrypoint where a request enters the Component world.
18
+ # @param verb_config [Hash] The config generated by Compony::ComponentMixins::Default::Standalone::VerbDsl#to_conf
19
+ # @param controller [ComponyController] The controller instance that calls this method.
20
+ # @see ComponyController
17
21
  def on_standalone_access(verb_config, controller)
18
22
  # Register as root comp
19
23
  if parent_comp.nil?
@@ -8,6 +8,7 @@ module Compony
8
8
 
9
9
  def value_for(data, link_to_component: nil, link_opts: {}, controller: nil)
10
10
  if link_to_component
11
+ fail('Must pass controller if link_to_component is given.') unless controller
11
12
  return transform_and_join(data.send(@name), controller:) do |el|
12
13
  el.nil? ? nil : controller.helpers.compony_link(link_to_component, el, **link_opts)
13
14
  end
@@ -0,0 +1,20 @@
1
+ module Compony
2
+ module ModelFields
3
+ # @api description
4
+ # Model field type representing an ActiveStorage attachment.
5
+ class Attachment < Base
6
+ def value_for(data, controller: nil, **_)
7
+ return transform_and_join(data.send(@name), controller:) do |el|
8
+ fail('Must pass controller to generate the link to the attachment.') unless controller
9
+ return nil unless el.attached?
10
+ return controller.helpers.link_to(I18n.t('compony.model_fields.attachment.download'), controller.helpers.rails_blob_path(el))
11
+ end
12
+ end
13
+
14
+ def simpleform_input(form, _component, accept: nil, **input_opts)
15
+ input_opts.merge!(input_html: { accept: }) if accept
16
+ return form.input(:proof_photo, **input_opts)
17
+ end
18
+ end
19
+ end
20
+ end
@@ -2,7 +2,7 @@ module Compony
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- PATCH = 1
5
+ PATCH = 2
6
6
 
7
7
  EDGE = false
8
8
 
data/lib/compony.rb CHANGED
@@ -11,7 +11,7 @@ module Compony
11
11
  # Setter for the global button component class. This allows you to implement a
12
12
  # custom button component and have all Compony button helpers use your custom
13
13
  # button component instead of {Compony::Components::Button}.
14
- # @param button_component_class [Class] Your custom button component class (inherit from {Compony::Components::Button} or {Compony::Component})
14
+ # @param button_component_class [String] Name of your custom button component class (inherit from {Compony::Components::Button} or {Compony::Component})
15
15
  def self.button_component_class=(button_component_class)
16
16
  @button_component_class = button_component_class
17
17
  end
@@ -22,6 +22,7 @@ module Compony
22
22
  # the field type. The array is queried in order, if the first namespace does not
23
23
  # contain the class we're looking for, the next is considered and so on.
24
24
  # The classes defined in the namespace must inherit from Compony::ModelFields::Base
25
+ # @param model_field_namespaces [Array] Array of strings, the names of the namespaces in the order they should be searched
25
26
  def self.model_field_namespaces=(model_field_namespaces)
26
27
  @model_field_namespaces = model_field_namespaces
27
28
  end
@@ -34,6 +35,7 @@ module Compony
34
35
  # by {ComponyController} and the easiest way to achieve this is to implement
35
36
  # the action in your `ApplicationController`. If this is never called,
36
37
  # authentication is disabled.
38
+ # @param authentication_before_action [Symbol] Name of the method you want to call for authentication
37
39
  def self.authentication_before_action=(authentication_before_action)
38
40
  @authentication_before_action = authentication_before_action.to_sym
39
41
  end
@@ -98,7 +100,8 @@ module Compony
98
100
  return family_constant.const_get(comp_cst_str)
99
101
  end
100
102
 
101
- # As above but fails if none found
103
+ # Same as Compony#comp_class_for but fails if none found
104
+ # @see Compony#comp_class_for
102
105
  def self.comp_class_for!(comp_name_or_cst, model_or_family_name_or_cst)
103
106
  comp_class_for(comp_name_or_cst, model_or_family_name_or_cst) || fail(
104
107
  "No component found for [#{comp_name_or_cst.inspect}, #{model_or_family_name_or_cst.inspect}]"
@@ -131,10 +134,11 @@ module Compony
131
134
  # `Users`, `'Users'`, `:users`, `User.first`
132
135
  # @param label_opts [Hash] Options hash that will be passed to the label method (see {Compony::ComponentMixins::Default::Labelling#label})
133
136
  # @param params [Hash] GET parameters to be inclued into the path this button points to. Special case: e.g. format: :pdf -> some.url/foo/bar.pdf
137
+ # @param feasibility_action [Symbol] Name of the feasibility action that should be checked for this button, defaults to the component name
138
+ # @param feasibility_target [Symbol] Name of the feasibility target (subject) that the feasibility should be checked on, defaults to the model if given
134
139
  # @param override_kwargs [Hash] Override button options, see options for {Compony::Components::Button}
135
140
  # @see Compony::ViewHelpers#compony_button View helper providing a wrapper for this method that immediately renders a button.
136
141
  # @see Compony::Components::Button Compony::Components::Button: the default underlying implementation
137
- # @todo add doc for feasibility
138
142
  def self.button(comp_name_or_cst,
139
143
  model_or_family_name_or_cst,
140
144
  label_opts: nil,
@@ -189,7 +193,9 @@ module Compony
189
193
  end
190
194
 
191
195
  # Overwrites the keys of the current button defaults by the ones provided during the execution of a given block and restores them afterwords.
192
- # @todo document params
196
+ # This method is useful when the same set of options is to be given to a multitude of buttons.
197
+ # @param keys_to_overwrite [Hash] Options that should be given to the buttons within the block, with their values
198
+ # @param block [Block] Within this block, all omitted button options point to `keys_to_overwrite`
193
199
  def self.with_button_defaults(**keys_to_overwrite, &block)
194
200
  # Lazy initialize butto_defaults store if it hasn't been yet
195
201
  RequestStore.store[:button_defaults] ||= {}
@@ -233,8 +239,9 @@ require 'simple_form'
233
239
 
234
240
  require 'compony/engine'
235
241
  require 'compony/model_fields/base'
236
- require 'compony/model_fields/association'
237
242
  require 'compony/model_fields/anchormodel'
243
+ require 'compony/model_fields/association'
244
+ require 'compony/model_fields/attachment'
238
245
  require 'compony/model_fields/boolean'
239
246
  require 'compony/model_fields/currency'
240
247
  require 'compony/model_fields/date'
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.0.1
4
+ version: 0.0.2
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: 2023-05-12 00:00:00.000000000 Z
12
+ date: 2024-03-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: yard
@@ -160,6 +160,7 @@ files:
160
160
  - ".gitignore"
161
161
  - ".ruby-version"
162
162
  - ".yardopts"
163
+ - CHANGELOG.md
163
164
  - Gemfile
164
165
  - Gemfile.lock
165
166
  - LICENSE
@@ -191,6 +192,7 @@ files:
191
192
  - lib/compony/method_accessible_hash.rb
192
193
  - lib/compony/model_fields/anchormodel.rb
193
194
  - lib/compony/model_fields/association.rb
195
+ - lib/compony/model_fields/attachment.rb
194
196
  - lib/compony/model_fields/base.rb
195
197
  - lib/compony/model_fields/boolean.rb
196
198
  - lib/compony/model_fields/currency.rb