plutonium 0.12.9 → 0.12.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/# Plutonium: The pre-alpha demo.md +218 -0
- data/app/views/components/form/form_component.html.erb +1 -3
- data/app/views/components/interactive_action_form/interactive_action_form_component.html.erb +5 -7
- data/app/views/components/nested_resource_form_fields/nested_resource_form_fields_component.html.erb +2 -2
- data/app/views/components/table_search_input/table_search_input_component.html.erb +8 -2
- data/app/views/resource/_interactive_resource_action_form.html.erb +1 -1
- data/app/views/resource/_resource_details.html.erb +9 -2
- data/app/views/resource/_resource_table.html.erb +9 -1
- data/lib/generators/pu/core/assets/templates/tailwind.config.js +2 -0
- data/lib/generators/pu/core/install/install_generator.rb +1 -1
- data/lib/generators/pu/core/install/templates/config/initializers/plutonium.rb +4 -0
- data/lib/generators/pu/eject/layout/layout_generator.rb +3 -2
- data/lib/generators/pu/eject/shell/shell_generator.rb +3 -2
- data/lib/generators/pu/field/input/input_generator.rb +32 -0
- data/lib/generators/pu/field/input/templates/.keep +0 -0
- data/lib/generators/pu/field/input/templates/input.rb.tt +15 -0
- data/lib/generators/pu/field/renderer/renderer_generator.rb +32 -0
- data/lib/generators/pu/field/renderer/templates/.keep +0 -0
- data/lib/generators/pu/field/renderer/templates/renderer.rb.tt +9 -0
- data/lib/generators/pu/gem/annotate/annotate_generator.rb +22 -0
- data/lib/generators/pu/gem/annotate/templates/.keep +0 -0
- data/lib/generators/pu/gem/annotate/templates/lib/tasks/auto_annotate_models.rake +59 -0
- data/lib/plutonium/core/actions/interactive_action.rb +2 -2
- data/lib/plutonium/core/associations/renderers/base.rb +77 -0
- data/lib/plutonium/core/associations/renderers/factory.rb +0 -2
- data/lib/plutonium/core/associations/renderers/has_many_renderer.rb +6 -4
- data/lib/plutonium/core/controllers/crud_actions.rb +1 -1
- data/lib/plutonium/core/controllers/presentable.rb +3 -3
- data/lib/plutonium/core/definers/field_definer.rb +4 -4
- data/lib/plutonium/core/definers/{input_definer.rb → field_input_definer.rb} +4 -4
- data/lib/plutonium/core/definers/{renderer_definer.rb → field_renderer_definer.rb} +10 -10
- data/lib/plutonium/core/fields/inputs/attachment_input.rb +2 -2
- data/lib/plutonium/core/fields/inputs/base.rb +76 -10
- data/lib/plutonium/core/fields/inputs/checkbox_input.rb +3 -1
- data/lib/plutonium/core/fields/inputs/date_time_input.rb +3 -1
- data/lib/plutonium/core/fields/inputs/nested_input.rb +36 -21
- data/lib/plutonium/core/fields/inputs/noop_input.rb +1 -4
- data/lib/plutonium/core/fields/inputs/polymorphic_belongs_to_association_input.rb +8 -7
- data/lib/plutonium/core/fields/inputs/simple_form_association_input.rb +4 -5
- data/lib/plutonium/core/fields/inputs/simple_form_input.rb +2 -3
- data/lib/plutonium/core/fields/renderers/association_renderer.rb +11 -5
- data/lib/plutonium/core/fields/renderers/attachment_renderer.rb +3 -10
- data/lib/plutonium/core/fields/renderers/base.rb +83 -0
- data/lib/plutonium/core/fields/renderers/basic_renderer.rb +3 -17
- data/lib/plutonium/core/fields/renderers/factory.rb +0 -1
- data/lib/plutonium/core/renderable.rb +20 -0
- data/lib/plutonium/helpers/display_helper.rb +1 -1
- data/lib/plutonium/resource/controller.rb +1 -1
- data/lib/plutonium/resource/policy.rb +1 -1
- data/lib/plutonium/resource/presenter.rb +3 -3
- data/lib/plutonium/resource/query_object.rb +4 -4
- data/lib/plutonium/resource/record.rb +1 -1
- data/lib/plutonium/simple_form/attachment_component.rb +1 -1
- data/lib/plutonium/version.rb +1 -1
- data/package.json +1 -1
- metadata +17 -5
- data/lib/plutonium/core/associations/renderers/basic_renderer.rb +0 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 443b2efe86f5242ef6355f8da9d8af08dbbf66ebeaf8feb3adebbe9c0858cf45
|
4
|
+
data.tar.gz: 532843ca3dd3a9456e135dfa371d5110f46c726f5d86fed70a1ebe02ed8cfde5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d19d82bd1f5ac2a2fd4d383fffbc78d0c773213ff1c6648e44723c113ae4e6a4c8065ec2318df7738012f676547c60231aa895542a139e5d55394179476c3bc
|
7
|
+
data.tar.gz: 22bbf75790b8bc214be9946f339e7d607a64e31e363bf6d76eead20713536168dbbd6838d6c4bb62f453ec168fa458c6126a48c0c083ec839c83675d71bcec91
|
@@ -0,0 +1,218 @@
|
|
1
|
+
# Plutonium: The pre-alpha demo
|
2
|
+
|
3
|
+
- Introduce the project
|
4
|
+
- Install Rails
|
5
|
+
```bash
|
6
|
+
rails new demo -c tailwind -j esbuild
|
7
|
+
```
|
8
|
+
- Install Plutonium
|
9
|
+
```bash
|
10
|
+
rails g pu:core:install
|
11
|
+
bundle add plutonium
|
12
|
+
```
|
13
|
+
- Install useful gems
|
14
|
+
```bash
|
15
|
+
rails g pu:gem:annotate
|
16
|
+
```
|
17
|
+
- Install rodauth
|
18
|
+
```bash
|
19
|
+
rails g pu:rodauth:install
|
20
|
+
```
|
21
|
+
- Create rodauth user account
|
22
|
+
```bash
|
23
|
+
rails g pu:rodauth:account user
|
24
|
+
```
|
25
|
+
- Create blogging feature package
|
26
|
+
```bash
|
27
|
+
rails g pu:pkg:feature blogging
|
28
|
+
```
|
29
|
+
- Create blog resource
|
30
|
+
```bash
|
31
|
+
rails g pu:res:scaffold blog user:belongs_to slug:text title:string content:text state:string published_at:datetime
|
32
|
+
```
|
33
|
+
- Create dashboard app package
|
34
|
+
```bash
|
35
|
+
rails g pu:pkg:app dashboard
|
36
|
+
```
|
37
|
+
- Connect the blog to the dashboard
|
38
|
+
```bash
|
39
|
+
rails g pu:res:conn
|
40
|
+
```
|
41
|
+
- Scope dashboard to user
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
# packages/dashboard_app/lib/engine.rb
|
45
|
+
|
46
|
+
scope_to_entity User, strategy: :current_user
|
47
|
+
# add directives above.
|
48
|
+
```
|
49
|
+
|
50
|
+
- Demonstrate queries
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
# packages/dashboard_app/lib/engine.rb
|
54
|
+
|
55
|
+
def define_filters
|
56
|
+
# define custom filters
|
57
|
+
define_search -> (scope, search:) { scope.where("title LIKE ?", "%#{search}%") }
|
58
|
+
end
|
59
|
+
|
60
|
+
def define_scopes
|
61
|
+
# define custom scopes
|
62
|
+
define_scope :published, -> (scope) { scope.where(state: :published) }
|
63
|
+
define_scope :drafts, -> (scope) { scope.where(state: :draft) }
|
64
|
+
end
|
65
|
+
|
66
|
+
def define_sorters
|
67
|
+
# define custom sorters
|
68
|
+
define_sorter :title
|
69
|
+
define_sorter :content
|
70
|
+
end
|
71
|
+
```
|
72
|
+
|
73
|
+
- Create a custom action
|
74
|
+
|
75
|
+
```ruby
|
76
|
+
# packages/blogging/app/interactions/blogging/blog_interactions/publish.rb
|
77
|
+
|
78
|
+
module Blogging
|
79
|
+
module BlogInteractions
|
80
|
+
class Publish < ResourceInteraction
|
81
|
+
object :resource, class: Blog
|
82
|
+
|
83
|
+
def execute
|
84
|
+
errors.merge!(resource.errors) unless resource.update(state: "published", published_at: Time.current)
|
85
|
+
resource
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
```
|
91
|
+
|
92
|
+
```ruby
|
93
|
+
# packages/blogging/app/presenters/blogging/blog_presenter.rb
|
94
|
+
|
95
|
+
define_interactive_action :publish, label: 'Publish',
|
96
|
+
interaction: BlogInteractions::Publish,
|
97
|
+
icon: "outline/book",
|
98
|
+
color: :green
|
99
|
+
```
|
100
|
+
|
101
|
+
- Create blog_comment resource
|
102
|
+
```bash
|
103
|
+
rails g pu:res:scaffold blog_comment blogging/blog:belongs_to user:belongs_to content:text
|
104
|
+
```
|
105
|
+
- Define associations
|
106
|
+
|
107
|
+
```ruby
|
108
|
+
# packages/blogging/app/models/blogging/blog.rb
|
109
|
+
|
110
|
+
has_many :comments
|
111
|
+
```
|
112
|
+
|
113
|
+
```ruby
|
114
|
+
# packages/blogging/app/policies/blogging/blog_policy.rb
|
115
|
+
|
116
|
+
def permitted_attributes_for_show
|
117
|
+
super + [:comments]
|
118
|
+
end
|
119
|
+
```
|
120
|
+
|
121
|
+
- Connect comments to demonstrate auto linking
|
122
|
+
```bash
|
123
|
+
rail g pu:res:conn
|
124
|
+
```
|
125
|
+
- Demonstrate plutonium association panels
|
126
|
+
|
127
|
+
```ruby
|
128
|
+
# packages/blogging/app/policies/blogging/blog_policy.rb
|
129
|
+
|
130
|
+
def permitted_attributes_for_show
|
131
|
+
super
|
132
|
+
end
|
133
|
+
|
134
|
+
def permitted_associations
|
135
|
+
%i[comments]
|
136
|
+
end
|
137
|
+
```
|
138
|
+
|
139
|
+
19. Demonstrate nested_attributes
|
140
|
+
|
141
|
+
```ruby
|
142
|
+
accepts_nested_attributes_for :comments, reject_if: :all_blank
|
143
|
+
|
144
|
+
define_nested_input :comments, inputs: %i[user content], limit: 1 do |input|
|
145
|
+
input.define_field_input :content, type: :markdown
|
146
|
+
end
|
147
|
+
```
|
148
|
+
|
149
|
+
- Create a custom field renderer
|
150
|
+
|
151
|
+
```bash
|
152
|
+
rails g pu:field:renderer markdown
|
153
|
+
bundle add redcarpet markdown
|
154
|
+
```
|
155
|
+
|
156
|
+
```ruby
|
157
|
+
Redcarpet::Markdown.new(Redcarpet::Render::HTML, autolink: true).render "content"
|
158
|
+
```
|
159
|
+
|
160
|
+
- Create a custom field input
|
161
|
+
|
162
|
+
```bash
|
163
|
+
rails g pu:field:input
|
164
|
+
```
|
165
|
+
|
166
|
+
https://github.com/Ionaru/easy-markdown-editor
|
167
|
+
|
168
|
+
```html
|
169
|
+
# app/views/layouts/resource.html.erb <% layout.with_assets do %>
|
170
|
+
<link
|
171
|
+
rel="stylesheet"
|
172
|
+
href="https://unpkg.com/easymde/dist/easymde.min.css"
|
173
|
+
/>
|
174
|
+
<script src="https://unpkg.com/easymde/dist/easymde.min.js"></script>
|
175
|
+
<% end %>
|
176
|
+
```
|
177
|
+
|
178
|
+
```bash
|
179
|
+
rails g stimulus markdown_input
|
180
|
+
```
|
181
|
+
|
182
|
+
```js
|
183
|
+
// app/javascript/controllers/markdown_input_controller.js
|
184
|
+
|
185
|
+
connect() {
|
186
|
+
console.log("markdown-input connected", this.element)
|
187
|
+
|
188
|
+
this.markdown = new EasyMDE({
|
189
|
+
element: this.element,
|
190
|
+
toolbar: ["bold", "italic", "heading", "|", "quote"]
|
191
|
+
})
|
192
|
+
}
|
193
|
+
|
194
|
+
disconnect() {
|
195
|
+
this.markdown.toTextArea()
|
196
|
+
this.markdown = null
|
197
|
+
}
|
198
|
+
```
|
199
|
+
|
200
|
+
```ruby
|
201
|
+
# app/plutonium/fields/inputs/markdown_input.rb
|
202
|
+
|
203
|
+
class MarkdownInput < Plutonium::Core::Fields::Inputs::Base
|
204
|
+
def render
|
205
|
+
form.input name, **options
|
206
|
+
end
|
207
|
+
|
208
|
+
private
|
209
|
+
|
210
|
+
def input_options
|
211
|
+
{input_html: {data: {controller: "markdown-input"}}}
|
212
|
+
end
|
213
|
+
end
|
214
|
+
```
|
215
|
+
|
216
|
+
```bash
|
217
|
+
rails g pu:core:assets
|
218
|
+
```
|
@@ -8,20 +8,18 @@
|
|
8
8
|
</svg>
|
9
9
|
<div>
|
10
10
|
<span class="font-medium"><%= f.error_notification %></span>
|
11
|
-
<!--
|
12
11
|
<ul class="mt-1.5 list-disc list-inside">
|
13
12
|
<% f.object.errors.full_messages.each do |message| %>
|
14
13
|
<li><%= f.error_notification message: message %></li>
|
15
14
|
<% end %>
|
16
15
|
</ul>
|
17
|
-
-->
|
18
16
|
</div>
|
19
17
|
</div>
|
20
18
|
<% end %>
|
21
19
|
|
22
20
|
<div>
|
23
21
|
<% form.inputs.values.each do |input| %>
|
24
|
-
<%= input.
|
22
|
+
<%= render input.with(form: f, record: form.record) %>
|
25
23
|
<% end %>
|
26
24
|
</div>
|
27
25
|
|
data/app/views/components/interactive_action_form/interactive_action_form_component.html.erb
CHANGED
@@ -8,20 +8,18 @@
|
|
8
8
|
</svg>
|
9
9
|
<div>
|
10
10
|
<span class="font-medium"><%= f.error_notification %></span>
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
<% end %>
|
11
|
+
<ul class="mt-1.5 list-disc list-inside">
|
12
|
+
<% f.object.errors.full_messages.each do |message| %>
|
13
|
+
<li><%= f.error_notification message: message %></li>
|
14
|
+
<% end %>
|
16
15
|
</ul>
|
17
|
-
-->
|
18
16
|
</div>
|
19
17
|
</div>
|
20
18
|
<% end %>
|
21
19
|
|
22
20
|
<div>
|
23
21
|
<% interactive_action.inputs.values.each do |input| %>
|
24
|
-
<%= input.
|
22
|
+
<%= render input.with(form: f, record: interaction) %>
|
25
23
|
<% end %>
|
26
24
|
</div>
|
27
25
|
|
data/app/views/components/nested_resource_form_fields/nested_resource_form_fields_component.html.erb
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
<%= form.simple_fields_for name, new_record, child_index: 'NEW_RECORD' do |nested| %>
|
12
12
|
<fieldset class="border-t mt-4 pt-4 first:border-t-0 first:pt-0 nested-resource-form-fields" data-new-record="<%= nested.object.new_record? %>">
|
13
13
|
<% inputs.values.each do |input| %>
|
14
|
-
<%= input.
|
14
|
+
<%= render input.with(form: nested, record: new_record) %>
|
15
15
|
<% end %>
|
16
16
|
|
17
17
|
<div class="text-right">
|
@@ -34,7 +34,7 @@
|
|
34
34
|
<%= form.simple_fields_for name do |nested| %>
|
35
35
|
<fieldset class="border-t mt-4 pt-4 first:border-t-0 first:pt-0 nested-resource-form-fields" data-new-record="<%= nested.object.new_record? %>">
|
36
36
|
<% inputs.values.each do |input| %>
|
37
|
-
<%= input.
|
37
|
+
<%= render input.with(form: nested, record: new_record) %>
|
38
38
|
<% end %>
|
39
39
|
|
40
40
|
<div>
|
@@ -7,7 +7,11 @@
|
|
7
7
|
<path fill-rule="evenodd" d="M8 4a4 4 0 100 8 4 4 0 000-8zM2 8a6 6 0 1110.89 3.476l4.817 4.817a1 1 0 01-1.414 1.414l-4.816-4.816A6 6 0 012 8z" clip-rule="evenodd" />
|
8
8
|
</svg>
|
9
9
|
</div>
|
10
|
-
|
10
|
+
|
11
|
+
<%=
|
12
|
+
render search_object.search_filter.input_definitions[:search].with(
|
13
|
+
form: f,
|
14
|
+
record:nil,
|
11
15
|
wrapper: false, label: false,
|
12
16
|
as: :string, # force string for search
|
13
17
|
placeholder: "search...",
|
@@ -21,7 +25,9 @@
|
|
21
25
|
# form_target: "focus",
|
22
26
|
turbo_permanent: true
|
23
27
|
}
|
24
|
-
|
28
|
+
}
|
29
|
+
)
|
30
|
+
%>
|
25
31
|
</div>
|
26
32
|
|
27
33
|
|
@@ -9,12 +9,19 @@
|
|
9
9
|
<div class="p-4">
|
10
10
|
<dl class="divide-y divide-gray-100">
|
11
11
|
<% details.fields.each do |name, renderer| %>
|
12
|
+
<%#
|
13
|
+
TODO:
|
14
|
+
For now, we are hacking around the need to call #with before #label
|
15
|
+
This proves there's an issue with the rendering api.
|
16
|
+
While I think of an elegant solution, this works for now.
|
17
|
+
%>
|
18
|
+
<% renderer.with(record: details.record) %>
|
12
19
|
<div class="py-6 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-0">
|
13
20
|
<dt class="text-sm font-medium leading-6 text-gray-900 dark:text-gray-300">
|
14
21
|
<%= renderer.label %>
|
15
22
|
</dt>
|
16
23
|
<dd class="mt-1 text-sm leading-6 text-gray-700 dark:text-gray-200 sm:col-span-2 sm:mt-0">
|
17
|
-
<%=
|
24
|
+
<%= render renderer %>
|
18
25
|
</dd>
|
19
26
|
</div>
|
20
27
|
<% end %>
|
@@ -24,6 +31,6 @@
|
|
24
31
|
|
25
32
|
<% if present_associations? %>
|
26
33
|
<% details.associations.each do |name, renderer| %>
|
27
|
-
<%= renderer.
|
34
|
+
<%= render renderer.with(record: details.record) %>
|
28
35
|
<% end %>
|
29
36
|
<% end %>
|
@@ -71,8 +71,16 @@
|
|
71
71
|
<% end %>
|
72
72
|
|
73
73
|
<% fields.each do |name, field| %>
|
74
|
+
<%#
|
75
|
+
TODO:
|
76
|
+
For now, we are hacking around the need to call #with before #label
|
77
|
+
This proves there's an issue with the rendering api.
|
78
|
+
While I think of an elegant solution, this works for now.
|
79
|
+
%>
|
80
|
+
<% field.with(record: resources[0]) %>
|
74
81
|
<% table.column(name:, label: field.label, search_object: search_object) do |resource| %>
|
75
|
-
|
82
|
+
<% field.with(record: resource) %>
|
83
|
+
<%= render field %>
|
76
84
|
<% end %>
|
77
85
|
<% end %>
|
78
86
|
<% end %>
|
@@ -13,6 +13,8 @@ module.exports = {
|
|
13
13
|
`${__dirname}/app/helpers/**/*.rb`,
|
14
14
|
`${__dirname}/app/assets/stylesheets/**/*.css`,
|
15
15
|
`${__dirname}/app/javascript/**/*.js`,
|
16
|
+
`${__dirname}/app/plutonium/**/*.rb`,
|
17
|
+
`${__dirname}/packages/**/app/plutonium/**/*.rb`,
|
16
18
|
`${__dirname}/packages/**/app/views/**/*.html.erb`,
|
17
19
|
].concat(plutoniumTailwindConfig.content),
|
18
20
|
}
|
@@ -15,11 +15,11 @@ module Pu
|
|
15
15
|
class_option :rodauth, type: :boolean
|
16
16
|
|
17
17
|
def start
|
18
|
-
destination_dir = (destination_app == "main_app") ? "app/views/" : "packages/#{destination_app}/app/views
|
18
|
+
destination_dir = (destination_app == "main_app") ? "app/views/" : "packages/#{destination_app}/app/views/"
|
19
19
|
[
|
20
20
|
"layouts/resource.html.erb"
|
21
21
|
].each do |file|
|
22
|
-
copy_file Plutonium.root.join("app", "views", file), Rails.root.join(destination_dir)
|
22
|
+
copy_file Plutonium.root.join("app", "views", file), Rails.root.join(destination_dir, file)
|
23
23
|
end
|
24
24
|
rescue => e
|
25
25
|
exception "#{self.class} failed:", e
|
@@ -33,6 +33,7 @@ module Pu
|
|
33
33
|
|
34
34
|
def copy_file(source_path, destination_path)
|
35
35
|
if File.exist?(source_path)
|
36
|
+
FileUtils.mkdir_p(File.dirname(destination_path))
|
36
37
|
FileUtils.cp(source_path, destination_path)
|
37
38
|
say_status("info", "Copied #{source_path} to #{destination_path}", :green)
|
38
39
|
else
|
@@ -14,12 +14,12 @@ module Pu
|
|
14
14
|
class_option :dest, type: :string
|
15
15
|
|
16
16
|
def start
|
17
|
-
destination_dir = (destination_app == "main_app") ? "app/views/" : "packages/#{destination_app}/app/views
|
17
|
+
destination_dir = (destination_app == "main_app") ? "app/views/" : "packages/#{destination_app}/app/views"
|
18
18
|
[
|
19
19
|
"application/_resource_header.html.erb",
|
20
20
|
"application/_resource_sidebar.html.erb"
|
21
21
|
].each do |file|
|
22
|
-
copy_file Plutonium.root.join("app", "views", file), Rails.root.join(destination_dir)
|
22
|
+
copy_file Plutonium.root.join("app", "views", file), Rails.root.join(destination_dir, file)
|
23
23
|
end
|
24
24
|
rescue => e
|
25
25
|
exception "#{self.class} failed:", e
|
@@ -33,6 +33,7 @@ module Pu
|
|
33
33
|
|
34
34
|
def copy_file(source_path, destination_path)
|
35
35
|
if File.exist?(source_path)
|
36
|
+
FileUtils.mkdir_p(File.dirname(destination_path))
|
36
37
|
FileUtils.cp(source_path, destination_path)
|
37
38
|
say_status("info", "Copied #{source_path} to #{destination_path}", :green)
|
38
39
|
else
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../../lib/plutonium_generators"
|
4
|
+
|
5
|
+
module Pu
|
6
|
+
module Field
|
7
|
+
class InputGenerator < Rails::Generators::Base
|
8
|
+
include PlutoniumGenerators::Generator
|
9
|
+
|
10
|
+
source_root File.expand_path("templates", __dir__)
|
11
|
+
|
12
|
+
desc "Generates a field input"
|
13
|
+
|
14
|
+
argument :name
|
15
|
+
|
16
|
+
def start
|
17
|
+
in_root do
|
18
|
+
template "input.rb", "app/plutonium/fields/inputs/#{name.underscore}_input.rb"
|
19
|
+
insert_into_file "config/initializers/plutonium.rb", registration_statement, after: /.*# Register components here.*\n/
|
20
|
+
end
|
21
|
+
rescue => e
|
22
|
+
exception "#{self.class} failed:", e
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def registration_statement
|
28
|
+
indent "Plutonium::Core::Fields::Inputs::Factory.map_type :#{name.underscore}, to: Fields::Inputs::#{name.camelize}Input\n", 2
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
File without changes
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../../lib/plutonium_generators"
|
4
|
+
|
5
|
+
module Pu
|
6
|
+
module Field
|
7
|
+
class RendererGenerator < Rails::Generators::Base
|
8
|
+
include PlutoniumGenerators::Generator
|
9
|
+
|
10
|
+
source_root File.expand_path("templates", __dir__)
|
11
|
+
|
12
|
+
desc "Generates a field renderer"
|
13
|
+
|
14
|
+
argument :name
|
15
|
+
|
16
|
+
def start
|
17
|
+
in_root do
|
18
|
+
template "renderer.rb", "app/plutonium/fields/renderers/#{name.underscore}_renderer.rb"
|
19
|
+
insert_into_file "config/initializers/plutonium.rb", registration_statement, after: /.*# Register components here.*\n/
|
20
|
+
end
|
21
|
+
rescue => e
|
22
|
+
exception "#{self.class} failed:", e
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def registration_statement
|
28
|
+
indent "Plutonium::Core::Fields::Renderers::Factory.map_type :#{name.underscore}, to: Fields::Renderers::#{name.camelize}Renderer\n", 2
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
File without changes
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../../lib/plutonium_generators"
|
4
|
+
|
5
|
+
module Pu
|
6
|
+
module Gem
|
7
|
+
class AnnotateGenerator < Rails::Generators::Base
|
8
|
+
include PlutoniumGenerators::Generator
|
9
|
+
|
10
|
+
source_root File.expand_path("templates", __dir__)
|
11
|
+
|
12
|
+
desc "Install the annnotate gem"
|
13
|
+
|
14
|
+
def start
|
15
|
+
bundle "annotate", group: :development
|
16
|
+
copy_file "lib/tasks/auto_annotate_models.rake"
|
17
|
+
rescue => e
|
18
|
+
exception "#{self.class} failed:", e
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
File without changes
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# NOTE: only doing this in development as some production environments (Heroku)
|
2
|
+
# NOTE: are sensitive to local FS writes, and besides -- it's just not proper
|
3
|
+
# NOTE: to have a dev-mode tool do its thing in production.
|
4
|
+
return unless Rails.env.development?
|
5
|
+
|
6
|
+
require "annotate"
|
7
|
+
task :set_annotation_options do
|
8
|
+
# You can override any of these by setting an environment variable of the
|
9
|
+
# same name.
|
10
|
+
Annotate.set_defaults(
|
11
|
+
"active_admin" => "false",
|
12
|
+
"additional_file_patterns" => [],
|
13
|
+
"routes" => "false",
|
14
|
+
"models" => "true",
|
15
|
+
"position_in_routes" => "before",
|
16
|
+
"position_in_class" => "before",
|
17
|
+
"position_in_test" => "before",
|
18
|
+
"position_in_fixture" => "before",
|
19
|
+
"position_in_factory" => "before",
|
20
|
+
"position_in_serializer" => "before",
|
21
|
+
"show_foreign_keys" => "true",
|
22
|
+
"show_complete_foreign_keys" => "false",
|
23
|
+
"show_indexes" => "true",
|
24
|
+
"simple_indexes" => "false",
|
25
|
+
"model_dir" => ([Rails.application.root.join("app/models")] + Dir[Rails.application.root.join("packages/*/app/models")]).join(","),
|
26
|
+
"root_dir" => "",
|
27
|
+
"include_version" => "false",
|
28
|
+
"require" => "",
|
29
|
+
"exclude_tests" => "true",
|
30
|
+
"exclude_fixtures" => "true",
|
31
|
+
"exclude_factories" => "true",
|
32
|
+
"exclude_serializers" => "true",
|
33
|
+
"exclude_scaffolds" => "true",
|
34
|
+
"exclude_controllers" => "true",
|
35
|
+
"exclude_helpers" => "true",
|
36
|
+
"exclude_sti_subclasses" => "false",
|
37
|
+
"ignore_model_sub_dir" => "false",
|
38
|
+
"ignore_columns" => nil,
|
39
|
+
"ignore_routes" => nil,
|
40
|
+
"ignore_unknown_models" => "false",
|
41
|
+
"hide_limit_column_types" => "integer,bigint,boolean",
|
42
|
+
"hide_default_column_types" => "json,jsonb,hstore",
|
43
|
+
"skip_on_db_migrate" => "false",
|
44
|
+
"format_bare" => "true",
|
45
|
+
"format_rdoc" => "false",
|
46
|
+
"format_yard" => "false",
|
47
|
+
"format_markdown" => "false",
|
48
|
+
"sort" => "false",
|
49
|
+
"force" => "false",
|
50
|
+
"frozen" => "false",
|
51
|
+
"classified_sort" => "true",
|
52
|
+
"trace" => "false",
|
53
|
+
"wrapper_open" => nil,
|
54
|
+
"wrapper_close" => nil,
|
55
|
+
"with_comment" => "true"
|
56
|
+
)
|
57
|
+
end
|
58
|
+
|
59
|
+
Annotate.load_tasks
|
@@ -2,7 +2,7 @@ module Plutonium
|
|
2
2
|
module Core
|
3
3
|
module Actions
|
4
4
|
class InteractiveAction < Plutonium::Core::Action
|
5
|
-
include Plutonium::Core::Definers::
|
5
|
+
include Plutonium::Core::Definers::FieldInputDefiner
|
6
6
|
|
7
7
|
Context = Data.define :resource_class
|
8
8
|
|
@@ -37,7 +37,7 @@ module Plutonium
|
|
37
37
|
|
38
38
|
def set_interaction(interaction)
|
39
39
|
@interaction = interaction
|
40
|
-
@inputs =
|
40
|
+
@inputs = defined_field_inputs_for(*(interaction.filters.keys - [:resource, :resources]))
|
41
41
|
@inline = @inputs.blank? unless inline == false
|
42
42
|
end
|
43
43
|
|