super 0.0.2 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +11 -0
  3. data/README.md +68 -76
  4. data/app/assets/javascripts/super/application.js +1252 -316
  5. data/app/assets/stylesheets/super/application.css +102704 -17321
  6. data/app/controllers/super/application_controller.rb +49 -71
  7. data/app/views/layouts/super/application.html.erb +10 -8
  8. data/app/views/super/application/_collection_header.html.erb +15 -0
  9. data/app/views/super/application/_filter.html.erb +14 -0
  10. data/app/views/super/application/_filter_type_select.html.erb +31 -0
  11. data/app/views/super/application/_filter_type_text.html.erb +22 -0
  12. data/app/views/super/application/_filter_type_timestamp.html.erb +35 -0
  13. data/app/views/super/application/_flash.html.erb +13 -13
  14. data/app/views/super/application/_form_field__destroy.html.erb +9 -0
  15. data/app/views/super/application/_form_field_select.html.erb +23 -0
  16. data/app/views/super/application/_form_field_text.html.erb +13 -0
  17. data/app/views/super/application/_form_fieldset.html.erb +8 -0
  18. data/app/views/super/application/_form_has_many.html.erb +21 -0
  19. data/app/views/super/application/_form_has_one.html.erb +11 -0
  20. data/app/views/super/application/_form_inline_errors.html.erb +10 -0
  21. data/app/views/super/application/_member_header.html.erb +16 -0
  22. data/app/views/super/application/_super_layout.html.erb +29 -0
  23. data/app/views/super/application/_super_pagination.html.erb +16 -0
  24. data/app/views/super/application/_super_panel.html.erb +7 -0
  25. data/app/views/super/application/_super_schema_display_actions.html.erb +5 -0
  26. data/app/views/super/application/_super_schema_display_index.html.erb +24 -0
  27. data/app/views/super/application/_super_schema_display_show.html.erb +8 -0
  28. data/app/views/super/application/_super_schema_form.html.erb +15 -0
  29. data/app/views/super/application/edit.html.erb +1 -6
  30. data/app/views/super/application/index.html.erb +1 -1
  31. data/app/views/super/application/new.html.erb +1 -6
  32. data/app/views/super/application/show.html.erb +1 -1
  33. data/app/views/super/feather/{_chevron_down.svg → _chevron_down.html} +0 -0
  34. data/config/locales/en.yml +5 -0
  35. data/docs/README.md +6 -0
  36. data/docs/cheat.md +41 -0
  37. data/docs/faq.md +44 -0
  38. data/docs/quick_start.md +45 -0
  39. data/docs/webpacker.md +17 -0
  40. data/docs/yard_customizations.rb +41 -0
  41. data/frontend/super-frontend/build.js +14 -12
  42. data/frontend/super-frontend/dist/application.css +102704 -17321
  43. data/frontend/super-frontend/dist/application.js +1252 -316
  44. data/frontend/super-frontend/package.json +11 -4
  45. data/frontend/super-frontend/postcss.config.js +4 -4
  46. data/frontend/super-frontend/src/javascripts/super/application.ts +18 -0
  47. data/frontend/super-frontend/src/javascripts/super/apply_template_controller.ts +19 -0
  48. data/frontend/super-frontend/src/javascripts/super/rails__ujs.d.ts +1 -0
  49. data/frontend/super-frontend/src/javascripts/super/toggle_pending_destruction_controller.ts +15 -0
  50. data/frontend/super-frontend/src/stylesheets/super/application.css +63 -0
  51. data/frontend/super-frontend/tailwind.config.js +12 -4
  52. data/frontend/super-frontend/tsconfig.json +13 -0
  53. data/frontend/super-frontend/yarn.lock +1891 -1798
  54. data/lib/generators/super/install/install_generator.rb +16 -0
  55. data/lib/generators/super/webpacker/webpacker_generator.rb +8 -0
  56. data/lib/super.rb +16 -6
  57. data/lib/super/action_inquirer.rb +14 -1
  58. data/lib/super/assets.rb +1 -0
  59. data/lib/super/client_error.rb +43 -0
  60. data/lib/super/compatibility.rb +25 -0
  61. data/lib/super/configuration.rb +66 -44
  62. data/lib/super/controls.rb +26 -15
  63. data/lib/super/controls/optional.rb +54 -0
  64. data/lib/super/controls/required.rb +41 -0
  65. data/lib/super/controls/steps.rb +128 -0
  66. data/lib/super/display/schema_types.rb +90 -18
  67. data/lib/super/engine.rb +7 -0
  68. data/lib/super/error.rb +9 -8
  69. data/lib/super/filter.rb +137 -0
  70. data/lib/super/filter/operator.rb +103 -0
  71. data/lib/super/filter/schema_types.rb +118 -0
  72. data/lib/super/form.rb +48 -0
  73. data/lib/super/form/schema_types.rb +96 -21
  74. data/lib/super/layout.rb +47 -0
  75. data/lib/super/link.rb +110 -0
  76. data/lib/super/navigation/automatic.rb +2 -0
  77. data/lib/super/pagination.rb +80 -8
  78. data/lib/super/panel.rb +30 -0
  79. data/lib/super/partial.rb +23 -0
  80. data/lib/super/partial/resolving.rb +24 -0
  81. data/lib/super/plugin.rb +34 -63
  82. data/lib/super/schema.rb +65 -1
  83. data/lib/super/version.rb +1 -1
  84. data/lib/super/view_helper.rb +43 -0
  85. metadata +132 -33
  86. data/app/views/super/application/_form.html.erb +0 -15
  87. data/app/views/super/application/_form_field.html.erb +0 -7
  88. data/app/views/super/application/_form_generic_select.html.erb +0 -19
  89. data/app/views/super/application/_form_generic_text.html.erb +0 -7
  90. data/app/views/super/application/_index.html.erb +0 -60
  91. data/app/views/super/application/_show.html.erb +0 -12
  92. data/frontend/super-frontend/src/javascripts/super/application.js +0 -11
  93. data/lib/super/display.rb +0 -9
  94. data/lib/super/inline_callback.rb +0 -82
  95. data/lib/super/test_support/copy_app_templates/20190216224956_create_members.rb +0 -11
  96. data/lib/super/test_support/copy_app_templates/20190803143320_create_ships.rb +0 -11
  97. data/lib/super/test_support/copy_app_templates/20190806014121_add_ship_to_members.rb +0 -5
  98. data/lib/super/test_support/copy_app_templates/member.rb +0 -16
  99. data/lib/super/test_support/copy_app_templates/members_controller.rb +0 -52
  100. data/lib/super/test_support/copy_app_templates/routes.rb +0 -10
  101. data/lib/super/test_support/copy_app_templates/seeds.rb +0 -2
  102. data/lib/super/test_support/copy_app_templates/ship.rb +0 -3
  103. data/lib/super/test_support/copy_app_templates/ships_controller.rb +0 -47
  104. data/lib/super/test_support/fixtures/members.yml +0 -336
  105. data/lib/super/test_support/fixtures/ships.yml +0 -10
  106. data/lib/super/test_support/generate_copy_app.rb +0 -52
  107. data/lib/super/test_support/generate_dummy.rb +0 -94
  108. data/lib/super/test_support/starfleet_seeder.rb +0 -49
  109. data/lib/super/view.rb +0 -25
  110. data/lib/tasks/super_tasks.rake +0 -4
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: super
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zach Ahn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-24 00:00:00.000000000 Z
11
+ date: 2020-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rails
14
+ name: railties
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -24,20 +24,82 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '5.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '5.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '5.0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: capybara
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.18'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.18'
55
+ - !ruby/object:Gem::Dependency
56
+ name: selenium-webdriver
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.142'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.142'
69
+ - !ruby/object:Gem::Dependency
70
+ name: webdrivers
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '4.3'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '4.3'
83
+ - !ruby/object:Gem::Dependency
84
+ name: puma
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '4.3'
31
90
  - - ">="
32
91
  - !ruby/object:Gem::Version
33
- version: '0'
92
+ version: 4.3.6
34
93
  type: :development
35
94
  prerelease: false
36
95
  version_requirements: !ruby/object:Gem::Requirement
37
96
  requirements:
97
+ - - "~>"
98
+ - !ruby/object:Gem::Version
99
+ version: '4.3'
38
100
  - - ">="
39
101
  - !ruby/object:Gem::Version
40
- version: '0'
102
+ version: 4.3.6
41
103
  - !ruby/object:Gem::Dependency
42
104
  name: sqlite3
43
105
  requirement: !ruby/object:Gem::Requirement
@@ -122,6 +184,20 @@ dependencies:
122
184
  - - ">="
123
185
  - !ruby/object:Gem::Version
124
186
  version: '0'
187
+ - !ruby/object:Gem::Dependency
188
+ name: i18n-debug
189
+ requirement: !ruby/object:Gem::Requirement
190
+ requirements:
191
+ - - ">="
192
+ - !ruby/object:Gem::Version
193
+ version: '0'
194
+ type: :development
195
+ prerelease: false
196
+ version_requirements: !ruby/object:Gem::Requirement
197
+ requirements:
198
+ - - ">="
199
+ - !ruby/object:Gem::Version
200
+ version: '0'
125
201
  description:
126
202
  email:
127
203
  - engineering@zachahn.com
@@ -129,6 +205,7 @@ executables: []
129
205
  extensions: []
130
206
  extra_rdoc_files: []
131
207
  files:
208
+ - ".yardopts"
132
209
  - LICENSE
133
210
  - README.md
134
211
  - Rakefile
@@ -137,29 +214,54 @@ files:
137
214
  - app/assets/stylesheets/super/application.css
138
215
  - app/controllers/super/application_controller.rb
139
216
  - app/views/layouts/super/application.html.erb
217
+ - app/views/super/application/_collection_header.html.erb
218
+ - app/views/super/application/_filter.html.erb
219
+ - app/views/super/application/_filter_type_select.html.erb
220
+ - app/views/super/application/_filter_type_text.html.erb
221
+ - app/views/super/application/_filter_type_timestamp.html.erb
140
222
  - app/views/super/application/_flash.html.erb
141
- - app/views/super/application/_form.html.erb
142
- - app/views/super/application/_form_field.html.erb
143
- - app/views/super/application/_form_generic_select.html.erb
144
- - app/views/super/application/_form_generic_text.html.erb
145
- - app/views/super/application/_index.html.erb
146
- - app/views/super/application/_show.html.erb
223
+ - app/views/super/application/_form_field__destroy.html.erb
224
+ - app/views/super/application/_form_field_select.html.erb
225
+ - app/views/super/application/_form_field_text.html.erb
226
+ - app/views/super/application/_form_fieldset.html.erb
227
+ - app/views/super/application/_form_has_many.html.erb
228
+ - app/views/super/application/_form_has_one.html.erb
229
+ - app/views/super/application/_form_inline_errors.html.erb
230
+ - app/views/super/application/_member_header.html.erb
231
+ - app/views/super/application/_super_layout.html.erb
232
+ - app/views/super/application/_super_pagination.html.erb
233
+ - app/views/super/application/_super_panel.html.erb
234
+ - app/views/super/application/_super_schema_display_actions.html.erb
235
+ - app/views/super/application/_super_schema_display_index.html.erb
236
+ - app/views/super/application/_super_schema_display_show.html.erb
237
+ - app/views/super/application/_super_schema_form.html.erb
147
238
  - app/views/super/application/edit.html.erb
148
239
  - app/views/super/application/index.html.erb
149
240
  - app/views/super/application/new.html.erb
150
241
  - app/views/super/application/nothing.html.erb
151
242
  - app/views/super/application/show.html.erb
152
243
  - app/views/super/feather/README.md
153
- - app/views/super/feather/_chevron_down.svg
244
+ - app/views/super/feather/_chevron_down.html
245
+ - config/locales/en.yml
154
246
  - config/routes.rb
247
+ - docs/README.md
248
+ - docs/cheat.md
249
+ - docs/faq.md
250
+ - docs/quick_start.md
251
+ - docs/webpacker.md
252
+ - docs/yard_customizations.rb
155
253
  - frontend/super-frontend/build.js
156
254
  - frontend/super-frontend/dist/application.css
157
255
  - frontend/super-frontend/dist/application.js
158
256
  - frontend/super-frontend/package.json
159
257
  - frontend/super-frontend/postcss.config.js
160
- - frontend/super-frontend/src/javascripts/super/application.js
258
+ - frontend/super-frontend/src/javascripts/super/application.ts
259
+ - frontend/super-frontend/src/javascripts/super/apply_template_controller.ts
260
+ - frontend/super-frontend/src/javascripts/super/rails__ujs.d.ts
261
+ - frontend/super-frontend/src/javascripts/super/toggle_pending_destruction_controller.ts
161
262
  - frontend/super-frontend/src/stylesheets/super/application.css
162
263
  - frontend/super-frontend/tailwind.config.js
264
+ - frontend/super-frontend/tsconfig.json
163
265
  - frontend/super-frontend/yarn.lock
164
266
  - lib/generators/super/install/USAGE
165
267
  - lib/generators/super/install/install_generator.rb
@@ -174,35 +276,32 @@ files:
174
276
  - lib/super.rb
175
277
  - lib/super/action_inquirer.rb
176
278
  - lib/super/assets.rb
279
+ - lib/super/client_error.rb
280
+ - lib/super/compatibility.rb
177
281
  - lib/super/configuration.rb
178
282
  - lib/super/controls.rb
179
- - lib/super/display.rb
283
+ - lib/super/controls/optional.rb
284
+ - lib/super/controls/required.rb
285
+ - lib/super/controls/steps.rb
180
286
  - lib/super/display/schema_types.rb
181
287
  - lib/super/engine.rb
182
288
  - lib/super/error.rb
289
+ - lib/super/filter.rb
290
+ - lib/super/filter/operator.rb
291
+ - lib/super/filter/schema_types.rb
292
+ - lib/super/form.rb
183
293
  - lib/super/form/schema_types.rb
184
- - lib/super/inline_callback.rb
294
+ - lib/super/layout.rb
295
+ - lib/super/link.rb
185
296
  - lib/super/navigation/automatic.rb
186
297
  - lib/super/pagination.rb
298
+ - lib/super/panel.rb
299
+ - lib/super/partial.rb
300
+ - lib/super/partial/resolving.rb
187
301
  - lib/super/plugin.rb
188
302
  - lib/super/schema.rb
189
- - lib/super/test_support/copy_app_templates/20190216224956_create_members.rb
190
- - lib/super/test_support/copy_app_templates/20190803143320_create_ships.rb
191
- - lib/super/test_support/copy_app_templates/20190806014121_add_ship_to_members.rb
192
- - lib/super/test_support/copy_app_templates/member.rb
193
- - lib/super/test_support/copy_app_templates/members_controller.rb
194
- - lib/super/test_support/copy_app_templates/routes.rb
195
- - lib/super/test_support/copy_app_templates/seeds.rb
196
- - lib/super/test_support/copy_app_templates/ship.rb
197
- - lib/super/test_support/copy_app_templates/ships_controller.rb
198
- - lib/super/test_support/fixtures/members.yml
199
- - lib/super/test_support/fixtures/ships.yml
200
- - lib/super/test_support/generate_copy_app.rb
201
- - lib/super/test_support/generate_dummy.rb
202
- - lib/super/test_support/starfleet_seeder.rb
203
303
  - lib/super/version.rb
204
- - lib/super/view.rb
205
- - lib/tasks/super_tasks.rake
304
+ - lib/super/view_helper.rb
206
305
  homepage:
207
306
  licenses:
208
307
  - LGPL-3.0-only
@@ -222,8 +321,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
222
321
  - !ruby/object:Gem::Version
223
322
  version: '0'
224
323
  requirements: []
225
- rubygems_version: 3.0.3
324
+ rubygems_version: 3.1.4
226
325
  signing_key:
227
326
  specification_version: 4
228
- summary: A simple, powerful, single dependency Rails admin framework
327
+ summary: A simple, powerful, zero dependency Rails admin framework
229
328
  test_files: []
@@ -1,15 +0,0 @@
1
- <% schema = controls.form_schema(action: action_inquirer) %>
2
-
3
- <%= form_for(Super.configuration.path_parts(resource)) do |f| %>
4
- <% schema.fields.each do |field, type| %>
5
- <%= render(
6
- type,
7
- form: f,
8
- column: field,
9
- resource: resource
10
- ) %>
11
- <% end %>
12
- <div>
13
- <%= f.submit class: "bg-blue-700 hover:bg-blue-800 text-white py-2 px-4 rounded mt-2" %>
14
- </div>
15
- <% end %>
@@ -1,7 +0,0 @@
1
- <div class="lg:w-1/3">
2
- <%= f.label column %>
3
- <%= f.text_field column, class: "appearance-none border rounded w-full py-2 px-2 text-gray-900 leading-tight border border-gray-400 focus:border-blue-400 mt-2" %>
4
- <% resource.errors.full_messages_for(column).each do |error_message| %>
5
- <p class="text-red-400 text-xs italic pt-1"><%= error_message %></p>
6
- <% end %>
7
- </div>
@@ -1,19 +0,0 @@
1
- <div class="lg:w-1/3">
2
- <%= form.label(column) %>
3
- <div class="relative mt-2">
4
- <%= form.select(
5
- column,
6
- form_generic_select[:collection],
7
- { include_blank: true },
8
- { class: "appearance-none border rounded w-full py-2 px-2 text-gray-900 leading-tight border border-gray-400 focus:border-blue-400 block" }
9
- ) %>
10
- <div class="pointer-events-none absolute inset-y-0 right-0 flex items-center px-2 text-gray-700">
11
- <span class="fill-current h-4 w-4">
12
- <%= render "super/feather/chevron_down.svg" %>
13
- </span>
14
- </div>
15
- </div>
16
- <% resource.errors.full_messages_for(column).each do |error_message| %>
17
- <p class="text-red-400 text-xs italic pt-1"><%= error_message %></p>
18
- <% end %>
19
- </div>
@@ -1,7 +0,0 @@
1
- <div class="lg:w-1/3">
2
- <%= form.label(column) %>
3
- <%= form.text_field(column, class: "appearance-none border rounded w-full py-2 px-2 text-gray-900 leading-tight border border-gray-400 focus:border-blue-400 mt-2") %>
4
- <% resource.errors.full_messages_for(column).each do |error_message| %>
5
- <p class="text-red-400 text-xs italic pt-1"><%= error_message %></p>
6
- <% end %>
7
- </div>
@@ -1,60 +0,0 @@
1
- <% schema = controls.display_schema(action: action_inquirer) %>
2
-
3
- <% content_for(:header) do %>
4
- <header>
5
- <h1 class="text-3xl inline-block">
6
- <%= controls.title %>
7
- </h1>
8
- <%= link_to(
9
- "New #{controls.model.name}",
10
- new_polymorphic_path(Super.configuration.path_parts(controls.model.new)),
11
- class: "inline-block"
12
- ) %>
13
- </header>
14
- <% end %>
15
-
16
- <table class="w-full leading-loose mt-4">
17
- <thead class="border-gray-400 border-solid">
18
- <tr>
19
- <% (schema.field_keys + ["Actions"]).each do |column| %>
20
- <th class="text-left"><%= column.to_s.humanize %></th>
21
- <% end %>
22
- </tr>
23
- </thead>
24
- <tbody>
25
- <% @resources.each.with_index do |resource, index| %>
26
- <tr id="resource-pk-<%= resource.id %>" class="<%= index.even? ? "bg-gray-100" : "" %>" >
27
- <% schema.field_keys.each do |column| %>
28
- <td><%= Super::Display.format(schema, resource, column) %></td>
29
- <% end %>
30
- <td>
31
- <%= link_to(
32
- "View",
33
- polymorphic_path(Super.configuration.path_parts(resource))
34
- ) %>
35
- <%= link_to(
36
- "Edit",
37
- edit_polymorphic_path(Super.configuration.path_parts(resource))
38
- ) %>
39
- <%= link_to(
40
- "Delete",
41
- polymorphic_path(Super.configuration.path_parts(resource)),
42
- method: :delete,
43
- data: { confirm: "Really delete?" }
44
- ) %>
45
- </td>
46
- </tr>
47
- <% end %>
48
- </tbody>
49
- </table>
50
-
51
- <% @pagination.each do |page_query_params, is_current_page, display| %>
52
- <%= link_to(
53
- display,
54
- polymorphic_path(
55
- Super.configuration.path_parts(controls.model),
56
- page_query_params
57
- ),
58
- class: "#{is_current_page ? " text-gray-900" : ""}"
59
- ) %>
60
- <% end %>
@@ -1,12 +0,0 @@
1
- <% schema = controls.display_schema(action: action_inquirer) %>
2
-
3
- <h1 class="text-3xl"><%= controls.title %></h1>
4
-
5
- <table class="max-w-full leading-loose mt-4">
6
- <% schema.field_keys.each do |column| %>
7
- <tr>
8
- <th class="text-right px-4"><%= column.to_s.humanize %></th>
9
- <td><%= Super::Display.format(schema, @resource, column) %></td>
10
- </tr>
11
- <% end %>
12
- </table>
@@ -1,11 +0,0 @@
1
- import RailsUjs from 'rails-ujs';
2
- import { Application, Controller } from 'stimulus';
3
-
4
- RailsUjs.start();
5
-
6
- const application = Application.start()
7
-
8
- export default {
9
- StimulusApplication: application,
10
- StimulusController: Controller,
11
- };
@@ -1,9 +0,0 @@
1
- module Super
2
- class Display
3
- def self.format(schema, resource, column)
4
- value = resource.public_send(column)
5
-
6
- schema.fields[column].present(value)
7
- end
8
- end
9
- end
@@ -1,82 +0,0 @@
1
- module Super
2
- module InlineCallback
3
- extend ActiveSupport::Concern
4
-
5
- included do
6
- register_inline_callback(:yield, on: :index)
7
- end
8
-
9
- class_methods do
10
- def inline_callback_registry
11
- @inline_callback_registry ||= {}
12
- end
13
-
14
- def inline_callback_defined?(action)
15
- action = action.to_sym
16
-
17
- inline_callback_registry.key?(action)
18
- end
19
-
20
- def inline_callbacks_for(action, check_ancestors = true)
21
- action = action.to_sym
22
-
23
- inline_callback_registry[action] ||= {}
24
-
25
- if check_ancestors
26
- ancestors.each do |ancestor|
27
- if ancestor.respond_to?(:inline_callback_defined?)
28
- if ancestor.inline_callback_defined?(action)
29
- parent_class_callbacks = ancestor.inline_callbacks_for(action, false)
30
- inline_callback_registry[action] = parent_class_callbacks.merge(inline_callback_registry[action])
31
- end
32
- end
33
-
34
- if ancestor == Super::ApplicationController
35
- break
36
- end
37
- end
38
- end
39
-
40
- inline_callback_registry[action]
41
- end
42
-
43
- def register_inline_callback(callback, on:, after: nil)
44
- action = on.to_sym
45
- after = after.to_sym if after.respond_to?(:to_sym)
46
-
47
- callbacks = inline_callbacks_for(action)
48
- if !callbacks.key?(callback)
49
- callbacks[callback] = []
50
- end
51
-
52
- if after
53
- callbacks[callback].push(after)
54
- end
55
- end
56
- end
57
-
58
- def with_inline_callbacks
59
- action = params[:action].to_sym
60
-
61
- callbacks = self.class.inline_callbacks_for(action)
62
-
63
- each_node = -> (&b) { callbacks.each_key(&b) }
64
- each_child = -> (cb, &b) { callbacks[cb].each(&b) }
65
-
66
- yield_called = false
67
-
68
- TSort.tsort_each(each_node, each_child) do |callback|
69
- if callback == :yield
70
- yield_called = true
71
- yield
72
- else
73
- send(callback)
74
- end
75
- end
76
-
77
- if !yield_called
78
- yield
79
- end
80
- end
81
- end
82
- end