compony 0.9.0 → 0.10.0
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 +4 -4
- data/CHANGELOG.md +21 -0
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/VERSION +1 -1
- data/compony.gemspec +4 -4
- data/doc/ComponentGenerator.html +1 -1
- data/doc/Components.html +1 -1
- data/doc/ComponentsGenerator.html +1 -1
- data/doc/Compony/Component.html +2 -2
- data/doc/Compony/ComponentMixins/Default/Labelling.html +120 -39
- data/doc/Compony/ComponentMixins/Default/Standalone/ResourcefulVerbDsl.html +1 -1
- data/doc/Compony/ComponentMixins/Default/Standalone/StandaloneDsl.html +1 -1
- data/doc/Compony/ComponentMixins/Default/Standalone/VerbDsl.html +1 -1
- data/doc/Compony/ComponentMixins/Default/Standalone.html +1 -1
- data/doc/Compony/ComponentMixins/Default.html +1 -1
- data/doc/Compony/ComponentMixins/Resourceful.html +1 -1
- data/doc/Compony/ComponentMixins.html +1 -1
- data/doc/Compony/Components/Buttons/CssButton.html +1 -1
- data/doc/Compony/Components/Buttons/Link.html +1 -1
- data/doc/Compony/Components/Buttons.html +1 -1
- data/doc/Compony/Components/Destroy.html +13 -13
- data/doc/Compony/Components/Edit.html +17 -17
- data/doc/Compony/Components/Form.html +49 -49
- data/doc/Compony/Components/Index.html +1 -1
- data/doc/Compony/Components/List.html +346 -473
- data/doc/Compony/Components/New.html +13 -13
- data/doc/Compony/Components/Show.html +28 -28
- data/doc/Compony/Components/WithForm.html +1 -1
- data/doc/Compony/Components.html +1 -1
- data/doc/Compony/ControllerMixin.html +1 -1
- data/doc/Compony/Engine.html +1 -1
- data/doc/Compony/ExposedIntentsDsl.html +1 -1
- data/doc/Compony/Intent.html +79 -65
- data/doc/Compony/MethodAccessibleHash.html +1 -1
- data/doc/Compony/ModelFields/Anchormodel.html +1 -1
- data/doc/Compony/ModelFields/Association.html +1 -1
- data/doc/Compony/ModelFields/Attachment.html +1 -1
- data/doc/Compony/ModelFields/Base.html +1 -1
- data/doc/Compony/ModelFields/Boolean.html +1 -1
- data/doc/Compony/ModelFields/Color.html +1 -1
- data/doc/Compony/ModelFields/Currency.html +1 -1
- data/doc/Compony/ModelFields/Date.html +1 -1
- data/doc/Compony/ModelFields/Datetime.html +1 -1
- data/doc/Compony/ModelFields/Decimal.html +1 -1
- data/doc/Compony/ModelFields/Email.html +1 -1
- data/doc/Compony/ModelFields/Float.html +1 -1
- data/doc/Compony/ModelFields/Integer.html +1 -1
- data/doc/Compony/ModelFields/Percentage.html +1 -1
- data/doc/Compony/ModelFields/Phone.html +1 -1
- data/doc/Compony/ModelFields/RichText.html +1 -1
- data/doc/Compony/ModelFields/String.html +1 -1
- data/doc/Compony/ModelFields/Text.html +1 -1
- data/doc/Compony/ModelFields/Time.html +1 -1
- data/doc/Compony/ModelFields/Url.html +1 -1
- data/doc/Compony/ModelFields.html +1 -1
- data/doc/Compony/ModelMixin.html +1 -1
- data/doc/Compony/NaturalOrdering.html +1 -1
- data/doc/Compony/RequestContext.html +22 -10
- data/doc/Compony/Version.html +1 -1
- data/doc/Compony/ViewHelpers.html +1 -1
- data/doc/Compony/VirtualModel.html +1 -1
- data/doc/Compony.html +8 -8
- data/doc/ComponyController.html +1 -1
- data/doc/_index.html +8 -8
- data/doc/class_list.html +1 -1
- data/doc/file.README.html +2 -2
- data/doc/guide/nesting.md +26 -4
- data/doc/index.html +2 -2
- data/doc/method_list.html +174 -182
- data/doc/top-level-namespace.html +1 -1
- data/lib/compony/component.rb +1 -1
- data/lib/compony/component_mixins/default/labelling.rb +28 -17
- data/lib/compony/components/destroy.rb +2 -5
- data/lib/compony/components/edit.rb +2 -4
- data/lib/compony/components/form.rb +0 -1
- data/lib/compony/components/index.rb +1 -1
- data/lib/compony/components/list.rb +57 -62
- data/lib/compony/components/new.rb +0 -1
- data/lib/compony/components/show.rb +4 -11
- data/lib/compony/intent.rb +10 -4
- data/lib/compony/{exposed_intents_dsl.rb → manage_intents_dsl.rb} +6 -3
- data/lib/compony/model_mixin.rb +1 -1
- data/lib/compony/request_context.rb +10 -3
- data/lib/compony.rb +4 -4
- metadata +3 -3
data/doc/guide/nesting.md
CHANGED
|
@@ -49,9 +49,9 @@ class Components::Nestings::BinaryComparator < Compony::Component
|
|
|
49
49
|
setup do
|
|
50
50
|
# standalone and other configs are omitted in this example.
|
|
51
51
|
content do
|
|
52
|
-
concat
|
|
53
|
-
concat
|
|
54
|
-
concat
|
|
52
|
+
concat render_sub_comp(Components::Nestings::Binary, number: 1)
|
|
53
|
+
concat render_sub_comp(Components::Nestings::Binary, number: 2)
|
|
54
|
+
concat render_sub_comp(Components::Nestings::Binary, number: 3)
|
|
55
55
|
end
|
|
56
56
|
end
|
|
57
57
|
end
|
|
@@ -99,7 +99,7 @@ class Components::Nestings::BinaryComparator < Compony::Component
|
|
|
99
99
|
# standalone and other configs are omitted in this example.
|
|
100
100
|
content do
|
|
101
101
|
3.times do
|
|
102
|
-
concat
|
|
102
|
+
concat render_sub_comp(Components::Nestings::Binary)
|
|
103
103
|
end
|
|
104
104
|
end
|
|
105
105
|
end
|
|
@@ -131,4 +131,26 @@ The number 8 has the binary form 1000. Enter a number and press ENTER: [8]
|
|
|
131
131
|
|
|
132
132
|
Note that this example is completely stateless, as all the info is encoded in the URL.
|
|
133
133
|
|
|
134
|
+
## Rendering `List` as sub comp in `Show`
|
|
135
|
+
|
|
136
|
+
A pattern often used is the following:
|
|
137
|
+
|
|
138
|
+
```ruby
|
|
139
|
+
class Components::Users::Show < Compony::Components::Show
|
|
140
|
+
setup do
|
|
141
|
+
content :quotes do
|
|
142
|
+
h1 "Quotes of #{@data.label}"
|
|
143
|
+
concat render_sub_comp(:list, @data.quotes.accessible_by(current_ability), turbo_frame: :"user_#{@data.id}_quotes")
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Again, there is a lot going on here:
|
|
150
|
+
|
|
151
|
+
- Since the component inherits from the [pre-built Show component](/doc/guide/pre_built_components/show.md), it automatically displays all fields of user in its `main` content block.
|
|
152
|
+
- We add a second content block `:quotes` with a title displaying "Quotes of John Deer" and tell compony to render the appropriate list as a sub comp, giving it all quotes of John Deer that are accessible by the user currently logged in (this is a cancancan feature).
|
|
153
|
+
- `render_sub_comp` is thus given an `ActiveRecord` collection of `Quote` models and it builts an [Intent](/doc/guide/intents.md) to figure out that `Components::Quotes::List` is the component that will be instanciated, given the appropriate quotes, and rendered here.
|
|
154
|
+
- We also give `:"user_#{@data.id}_quotes"` to the parameter `turbo_frame`, which causes `render_sub_comp` to place the sub comp inside a frame that is named something like `:user_1_quotes`. Since compony's [pre-built List component](/doc/guide/pre_built_components/list.md) contains search and filter forms, the turbo frame makes sure that anything entered there does not interfere with other parameters.
|
|
155
|
+
|
|
134
156
|
[Guide index](/README.md#guide--documentation)
|
data/doc/index.html
CHANGED
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
</li><li>
|
|
91
91
|
<p>Compony seamlessly integrates with Rails and does not interfere with existing code. Using Compony, you <strong>can</strong> write your application as components, but it is still possible to have regular routes, controllers and views side-to-side to it. This way, you can migrate your applications to Compony little by little and enter and leave the Compony world as you please. It is also possible to render Compony components from regular views and vice versa.</p>
|
|
92
92
|
</li><li>
|
|
93
|
-
<p>Compony is built for Rails 7, 7.1 and 8, and fully supports Stimulus and Turbo Drive. Turbo Frames and Streams
|
|
93
|
+
<p>Compony is built for Rails 7, 7.1 and 8, and fully supports Stimulus and Turbo Drive. It is also compatible Turbo Frames and Streams, but there are not many helpers specifically targetting theme at this point..</p>
|
|
94
94
|
</li><li>
|
|
95
95
|
<p>Compony uses <a href="https://github.com/CanCanCommunity/cancancan">CanCanCan</a> for authorization but does not provide an authentication mechanism. You can easily build your own by creating login/logout components that manage cookies, and configure Compony to enforce authentication using the <code>Compony.authentication_before_action</code> setter. I have also successfully tested Compony to work with <a href="https://github.com/heartcombo/devise">Devise</a>.</p>
|
|
96
96
|
</li></ul>
|
|
@@ -199,7 +199,7 @@
|
|
|
199
199
|
</div></div>
|
|
200
200
|
|
|
201
201
|
<div id="footer">
|
|
202
|
-
Generated on
|
|
202
|
+
Generated on Mon Dec 8 15:19:19 2025 by
|
|
203
203
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
204
204
|
0.9.34 (ruby-3.3.5).
|
|
205
205
|
</div>
|