super 0.19.0.rc1 → 0.21.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -5
  3. data/app/controllers/super/application_controller.rb +10 -19
  4. data/app/controllers/super/sitewide_controller.rb +33 -0
  5. data/app/controllers/super/substructure_controller.rb +63 -85
  6. data/app/controllers/super/view_controller.rb +55 -0
  7. data/app/views/super/application/_batch_checkbox.html.erb +4 -0
  8. data/app/views/super/application/_display_index.html.erb +8 -2
  9. data/app/views/super/application/_display_show.html.erb +10 -2
  10. data/app/views/super/application/_filter.html.erb +63 -59
  11. data/app/views/super/application/_form.html.erb +1 -1
  12. data/app/views/super/application/_layout.html.erb +0 -2
  13. data/app/views/super/application/_pagination.html.erb +1 -4
  14. data/app/views/super/application/_query.html.erb +13 -12
  15. data/app/views/super/application/_site_footer.html.erb +1 -1
  16. data/app/views/super/application/_sort.html.erb +18 -14
  17. data/app/views/super/application/_view_chain.html.erb +23 -4
  18. data/config/locales/en.yml +10 -1
  19. data/frontend/super-frontend/dist/application.js +6276 -6286
  20. data/frontend/super-frontend/dist/package.json +2 -2
  21. data/lib/super/action_inquirer.rb +3 -0
  22. data/lib/super/badge.rb +11 -2
  23. data/lib/super/cheat.rb +6 -1
  24. data/lib/super/display/schema_types.rb +37 -14
  25. data/lib/super/display.rb +5 -4
  26. data/lib/super/error.rb +3 -2
  27. data/lib/super/form/schema_types.rb +8 -36
  28. data/lib/super/form_builder/action_text_methods.rb +16 -0
  29. data/lib/super/form_builder/base_methods.rb +73 -0
  30. data/lib/super/form_builder/flatpickr_methods.rb +75 -0
  31. data/lib/super/form_builder/option_methods.rb +73 -0
  32. data/lib/super/form_builder.rb +143 -0
  33. data/{app/helpers → lib}/super/form_builder_helper.rb +15 -4
  34. data/lib/super/link.rb +47 -63
  35. data/lib/super/link_builder.rb +24 -43
  36. data/lib/super/navigation.rb +40 -40
  37. data/lib/super/query.rb +61 -0
  38. data/lib/super/{engine.rb → railtie.rb} +7 -1
  39. data/lib/super/reset.rb +7 -0
  40. data/lib/super/schema.rb +8 -2
  41. data/lib/super/sort.rb +1 -3
  42. data/lib/super/useful/deprecations.rb +18 -0
  43. data/lib/super/useful/i19.rb +35 -0
  44. data/lib/super/version.rb +1 -1
  45. data/lib/super/view_chain.rb +14 -4
  46. data/lib/super.rb +14 -3
  47. metadata +21 -56
  48. data/config/routes.rb +0 -4
  49. data/lib/super/form/builder.rb +0 -289
  50. data/lib/super/query/form_object.rb +0 -48
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.19.0.rc1
4
+ version: 0.21.0
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-12-14 00:00:00.000000000 Z
11
+ date: 2022-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -128,48 +128,6 @@ dependencies:
128
128
  - - ">="
129
129
  - !ruby/object:Gem::Version
130
130
  version: '0'
131
- - !ruby/object:Gem::Dependency
132
- name: minitest-ci
133
- requirement: !ruby/object:Gem::Requirement
134
- requirements:
135
- - - ">="
136
- - !ruby/object:Gem::Version
137
- version: '0'
138
- type: :development
139
- prerelease: false
140
- version_requirements: !ruby/object:Gem::Requirement
141
- requirements:
142
- - - ">="
143
- - !ruby/object:Gem::Version
144
- version: '0'
145
- - !ruby/object:Gem::Dependency
146
- name: appraisal
147
- requirement: !ruby/object:Gem::Requirement
148
- requirements:
149
- - - ">="
150
- - !ruby/object:Gem::Version
151
- version: '0'
152
- type: :development
153
- prerelease: false
154
- version_requirements: !ruby/object:Gem::Requirement
155
- requirements:
156
- - - ">="
157
- - !ruby/object:Gem::Version
158
- version: '0'
159
- - !ruby/object:Gem::Dependency
160
- name: yard
161
- requirement: !ruby/object:Gem::Requirement
162
- requirements:
163
- - - ">="
164
- - !ruby/object:Gem::Version
165
- version: '0'
166
- type: :development
167
- prerelease: false
168
- version_requirements: !ruby/object:Gem::Requirement
169
- requirements:
170
- - - ">="
171
- - !ruby/object:Gem::Version
172
- version: '0'
173
131
  - !ruby/object:Gem::Dependency
174
132
  name: mocha
175
133
  requirement: !ruby/object:Gem::Requirement
@@ -254,8 +212,9 @@ files:
254
212
  - app/assets/javascripts/super/application.js
255
213
  - app/assets/stylesheets/super/application.css
256
214
  - app/controllers/super/application_controller.rb
215
+ - app/controllers/super/sitewide_controller.rb
257
216
  - app/controllers/super/substructure_controller.rb
258
- - app/helpers/super/form_builder_helper.rb
217
+ - app/controllers/super/view_controller.rb
259
218
  - app/views/layouts/super/application.html.erb
260
219
  - app/views/super/application/_batch_button.html.erb
261
220
  - app/views/super/application/_batch_checkbox.csv.erb
@@ -295,7 +254,6 @@ files:
295
254
  - app/views/super/feather/README.md
296
255
  - app/views/super/feather/_x.html
297
256
  - config/locales/en.yml
298
- - config/routes.rb
299
257
  - frontend/super-frontend/dist/application.css
300
258
  - frontend/super-frontend/dist/application.js
301
259
  - frontend/super-frontend/dist/package.json
@@ -324,7 +282,6 @@ files:
324
282
  - lib/super/display.rb
325
283
  - lib/super/display/guesser.rb
326
284
  - lib/super/display/schema_types.rb
327
- - lib/super/engine.rb
328
285
  - lib/super/error.rb
329
286
  - lib/super/filter.rb
330
287
  - lib/super/filter/form_object.rb
@@ -332,12 +289,17 @@ files:
332
289
  - lib/super/filter/operator.rb
333
290
  - lib/super/filter/schema_types.rb
334
291
  - lib/super/form.rb
335
- - lib/super/form/builder.rb
336
292
  - lib/super/form/field_transcript.rb
337
293
  - lib/super/form/guesser.rb
338
294
  - lib/super/form/inline_errors.rb
339
295
  - lib/super/form/schema_types.rb
340
296
  - lib/super/form/strong_params.rb
297
+ - lib/super/form_builder.rb
298
+ - lib/super/form_builder/action_text_methods.rb
299
+ - lib/super/form_builder/base_methods.rb
300
+ - lib/super/form_builder/flatpickr_methods.rb
301
+ - lib/super/form_builder/option_methods.rb
302
+ - lib/super/form_builder_helper.rb
341
303
  - lib/super/layout.rb
342
304
  - lib/super/link.rb
343
305
  - lib/super/link_builder.rb
@@ -348,7 +310,8 @@ files:
348
310
  - lib/super/partial.rb
349
311
  - lib/super/partial/resolving.rb
350
312
  - lib/super/plugin.rb
351
- - lib/super/query/form_object.rb
313
+ - lib/super/query.rb
314
+ - lib/super/railtie.rb
352
315
  - lib/super/reorderable_hash.rb
353
316
  - lib/super/reset.rb
354
317
  - lib/super/schema.rb
@@ -356,7 +319,9 @@ files:
356
319
  - lib/super/schema/guesser.rb
357
320
  - lib/super/sort.rb
358
321
  - lib/super/useful/builder.rb
322
+ - lib/super/useful/deprecations.rb
359
323
  - lib/super/useful/enum.rb
324
+ - lib/super/useful/i19.rb
360
325
  - lib/super/version.rb
361
326
  - lib/super/view_chain.rb
362
327
  - lib/super/view_helper.rb
@@ -365,11 +330,11 @@ homepage:
365
330
  licenses:
366
331
  - LGPL-3.0-only
367
332
  metadata:
368
- bug_tracker_uri: https://github.com/zachahn/super/issues
369
- changelog_uri: https://github.com/zachahn/super/blob/main/CHANGELOG.md
333
+ bug_tracker_uri: https://github.com/superadministration/super/issues
334
+ changelog_uri: https://github.com/superadministration/super/blob/main/CHANGELOG.md
370
335
  documentation_uri: https://superadministration.github.io/
371
- homepage_uri: https://github.com/zachahn/super
372
- source_code_uri: https://github.com/zachahn/super
336
+ homepage_uri: https://github.com/superadministration/super
337
+ source_code_uri: https://github.com/superadministration/super
373
338
  post_install_message:
374
339
  rdoc_options: []
375
340
  require_paths:
@@ -381,11 +346,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
381
346
  version: 2.3.0
382
347
  required_rubygems_version: !ruby/object:Gem::Requirement
383
348
  requirements:
384
- - - ">"
349
+ - - ">="
385
350
  - !ruby/object:Gem::Version
386
- version: 1.3.1
351
+ version: '0'
387
352
  requirements: []
388
- rubygems_version: 3.0.3.1
353
+ rubygems_version: 3.2.33
389
354
  signing_key:
390
355
  specification_version: 4
391
356
  summary: A simple, powerful, zero dependency Rails admin framework
data/config/routes.rb DELETED
@@ -1,4 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Rails.application.routes.draw do
4
- end
@@ -1,289 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Super
4
- class Form
5
- # Example
6
- #
7
- # ```ruby
8
- # super_form_for([:admin, @member]) do |f|
9
- # # the long way
10
- # f.super.label :name
11
- # f.super.text_field :name
12
- # f.super.inline_errors :name
13
- #
14
- # # the short way (slightly different from the long way, for alignment)
15
- # f.super.text_field! :position
16
- # end
17
- # ```
18
- #
19
- # Refer to the Rails docs:
20
- # https://api.rubyonrails.org/classes/ActionView/Helpers/FormBuilder.html
21
- class Builder < ActionView::Helpers::FormBuilder
22
- FIELD_ERROR_PROC = proc { |html_tag, instance| html_tag }
23
- FORM_BUILDER_DEFAULTS = { builder: self }.freeze
24
-
25
- def super(**options)
26
- @super_wrappers ||= Wrappers.new(self, @template)
27
- end
28
-
29
- class Wrappers
30
- def initialize(builder, template)
31
- @builder = builder
32
- @template = template
33
- end
34
-
35
- def inline_errors(attribute)
36
- if @builder.object
37
- messages = InlineErrors.error_messages(@builder.object, attribute).map do |msg|
38
- error_content_tag(msg)
39
- end
40
-
41
- @template.safe_join(messages)
42
- else
43
- error_content_tag(<<~MSG.html_safe)
44
- This form doesn't have an object, so something is probably wrong.
45
- Maybe <code>accepts_nested_attributes_for</code> isn't set up?
46
- MSG
47
- end
48
- end
49
-
50
- def label(attribute, text = nil, options = {}, &block)
51
- options, defaults = split_defaults(options, class: "block")
52
- options[:class] = join_classes(defaults[:class], options[:class])
53
-
54
- @builder.label(attribute, text, options, &block)
55
- end
56
-
57
- def check_box(attribute, options = {}, checked_value = "1", unchecked_value = "0")
58
- @builder.check_box(attribute, options, checked_value, unchecked_value)
59
- end
60
-
61
- def date_flatpickr(attribute, options = {})
62
- options, defaults = split_defaults(
63
- options,
64
- class: "super-input w-full",
65
- data: {
66
- controller: "flatpickr",
67
- flatpickr_options_value: {
68
- dateFormat: "Y-m-d",
69
- }
70
- }
71
- )
72
- options[:class] = join_classes(defaults[:class], options[:class])
73
- options[:data] = defaults[:data].deep_merge(options[:data] || {})
74
- options[:value] = @builder.object.public_send(attribute).presence
75
- options[:value] = options[:value].iso8601 if options[:value].respond_to?(:iso8601)
76
-
77
- @builder.text_field(attribute, options)
78
- end
79
-
80
- def datetime_flatpickr(attribute, options = {})
81
- options, defaults = split_defaults(
82
- options,
83
- class: "super-input w-full",
84
- data: {
85
- controller: "flatpickr",
86
- flatpickr_options_value: {
87
- enableSeconds: true,
88
- enableTime: true,
89
- dateFormat: "Z",
90
- }
91
- }
92
- )
93
- options[:class] = join_classes(defaults[:class], options[:class])
94
- options[:data] = defaults[:data].deep_merge(options[:data] || {})
95
- options[:value] = @builder.object.public_send(attribute).presence
96
- options[:value] = options[:value].iso8601 if options[:value].respond_to?(:iso8601)
97
-
98
- @builder.text_field(attribute, options)
99
- end
100
-
101
- def time_flatpickr(attribute, options = {})
102
- options, defaults = split_defaults(
103
- options,
104
- class: "super-input w-full",
105
- data: {
106
- controller: "flatpickr",
107
- flatpickr_options_value: {
108
- enableSeconds: true,
109
- enableTime: true,
110
- noCalendar: true,
111
- dateFormat: "H:i:S",
112
- }
113
- }
114
- )
115
- options[:class] = join_classes(defaults[:class], options[:class])
116
- options[:data] = defaults[:data].deep_merge(options[:data] || {})
117
- options[:value] = @builder.object.public_send(attribute).presence
118
- options[:value] = options[:value].strftime("%H:%M:%S") if options[:value].respond_to?(:strftime)
119
-
120
- @builder.text_field(attribute, options)
121
- end
122
-
123
- def password_field(attribute, options = {})
124
- options, defaults = split_defaults(options, class: "super-input w-full")
125
- options[:class] = join_classes(defaults[:class], options[:class])
126
-
127
- @builder.password_field(attribute, options)
128
- end
129
-
130
- def rich_text_area(attribute, options = {})
131
- options, defaults = split_defaults(options, class: "trix-content super-input w-full")
132
- options[:class] = join_classes(defaults[:class], options[:class])
133
-
134
- @builder.rich_text_area(attribute, options)
135
- end
136
-
137
- def select(attribute, choices, options = {}, html_options = {}, &block)
138
- options, defaults = split_defaults(options, include_blank: true)
139
- options = defaults.merge(options)
140
- html_options, html_defaults = split_defaults(html_options, class: "super-input super-input-select")
141
- html_options[:class] = join_classes(html_defaults[:class], html_options[:class])
142
-
143
- @builder.select(attribute, choices, options, html_options, &block)
144
- end
145
-
146
- def submit(value = nil, options = {})
147
- value, options = nil, value if value.is_a?(Hash)
148
- options, defaults = split_defaults(options, class: "super-button")
149
- options[:class] = join_classes(defaults[:class], options[:class])
150
-
151
- @builder.submit(value, options)
152
- end
153
-
154
- def text_field(attribute, options = {})
155
- options, defaults = split_defaults(options, class: "super-input w-full")
156
- options[:class] = join_classes(defaults[:class], options[:class])
157
-
158
- @builder.text_field(attribute, options)
159
- end
160
-
161
- def container(&block)
162
- @template.content_tag(:div, class: "super-field-group", &block)
163
- end
164
-
165
- def check_box!(attribute, checked_value: "1", unchecked_value: "0", label_text: nil, label: {}, field: {}, show_errors: true)
166
- label[:super] ||= {}
167
- label[:super] = { class: "select-none ml-1" }.merge(label[:super])
168
- container do
169
- compact_join([
170
- "<div>".html_safe,
171
- public_send(:check_box, attribute, field, checked_value, unchecked_value),
172
- public_send(:label, attribute, label_text, label),
173
- "</div>".html_safe,
174
- show_errors && inline_errors(attribute),
175
- ])
176
- end
177
- end
178
-
179
- def date_flatpickr!(attribute, label_text: nil, label: {}, field: {}, show_errors: true)
180
- container do
181
- compact_join([
182
- public_send(:label, attribute, label_text, label),
183
- %(<div class="mt-1">).html_safe,
184
- public_send(:date_flatpickr, attribute, field),
185
- show_errors && inline_errors(attribute),
186
- %(</div>).html_safe,
187
- ])
188
- end
189
- end
190
-
191
- def datetime_flatpickr!(attribute, label_text: nil, label: {}, field: {}, show_errors: true)
192
- container do
193
- compact_join([
194
- public_send(:label, attribute, label_text, label),
195
- %(<div class="mt-1">).html_safe,
196
- public_send(:datetime_flatpickr, attribute, field),
197
- show_errors && inline_errors(attribute),
198
- %(</div>).html_safe,
199
- ])
200
- end
201
- end
202
-
203
- def time_flatpickr!(attribute, label_text: nil, label: {}, field: {}, show_errors: true)
204
- container do
205
- compact_join([
206
- public_send(:label, attribute, label_text, label),
207
- %(<div class="mt-1">).html_safe,
208
- public_send(:time_flatpickr, attribute, field),
209
- show_errors && inline_errors(attribute),
210
- %(</div>).html_safe,
211
- ])
212
- end
213
- end
214
-
215
- def password_field!(attribute, label_text: nil, label: {}, field: {}, show_errors: true)
216
- container do
217
- compact_join([
218
- public_send(:label, attribute, label_text, label),
219
- %(<div class="mt-1">).html_safe,
220
- public_send(:password_field, attribute, field),
221
- show_errors && inline_errors(attribute),
222
- %(</div>).html_safe,
223
- ])
224
- end
225
- end
226
-
227
- def rich_text_area!(attribute, label_text: nil, label: {}, field: {}, show_errors: true)
228
- container do
229
- compact_join([
230
- public_send(:label, attribute, label_text, label),
231
- %(<div class="mt-1">).html_safe,
232
- public_send(:rich_text_area, attribute, field),
233
- show_errors && inline_errors(attribute),
234
- %(</div>).html_safe,
235
- ])
236
- end
237
- end
238
-
239
- def select!(attribute, collection, label_text: nil, label: {}, field: {}, show_errors: true)
240
- container do
241
- compact_join([
242
- public_send(:label, attribute, label_text, label),
243
- %(<div class="mt-1">).html_safe,
244
- public_send(:select, attribute, collection, field),
245
- show_errors && inline_errors(attribute),
246
- %(</div>).html_safe,
247
- ])
248
- end
249
- end
250
-
251
- def text_field!(attribute, label_text: nil, label: {}, field: {}, show_errors: true)
252
- container do
253
- compact_join([
254
- public_send(:label, attribute, label_text, label),
255
- %(<div class="mt-1">).html_safe,
256
- public_send(:text_field, attribute, field),
257
- show_errors && inline_errors(attribute),
258
- %(</div>).html_safe,
259
- ])
260
- end
261
- end
262
-
263
- private
264
-
265
- def split_defaults(options, **internal_defaults)
266
- defaults = options.delete(:super) || {}
267
- # prefer options set in `defaults`, since they are user overrides
268
- defaults = internal_defaults.merge(defaults)
269
-
270
- [options, defaults]
271
- end
272
-
273
- def join_classes(*class_lists)
274
- class_lists.flatten.map(&:presence).compact
275
- end
276
-
277
- def error_content_tag(content)
278
- @template.content_tag(:p, content, class: "text-red-400 text-xs italic pt-1")
279
- end
280
-
281
- def compact_join(*parts)
282
- @template.safe_join(
283
- parts.flatten.map(&:presence).compact
284
- )
285
- end
286
- end
287
- end
288
- end
289
- end
@@ -1,48 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Super
4
- class Query
5
- class FormObject
6
- def initialize(model:, params:, namespace:, current_path:)
7
- @model = model
8
- @all_params = params.dup
9
- @namespace = namespace
10
- @params = params[namespace] || ActionController::Parameters.new
11
- @path = current_path
12
- @addons = {}
13
- end
14
-
15
- attr_reader :namespace
16
- attr_reader :path
17
- attr_reader :addons
18
-
19
- def add(klass, namespace:, **additional_initialization_arguments)
20
- instance = klass.new(
21
- model: @model,
22
- params: params_dig(namespace),
23
- **additional_initialization_arguments
24
- )
25
-
26
- addons[namespace] = instance
27
- end
28
-
29
- def apply_changes(records)
30
- addons.each_value do |addon|
31
- records = addon.apply_changes(records)
32
- end
33
-
34
- records
35
- end
36
-
37
- def to_partial_path
38
- "query"
39
- end
40
-
41
- private
42
-
43
- def params_dig(*keys)
44
- @params.dig(*keys) || ActionController::Parameters.new
45
- end
46
- end
47
- end
48
- end