compony 0.11.8 → 0.11.9
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/.yardopts +36 -1
- data/CHANGELOG.md +31 -0
- data/CLAUDE.md +85 -0
- data/Gemfile.lock +1 -1
- data/README.md +13 -3
- data/VERSION +1 -1
- data/compony.gemspec +3 -3
- data/doc/ComponentGenerator.html +1 -1
- data/doc/Components.html +1 -1
- data/doc/ComponentsGenerator.html +1 -1
- data/doc/Compony/Component.html +54 -54
- 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 +109 -70
- data/doc/Compony/ComponentMixins/Default/Standalone/VerbDsl.html +64 -28
- data/doc/Compony/ComponentMixins/Default/Standalone.html +1 -1
- data/doc/Compony/ComponentMixins/Default.html +1 -1
- data/doc/Compony/ComponentMixins/Resourceful.html +213 -74
- 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 +83 -29
- data/doc/Compony/Components/Edit.html +110 -38
- data/doc/Compony/Components/Form.html +551 -208
- data/doc/Compony/Components/Index.html +1 -1
- data/doc/Compony/Components/List.html +3 -3
- data/doc/Compony/Components/New.html +110 -38
- data/doc/Compony/Components/Show.html +1 -1
- data/doc/Compony/Components/WithForm.html +194 -47
- data/doc/Compony/Components.html +1 -1
- data/doc/Compony/ControllerMixin.html +1 -1
- data/doc/Compony/Engine.html +1 -1
- data/doc/Compony/Intent.html +2 -2
- data/doc/Compony/ManageIntentsDsl.html +1 -1
- 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 +1 -1
- 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 +1 -1
- data/doc/ComponyController.html +1 -1
- data/doc/_index.html +97 -1
- data/doc/file.CHANGELOG.html +758 -0
- data/doc/file.README.html +25 -4
- data/doc/file.basic_component.html +314 -0
- data/doc/file.cookbook.html +189 -0
- data/doc/file.destroy.html +105 -0
- data/doc/file.dsl_reference.html +672 -0
- data/doc/file.edit.html +109 -0
- data/doc/file.example.html +291 -0
- data/doc/file.example_advanced.html +257 -0
- data/doc/file.feasibility.html +115 -0
- data/doc/file.form.html +195 -0
- data/doc/file.generators.html +89 -0
- data/doc/file.glossary.html +217 -0
- data/doc/file.gotchas.html +222 -0
- data/doc/file.index.html +135 -0
- data/doc/file.inheritance.html +136 -0
- data/doc/file.installation.html +115 -0
- data/doc/file.integrations.html +218 -0
- data/doc/file.intents.html +265 -0
- data/doc/file.internal_datastructures.html +129 -0
- data/doc/file.list.html +253 -0
- data/doc/file.maintaining.html +127 -0
- data/doc/file.model_fields.html +137 -0
- data/doc/file.nesting.html +237 -0
- data/doc/file.new.html +109 -0
- data/doc/file.ownership.html +98 -0
- data/doc/file.patterns.html +669 -0
- data/doc/file.pre_built_components.html +99 -0
- data/doc/file.resourceful.html +181 -0
- data/doc/file.show.html +158 -0
- data/doc/file.standalone.html +233 -0
- data/doc/file.virtual_models.html +117 -0
- data/doc/file.with_form.html +157 -0
- data/doc/file_list.html +160 -0
- data/doc/guide/cookbook.md +41 -0
- data/doc/guide/dsl_reference.md +155 -0
- data/doc/guide/example_advanced.md +209 -0
- data/doc/guide/generators.md +1 -1
- data/doc/guide/glossary.md +42 -0
- data/doc/guide/gotchas.md +125 -0
- data/doc/guide/maintaining.md +64 -0
- data/doc/guide/patterns.md +681 -0
- data/doc/guide/pre_built_components/edit.md +1 -1
- data/doc/guide/pre_built_components/index.md +64 -1
- data/doc/guide/pre_built_components/list.md +111 -7
- data/doc/guide/pre_built_components/show.md +57 -2
- data/doc/guide/pre_built_components/with_form.md +56 -9
- data/doc/guide/pre_built_components.md +7 -2
- data/doc/guide/standalone.md +16 -1
- data/doc/index.html +25 -4
- data/doc/integrations.md +61 -0
- data/doc/llms.txt +62 -0
- data/doc/top-level-namespace.html +1 -1
- data/lib/compony/component.rb +8 -3
- data/lib/compony/component_mixins/default/standalone/standalone_dsl.rb +32 -15
- data/lib/compony/component_mixins/default/standalone/verb_dsl.rb +11 -3
- data/lib/compony/component_mixins/resourceful.rb +30 -16
- data/lib/compony/components/destroy.rb +21 -1
- data/lib/compony/components/edit.rb +25 -1
- data/lib/compony/components/form.rb +63 -21
- data/lib/compony/components/list.rb +1 -1
- data/lib/compony/components/new.rb +25 -1
- data/lib/compony/components/with_form.rb +20 -5
- data/lib/compony/intent.rb +1 -1
- metadata +43 -1
data/doc/file.form.html
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>
|
|
7
|
+
File: form
|
|
8
|
+
|
|
9
|
+
— Documentation by YARD 0.9.34
|
|
10
|
+
|
|
11
|
+
</title>
|
|
12
|
+
|
|
13
|
+
<link rel="stylesheet" href="css/style.css" type="text/css" />
|
|
14
|
+
|
|
15
|
+
<link rel="stylesheet" href="css/common.css" type="text/css" />
|
|
16
|
+
|
|
17
|
+
<script type="text/javascript">
|
|
18
|
+
pathId = "form";
|
|
19
|
+
relpath = '';
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
|
24
|
+
|
|
25
|
+
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
</head>
|
|
29
|
+
<body>
|
|
30
|
+
<div class="nav_wrap">
|
|
31
|
+
<iframe id="nav" src="file_list.html?1"></iframe>
|
|
32
|
+
<div id="resizer"></div>
|
|
33
|
+
</div>
|
|
34
|
+
|
|
35
|
+
<div id="main" tabindex="-1">
|
|
36
|
+
<div id="header">
|
|
37
|
+
<div id="menu">
|
|
38
|
+
|
|
39
|
+
<a href="_index.html">Index</a> »
|
|
40
|
+
<span class="title">File: form</span>
|
|
41
|
+
|
|
42
|
+
</div>
|
|
43
|
+
|
|
44
|
+
<div id="search">
|
|
45
|
+
|
|
46
|
+
<a class="full_list_link" id="class_list_link"
|
|
47
|
+
href="class_list.html">
|
|
48
|
+
|
|
49
|
+
<svg width="24" height="24">
|
|
50
|
+
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
|
51
|
+
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
|
52
|
+
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
|
53
|
+
</svg>
|
|
54
|
+
</a>
|
|
55
|
+
|
|
56
|
+
</div>
|
|
57
|
+
<div class="clear"></div>
|
|
58
|
+
</div>
|
|
59
|
+
|
|
60
|
+
<div id="content"><div id='filecontents'><ul><li>
|
|
61
|
+
<p><a href="/README_md.html#guide--documentation">Back to the guide</a></p>
|
|
62
|
+
</li><li>
|
|
63
|
+
<p><a href="/doc/guide/pre_built_components_md.html">List of pre-built components</a></p>
|
|
64
|
+
</li></ul>
|
|
65
|
+
|
|
66
|
+
<h1 id="label-Pre-built+components-3A+Form">Pre-built components: Form</h1>
|
|
67
|
+
|
|
68
|
+
<p>This component holds a form and should only be instantiated by the <code>form_comp</code> call of a component that inherits from href="./with_form_md.html"></a>.</p>
|
|
69
|
+
|
|
70
|
+
<p><code>Compony::Components::Form</code> is an abstract base class for any components presenting a regular form. This class comes with a lot of tooling for rendering forms and inputs, as well as validating parameters. When the component is rendered, the Gem SimpleForm is used to create the actual form: <a href="https://github.com/heartcombo/simple_form">github.com/heartcombo/simple_form</a>.</p>
|
|
71
|
+
|
|
72
|
+
<p>Parameters are structured like typical Rails forms. For instance, if you have a form for a <code>User</code> model and the attribute is <code>first_name</code>, the parameter looks like <code>user[first_name]=Tom</code>. In this case, we will call <code>user</code> the <code>schema_wrapper_key</code>. Parameters are validated using Schemacop: <a href="https://github.com/sitrox/schemacop">github.com/sitrox/schemacop</a>.</p>
|
|
73
|
+
|
|
74
|
+
<p>The following DSL calls are provided by the Form component:</p>
|
|
75
|
+
<ul><li>
|
|
76
|
+
<p>Required: <code>form_fields</code> takes a block that renders the inputs of your form. More on that below.</p>
|
|
77
|
+
</li><li>
|
|
78
|
+
<p>Optional: <code>skip_autofocus</code> will prevent the first input to be auto-focussed when the user visits the form.</p>
|
|
79
|
+
</li><li>
|
|
80
|
+
<p>Typically required: <code>schema_fields</code> takes the names of fields as a whitelist for strong parameters. Together with model fields, this will completely auto-generate a Schemacop schema suitable for validating this form. If your argument list gets too long, you can use multiple calls to <code>schema_field</code> instead to declare your fields one by one on separate lines.</p>
|
|
81
|
+
</li><li>
|
|
82
|
+
<p>Optional: <code>schema_line</code> takes a single Schemacop line. Use this for custom whitelisting of an argument, e.g. if you have an input that does not have a corresponding model field.</p>
|
|
83
|
+
</li><li>
|
|
84
|
+
<p>Optional: <code>schema</code> allows you to instead fully define your own custom Schemacop V3 schema manually. Note that this disables all of the above schema calls.</p>
|
|
85
|
+
</li><li>
|
|
86
|
+
<p>Optional: <code>disable!</code> causes generated inputs to be disabled. Alternatively, <code>disabled: true</code> can be passed to the initializer to achieve the same result.</p>
|
|
87
|
+
</li></ul>
|
|
88
|
+
|
|
89
|
+
<p>The <code>form_fields</code> block acts much like a content block and you will use Dyny there. Two additional methods are made available exclusively inside the block:</p>
|
|
90
|
+
<ul><li>
|
|
91
|
+
<p><code>field</code> (not to be confused with the model mixin’s static method) takes the name of a model field and auto-generates a suitable SimpleForm input as defined in the field’s type.</p>
|
|
92
|
+
</li><li>
|
|
93
|
+
<p><code>f</code> gives you direct access to the <code>simple_form</code> instance. You can use it to write e.g. <code>f.input(...)</code>.</p>
|
|
94
|
+
</li></ul>
|
|
95
|
+
|
|
96
|
+
<p>Here is a simple example for a form for a sample user:</p>
|
|
97
|
+
|
|
98
|
+
<pre class="code ruby"><code class="ruby"><span class='kw'>class</span> <span class='const'><span class='object_link'><a href="Components.html" title="Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Users</span><span class='op'>::</span><span class='const'>Form</span> <span class='op'><</span> <span class='const'><span class='object_link'><a href="Compony.html" title="Compony (module)">Compony</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Compony/Components.html" title="Compony::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Compony/Components/Form.html" title="Compony::Components::Form (class)">Form</a></span></span>
|
|
99
|
+
<span class='id identifier rubyid_setup'>setup</span> <span class='kw'>do</span>
|
|
100
|
+
<span class='id identifier rubyid_form_fields'>form_fields</span> <span class='kw'>do</span>
|
|
101
|
+
<span class='id identifier rubyid_concat'>concat</span> <span class='id identifier rubyid_field'>field</span><span class='lparen'>(</span><span class='symbol'>:first_name</span><span class='rparen'>)</span>
|
|
102
|
+
<span class='id identifier rubyid_concat'>concat</span> <span class='id identifier rubyid_field'>field</span><span class='lparen'>(</span><span class='symbol'>:last_name</span><span class='rparen'>)</span>
|
|
103
|
+
<span class='id identifier rubyid_concat'>concat</span> <span class='id identifier rubyid_field'>field</span><span class='lparen'>(</span><span class='symbol'>:age</span><span class='rparen'>)</span>
|
|
104
|
+
<span class='id identifier rubyid_concat'>concat</span> <span class='id identifier rubyid_field'>field</span><span class='lparen'>(</span><span class='symbol'>:comment</span><span class='rparen'>)</span>
|
|
105
|
+
<span class='id identifier rubyid_concat'>concat</span> <span class='id identifier rubyid_field'>field</span><span class='lparen'>(</span><span class='symbol'>:role</span><span class='rparen'>)</span>
|
|
106
|
+
<span class='kw'>end</span>
|
|
107
|
+
<span class='id identifier rubyid_schema_fields'>schema_fields</span> <span class='symbol'>:first_name</span><span class='comma'>,</span> <span class='symbol'>:last_name</span><span class='comma'>,</span> <span class='symbol'>:age</span><span class='comma'>,</span> <span class='symbol'>:comment</span><span class='comma'>,</span> <span class='symbol'>:role</span>
|
|
108
|
+
<span class='kw'>end</span>
|
|
109
|
+
<span class='kw'>end</span>
|
|
110
|
+
</code></pre>
|
|
111
|
+
|
|
112
|
+
<p>Note that the inputs and schema are two completely different concepts that are not auto-inferred from each other. You must make sure that they always correspond. If you forget to mention a field in <code>schema_fields</code>, posting the form will fail. Luckily, Schemacop’s excellent error messaging will explain which parameter is prohibited.</p>
|
|
113
|
+
|
|
114
|
+
<p>Both calls respect Cancancan’s <code>permitted_attributes</code> directive. This means that you can safely declare <code>field</code> and <code>schema_field</code> in a form that is shared among users with different kinds of permissions. If the current user is not allowed to access a field, the input will be omitted automatically. Further, the parameter validation will exclude that field, effectively disallowing that user from submitting that parameter.</p>
|
|
115
|
+
|
|
116
|
+
<h2 id="label-Handling+password+fields">Handling password fields</h2>
|
|
117
|
+
|
|
118
|
+
<p>When using Rails’ <code>has_secure_password</code> method, which typically generates the attributes accessors <code>:password</code> and <code>password_confirmation</code>, do not declare these two as fields in your User model.</p>
|
|
119
|
+
|
|
120
|
+
<p>There are two main reasons for this:</p>
|
|
121
|
+
<ul><li>
|
|
122
|
+
<p><code>password</code> and <code>password_confirmation</code> should never show up in lists and show pages, and as these kinds of components tend to iterate over all fields, it’s best to have anything that should not show up there declared as a field in the first place.</p>
|
|
123
|
+
</li><li>
|
|
124
|
+
<p>Rails’ <code>authenticate_by</code> does not work when <code>password</code> is declared as a model attribute.</p>
|
|
125
|
+
</li></ul>
|
|
126
|
+
|
|
127
|
+
<p>Instead of making these accessors Compony fields, ignore them in the User model and use the following methods in your Form:</p>
|
|
128
|
+
|
|
129
|
+
<pre class="code ruby"><code class="ruby"><span class='kw'>class</span> <span class='const'><span class='object_link'><a href="Components.html" title="Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Users</span><span class='op'>::</span><span class='const'>Form</span> <span class='op'><</span> <span class='const'><span class='object_link'><a href="Compony.html" title="Compony (module)">Compony</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Compony/Components.html" title="Compony::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Compony/Components/Form.html" title="Compony::Components::Form (class)">Form</a></span></span>
|
|
130
|
+
<span class='id identifier rubyid_setup'>setup</span> <span class='kw'>do</span>
|
|
131
|
+
<span class='id identifier rubyid_form_fields'>form_fields</span> <span class='kw'>do</span>
|
|
132
|
+
<span class='comment'># ...
|
|
133
|
+
</span> <span class='id identifier rubyid_concat'>concat</span> <span class='id identifier rubyid_pw_field'>pw_field</span><span class='lparen'>(</span><span class='symbol'>:password</span><span class='rparen'>)</span>
|
|
134
|
+
<span class='id identifier rubyid_concat'>concat</span> <span class='id identifier rubyid_pw_field'>pw_field</span><span class='lparen'>(</span><span class='symbol'>:password_confirmation</span><span class='rparen'>)</span>
|
|
135
|
+
<span class='kw'>end</span>
|
|
136
|
+
|
|
137
|
+
<span class='comment'># ...
|
|
138
|
+
</span> <span class='id identifier rubyid_schema_pw_field'>schema_pw_field</span> <span class='symbol'>:password</span>
|
|
139
|
+
<span class='id identifier rubyid_schema_pw_field'>schema_pw_field</span> <span class='symbol'>:password_confirmation</span>
|
|
140
|
+
<span class='kw'>end</span>
|
|
141
|
+
<span class='kw'>end</span>
|
|
142
|
+
</code></pre>
|
|
143
|
+
|
|
144
|
+
<p>In contrast to the regular <code>field</code> and <code>schema_field</code> calls, their <code>pw_...</code> pendants do not check for per-field authorization. Instead, they check whether the current user can <code>:set_password</code> on the form’s object. Therefore, your ability may look something like:</p>
|
|
145
|
+
|
|
146
|
+
<pre class="code ruby"><code class="ruby">class Ability
|
|
147
|
+
# ...
|
|
148
|
+
can :manage, User # This allows full access to all users
|
|
149
|
+
cannot :manage, User, [:user_role] # This prohibits access to user_role, thus removing the input and making the parameter invalid if passed anyway
|
|
150
|
+
cannot :set_password, User # This prohibits setting and changing passwords of any user
|
|
151
|
+
</code></pre>
|
|
152
|
+
|
|
153
|
+
<h2 id="label-Dealing+with+multilingual+fields">Dealing with multilingual fields</h2>
|
|
154
|
+
|
|
155
|
+
<p>When using Gems such as <code>mobility</code>, Compony provides support for multilingual fields. For instance, assuming that a model has the attribute <code>label</code> translated in English and German, making <code>label</code> a virtual attribute reading either <code>label_en</code> and <code>label_de</code>, depending on the user’s language, Compony automatically generates a multilingual field if the following is used:</p>
|
|
156
|
+
|
|
157
|
+
<p>In the model:</p>
|
|
158
|
+
|
|
159
|
+
<pre class="code ruby"><code class="ruby"><span class='kw'>class</span> <span class='const'>Foo</span> <span class='op'><</span> <span class='const'>ApplicationRecord</span>
|
|
160
|
+
<span class='comment'># No need to write:
|
|
161
|
+
</span> <span class='id identifier rubyid_field'>field</span> <span class='symbol'>:label</span><span class='comma'>,</span> <span class='symbol'>:string</span><span class='comma'>,</span> <span class='label'>virtual:</span> <span class='kw'>true</span>
|
|
162
|
+
<span class='const'>I18n</span><span class='period'>.</span><span class='id identifier rubyid_available_locales'>available_locales</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_locale'>locale</span><span class='op'>|</span>
|
|
163
|
+
<span class='id identifier rubyid_field'>field</span> <span class='symbol'>:"label_</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_locale'>locale</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='symbol'>:string</span>
|
|
164
|
+
<span class='kw'>end</span>
|
|
165
|
+
|
|
166
|
+
<span class='comment'># Instead, write this, which is equivalent:
|
|
167
|
+
</span> <span class='id identifier rubyid_field'>field</span> <span class='symbol'>:label</span><span class='comma'>,</span> <span class='symbol'>:string</span><span class='comma'>,</span> <span class='label'>multilang:</span> <span class='kw'>true</span>
|
|
168
|
+
<span class='kw'>end</span>
|
|
169
|
+
</code></pre>
|
|
170
|
+
|
|
171
|
+
<p>In the same mindset, you can simplify your form as follows to generate one input per language:</p>
|
|
172
|
+
|
|
173
|
+
<pre class="code ruby"><code class="ruby"><span class='kw'>class</span> <span class='const'><span class='object_link'><a href="Components.html" title="Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Foos</span><span class='op'>::</span><span class='const'>Form</span> <span class='op'><</span> <span class='const'><span class='object_link'><a href="Compony.html" title="Compony (module)">Compony</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Compony/Components.html" title="Compony::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Compony/Components/Form.html" title="Compony::Components::Form (class)">Form</a></span></span>
|
|
174
|
+
<span class='id identifier rubyid_setup'>setup</span> <span class='kw'>do</span>
|
|
175
|
+
<span class='id identifier rubyid_form_fields'>form_fields</span> <span class='kw'>do</span>
|
|
176
|
+
<span class='comment'># Since `field` only generates an input, you must loop over them and render them as you wish, e.g. with "concat":
|
|
177
|
+
</span> <span class='id identifier rubyid_field'>field</span><span class='lparen'>(</span><span class='symbol'>:label</span><span class='comma'>,</span> <span class='label'>multilang:</span> <span class='kw'>true</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_inp'>inp</span><span class='op'>|</span> <span class='id identifier rubyid_concat'>concat</span> <span class='id identifier rubyid_inp'>inp</span> <span class='rbrace'>}</span>
|
|
178
|
+
<span class='kw'>end</span>
|
|
179
|
+
|
|
180
|
+
<span class='comment'># Don't forget to mark `schema_field` as multilingual as well, which will accept label_en and label_de:
|
|
181
|
+
</span> <span class='id identifier rubyid_schema_field'>schema_field</span> <span class='symbol'>:label</span><span class='comma'>,</span> <span class='label'>multilang:</span> <span class='kw'>true</span>
|
|
182
|
+
<span class='kw'>end</span>
|
|
183
|
+
<span class='kw'>end</span>
|
|
184
|
+
</code></pre>
|
|
185
|
+
</div></div>
|
|
186
|
+
|
|
187
|
+
<div id="footer">
|
|
188
|
+
Generated on Mon May 18 13:55:34 2026 by
|
|
189
|
+
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
190
|
+
0.9.34 (ruby-3.3.5).
|
|
191
|
+
</div>
|
|
192
|
+
|
|
193
|
+
</div>
|
|
194
|
+
</body>
|
|
195
|
+
</html>
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>
|
|
7
|
+
File: generators
|
|
8
|
+
|
|
9
|
+
— Documentation by YARD 0.9.34
|
|
10
|
+
|
|
11
|
+
</title>
|
|
12
|
+
|
|
13
|
+
<link rel="stylesheet" href="css/style.css" type="text/css" />
|
|
14
|
+
|
|
15
|
+
<link rel="stylesheet" href="css/common.css" type="text/css" />
|
|
16
|
+
|
|
17
|
+
<script type="text/javascript">
|
|
18
|
+
pathId = "generators";
|
|
19
|
+
relpath = '';
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
|
24
|
+
|
|
25
|
+
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
</head>
|
|
29
|
+
<body>
|
|
30
|
+
<div class="nav_wrap">
|
|
31
|
+
<iframe id="nav" src="file_list.html?1"></iframe>
|
|
32
|
+
<div id="resizer"></div>
|
|
33
|
+
</div>
|
|
34
|
+
|
|
35
|
+
<div id="main" tabindex="-1">
|
|
36
|
+
<div id="header">
|
|
37
|
+
<div id="menu">
|
|
38
|
+
|
|
39
|
+
<a href="_index.html">Index</a> »
|
|
40
|
+
<span class="title">File: generators</span>
|
|
41
|
+
|
|
42
|
+
</div>
|
|
43
|
+
|
|
44
|
+
<div id="search">
|
|
45
|
+
|
|
46
|
+
<a class="full_list_link" id="class_list_link"
|
|
47
|
+
href="class_list.html">
|
|
48
|
+
|
|
49
|
+
<svg width="24" height="24">
|
|
50
|
+
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
|
51
|
+
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
|
52
|
+
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
|
53
|
+
</svg>
|
|
54
|
+
</a>
|
|
55
|
+
|
|
56
|
+
</div>
|
|
57
|
+
<div class="clear"></div>
|
|
58
|
+
</div>
|
|
59
|
+
|
|
60
|
+
<div id="content"><div id='filecontents'>
|
|
61
|
+
<p><a href="/README_md.html#guide--documentation">Back to the guide</a></p>
|
|
62
|
+
|
|
63
|
+
<h1 id="label-Rails+Generators+provided+by+Compony">Rails Generators provided by Compony</h1>
|
|
64
|
+
|
|
65
|
+
<p>To make your life easier and coding faster, Compony comes with two generators:</p>
|
|
66
|
+
<ul><li>
|
|
67
|
+
<p><code>rails g component Users::New</code> will create <code>app/components/users/new.rb</code> and, since the component’s name coincides with a a pre-built component, automatically inherit from that. If the name is unknown, the generated component will inherit form <code>Compony::Component</code> instead. The generator also equips generated components with the boilerplate code that wil be required to make the component work.</p>
|
|
68
|
+
</li><li>
|
|
69
|
+
<p>The generator can also be called via its alternative form <code>rails g component users/new</code>.</p>
|
|
70
|
+
</li><li>
|
|
71
|
+
<p><code>rails g components Users</code> will generate a set of the most used components.</p>
|
|
72
|
+
</li></ul>
|
|
73
|
+
|
|
74
|
+
<h3 id="label-Support+for+custom+base+components">Support for custom base components</h3>
|
|
75
|
+
|
|
76
|
+
<p>Generators will automatically detect your <code>BaseComponents</code> (see <a href="./inheritance_md.html#best-practice">Inheritance: best practice</a>).</p>
|
|
77
|
+
|
|
78
|
+
<p><a href="/README_md.html#guide--documentation">Guide index</a></p>
|
|
79
|
+
</div></div>
|
|
80
|
+
|
|
81
|
+
<div id="footer">
|
|
82
|
+
Generated on Mon May 18 13:55:33 2026 by
|
|
83
|
+
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
84
|
+
0.9.34 (ruby-3.3.5).
|
|
85
|
+
</div>
|
|
86
|
+
|
|
87
|
+
</div>
|
|
88
|
+
</body>
|
|
89
|
+
</html>
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>
|
|
7
|
+
File: glossary
|
|
8
|
+
|
|
9
|
+
— Documentation by YARD 0.9.34
|
|
10
|
+
|
|
11
|
+
</title>
|
|
12
|
+
|
|
13
|
+
<link rel="stylesheet" href="css/style.css" type="text/css" />
|
|
14
|
+
|
|
15
|
+
<link rel="stylesheet" href="css/common.css" type="text/css" />
|
|
16
|
+
|
|
17
|
+
<script type="text/javascript">
|
|
18
|
+
pathId = "glossary";
|
|
19
|
+
relpath = '';
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
|
24
|
+
|
|
25
|
+
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
</head>
|
|
29
|
+
<body>
|
|
30
|
+
<div class="nav_wrap">
|
|
31
|
+
<iframe id="nav" src="file_list.html?1"></iframe>
|
|
32
|
+
<div id="resizer"></div>
|
|
33
|
+
</div>
|
|
34
|
+
|
|
35
|
+
<div id="main" tabindex="-1">
|
|
36
|
+
<div id="header">
|
|
37
|
+
<div id="menu">
|
|
38
|
+
|
|
39
|
+
<a href="_index.html">Index</a> »
|
|
40
|
+
<span class="title">File: glossary</span>
|
|
41
|
+
|
|
42
|
+
</div>
|
|
43
|
+
|
|
44
|
+
<div id="search">
|
|
45
|
+
|
|
46
|
+
<a class="full_list_link" id="class_list_link"
|
|
47
|
+
href="class_list.html">
|
|
48
|
+
|
|
49
|
+
<svg width="24" height="24">
|
|
50
|
+
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
|
51
|
+
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
|
52
|
+
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
|
53
|
+
</svg>
|
|
54
|
+
</a>
|
|
55
|
+
|
|
56
|
+
</div>
|
|
57
|
+
<div class="clear"></div>
|
|
58
|
+
</div>
|
|
59
|
+
|
|
60
|
+
<div id="content"><div id='filecontents'>
|
|
61
|
+
<p><a href="/README_md.html#guide--documentation">Back to the guide</a></p>
|
|
62
|
+
|
|
63
|
+
<h1 id="label-Glossary">Glossary</h1>
|
|
64
|
+
|
|
65
|
+
<p>One-line definitions of Compony vocabulary. Deeper treatment is linked.</p>
|
|
66
|
+
|
|
67
|
+
<table role="table">
|
|
68
|
+
<thead>
|
|
69
|
+
<tr>
|
|
70
|
+
<th>Term</th>
|
|
71
|
+
<th>Definition</th>
|
|
72
|
+
</tr>
|
|
73
|
+
</thead>
|
|
74
|
+
<tbody>
|
|
75
|
+
<tr>
|
|
76
|
+
<td><strong>Component</strong></td>
|
|
77
|
+
<td>A Ruby class (‘Components::Family::Name`) bundling a route, controller action and view. See [basic_component.md](/doc/guide/basic_component.md).</td>
|
|
78
|
+
</tr>
|
|
79
|
+
<tr>
|
|
80
|
+
<td><strong>Family</strong></td>
|
|
81
|
+
<td>The plural namespace grouping a model’s components, analogous to a Rails controller (‘Users`).</td>
|
|
82
|
+
</tr>
|
|
83
|
+
<tr>
|
|
84
|
+
<td>**Comp name**</td>
|
|
85
|
+
<td>The component’s own name, analogous to a Rails action (‘show`).</td>
|
|
86
|
+
</tr>
|
|
87
|
+
<tr>
|
|
88
|
+
<td>**‘setup`**</td>
|
|
89
|
+
<td>Class-level block holding nearly all component config; parent’s runs before child’s.</td>
|
|
90
|
+
</tr>
|
|
91
|
+
<tr>
|
|
92
|
+
<td>**Content block**</td>
|
|
93
|
+
<td>A named (‘:main` default) view block rendered via Dyny inside a RequestContext.</td>
|
|
94
|
+
</tr>
|
|
95
|
+
<tr>
|
|
96
|
+
<td>**‘before_render`**</td>
|
|
97
|
+
<td>Hook chain run before content; if it sets a response body (e.g. redirect) content is skipped.</td>
|
|
98
|
+
</tr>
|
|
99
|
+
<tr>
|
|
100
|
+
<td><strong>Standalone</strong></td>
|
|
101
|
+
<td>A ‘standalone` config that makes Compony emit a Rails route for the component. See [standalone.md](/doc/guide/standalone.md).</td>
|
|
102
|
+
</tr>
|
|
103
|
+
<tr>
|
|
104
|
+
<td>**Standalone name**</td>
|
|
105
|
+
<td>Identifier for one of several routes a component exposes; ‘nil` = the main one.</td>
|
|
106
|
+
</tr>
|
|
107
|
+
<tr>
|
|
108
|
+
<td><strong>Verb</strong></td>
|
|
109
|
+
<td>An HTTP method config inside a standalone (‘verb :get do … end`).</td>
|
|
110
|
+
</tr>
|
|
111
|
+
<tr>
|
|
112
|
+
<td>**‘authorize`**</td>
|
|
113
|
+
<td>Mandatory per-verb block; truthy grants access, falsy raises ‘CanCan::AccessDenied`.</td>
|
|
114
|
+
</tr>
|
|
115
|
+
<tr>
|
|
116
|
+
<td>**‘respond`**</td>
|
|
117
|
+
<td>Per-verb block overriding the controller response; overriding it skips the default authorize step.</td>
|
|
118
|
+
</tr>
|
|
119
|
+
<tr>
|
|
120
|
+
<td><strong>Resourceful</strong></td>
|
|
121
|
+
<td>A component that auto-loads a record/relation into ‘@data` (mixin or pre-built parent). See [resourceful.md](/doc/guide/resourceful.md).</td>
|
|
122
|
+
</tr>
|
|
123
|
+
<tr>
|
|
124
|
+
<td>**‘@data`**</td>
|
|
125
|
+
<td>The record (or AR relation) a resourceful component operates on.</td>
|
|
126
|
+
</tr>
|
|
127
|
+
<tr>
|
|
128
|
+
<td>**‘data_class`**</td>
|
|
129
|
+
<td>The model class a resourceful component expects; defaults from the family name.</td>
|
|
130
|
+
</tr>
|
|
131
|
+
<tr>
|
|
132
|
+
<td>**Lifecycle hooks**</td>
|
|
133
|
+
<td>‘load_data → after_load_data → authorize → assign_attributes → after_assign_attributes → store_data`.</td>
|
|
134
|
+
</tr>
|
|
135
|
+
<tr>
|
|
136
|
+
<td><strong>Intent</strong></td>
|
|
137
|
+
<td>A gateway object to a target component carrying context (model, path, feasibility, label). See [intents.md](/doc/guide/intents.md).</td>
|
|
138
|
+
</tr>
|
|
139
|
+
<tr>
|
|
140
|
+
<td>**Exposed intent**</td>
|
|
141
|
+
<td>An intent a component declares for its parent/layout to render (e.g. an actions toolbar).</td>
|
|
142
|
+
</tr>
|
|
143
|
+
<tr>
|
|
144
|
+
<td>**‘Compony.path`**</td>
|
|
145
|
+
<td>Helper that builds a Rails path string via an intent (use for redirects).</td>
|
|
146
|
+
</tr>
|
|
147
|
+
<tr>
|
|
148
|
+
<td>**‘render_intent`**</td>
|
|
149
|
+
<td>Content/view helper that renders a link or button to another component.</td>
|
|
150
|
+
</tr>
|
|
151
|
+
<tr>
|
|
152
|
+
<td>**‘render_sub_comp`**</td>
|
|
153
|
+
<td>Content helper that instantiates and nests another component.</td>
|
|
154
|
+
</tr>
|
|
155
|
+
<tr>
|
|
156
|
+
<td>**Sub comp / parent comp**</td>
|
|
157
|
+
<td>A component instantiated inside another; the outer one is its ‘parent_comp`.</td>
|
|
158
|
+
</tr>
|
|
159
|
+
<tr>
|
|
160
|
+
<td>**Root comp**</td>
|
|
161
|
+
<td>The top component of the current render tree (no parent); ‘Compony.root_comp`.</td>
|
|
162
|
+
</tr>
|
|
163
|
+
<tr>
|
|
164
|
+
<td><strong>RequestContext</strong></td>
|
|
165
|
+
<td>Dslblend object content blocks run in: providers are the component, controller, helpers. See [internal_datastructures.md](/doc/guide/internal_datastructures.md).</td>
|
|
166
|
+
</tr>
|
|
167
|
+
<tr>
|
|
168
|
+
<td><strong>Backfire</strong></td>
|
|
169
|
+
<td>Dslblend mechanism copying instance vars set in a block back onto the component.</td>
|
|
170
|
+
</tr>
|
|
171
|
+
<tr>
|
|
172
|
+
<td>**Button / style**</td>
|
|
173
|
+
<td>A presenter component for an intent; ‘style` (`:css_button`, `:link`, custom) selects the class.</td>
|
|
174
|
+
</tr>
|
|
175
|
+
<tr>
|
|
176
|
+
<td><strong>Feasibility</strong></td>
|
|
177
|
+
<td>Framework where model ‘prevent` blocks disable buttons/links to an action with a reason. See [feasibility.md](/doc/guide/feasibility.md).</td>
|
|
178
|
+
</tr>
|
|
179
|
+
<tr>
|
|
180
|
+
<td>**‘prevent`**</td>
|
|
181
|
+
<td>Model class DSL declaring a feasibility prevention for one or more actions.</td>
|
|
182
|
+
</tr>
|
|
183
|
+
<tr>
|
|
184
|
+
<td><strong>Field</strong></td>
|
|
185
|
+
<td>A model-level declaration (‘field :name, :type`) of a UI-relevant attribute and its formatting. See [model_fields.md](/doc/guide/model_fields.md).</td>
|
|
186
|
+
</tr>
|
|
187
|
+
<tr>
|
|
188
|
+
<td>**Ownership / ‘owned_by`**</td>
|
|
189
|
+
<td>Declares a model conceptually part of another, adjusting redirects/top actions. See [ownership.md](/doc/guide/ownership.md).</td>
|
|
190
|
+
</tr>
|
|
191
|
+
<tr>
|
|
192
|
+
<td>**Virtual model**</td>
|
|
193
|
+
<td>A non-persistent ActiveType-backed model usable as a form target. See [virtual_models.md](/doc/guide/virtual_models.md).</td>
|
|
194
|
+
</tr>
|
|
195
|
+
<tr>
|
|
196
|
+
<td><strong>Dyny</strong></td>
|
|
197
|
+
<td>The HTML-as-Ruby templating gem content blocks are written in ([repo](<a href="https://github.com/kalsan/dyny">github.com/kalsan/dyny</a>)).</td>
|
|
198
|
+
</tr>
|
|
199
|
+
<tr>
|
|
200
|
+
<td>**Abstract component**</td>
|
|
201
|
+
<td>A component never routed directly, only inherited from (e.g. an app’s ‘BaseComponents::*`).</td>
|
|
202
|
+
</tr>
|
|
203
|
+
</tbody>
|
|
204
|
+
</table>
|
|
205
|
+
|
|
206
|
+
<p><a href="/README_md.html#guide--documentation">Guide index</a></p>
|
|
207
|
+
</div></div>
|
|
208
|
+
|
|
209
|
+
<div id="footer">
|
|
210
|
+
Generated on Mon May 18 13:55:34 2026 by
|
|
211
|
+
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
212
|
+
0.9.34 (ruby-3.3.5).
|
|
213
|
+
</div>
|
|
214
|
+
|
|
215
|
+
</div>
|
|
216
|
+
</body>
|
|
217
|
+
</html>
|