super 0.0.15 → 0.19.0.rc1

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.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/app/assets/javascripts/super/application.js +1403 -127
  4. data/app/assets/stylesheets/super/application.css +90708 -90026
  5. data/app/controllers/super/application_controller.rb +73 -40
  6. data/app/controllers/super/substructure_controller.rb +349 -0
  7. data/app/helpers/super/form_builder_helper.rb +7 -0
  8. data/app/views/layouts/super/application.html.erb +3 -21
  9. data/app/views/super/application/_batch_button.html.erb +12 -0
  10. data/app/views/super/application/_batch_checkbox.csv.erb +1 -0
  11. data/app/views/super/application/_batch_checkbox.html.erb +5 -0
  12. data/app/views/super/application/_batch_form.html.erb +3 -0
  13. data/app/views/super/application/_collection_header.html.erb +8 -7
  14. data/app/views/super/application/_csv_button.html.erb +25 -0
  15. data/app/views/super/application/_display_actions.html.erb +2 -2
  16. data/app/views/super/application/_display_index.html.erb +1 -1
  17. data/app/views/super/application/_display_show.html.erb +1 -1
  18. data/app/views/super/application/_filter.html.erb +62 -2
  19. data/app/views/super/application/_layout.html.erb +13 -14
  20. data/app/views/super/application/_link.html.erb +8 -0
  21. data/app/views/super/application/_member_header.html.erb +8 -8
  22. data/app/views/super/application/_pagination.html.erb +2 -1
  23. data/app/views/super/application/_site_footer.html.erb +3 -0
  24. data/app/views/super/application/_site_header.html.erb +17 -0
  25. data/app/views/super/application/_sort_expression.html.erb +2 -2
  26. data/app/views/super/application/_view_chain.html.erb +5 -0
  27. data/app/views/super/application/index.csv.erb +14 -0
  28. data/config/locales/en.yml +8 -0
  29. data/frontend/super-frontend/dist/application.css +90708 -90026
  30. data/frontend/super-frontend/dist/application.js +1403 -127
  31. data/frontend/super-frontend/dist/package.json +13 -0
  32. data/lib/generators/super/install/templates/base_controller.rb.tt +0 -8
  33. data/lib/generators/super/resource/templates/resources_controller.rb.tt +4 -4
  34. data/lib/generators/super/webpacker/USAGE +1 -7
  35. data/lib/generators/super/webpacker/templates/pack_super_application.js.tt +2 -0
  36. data/lib/generators/super/webpacker/webpacker_generator.rb +10 -6
  37. data/lib/super/action_inquirer.rb +7 -0
  38. data/lib/super/badge.rb +0 -1
  39. data/lib/super/cheat.rb +7 -6
  40. data/lib/super/display/guesser.rb +1 -1
  41. data/lib/super/display/schema_types.rb +6 -1
  42. data/lib/super/display.rb +2 -1
  43. data/lib/super/engine.rb +5 -0
  44. data/lib/super/error.rb +12 -0
  45. data/lib/super/filter/form_object.rb +74 -48
  46. data/lib/super/filter/guesser.rb +2 -0
  47. data/lib/super/filter/operator.rb +90 -64
  48. data/lib/super/filter/schema_types.rb +63 -80
  49. data/lib/super/filter.rb +1 -1
  50. data/lib/super/form/builder.rb +6 -3
  51. data/lib/super/form/field_transcript.rb +43 -0
  52. data/lib/super/form/guesser.rb +1 -1
  53. data/lib/super/form/schema_types.rb +11 -20
  54. data/lib/super/layout.rb +9 -33
  55. data/lib/super/link.rb +3 -8
  56. data/lib/super/link_builder.rb +0 -4
  57. data/lib/super/packaged_asset.rb +49 -0
  58. data/lib/super/pagination.rb +4 -3
  59. data/lib/super/reorderable_hash.rb +88 -0
  60. data/lib/super/reset.rb +24 -0
  61. data/lib/super/schema.rb +4 -0
  62. data/lib/super/version.rb +1 -1
  63. data/lib/super/view_chain.rb +25 -0
  64. data/lib/super.rb +4 -1
  65. data/lib/tasks/super/cheat.rake +1 -1
  66. metadata +51 -15
  67. data/app/views/super/application/_filter_type_select.html.erb +0 -21
  68. data/app/views/super/application/_filter_type_text.html.erb +0 -18
  69. data/app/views/super/application/_filter_type_timestamp.html.erb +0 -24
  70. data/app/views/super/application/_form_field_select.html.erb +0 -1
  71. data/lib/generators/super/webpacker/templates/pack_super_application.js.erb.tt +0 -2
  72. data/lib/super/controls/optional.rb +0 -122
  73. data/lib/super/controls/steps.rb +0 -133
  74. data/lib/super/controls/view.rb +0 -55
  75. data/lib/super/controls.rb +0 -22
data/lib/super.rb CHANGED
@@ -14,7 +14,6 @@ require "super/badge"
14
14
  require "super/client_error"
15
15
  require "super/compatibility"
16
16
  require "super/configuration"
17
- require "super/controls"
18
17
  require "super/display"
19
18
  require "super/display/guesser"
20
19
  require "super/display/schema_types"
@@ -26,6 +25,7 @@ require "super/filter/operator"
26
25
  require "super/filter/schema_types"
27
26
  require "super/form"
28
27
  require "super/form/builder"
28
+ require "super/form/field_transcript"
29
29
  require "super/form/guesser"
30
30
  require "super/form/inline_errors"
31
31
  require "super/form/schema_types"
@@ -34,16 +34,19 @@ require "super/layout"
34
34
  require "super/link"
35
35
  require "super/link_builder"
36
36
  require "super/navigation"
37
+ require "super/packaged_asset"
37
38
  require "super/pagination"
38
39
  require "super/panel"
39
40
  require "super/partial"
40
41
  require "super/plugin"
41
42
  require "super/query/form_object"
43
+ require "super/reorderable_hash"
42
44
  require "super/reset"
43
45
  require "super/schema"
44
46
  require "super/schema/guesser"
45
47
  require "super/sort"
46
48
  require "super/version"
49
+ require "super/view_chain"
47
50
  require "super/view_helper"
48
51
 
49
52
  require "super/engine"
@@ -4,6 +4,6 @@ namespace :super do
4
4
  task :cheat do
5
5
  require "super/cheat"
6
6
  cheat = Super::Cheat.new
7
- cheat.controls
7
+ cheat.controller
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: super
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.19.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zach Ahn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-01 00:00:00.000000000 Z
11
+ date: 2021-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -115,7 +115,7 @@ dependencies:
115
115
  - !ruby/object:Gem::Version
116
116
  version: '0'
117
117
  - !ruby/object:Gem::Dependency
118
- name: pry
118
+ name: pry-rails
119
119
  requirement: !ruby/object:Gem::Requirement
120
120
  requirements:
121
121
  - - ">="
@@ -212,6 +212,34 @@ dependencies:
212
212
  - - ">="
213
213
  - !ruby/object:Gem::Version
214
214
  version: '0'
215
+ - !ruby/object:Gem::Dependency
216
+ name: rails_anonymous_controller_testing
217
+ requirement: !ruby/object:Gem::Requirement
218
+ requirements:
219
+ - - ">="
220
+ - !ruby/object:Gem::Version
221
+ version: '0'
222
+ type: :development
223
+ prerelease: false
224
+ version_requirements: !ruby/object:Gem::Requirement
225
+ requirements:
226
+ - - ">="
227
+ - !ruby/object:Gem::Version
228
+ version: '0'
229
+ - !ruby/object:Gem::Dependency
230
+ name: minitest-bisect
231
+ requirement: !ruby/object:Gem::Requirement
232
+ requirements:
233
+ - - ">="
234
+ - !ruby/object:Gem::Version
235
+ version: '0'
236
+ type: :development
237
+ prerelease: false
238
+ version_requirements: !ruby/object:Gem::Requirement
239
+ requirements:
240
+ - - ">="
241
+ - !ruby/object:Gem::Version
242
+ version: '0'
215
243
  description:
216
244
  email:
217
245
  - engineering@zachahn.com
@@ -226,33 +254,40 @@ files:
226
254
  - app/assets/javascripts/super/application.js
227
255
  - app/assets/stylesheets/super/application.css
228
256
  - app/controllers/super/application_controller.rb
257
+ - app/controllers/super/substructure_controller.rb
229
258
  - app/helpers/super/form_builder_helper.rb
230
259
  - app/views/layouts/super/application.html.erb
260
+ - app/views/super/application/_batch_button.html.erb
261
+ - app/views/super/application/_batch_checkbox.csv.erb
262
+ - app/views/super/application/_batch_checkbox.html.erb
263
+ - app/views/super/application/_batch_form.html.erb
231
264
  - app/views/super/application/_collection_header.html.erb
265
+ - app/views/super/application/_csv_button.html.erb
232
266
  - app/views/super/application/_display_actions.html.erb
233
267
  - app/views/super/application/_display_index.html.erb
234
268
  - app/views/super/application/_display_rich_text.html.erb
235
269
  - app/views/super/application/_display_show.html.erb
236
270
  - app/views/super/application/_filter.html.erb
237
- - app/views/super/application/_filter_type_select.html.erb
238
- - app/views/super/application/_filter_type_text.html.erb
239
- - app/views/super/application/_filter_type_timestamp.html.erb
240
271
  - app/views/super/application/_flash.html.erb
241
272
  - app/views/super/application/_form.html.erb
242
273
  - app/views/super/application/_form_field.html.erb
243
274
  - app/views/super/application/_form_field__destroy.html.erb
244
- - app/views/super/application/_form_field_select.html.erb
245
275
  - app/views/super/application/_form_fieldset.html.erb
246
276
  - app/views/super/application/_form_has_many.html.erb
247
277
  - app/views/super/application/_form_has_one.html.erb
248
278
  - app/views/super/application/_layout.html.erb
279
+ - app/views/super/application/_link.html.erb
249
280
  - app/views/super/application/_member_header.html.erb
250
281
  - app/views/super/application/_pagination.html.erb
251
282
  - app/views/super/application/_panel.html.erb
252
283
  - app/views/super/application/_query.html.erb
284
+ - app/views/super/application/_site_footer.html.erb
285
+ - app/views/super/application/_site_header.html.erb
253
286
  - app/views/super/application/_sort.html.erb
254
287
  - app/views/super/application/_sort_expression.html.erb
288
+ - app/views/super/application/_view_chain.html.erb
255
289
  - app/views/super/application/edit.html.erb
290
+ - app/views/super/application/index.csv.erb
256
291
  - app/views/super/application/index.html.erb
257
292
  - app/views/super/application/new.html.erb
258
293
  - app/views/super/application/nothing.html.erb
@@ -263,6 +298,7 @@ files:
263
298
  - config/routes.rb
264
299
  - frontend/super-frontend/dist/application.css
265
300
  - frontend/super-frontend/dist/application.js
301
+ - frontend/super-frontend/dist/package.json
266
302
  - lib/generators/super/action_text/USAGE
267
303
  - lib/generators/super/action_text/action_text_generator.rb
268
304
  - lib/generators/super/action_text/templates/pack_super_action_text.css
@@ -275,7 +311,7 @@ files:
275
311
  - lib/generators/super/resource/resource_generator.rb
276
312
  - lib/generators/super/resource/templates/resources_controller.rb.tt
277
313
  - lib/generators/super/webpacker/USAGE
278
- - lib/generators/super/webpacker/templates/pack_super_application.js.erb.tt
314
+ - lib/generators/super/webpacker/templates/pack_super_application.js.tt
279
315
  - lib/generators/super/webpacker/webpacker_generator.rb
280
316
  - lib/super.rb
281
317
  - lib/super/action_inquirer.rb
@@ -285,10 +321,6 @@ files:
285
321
  - lib/super/client_error.rb
286
322
  - lib/super/compatibility.rb
287
323
  - lib/super/configuration.rb
288
- - lib/super/controls.rb
289
- - lib/super/controls/optional.rb
290
- - lib/super/controls/steps.rb
291
- - lib/super/controls/view.rb
292
324
  - lib/super/display.rb
293
325
  - lib/super/display/guesser.rb
294
326
  - lib/super/display/schema_types.rb
@@ -301,6 +333,7 @@ files:
301
333
  - lib/super/filter/schema_types.rb
302
334
  - lib/super/form.rb
303
335
  - lib/super/form/builder.rb
336
+ - lib/super/form/field_transcript.rb
304
337
  - lib/super/form/guesser.rb
305
338
  - lib/super/form/inline_errors.rb
306
339
  - lib/super/form/schema_types.rb
@@ -309,12 +342,14 @@ files:
309
342
  - lib/super/link.rb
310
343
  - lib/super/link_builder.rb
311
344
  - lib/super/navigation.rb
345
+ - lib/super/packaged_asset.rb
312
346
  - lib/super/pagination.rb
313
347
  - lib/super/panel.rb
314
348
  - lib/super/partial.rb
315
349
  - lib/super/partial/resolving.rb
316
350
  - lib/super/plugin.rb
317
351
  - lib/super/query/form_object.rb
352
+ - lib/super/reorderable_hash.rb
318
353
  - lib/super/reset.rb
319
354
  - lib/super/schema.rb
320
355
  - lib/super/schema/common.rb
@@ -323,6 +358,7 @@ files:
323
358
  - lib/super/useful/builder.rb
324
359
  - lib/super/useful/enum.rb
325
360
  - lib/super/version.rb
361
+ - lib/super/view_chain.rb
326
362
  - lib/super/view_helper.rb
327
363
  - lib/tasks/super/cheat.rake
328
364
  homepage:
@@ -345,11 +381,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
345
381
  version: 2.3.0
346
382
  required_rubygems_version: !ruby/object:Gem::Requirement
347
383
  requirements:
348
- - - ">="
384
+ - - ">"
349
385
  - !ruby/object:Gem::Version
350
- version: '0'
386
+ version: 1.3.1
351
387
  requirements: []
352
- rubygems_version: 3.2.4
388
+ rubygems_version: 3.0.3.1
353
389
  signing_key:
354
390
  specification_version: 4
355
391
  summary: A simple, powerful, zero dependency Rails admin framework
@@ -1,21 +0,0 @@
1
- <div class="super-field-group" data-controller="clean-filter-param">
2
- <%= form.fields_for(filter_type_select.field_name, filter_type_select) do |form_field| %>
3
- <%= form_field.label(:q, filter_type_select.humanized_field_name) %>
4
- <div class="inline-block">
5
- <%= form_field.super.select(
6
- :op,
7
- filter_type_select.operators,
8
- { include_blank: false },
9
- data: { clean_filter_param_target: "candidate" }
10
- ) %>
11
- </div>
12
- <div class="mt-3">
13
- <%= form_field.super.select(
14
- :q,
15
- filter_type_select.field_type.collection,
16
- {},
17
- data: { clean_filter_param_target: "control candidate" }
18
- ) %>
19
- </div>
20
- <% end %>
21
- </div>
@@ -1,18 +0,0 @@
1
- <div class="super-field-group" data-controller="clean-filter-param">
2
- <%= form.fields_for(filter_type_text.field_name, filter_type_text) do |form_field| %>
3
- <%= form_field.label(:q, filter_type_text.humanized_field_name) %>
4
- <div class="inline-block">
5
- <%= form_field.super.select(
6
- :op,
7
- filter_type_text.operators,
8
- { include_blank: false },
9
- data: { clean_filter_param_target: "candidate" }
10
- ) %>
11
- </div>
12
- <%= form_field.super.text_field(
13
- :q,
14
- class: "mt-3",
15
- data: { clean_filter_param_target: "control candidate" }
16
- ) %>
17
- <% end %>
18
- </div>
@@ -1,24 +0,0 @@
1
- <div class="super-field-group" data-controller="clean-filter-param">
2
- <%= form.fields_for(filter_type_timestamp.field_name, filter_type_timestamp) do |form_field| %>
3
- <%= form_field.label(:q0, filter_type_timestamp.humanized_field_name) %>
4
- <div class="inline-block mt-2">
5
- <%= form_field.super.select(
6
- :op,
7
- filter_type_timestamp.operators,
8
- { include_blank: false },
9
- data: { clean_filter_param_target: "candidate" }
10
- ) %>
11
- </div>
12
- <div class="flex items-center mt-3">
13
- <div class="flex-initial">
14
- <%= form_field.super.datetime_flatpickr(:q0, data: { clean_filter_param_target: "control candidate" }) %>
15
- </div>
16
- <div class="flex-initial px-2">
17
- &ndash;
18
- </div>
19
- <div class="flex-initial">
20
- <%= form_field.super.datetime_flatpickr(:q1, data: { clean_filter_param_target: "control candidate" }) %>
21
- </div>
22
- </div>
23
- <% end %>
24
- </div>
@@ -1 +0,0 @@
1
- <%= form.super.select!(column, form_field_select[:collection]) %>
@@ -1,2 +0,0 @@
1
- import Super from "<%%= Super::Assets.dist("super", "super-frontend").join("application") %>";
2
- import "<%%= Super::Assets.dist("super", "super-frontend").join("application.css") %>";
@@ -1,122 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Super
4
- class Controls
5
- # Methods for `Controls` that have a sane default implementation
6
- module Optional
7
- # This is an optional method
8
- #
9
- # @return [String]
10
- def title
11
- model.name.pluralize
12
- end
13
-
14
- # Configures what database records are visible on load. This is an optional
15
- # method, it defaults to "`all`" methods
16
- #
17
- # @param action [ActionInquirer]
18
- # @return [ActiveRecord::Relation]
19
- def scope(action:)
20
- model.all
21
- end
22
-
23
- # Configures the fields that are displayed on the index and show actions.
24
- # This is a required method
25
- #
26
- # @param action [ActionInquirer]
27
- # @return [Display]
28
- def display_schema(action:)
29
- Display.new do |fields, type|
30
- Display::Guesser.new(model: model, action: action, fields: fields, type: type).call
31
- end
32
- end
33
-
34
- # Configures the editable fields on the new and edit actions. This is a
35
- # required method
36
- #
37
- # @param action [ActionInquirer]
38
- # @return [Form]
39
- def form_schema(action:)
40
- Form.new do |fields, type|
41
- Form::Guesser.new(model: model, fields: fields, type: type).call
42
- end
43
- end
44
-
45
- # Configures which parameters could be written to the database. This is a
46
- # required method
47
- #
48
- # @param params [ActionController::Parameters]
49
- # @param action [ActionInquirer]
50
- # @return [ActionController::Parameters]
51
- def permitted_params(params, action:)
52
- strong_params = Super::Form::StrongParams.new(form_schema(action: action))
53
- params.require(strong_params.require(model)).permit(strong_params.permit)
54
- end
55
-
56
- # Configures the actions linked to on the index page. This is an optional
57
- # method
58
- #
59
- # @param action [ActionInquirer]
60
- # @return [Array<Link>]
61
- def collection_actions(action:)
62
- Super::Link.find_all(:new)
63
- end
64
-
65
- # Configures the actions linked to on the show page as well as each row of
66
- # the table on the index page. This is an optional method
67
- #
68
- # @param action [ActionInquirer]
69
- # @return [Array<Link>]
70
- def member_actions(action:)
71
- if action.show?
72
- Super::Link.find_all(:edit, :destroy)
73
- elsif action.edit?
74
- Super::Link.find_all(:show, :destroy)
75
- else
76
- Super::Link.find_all(:show, :edit, :destroy)
77
- end
78
- end
79
-
80
- def filters_enabled?
81
- true
82
- end
83
-
84
- def filter_schema
85
- Super::Filter.new do |fields, type|
86
- Super::Filter::Guesser.new(model: model, fields: fields, type: type).call
87
- end
88
- end
89
-
90
- def sort_enabled?
91
- true
92
- end
93
-
94
- def sortable_columns
95
- action = ActionInquirer.new(
96
- ActionInquirer.default_for_resources,
97
- "index"
98
- )
99
- attribute_names =
100
- display_schema(action: action).each_attribute.map do |key, val|
101
- val = val.build if val.respond_to?(:build)
102
- key if val.real?
103
- end
104
-
105
- attribute_names.compact
106
- end
107
-
108
- def default_sort
109
- { id: :desc }
110
- end
111
-
112
- # Specifies how many records to show per page
113
- #
114
- # @param action [ActionInquirer]
115
- # @param query_params [Hash]
116
- # @return [ActiveRecord::Relation]
117
- def records_per_page(action:, query_params:)
118
- Super.configuration.index_records_per_page
119
- end
120
- end
121
- end
122
- end
@@ -1,133 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Super
4
- class Controls
5
- # Methods that are called by controller actions. All of these methods have
6
- # a default implementation, but feel free to override as needed.
7
- module Steps
8
- # Tells the controller how to load records in the index action using
9
- # `#scope`
10
- #
11
- # @param action [ActionInquirer]
12
- # @param params [ActionController::Parameters]
13
- # @return [ActiveRecord::Relation]
14
- def load_records(action:, params:)
15
- scope(action: action)
16
- end
17
-
18
- # Loads a record using `#scope`
19
- #
20
- # @param action [ActionInquirer]
21
- # @param params [ActionController::Parameters]
22
- # @return [ActiveRecord::Base]
23
- def load_record(action:, params:)
24
- scope(action: action).find(params[:id])
25
- end
26
-
27
- # Builds a record using `#scope`
28
- #
29
- # @param action [ActionInquirer]
30
- # @return [ActiveRecord::Base]
31
- def build_record(action:)
32
- scope(action: action).build
33
- end
34
-
35
- # Builds and populates a record using `#scope`
36
- #
37
- # @param action [ActionInquirer]
38
- # @param params [ActionController::Parameters]
39
- # @return [ActiveRecord::Base]
40
- def build_record_with_params(action:, params:)
41
- scope(action: action).build(permitted_params(params, action: action))
42
- end
43
-
44
- # Saves a record
45
- #
46
- # @param action [ActionInquirer]
47
- # @param params [ActionController::Parameters]
48
- # @return [true, false]
49
- def save_record(action:, record:, params:)
50
- record.save
51
- end
52
-
53
- # Saves a record
54
- #
55
- # @param action [ActionInquirer]
56
- # @param params [ActionController::Parameters]
57
- # @return [true, false]
58
- def update_record(action:, record:, params:)
59
- record.update(permitted_params(params, action: action))
60
- end
61
-
62
- # Destroys a record
63
- #
64
- # @param action [ActionInquirer]
65
- # @param params [ActionController::Parameters]
66
- # @return [ActiveRecord::Base, false]
67
- def destroy_record(action:, record:, params:)
68
- record.destroy
69
- end
70
-
71
- def initialize_query_form(params:, current_path:)
72
- Super::Query::FormObject.new(
73
- model: model,
74
- params: params,
75
- namespace: :q,
76
- current_path: current_path,
77
- )
78
- end
79
-
80
- def apply_queries(query_form:, records:)
81
- query_form.apply_changes(records)
82
- end
83
-
84
- def initialize_filter_form(query_form:)
85
- if filters_enabled?
86
- query_form.add(
87
- Super::Filter::FormObject,
88
- namespace: :f,
89
- schema: filter_schema
90
- )
91
- end
92
- end
93
-
94
- def initialize_sort_form(query_form:)
95
- if sort_enabled?
96
- query_form.add(
97
- Super::Sort::FormObject,
98
- namespace: :s,
99
- default: default_sort,
100
- sortable_columns: sortable_columns
101
- )
102
- end
103
- end
104
-
105
- # Sets up pagination
106
- #
107
- # @param action [ActionInquirer]
108
- # @param records [ActiveRecord::Relation]
109
- # @param query_params [Hash]
110
- # @return [Pagination]
111
- def initialize_pagination(action:, records:, query_params:)
112
- Pagination.new(
113
- total_count: records.size,
114
- limit: records_per_page(action: action, query_params: query_params),
115
- query_params: query_params,
116
- page_query_param: :page
117
- )
118
- end
119
-
120
- # Paginates
121
- #
122
- # @param action [ActionInquirer]
123
- # @param records [ActiveRecord::Relation]
124
- # @param pagination [Pagination]
125
- # @return [ActiveRecord::Relation]
126
- def paginate_records(action:, records:, pagination:)
127
- records
128
- .limit(pagination.limit)
129
- .offset(pagination.offset)
130
- end
131
- end
132
- end
133
- end
@@ -1,55 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Super
4
- class Controls
5
- # Methods for `Controls` that have a sane default implementation
6
- module View
7
- def index_view
8
- Super::Layout.new(
9
- mains: [
10
- Super::Panel.new(
11
- Super::Partial.new("collection_header"),
12
- :@display
13
- ),
14
- ],
15
- asides: [
16
- :@query_form,
17
- ]
18
- )
19
- end
20
-
21
- def show_view
22
- Super::Layout.new(
23
- mains: [
24
- Super::Panel.new(
25
- Super::Partial.new("member_header"),
26
- :@display
27
- ),
28
- ]
29
- )
30
- end
31
-
32
- def new_view
33
- Super::Layout.new(
34
- mains: [
35
- Super::Panel.new(
36
- Super::Partial.new("collection_header"),
37
- :@form
38
- ),
39
- ]
40
- )
41
- end
42
-
43
- def edit_view
44
- Super::Layout.new(
45
- mains: [
46
- Super::Panel.new(
47
- Super::Partial.new("member_header"),
48
- :@form
49
- ),
50
- ]
51
- )
52
- end
53
- end
54
- end
55
- end
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "super/controls/optional"
4
- require "super/controls/steps"
5
- require "super/controls/view"
6
-
7
- module Super
8
- # The base Controls class. Most parts of Super can be configured by
9
- # customizing its methods.
10
- class Controls
11
- include Optional
12
- include Steps
13
- include View
14
-
15
- # Specifies the model. This is a required method
16
- #
17
- # @return [ActiveRecord::Base]
18
- def model
19
- raise NotImplementedError
20
- end
21
- end
22
- end