compony 0.0.8 → 0.1.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 +27 -0
- data/Gemfile.lock +2 -2
- data/compony.gemspec +15 -15
- data/config/locales/de.yml +1 -0
- data/config/locales/en.yml +1 -0
- data/lib/compony/component.rb +10 -3
- data/lib/compony/component_mixins/default/standalone.rb +6 -1
- data/lib/compony/components/destroy.rb +13 -6
- data/lib/compony/components/edit.rb +10 -4
- data/lib/compony/components/new.rb +2 -0
- data/lib/compony/model_fields/association.rb +8 -4
- data/lib/compony/model_fields/percentage.rb +9 -0
- data/lib/compony/model_mixin.rb +14 -11
- data/lib/compony/version.rb +2 -2
- data/lib/compony.rb +27 -0
- 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: cb0673f11b76f52d4405874d3efc5d36c5711a7cd563cd5029df63893b8cbefb
|
4
|
+
data.tar.gz: '0196fe47b074ce2854ba847ed2064fbcc94946c221ed1ea8521b727d733f6deb'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f2f3c18aebe32eba38249171af0eb0d5a2a27b2bebeee71c8ced5555ec2755d1e65997d3e467a8f94563c64e2fdd7ad7aee5c80fde3e67c8e5e6a1c6333c6ca
|
7
|
+
data.tar.gz: '080f57ca5947d0ae472b5cea6789aea66435064ebd356c63e797bdfbd69174c25baf9b6cf4c5895a6501a2231b34f952523d8c1d87d91c1a0d73b840f4782753'
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,30 @@
|
|
1
|
+
# 0.1.0
|
2
|
+
|
3
|
+
- Remove (hopefully) obsolete database safeguard in `resolve_association!` as we should no longer be accessing the DB.
|
4
|
+
- BREAKING: Remove `primary_key_type` and tolerate int and str as primary and foreign key in all params.
|
5
|
+
- This fixes a bug introduced in 0.0.10 breaking polymorphic relations.
|
6
|
+
- Support Rails 7.1
|
7
|
+
- No longer rely on `controller.response.body.blank?` but use `controller.response_body.nil?` instead
|
8
|
+
|
9
|
+
## Steps to perform
|
10
|
+
|
11
|
+
- Remove any calls to `primary_key_type`
|
12
|
+
|
13
|
+
# 0.0.9
|
14
|
+
|
15
|
+
- Support forms with references to tables with uuid type primary key
|
16
|
+
- Support for `owned_by` in model:
|
17
|
+
- Smart redirect
|
18
|
+
- Auto-generate a back / cancel button
|
19
|
+
- Add `clear_standalone!` to components
|
20
|
+
- Allow passing an array to `prevent` to prevent multiple actions at once
|
21
|
+
- Add features `Compony.content_before_root_comp` and `Compony.content_after_root_comp`
|
22
|
+
- Add new field kind percentage
|
23
|
+
|
24
|
+
## KNOWN BUGS
|
25
|
+
|
26
|
+
- This version breaks polymorphic relations.
|
27
|
+
|
1
28
|
# 0.0.8
|
2
29
|
|
3
30
|
- Support selecting anchormodel inputs via radio buttons
|
data/Gemfile.lock
CHANGED
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
|
5
|
+
# stub: compony 0.1.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "compony".freeze
|
9
|
-
s.version = "0.0.
|
9
|
+
s.version = "0.1.0".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-
|
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/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 = "2023-11-06"
|
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]
|
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.21".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
|
data/config/locales/de.yml
CHANGED
data/config/locales/en.yml
CHANGED
data/lib/compony/component.rb
CHANGED
@@ -146,21 +146,28 @@ module Compony
|
|
146
146
|
end
|
147
147
|
|
148
148
|
# Renders the component using the controller passsed to it and returns it as a string.
|
149
|
+
# @param standalone: pass true iff `render` is called from `render_standalone`
|
149
150
|
# Do not overwrite.
|
150
|
-
def render(controller, **locals)
|
151
|
+
def render(controller, standalone: false, **locals)
|
151
152
|
# Call before_render hook if any and backfire instance variables back to the component
|
152
153
|
RequestContext.new(self, controller, locals:).request_context.evaluate_with_backfire(&@before_render_block) if @before_render_block
|
153
154
|
# Render, unless before_render has already issued a body (e.g. through redirecting).
|
154
|
-
if controller.
|
155
|
+
if controller.response_body.nil?
|
155
156
|
fail "#{self.class.inspect} must define `content` or set a response body in `before_render`" if @content_blocks.none?
|
156
157
|
return controller.render_to_string(
|
157
158
|
type: :dyny,
|
158
|
-
locals: { content_blocks: @content_blocks, component: self, render_locals: locals },
|
159
|
+
locals: { content_blocks: @content_blocks, standalone:, component: self, render_locals: locals },
|
159
160
|
inline: <<~RUBY
|
161
|
+
if Compony.content_before_root_comp_block && standalone
|
162
|
+
Compony::RequestContext.new(component, controller, helpers: self, locals: render_locals).evaluate(&Compony.content_before_root_comp_block)
|
163
|
+
end
|
160
164
|
content_blocks.each do |block|
|
161
165
|
# Instanciate and evaluate a fresh RequestContext in order to use the buffer allocated by the ActionView (needed for `concat` calls)
|
162
166
|
Compony::RequestContext.new(component, controller, helpers: self, locals: render_locals).evaluate(&block)
|
163
167
|
end
|
168
|
+
if Compony.content_after_root_comp_block && standalone
|
169
|
+
Compony::RequestContext.new(component, controller, helpers: self, locals: render_locals).evaluate(&Compony.content_after_root_comp_block)
|
170
|
+
end
|
164
171
|
RUBY
|
165
172
|
)
|
166
173
|
else
|
@@ -88,7 +88,7 @@ module Compony
|
|
88
88
|
# Do not overwrite
|
89
89
|
def render_standalone(controller, status: nil, standalone_name: nil)
|
90
90
|
# Start the render process. This produces a nil value if before_render has already produced a response, e.g. a redirect.
|
91
|
-
rendered_html = render(controller)
|
91
|
+
rendered_html = render(controller, standalone: true)
|
92
92
|
if rendered_html.present? # If nil, a response body was already produced in the controller and we take no action here (would have DoubleRenderError)
|
93
93
|
opts = { html: rendered_html, layout: @standalone_configs[standalone_name].layout }
|
94
94
|
opts[:status] = status if status.present?
|
@@ -111,6 +111,11 @@ module Compony
|
|
111
111
|
@standalone_configs[name].deep_merge! StandaloneDsl.new(self, name, *args, **nargs).to_conf(&block)
|
112
112
|
end
|
113
113
|
|
114
|
+
# Undoes previous standalone calls
|
115
|
+
def clear_standalone!
|
116
|
+
@standalone_configs = {}
|
117
|
+
end
|
118
|
+
|
114
119
|
private
|
115
120
|
|
116
121
|
def init_standalone
|
@@ -36,14 +36,17 @@ module Compony
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
+
action :back_to_owner do
|
40
|
+
next if data_class.owner_model_attr.blank?
|
41
|
+
Compony.button(:show, @data.send(data_class.owner_model_attr), icon: :xmark, color: :secondary, label: I18n.t('compony.cancel'))
|
42
|
+
end
|
43
|
+
|
39
44
|
store_data do
|
40
45
|
# Validate params against the form's schema
|
41
|
-
local_data = @data # Capture data for usage in the Schemacop call
|
42
46
|
schema = Schemacop::Schema3.new :hash, additional_properties: true do
|
43
|
-
|
44
|
-
str
|
45
|
-
|
46
|
-
int! :id, cast_str: true
|
47
|
+
any_of! :id do
|
48
|
+
str
|
49
|
+
int cast_str: true
|
47
50
|
end
|
48
51
|
end
|
49
52
|
schema.validate!(controller.request.params)
|
@@ -58,7 +61,11 @@ module Compony
|
|
58
61
|
end
|
59
62
|
|
60
63
|
on_destroyed_redirect_path do
|
61
|
-
|
64
|
+
if data_class.owner_model_attr.present?
|
65
|
+
Compony.path(:show, @data.send(data_class.owner_model_attr))
|
66
|
+
else
|
67
|
+
Compony.path(:index, family_cst)
|
68
|
+
end
|
62
69
|
end
|
63
70
|
end
|
64
71
|
|
@@ -30,6 +30,11 @@ module Compony
|
|
30
30
|
label(:short) { |_| I18n.t('compony.components.edit.label.short') }
|
31
31
|
icon { :pencil }
|
32
32
|
|
33
|
+
action :back_to_owner do
|
34
|
+
next if data_class.owner_model_attr.blank?
|
35
|
+
Compony.button(:show, @data.send(data_class.owner_model_attr), icon: :xmark, color: :secondary, label: I18n.t('compony.cancel'))
|
36
|
+
end
|
37
|
+
|
33
38
|
content do
|
34
39
|
concat form_comp.render(controller, data: @data)
|
35
40
|
end
|
@@ -39,10 +44,9 @@ module Compony
|
|
39
44
|
local_form_comp = form_comp # Capture form_comp for usage in the Schemacop call
|
40
45
|
local_data = @data # Capture data for usage in the Schemacop call
|
41
46
|
schema = Schemacop::Schema3.new :hash, additional_properties: true do
|
42
|
-
|
43
|
-
str
|
44
|
-
|
45
|
-
int! :id, cast_str: true
|
47
|
+
any_of! :id do
|
48
|
+
str
|
49
|
+
int cast_str: true
|
46
50
|
end
|
47
51
|
hsh? local_form_comp.schema_wrapper_key_for(local_data), &local_form_comp.schema_block_for(local_data)
|
48
52
|
end
|
@@ -65,6 +69,8 @@ module Compony
|
|
65
69
|
on_updated_redirect_path do
|
66
70
|
if Compony.comp_class_for(:show, @data)
|
67
71
|
Compony.path(:show, @data)
|
72
|
+
elsif data_class.owner_model_attr.present?
|
73
|
+
Compony.path(:show, @data.send(data_class.owner_model_attr))
|
68
74
|
else
|
69
75
|
Compony.path(:index, @data)
|
70
76
|
end
|
@@ -64,6 +64,8 @@ module Compony
|
|
64
64
|
on_created_redirect_path do
|
65
65
|
if Compony.comp_class_for(:show, @data)
|
66
66
|
Compony.path(:show, @data)
|
67
|
+
elsif data_class.owner_model_attr.present?
|
68
|
+
Compony.path(:show, @data.send(data_class.owner_model_attr))
|
67
69
|
else
|
68
70
|
Compony.path(:index, @data)
|
69
71
|
end
|
@@ -27,12 +27,18 @@ module Compony
|
|
27
27
|
if multi?
|
28
28
|
return proc do
|
29
29
|
ary? local_schema_key do
|
30
|
-
list :
|
30
|
+
list :any_of do
|
31
|
+
int cast_str: true
|
32
|
+
str
|
33
|
+
end
|
31
34
|
end
|
32
35
|
end
|
33
36
|
else
|
34
37
|
return proc do
|
35
|
-
|
38
|
+
any_of? local_schema_key do
|
39
|
+
str
|
40
|
+
int cast_str: true
|
41
|
+
end
|
36
42
|
end
|
37
43
|
end
|
38
44
|
end
|
@@ -55,8 +61,6 @@ module Compony
|
|
55
61
|
@multi = association_info.macro == :has_many
|
56
62
|
id_name = "#{@name.to_s.singularize}_id"
|
57
63
|
@schema_key = @multi ? id_name.pluralize.to_sym : id_name.to_sym
|
58
|
-
rescue ActiveRecord::NoDatabaseError
|
59
|
-
Rails.logger.warn('Warning: Compony could not auto-detect fields due to missing database. This is ok when running db:create.')
|
60
64
|
end
|
61
65
|
end
|
62
66
|
end
|
data/lib/compony/model_mixin.rb
CHANGED
@@ -5,7 +5,7 @@ module Compony
|
|
5
5
|
included do
|
6
6
|
class_attribute :fields, default: {}
|
7
7
|
class_attribute :feasibility_preventions, default: {}
|
8
|
-
class_attribute :
|
8
|
+
class_attribute :owner_model_attr
|
9
9
|
|
10
10
|
class_attribute :autodetect_feasibilities_completed, default: false
|
11
11
|
end
|
@@ -26,20 +26,23 @@ module Compony
|
|
26
26
|
fields[name] = Compony.model_field_class_for(type.to_s.camelize).new(name, self, **extra_attrs)
|
27
27
|
end
|
28
28
|
|
29
|
-
# DSL method, sets the
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
self.
|
29
|
+
# DSL method, sets the containing model.
|
30
|
+
# Use this when a model only makes sense within the context of another model and typically has no own index page.
|
31
|
+
# For instance, a model LineItem that belongs_to :invoice would typically be owned_by :invoice.
|
32
|
+
# Compony will automatically adjust Redirects and top actions.
|
33
|
+
def owned_by(attribute_name)
|
34
|
+
self.owner_model_attr = attribute_name.to_sym
|
35
35
|
end
|
36
36
|
|
37
37
|
# DSL method, part of the Feasibility feature
|
38
38
|
# Block must return `false` if the action should be prevented.
|
39
|
-
def prevent(
|
40
|
-
|
41
|
-
|
42
|
-
|
39
|
+
def prevent(action_names, message, &block)
|
40
|
+
action_names = [action_names] unless action_names.is_a? Enumerable
|
41
|
+
action_names.each do |action_name|
|
42
|
+
self.feasibility_preventions = feasibility_preventions.dup # Prevent cross-class contamination
|
43
|
+
feasibility_preventions[action_name.to_sym] ||= []
|
44
|
+
feasibility_preventions[action_name.to_sym] << MethodAccessibleHash.new(action_name:, message:, block:)
|
45
|
+
end
|
43
46
|
end
|
44
47
|
|
45
48
|
# DSL method, part of the Feasibility feature
|
data/lib/compony/version.rb
CHANGED
data/lib/compony.rb
CHANGED
@@ -40,6 +40,20 @@ module Compony
|
|
40
40
|
@authentication_before_action = authentication_before_action.to_sym
|
41
41
|
end
|
42
42
|
|
43
|
+
# Setter for a content block that runs before the root component gets rendered (standalone only). Usage is the same as `content`.
|
44
|
+
# The block runs between `before_render` and `render`, i.e. before the first `content` block.
|
45
|
+
def self.content_before_root_comp(&block)
|
46
|
+
fail('`Compony.content_before` requires a block.') unless block_given?
|
47
|
+
@content_before_root_comp_block = block
|
48
|
+
end
|
49
|
+
|
50
|
+
# Setter for a content block that runs after the root component gets rendered (standalone only). Usage is the same as `content`.
|
51
|
+
# The block runs after `render`, i.e. after the last `content` block.
|
52
|
+
def self.content_after_root_comp(&block)
|
53
|
+
fail('`Compony.content_after` requires a block.') unless block_given?
|
54
|
+
@content_after_root_comp_block = block
|
55
|
+
end
|
56
|
+
|
43
57
|
##########=====-------
|
44
58
|
# Configuration readers
|
45
59
|
##########=====-------
|
@@ -64,6 +78,18 @@ module Compony
|
|
64
78
|
@authentication_before_action
|
65
79
|
end
|
66
80
|
|
81
|
+
# Getter for content_before_root_comp_block
|
82
|
+
# @see Compony#content_before_root_comp
|
83
|
+
def self.content_before_root_comp_block
|
84
|
+
@content_before_root_comp_block
|
85
|
+
end
|
86
|
+
|
87
|
+
# Getter for content_after_root_comp_block
|
88
|
+
# @see Compony#content_after_root_comp
|
89
|
+
def self.content_after_root_comp_block
|
90
|
+
@content_after_root_comp_block
|
91
|
+
end
|
92
|
+
|
67
93
|
##########=====-------
|
68
94
|
# Application-wide available pure helpers
|
69
95
|
##########=====-------
|
@@ -253,6 +279,7 @@ require 'compony/model_fields/decimal'
|
|
253
279
|
require 'compony/model_fields/email'
|
254
280
|
require 'compony/model_fields/float'
|
255
281
|
require 'compony/model_fields/integer'
|
282
|
+
require 'compony/model_fields/percentage'
|
256
283
|
require 'compony/model_fields/phone'
|
257
284
|
require 'compony/model_fields/rich_text'
|
258
285
|
require 'compony/model_fields/string'
|
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
|
4
|
+
version: 0.1.0
|
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-
|
12
|
+
date: 2023-11-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: yard
|
@@ -203,6 +203,7 @@ files:
|
|
203
203
|
- lib/compony/model_fields/email.rb
|
204
204
|
- lib/compony/model_fields/float.rb
|
205
205
|
- lib/compony/model_fields/integer.rb
|
206
|
+
- lib/compony/model_fields/percentage.rb
|
206
207
|
- lib/compony/model_fields/phone.rb
|
207
208
|
- lib/compony/model_fields/rich_text.rb
|
208
209
|
- lib/compony/model_fields/string.rb
|