compony 0.8.1 → 0.9.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 +12 -0
- data/Gemfile.lock +1 -1
- data/VERSION +1 -1
- data/compony.gemspec +2 -2
- data/doc/ComponentGenerator.html +1 -1
- data/doc/Components.html +1 -1
- data/doc/ComponentsGenerator.html +1 -1
- data/doc/Compony/Component.html +1 -1
- data/doc/Compony/ComponentMixins/Default/Labelling.html +1 -1
- 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 +1 -1
- data/doc/Compony/Components/Index.html +1 -1
- data/doc/Compony/Components/List.html +1 -1
- data/doc/Compony/Components/New.html +1 -1
- data/doc/Compony/Components/Show.html +23 -23
- 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 +130 -90
- data/doc/Compony/MethodAccessibleHash.html +1 -1
- data/doc/Compony/ModelFields/Anchormodel.html +1 -1
- data/doc/Compony/ModelFields/Association.html +2 -2
- 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 +11 -33
- 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 +3 -3
- data/doc/ComponyController.html +1 -1
- data/doc/_index.html +1 -1
- data/doc/file.README.html +1 -1
- data/doc/guide/intents.md +3 -3
- data/doc/index.html +1 -1
- data/doc/top-level-namespace.html +1 -1
- data/lib/compony/components/destroy.rb +4 -1
- data/lib/compony/components/edit.rb +4 -1
- data/lib/compony/components/show.rb +4 -1
- data/lib/compony/intent.rb +21 -16
- data/lib/compony/model_fields/association.rb +1 -1
- data/lib/compony/request_context.rb +2 -3
- data/lib/compony.rb +2 -2
- metadata +1 -1
|
@@ -230,7 +230,7 @@
|
|
|
230
230
|
</div>
|
|
231
231
|
|
|
232
232
|
<div id="footer">
|
|
233
|
-
Generated on Fri Nov 28
|
|
233
|
+
Generated on Fri Nov 28 12:38:45 2025 by
|
|
234
234
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
235
235
|
0.9.34 (ruby-3.3.5).
|
|
236
236
|
</div>
|
|
@@ -144,7 +144,7 @@
|
|
|
144
144
|
</div>
|
|
145
145
|
|
|
146
146
|
<div id="footer">
|
|
147
|
-
Generated on Fri Nov 28
|
|
147
|
+
Generated on Fri Nov 28 12:38:45 2025 by
|
|
148
148
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
149
149
|
0.9.34 (ruby-3.3.5).
|
|
150
150
|
</div>
|
|
@@ -222,7 +222,7 @@
|
|
|
222
222
|
</div>
|
|
223
223
|
|
|
224
224
|
<div id="footer">
|
|
225
|
-
Generated on Fri Nov 28
|
|
225
|
+
Generated on Fri Nov 28 12:38:45 2025 by
|
|
226
226
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
227
227
|
0.9.34 (ruby-3.3.5).
|
|
228
228
|
</div>
|
|
@@ -222,7 +222,7 @@
|
|
|
222
222
|
</div>
|
|
223
223
|
|
|
224
224
|
<div id="footer">
|
|
225
|
-
Generated on Fri Nov 28
|
|
225
|
+
Generated on Fri Nov 28 12:38:45 2025 by
|
|
226
226
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
227
227
|
0.9.34 (ruby-3.3.5).
|
|
228
228
|
</div>
|
|
@@ -291,7 +291,7 @@
|
|
|
291
291
|
</div>
|
|
292
292
|
|
|
293
293
|
<div id="footer">
|
|
294
|
-
Generated on Fri Nov 28
|
|
294
|
+
Generated on Fri Nov 28 12:38:45 2025 by
|
|
295
295
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
296
296
|
0.9.34 (ruby-3.3.5).
|
|
297
297
|
</div>
|
|
@@ -222,7 +222,7 @@
|
|
|
222
222
|
</div>
|
|
223
223
|
|
|
224
224
|
<div id="footer">
|
|
225
|
-
Generated on Fri Nov 28
|
|
225
|
+
Generated on Fri Nov 28 12:38:45 2025 by
|
|
226
226
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
227
227
|
0.9.34 (ruby-3.3.5).
|
|
228
228
|
</div>
|
|
@@ -144,7 +144,7 @@
|
|
|
144
144
|
</div>
|
|
145
145
|
|
|
146
146
|
<div id="footer">
|
|
147
|
-
Generated on Fri Nov 28
|
|
147
|
+
Generated on Fri Nov 28 12:38:45 2025 by
|
|
148
148
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
149
149
|
0.9.34 (ruby-3.3.5).
|
|
150
150
|
</div>
|
|
@@ -144,7 +144,7 @@
|
|
|
144
144
|
</div>
|
|
145
145
|
|
|
146
146
|
<div id="footer">
|
|
147
|
-
Generated on Fri Nov 28
|
|
147
|
+
Generated on Fri Nov 28 12:38:45 2025 by
|
|
148
148
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
149
149
|
0.9.34 (ruby-3.3.5).
|
|
150
150
|
</div>
|
|
@@ -144,7 +144,7 @@
|
|
|
144
144
|
</div>
|
|
145
145
|
|
|
146
146
|
<div id="footer">
|
|
147
|
-
Generated on Fri Nov 28
|
|
147
|
+
Generated on Fri Nov 28 12:38:45 2025 by
|
|
148
148
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
149
149
|
0.9.34 (ruby-3.3.5).
|
|
150
150
|
</div>
|
|
@@ -230,7 +230,7 @@
|
|
|
230
230
|
</div>
|
|
231
231
|
|
|
232
232
|
<div id="footer">
|
|
233
|
-
Generated on Fri Nov 28
|
|
233
|
+
Generated on Fri Nov 28 12:38:45 2025 by
|
|
234
234
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
235
235
|
0.9.34 (ruby-3.3.5).
|
|
236
236
|
</div>
|
|
@@ -116,7 +116,7 @@
|
|
|
116
116
|
</div>
|
|
117
117
|
|
|
118
118
|
<div id="footer">
|
|
119
|
-
Generated on Fri Nov 28
|
|
119
|
+
Generated on Fri Nov 28 12:38:44 2025 by
|
|
120
120
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
121
121
|
0.9.34 (ruby-3.3.5).
|
|
122
122
|
</div>
|
data/doc/Compony/ModelMixin.html
CHANGED
|
@@ -519,7 +519,7 @@
|
|
|
519
519
|
</div>
|
|
520
520
|
|
|
521
521
|
<div id="footer">
|
|
522
|
-
Generated on Fri Nov 28
|
|
522
|
+
Generated on Fri Nov 28 12:38:44 2025 by
|
|
523
523
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
524
524
|
0.9.34 (ruby-3.3.5).
|
|
525
525
|
</div>
|
|
@@ -290,7 +290,7 @@
|
|
|
290
290
|
</div>
|
|
291
291
|
|
|
292
292
|
<div id="footer">
|
|
293
|
-
Generated on Fri Nov 28
|
|
293
|
+
Generated on Fri Nov 28 12:38:45 2025 by
|
|
294
294
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
295
295
|
0.9.34 (ruby-3.3.5).
|
|
296
296
|
</div>
|
|
@@ -360,7 +360,7 @@
|
|
|
360
360
|
<li class="public ">
|
|
361
361
|
<span class="summary_signature">
|
|
362
362
|
|
|
363
|
-
<a href="#render_intent-instance_method" title="#render_intent (instance method)">#<strong>render_intent</strong>
|
|
363
|
+
<a href="#render_intent-instance_method" title="#render_intent (instance method)">#<strong>render_intent</strong> ⇒ Object </a>
|
|
364
364
|
|
|
365
365
|
|
|
366
366
|
|
|
@@ -893,7 +893,7 @@
|
|
|
893
893
|
<div class="method_details ">
|
|
894
894
|
<h3 class="signature " id="render_intent-instance_method">
|
|
895
895
|
|
|
896
|
-
#<strong>render_intent</strong>
|
|
896
|
+
#<strong>render_intent</strong> ⇒ <tt>Object</tt>
|
|
897
897
|
|
|
898
898
|
|
|
899
899
|
|
|
@@ -908,29 +908,7 @@
|
|
|
908
908
|
</div>
|
|
909
909
|
</div>
|
|
910
910
|
<div class="tags">
|
|
911
|
-
<p class="tag_title">Parameters:</p>
|
|
912
|
-
<ul class="param">
|
|
913
911
|
|
|
914
|
-
<li>
|
|
915
|
-
|
|
916
|
-
<span class='name'>button</span>
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
<span class='type'>(<tt>Hash</tt>)</span>
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
<em class="default">(defaults to: <tt>{}</tt>)</em>
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
—
|
|
926
|
-
<div class='inline'>
|
|
927
|
-
<p>Parameters that will be given to the button component initializer.</p>
|
|
928
|
-
</div>
|
|
929
|
-
|
|
930
|
-
</li>
|
|
931
|
-
|
|
932
|
-
</ul>
|
|
933
|
-
|
|
934
912
|
|
|
935
913
|
</div><table class="source_code">
|
|
936
914
|
<tr>
|
|
@@ -938,15 +916,15 @@
|
|
|
938
916
|
<pre class="lines">
|
|
939
917
|
|
|
940
918
|
|
|
919
|
+
76
|
|
941
920
|
77
|
|
942
|
-
78
|
|
943
|
-
79</pre>
|
|
921
|
+
78</pre>
|
|
944
922
|
</td>
|
|
945
923
|
<td>
|
|
946
|
-
<pre class="code"><span class="info file"># File 'lib/compony/request_context.rb', line
|
|
924
|
+
<pre class="code"><span class="info file"># File 'lib/compony/request_context.rb', line 76</span>
|
|
947
925
|
|
|
948
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_render_intent'>render_intent</span><span class='lparen'>(</span><span class='op'>*</span><span class='comma'>,</span> <span class='
|
|
949
|
-
<span class='const'><span class='object_link'><a href="../Compony.html" title="Compony (module)">Compony</a></span></span><span class='period'>.</span><span class='id identifier rubyid_intent'><span class='object_link'><a href="../Compony.html#intent-class_method" title="Compony.intent (method)">intent</a></span></span><span class='lparen'>(</span><span class='op'>*</span><span class='comma'>,</span> <span class='op'>**</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_render'>render</span><span class='lparen'>(</span><span class='id identifier rubyid_controller'>controller</span><span class='comma'>,</span> <span class='id identifier rubyid_component'>component</span><span class='
|
|
926
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_render_intent'>render_intent</span><span class='lparen'>(</span><span class='op'>*</span><span class='comma'>,</span> <span class='op'>**</span><span class='rparen'>)</span>
|
|
927
|
+
<span class='const'><span class='object_link'><a href="../Compony.html" title="Compony (module)">Compony</a></span></span><span class='period'>.</span><span class='id identifier rubyid_intent'><span class='object_link'><a href="../Compony.html#intent-class_method" title="Compony.intent (method)">intent</a></span></span><span class='lparen'>(</span><span class='op'>*</span><span class='comma'>,</span> <span class='op'>**</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_render'>render</span><span class='lparen'>(</span><span class='id identifier rubyid_controller'>controller</span><span class='comma'>,</span> <span class='id identifier rubyid_component'>component</span><span class='rparen'>)</span>
|
|
950
928
|
<span class='kw'>end</span></pre>
|
|
951
929
|
</td>
|
|
952
930
|
</tr>
|
|
@@ -979,12 +957,12 @@
|
|
|
979
957
|
<pre class="lines">
|
|
980
958
|
|
|
981
959
|
|
|
960
|
+
82
|
|
982
961
|
83
|
|
983
|
-
84
|
|
984
|
-
85</pre>
|
|
962
|
+
84</pre>
|
|
985
963
|
</td>
|
|
986
964
|
<td>
|
|
987
|
-
<pre class="code"><span class="info file"># File 'lib/compony/request_context.rb', line
|
|
965
|
+
<pre class="code"><span class="info file"># File 'lib/compony/request_context.rb', line 82</span>
|
|
988
966
|
|
|
989
967
|
<span class='kw'>def</span> <span class='id identifier rubyid_render_sub_comp'>render_sub_comp</span><span class='lparen'>(</span><span class='op'>...</span><span class='rparen'>)</span>
|
|
990
968
|
<span class='id identifier rubyid_sub_comp'>sub_comp</span><span class='lparen'>(</span><span class='op'>...</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_render'>render</span><span class='lparen'>(</span><span class='id identifier rubyid_controller'>controller</span><span class='rparen'>)</span>
|
|
@@ -1094,7 +1072,7 @@
|
|
|
1094
1072
|
</div>
|
|
1095
1073
|
|
|
1096
1074
|
<div id="footer">
|
|
1097
|
-
Generated on Fri Nov 28
|
|
1075
|
+
Generated on Fri Nov 28 12:38:45 2025 by
|
|
1098
1076
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
1099
1077
|
0.9.34 (ruby-3.3.5).
|
|
1100
1078
|
</div>
|
data/doc/Compony/Version.html
CHANGED
|
@@ -129,7 +129,7 @@
|
|
|
129
129
|
</div>
|
|
130
130
|
|
|
131
131
|
<div id="footer">
|
|
132
|
-
Generated on Fri Nov 28
|
|
132
|
+
Generated on Fri Nov 28 12:38:44 2025 by
|
|
133
133
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
134
134
|
0.9.34 (ruby-3.3.5).
|
|
135
135
|
</div>
|
|
@@ -222,7 +222,7 @@
|
|
|
222
222
|
</div>
|
|
223
223
|
|
|
224
224
|
<div id="footer">
|
|
225
|
-
Generated on Fri Nov 28
|
|
225
|
+
Generated on Fri Nov 28 12:38:44 2025 by
|
|
226
226
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
227
227
|
0.9.34 (ruby-3.3.5).
|
|
228
228
|
</div>
|
|
@@ -142,7 +142,7 @@
|
|
|
142
142
|
</div>
|
|
143
143
|
|
|
144
144
|
<div id="footer">
|
|
145
|
-
Generated on Fri Nov 28
|
|
145
|
+
Generated on Fri Nov 28 12:38:44 2025 by
|
|
146
146
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
147
147
|
0.9.34 (ruby-3.3.5).
|
|
148
148
|
</div>
|
data/doc/Compony.html
CHANGED
|
@@ -1541,8 +1541,8 @@
|
|
|
1541
1541
|
<td>
|
|
1542
1542
|
<pre class="code"><span class="info file"># File 'lib/compony.rb', line 135</span>
|
|
1543
1543
|
|
|
1544
|
-
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_path'>path</span><span class='lparen'>(</span><span class='id identifier rubyid_comp_name_or_cst_or_class'>comp_name_or_cst_or_class</span><span class='comma'>,</span> <span class='id identifier rubyid_model_or_family_name_or_cst'>model_or_family_name_or_cst</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='op'
|
|
1545
|
-
<span class='id identifier rubyid_intent'>intent</span><span class='lparen'>(</span><span class='id identifier rubyid_comp_name_or_cst_or_class'>comp_name_or_cst_or_class</span><span class='comma'>,</span> <span class='id identifier rubyid_model_or_family_name_or_cst'>model_or_family_name_or_cst</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_path'>path</span><span class='lparen'>(</span><span class='op'
|
|
1544
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_path'>path</span><span class='lparen'>(</span><span class='id identifier rubyid_comp_name_or_cst_or_class'>comp_name_or_cst_or_class</span><span class='comma'>,</span> <span class='id identifier rubyid_model_or_family_name_or_cst'>model_or_family_name_or_cst</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='op'>*</span><span class='comma'>,</span> <span class='op'>**</span><span class='rparen'>)</span>
|
|
1545
|
+
<span class='id identifier rubyid_intent'>intent</span><span class='lparen'>(</span><span class='id identifier rubyid_comp_name_or_cst_or_class'>comp_name_or_cst_or_class</span><span class='comma'>,</span> <span class='id identifier rubyid_model_or_family_name_or_cst'>model_or_family_name_or_cst</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_path'>path</span><span class='lparen'>(</span><span class='op'>*</span><span class='comma'>,</span> <span class='op'>**</span><span class='rparen'>)</span>
|
|
1546
1546
|
<span class='kw'>end</span></pre>
|
|
1547
1547
|
</td>
|
|
1548
1548
|
</tr>
|
|
@@ -1674,7 +1674,7 @@
|
|
|
1674
1674
|
</div>
|
|
1675
1675
|
|
|
1676
1676
|
<div id="footer">
|
|
1677
|
-
Generated on Fri Nov 28
|
|
1677
|
+
Generated on Fri Nov 28 12:38:44 2025 by
|
|
1678
1678
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
1679
1679
|
0.9.34 (ruby-3.3.5).
|
|
1680
1680
|
</div>
|
data/doc/ComponyController.html
CHANGED
|
@@ -114,7 +114,7 @@
|
|
|
114
114
|
</div>
|
|
115
115
|
|
|
116
116
|
<div id="footer">
|
|
117
|
-
Generated on Fri Nov 28
|
|
117
|
+
Generated on Fri Nov 28 12:38:45 2025 by
|
|
118
118
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
119
119
|
0.9.34 (ruby-3.3.5).
|
|
120
120
|
</div>
|
data/doc/_index.html
CHANGED
|
@@ -622,7 +622,7 @@
|
|
|
622
622
|
</div>
|
|
623
623
|
|
|
624
624
|
<div id="footer">
|
|
625
|
-
Generated on Fri Nov 28
|
|
625
|
+
Generated on Fri Nov 28 12:38:43 2025 by
|
|
626
626
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
627
627
|
0.9.34 (ruby-3.3.5).
|
|
628
628
|
</div>
|
data/doc/file.README.html
CHANGED
|
@@ -199,7 +199,7 @@
|
|
|
199
199
|
</div></div>
|
|
200
200
|
|
|
201
201
|
<div id="footer">
|
|
202
|
-
Generated on Fri Nov 28
|
|
202
|
+
Generated on Fri Nov 28 12:38:44 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>
|
data/doc/guide/intents.md
CHANGED
|
@@ -64,7 +64,7 @@ Use the `button` argument to customize the generated button. Example:
|
|
|
64
64
|
```ruby
|
|
65
65
|
setup do
|
|
66
66
|
content do
|
|
67
|
-
div render_intent(:show, User.first,
|
|
67
|
+
div render_intent(:show, User.first, style: :link, label: { format: :short })`
|
|
68
68
|
end
|
|
69
69
|
end
|
|
70
70
|
```
|
|
@@ -114,7 +114,7 @@ All button styles support the following keyword arguments to their initializer:
|
|
|
114
114
|
|
|
115
115
|
Note that since buttons are full components, they can be [nested](/doc/guide/nesting.md) into another component by providing `parent_comp`. If called from within a component's `content` block, the helper `render_intent` does this automatically.
|
|
116
116
|
|
|
117
|
-
As implicitely mentioned above, Compony buttons are referenced to by a name called a style (`:css_button` actually points to `Compony::Components::Buttons::CssButton`). When rendering an intent, the style can be passed as an argument: `render_intent(:show, User.first,
|
|
117
|
+
As implicitely mentioned above, Compony buttons are referenced to by a name called a style (`:css_button` actually points to `Compony::Components::Buttons::CssButton`). When rendering an intent, the style can be passed as an argument: `render_intent(:show, User.first, style: :link)` and the intent will automatically instanciate the desired component class.
|
|
118
118
|
|
|
119
119
|
Note: it is possible to use a button component to submit a form. In order to achieve this, you must implement a hidden submit button (for handling keyboard Enter and Return), as well as pass `onclick: "this.closest('form').requestSubmit(); return false;"` as an argument. See the pre-built Form component's implementation for an example.
|
|
120
120
|
|
|
@@ -124,7 +124,7 @@ In your application, you will likely want to implement your own button styles. C
|
|
|
124
124
|
|
|
125
125
|
Once your button class is ready, register it in `config/initializers/compony.rb` with: `Compony.register_button_style :my_button, '::Components::Commons::MyButton'`. You can also change the default button style there using: `Compony.default_button_style = :my_button`.
|
|
126
126
|
|
|
127
|
-
If you have multiple kinds of buttons (e.g. dropdown items, pill-style buttons, compact forms etc.), you should create a separate style and button component class for every kind. This will make it easy to refer to them by supplying something like `
|
|
127
|
+
If you have multiple kinds of buttons (e.g. dropdown items, pill-style buttons, compact forms etc.), you should create a separate style and button component class for every kind. This will make it easy to refer to them by supplying something like `style: :dropdown_item` in `render_intent`.
|
|
128
128
|
|
|
129
129
|
## Exposed intents
|
|
130
130
|
|
data/doc/index.html
CHANGED
|
@@ -199,7 +199,7 @@
|
|
|
199
199
|
</div></div>
|
|
200
200
|
|
|
201
201
|
<div id="footer">
|
|
202
|
-
Generated on Fri Nov 28
|
|
202
|
+
Generated on Fri Nov 28 12:38:44 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>
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
</div>
|
|
103
103
|
|
|
104
104
|
<div id="footer">
|
|
105
|
-
Generated on Fri Nov 28
|
|
105
|
+
Generated on Fri Nov 28 12:38:44 2025 by
|
|
106
106
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
107
107
|
0.9.34 (ruby-3.3.5).
|
|
108
108
|
</div>
|
|
@@ -46,7 +46,10 @@ module Compony
|
|
|
46
46
|
|
|
47
47
|
exposed_intents do
|
|
48
48
|
if data_class.owner_model_attr
|
|
49
|
-
add :show, @data.send(data_class.owner_model_attr),
|
|
49
|
+
add :show, @data.send(data_class.owner_model_attr),
|
|
50
|
+
button: { icon: :xmark, color: :secondary },
|
|
51
|
+
label: I18n.t('compony.cancel'),
|
|
52
|
+
name: :back_to_owner
|
|
50
53
|
end
|
|
51
54
|
end
|
|
52
55
|
|
|
@@ -35,7 +35,10 @@ module Compony
|
|
|
35
35
|
|
|
36
36
|
exposed_intents do
|
|
37
37
|
if data_class.owner_model_attr
|
|
38
|
-
add :show, @data.send(data_class.owner_model_attr),
|
|
38
|
+
add :show, @data.send(data_class.owner_model_attr),
|
|
39
|
+
button: { icon: :xmark, color: :secondary },
|
|
40
|
+
label: I18n.t('compony.cancel'),
|
|
41
|
+
name: :back_to_owner
|
|
39
42
|
end
|
|
40
43
|
end
|
|
41
44
|
|
|
@@ -18,7 +18,10 @@ module Compony
|
|
|
18
18
|
|
|
19
19
|
exposed_intents do
|
|
20
20
|
if data_class.owner_model_attr
|
|
21
|
-
add :show, @data.send(data_class.owner_model_attr),
|
|
21
|
+
add :show, @data.send(data_class.owner_model_attr),
|
|
22
|
+
button: { icon: :xmark, color: :secondary },
|
|
23
|
+
label: I18n.t('compony.back'),
|
|
24
|
+
name: :back_to_owner
|
|
22
25
|
end
|
|
23
26
|
|
|
24
27
|
if Compony.comp_class_for(:edit, family_name)
|
data/lib/compony/intent.rb
CHANGED
|
@@ -2,6 +2,7 @@ module Compony
|
|
|
2
2
|
# @api description
|
|
3
3
|
# An Intent is a a gateway to a component, along with relevant context, such as the comp and family, perhaps a resource, standalone name, feasibility etc.
|
|
4
4
|
# The class provides tooling used by various Compony helpers used to point to other components in some way.
|
|
5
|
+
# Note: The arguments `label` and `style` are not part of the `button:` hash, because they are processed by the Intent before affecting the button.
|
|
5
6
|
class Intent
|
|
6
7
|
attr_reader :comp_class
|
|
7
8
|
attr_reader :data
|
|
@@ -15,6 +16,8 @@ module Compony
|
|
|
15
16
|
# @param standalone_name [Symbol] If given, will override the standalone name for all `path` calls for this intent instance.
|
|
16
17
|
# @param name [Symbol] If given, will override the name of this intent. Defaults to component and family name joined by underscore.
|
|
17
18
|
# @param label [String,Hash] If given, will be used for generating the label. If Hash, is given as options to {Intent#label}.
|
|
19
|
+
# @param style [Symbol] If given, sets the button style to use and uses the default one otherwise.
|
|
20
|
+
# @param button [Hash] Parameters that will be given as-is to the button component initializer.
|
|
18
21
|
# @param path [String,Hash] If given, will be used for generating the path. If Hash, is given as options to {Intent#path}.
|
|
19
22
|
# @param data [ApplicationRecord,Object] If given, the target component will be instanciated with this argument. Omit if your second pos arg is a model.
|
|
20
23
|
# @param data_class [Class] If given, the target component will be instanciated with this argument.
|
|
@@ -25,13 +28,14 @@ module Compony
|
|
|
25
28
|
standalone_name: nil,
|
|
26
29
|
name: nil,
|
|
27
30
|
label: nil,
|
|
31
|
+
style: nil,
|
|
32
|
+
button: {},
|
|
28
33
|
path: nil,
|
|
29
34
|
method: nil,
|
|
30
35
|
data: nil,
|
|
31
36
|
data_class: nil,
|
|
32
37
|
feasibility_target: nil,
|
|
33
|
-
feasibility_action: nil
|
|
34
|
-
**custom_args)
|
|
38
|
+
feasibility_action: nil)
|
|
35
39
|
# Check for model / data
|
|
36
40
|
@data = data
|
|
37
41
|
@data ||= model_or_family_name_or_cst if model_or_family_name_or_cst.respond_to?(:model_name)
|
|
@@ -53,12 +57,13 @@ module Compony
|
|
|
53
57
|
@standalone_name = standalone_name
|
|
54
58
|
@label = label.is_a?(String) ? label : nil
|
|
55
59
|
@label_opts = label.is_a?(Hash) ? label : {}
|
|
60
|
+
@style = style&.to_sym
|
|
61
|
+
@button_opts = button
|
|
56
62
|
@path = path.is_a?(String) ? path : nil
|
|
57
63
|
@path_opts = path.is_a?(Hash) ? path : {}
|
|
58
64
|
@method = method&.to_sym
|
|
59
65
|
@feasibility_target = feasibility_target
|
|
60
66
|
@feasibility_action = feasibility_action
|
|
61
|
-
@custom_args = custom_args
|
|
62
67
|
end
|
|
63
68
|
|
|
64
69
|
# Returns true for things like User.first, but false for things like :users or User
|
|
@@ -113,27 +118,27 @@ module Compony
|
|
|
113
118
|
end
|
|
114
119
|
|
|
115
120
|
# Returns the options that are given to the initializer when creating a button from this intent.
|
|
116
|
-
def button_comp_opts
|
|
117
|
-
return
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
121
|
+
def button_comp_opts
|
|
122
|
+
return {
|
|
123
|
+
label:,
|
|
124
|
+
href: feasible? ? path : nil,
|
|
125
|
+
method:,
|
|
126
|
+
class: feasible? ? nil : 'disabled',
|
|
127
|
+
title: feasible? ? nil : feasibility_target.full_feasibility_messages(feasibility_action).presence
|
|
128
|
+
}.deep_merge(@button_opts)
|
|
124
129
|
end
|
|
125
130
|
|
|
126
131
|
# Renders this intent into a button defined by `style`.
|
|
127
132
|
# @param controller [ApplicationController] The controller from the request context, needed to render the button.
|
|
128
133
|
# @param parent_comp [Compony::Component] If called from within a component, pass the component to inform the button that it is nested within.
|
|
129
134
|
# @param style [Symbol] If present, overrides the class of the generated button component, defaults to {Compony#default_button_style}.
|
|
130
|
-
# @param
|
|
131
|
-
def render(controller, parent_comp = nil, style: nil,
|
|
132
|
-
#
|
|
135
|
+
# @param button_arg_overrides [Hash] Any further kwargs are passed to the button component's initializer.
|
|
136
|
+
def render(controller, parent_comp = nil, style: nil, **button_arg_overrides)
|
|
137
|
+
# Abort if not authorized
|
|
133
138
|
return nil unless comp.standalone_access_permitted_for?(controller, standalone_name: @standalone_name, verb: method)
|
|
134
139
|
# Prepare opts
|
|
135
|
-
button_comp_class ||= Compony.button_component_class(*[style].compact)
|
|
136
|
-
button_opts = button_comp_opts
|
|
140
|
+
button_comp_class ||= Compony.button_component_class(*[style || @style].compact)
|
|
141
|
+
button_opts = button_comp_opts.merge(button_arg_overrides)
|
|
137
142
|
# Perform render
|
|
138
143
|
if parent_comp
|
|
139
144
|
return parent_comp.sub_comp(button_comp_class, **button_opts).render(controller)
|
|
@@ -12,7 +12,7 @@ module Compony
|
|
|
12
12
|
return transform_and_join(data.send(@name), controller:) do |el|
|
|
13
13
|
next nil if el.nil?
|
|
14
14
|
if Compony.comp_class_for(link_to_component, el)
|
|
15
|
-
next controller.helpers.render_intent(link_to_component, el, **{
|
|
15
|
+
next controller.helpers.render_intent(link_to_component, el, **{ style: :link }.deep_merge(link_opts))
|
|
16
16
|
else
|
|
17
17
|
next el.label
|
|
18
18
|
end
|
|
@@ -73,9 +73,8 @@ module Compony
|
|
|
73
73
|
# View helper that renders an intent through the default button class.
|
|
74
74
|
# All non-mentioned parameters are given to the intent initializer.
|
|
75
75
|
# When inside a request context (`content do...`), this precedes {ViewHelpers#render_intent}.
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
Compony.intent(*, **).render(controller, component, **button)
|
|
76
|
+
def render_intent(*, **)
|
|
77
|
+
Compony.intent(*, **).render(controller, component)
|
|
79
78
|
end
|
|
80
79
|
|
|
81
80
|
# View helper that instanciates a sub comp and renders it.
|
data/lib/compony.rb
CHANGED
|
@@ -132,8 +132,8 @@ module Compony
|
|
|
132
132
|
|
|
133
133
|
# Generates a Rails path to a component. Examples: `Compony.path(:index, :users)`, `Compony.path(:show, User.first)`
|
|
134
134
|
# The first two arguments are given to create an {Intent} and all subsequend args and all kwargs are given to {Intent#path}
|
|
135
|
-
def self.path(comp_name_or_cst_or_class, model_or_family_name_or_cst = nil,
|
|
136
|
-
intent(comp_name_or_cst_or_class, model_or_family_name_or_cst).path(
|
|
135
|
+
def self.path(comp_name_or_cst_or_class, model_or_family_name_or_cst = nil, *, **)
|
|
136
|
+
intent(comp_name_or_cst_or_class, model_or_family_name_or_cst).path(*, **)
|
|
137
137
|
end
|
|
138
138
|
|
|
139
139
|
# Given a component and a family/model, this returns the matching component class if any, or nil if the component does not exist.
|