super 0.17.0 → 0.20.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -4
  3. data/app/assets/javascripts/super/application.js +1260 -117
  4. data/app/assets/stylesheets/super/application.css +90711 -90034
  5. data/app/controllers/super/application_controller.rb +34 -4
  6. data/app/controllers/super/substructure_controller.rb +125 -29
  7. data/app/helpers/super/form_builder_helper.rb +4 -4
  8. data/app/views/layouts/super/application.html.erb +1 -1
  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 +9 -0
  12. data/app/views/super/application/_batch_form.html.erb +3 -0
  13. data/app/views/super/application/_collection_header.html.erb +7 -6
  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/_form.html.erb +1 -1
  17. data/app/views/super/application/_layout.html.erb +13 -14
  18. data/app/views/super/application/_link.html.erb +8 -0
  19. data/app/views/super/application/_member_header.html.erb +7 -7
  20. data/app/views/super/application/_pagination.html.erb +2 -4
  21. data/app/views/super/application/_site_footer.html.erb +1 -1
  22. data/app/views/super/application/_site_header.html.erb +4 -4
  23. data/app/views/super/application/_view_chain.html.erb +5 -0
  24. data/app/views/super/application/index.csv.erb +14 -0
  25. data/config/locales/en.yml +15 -1
  26. data/frontend/super-frontend/dist/application.css +90711 -90034
  27. data/frontend/super-frontend/dist/application.js +6512 -5379
  28. data/frontend/super-frontend/dist/package.json +13 -0
  29. data/lib/generators/super/webpacker/USAGE +1 -7
  30. data/lib/generators/super/webpacker/templates/pack_super_application.js.tt +2 -0
  31. data/lib/generators/super/webpacker/webpacker_generator.rb +10 -6
  32. data/lib/super/action_inquirer.rb +3 -0
  33. data/lib/super/cheat.rb +1 -0
  34. data/lib/super/display/schema_types.rb +6 -0
  35. data/lib/super/display.rb +2 -1
  36. data/lib/super/engine.rb +5 -0
  37. data/lib/super/error.rb +11 -0
  38. data/lib/super/form/schema_types.rb +8 -36
  39. data/lib/super/form_builder/action_text_methods.rb +16 -0
  40. data/lib/super/form_builder/base_methods.rb +73 -0
  41. data/lib/super/form_builder/flatpickr_methods.rb +75 -0
  42. data/lib/super/form_builder/option_methods.rb +73 -0
  43. data/lib/super/form_builder.rb +143 -0
  44. data/lib/super/layout.rb +9 -33
  45. data/lib/super/link.rb +49 -70
  46. data/lib/super/link_builder.rb +24 -47
  47. data/lib/super/packaged_asset.rb +49 -0
  48. data/lib/super/pagination.rb +2 -1
  49. data/lib/super/reorderable_hash.rb +88 -0
  50. data/lib/super/reset.rb +20 -1
  51. data/lib/super/useful/i19.rb +35 -0
  52. data/lib/super/version.rb +1 -1
  53. data/lib/super/view_chain.rb +25 -0
  54. data/lib/super.rb +9 -1
  55. metadata +55 -10
  56. data/lib/generators/super/webpacker/templates/pack_super_application.js.erb.tt +0 -2
  57. data/lib/super/form/builder.rb +0 -289
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.17.0
4
+ version: 0.20.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-06-17 00:00:00.000000000 Z
11
+ date: 2022-01-09 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
@@ -229,7 +257,12 @@ files:
229
257
  - app/controllers/super/substructure_controller.rb
230
258
  - app/helpers/super/form_builder_helper.rb
231
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
232
264
  - app/views/super/application/_collection_header.html.erb
265
+ - app/views/super/application/_csv_button.html.erb
233
266
  - app/views/super/application/_display_actions.html.erb
234
267
  - app/views/super/application/_display_index.html.erb
235
268
  - app/views/super/application/_display_rich_text.html.erb
@@ -243,6 +276,7 @@ files:
243
276
  - app/views/super/application/_form_has_many.html.erb
244
277
  - app/views/super/application/_form_has_one.html.erb
245
278
  - app/views/super/application/_layout.html.erb
279
+ - app/views/super/application/_link.html.erb
246
280
  - app/views/super/application/_member_header.html.erb
247
281
  - app/views/super/application/_pagination.html.erb
248
282
  - app/views/super/application/_panel.html.erb
@@ -251,7 +285,9 @@ files:
251
285
  - app/views/super/application/_site_header.html.erb
252
286
  - app/views/super/application/_sort.html.erb
253
287
  - app/views/super/application/_sort_expression.html.erb
288
+ - app/views/super/application/_view_chain.html.erb
254
289
  - app/views/super/application/edit.html.erb
290
+ - app/views/super/application/index.csv.erb
255
291
  - app/views/super/application/index.html.erb
256
292
  - app/views/super/application/new.html.erb
257
293
  - app/views/super/application/nothing.html.erb
@@ -262,6 +298,7 @@ files:
262
298
  - config/routes.rb
263
299
  - frontend/super-frontend/dist/application.css
264
300
  - frontend/super-frontend/dist/application.js
301
+ - frontend/super-frontend/dist/package.json
265
302
  - lib/generators/super/action_text/USAGE
266
303
  - lib/generators/super/action_text/action_text_generator.rb
267
304
  - lib/generators/super/action_text/templates/pack_super_action_text.css
@@ -274,7 +311,7 @@ files:
274
311
  - lib/generators/super/resource/resource_generator.rb
275
312
  - lib/generators/super/resource/templates/resources_controller.rb.tt
276
313
  - lib/generators/super/webpacker/USAGE
277
- - lib/generators/super/webpacker/templates/pack_super_application.js.erb.tt
314
+ - lib/generators/super/webpacker/templates/pack_super_application.js.tt
278
315
  - lib/generators/super/webpacker/webpacker_generator.rb
279
316
  - lib/super.rb
280
317
  - lib/super/action_inquirer.rb
@@ -295,22 +332,28 @@ files:
295
332
  - lib/super/filter/operator.rb
296
333
  - lib/super/filter/schema_types.rb
297
334
  - lib/super/form.rb
298
- - lib/super/form/builder.rb
299
335
  - lib/super/form/field_transcript.rb
300
336
  - lib/super/form/guesser.rb
301
337
  - lib/super/form/inline_errors.rb
302
338
  - lib/super/form/schema_types.rb
303
339
  - lib/super/form/strong_params.rb
340
+ - lib/super/form_builder.rb
341
+ - lib/super/form_builder/action_text_methods.rb
342
+ - lib/super/form_builder/base_methods.rb
343
+ - lib/super/form_builder/flatpickr_methods.rb
344
+ - lib/super/form_builder/option_methods.rb
304
345
  - lib/super/layout.rb
305
346
  - lib/super/link.rb
306
347
  - lib/super/link_builder.rb
307
348
  - lib/super/navigation.rb
349
+ - lib/super/packaged_asset.rb
308
350
  - lib/super/pagination.rb
309
351
  - lib/super/panel.rb
310
352
  - lib/super/partial.rb
311
353
  - lib/super/partial/resolving.rb
312
354
  - lib/super/plugin.rb
313
355
  - lib/super/query/form_object.rb
356
+ - lib/super/reorderable_hash.rb
314
357
  - lib/super/reset.rb
315
358
  - lib/super/schema.rb
316
359
  - lib/super/schema/common.rb
@@ -318,18 +361,20 @@ files:
318
361
  - lib/super/sort.rb
319
362
  - lib/super/useful/builder.rb
320
363
  - lib/super/useful/enum.rb
364
+ - lib/super/useful/i19.rb
321
365
  - lib/super/version.rb
366
+ - lib/super/view_chain.rb
322
367
  - lib/super/view_helper.rb
323
368
  - lib/tasks/super/cheat.rake
324
369
  homepage:
325
370
  licenses:
326
371
  - LGPL-3.0-only
327
372
  metadata:
328
- bug_tracker_uri: https://github.com/zachahn/super/issues
329
- changelog_uri: https://github.com/zachahn/super/blob/main/CHANGELOG.md
373
+ bug_tracker_uri: https://github.com/superadministration/super/issues
374
+ changelog_uri: https://github.com/superadministration/super/blob/main/CHANGELOG.md
330
375
  documentation_uri: https://superadministration.github.io/
331
- homepage_uri: https://github.com/zachahn/super
332
- source_code_uri: https://github.com/zachahn/super
376
+ homepage_uri: https://github.com/superadministration/super
377
+ source_code_uri: https://github.com/superadministration/super
333
378
  post_install_message:
334
379
  rdoc_options: []
335
380
  require_paths:
@@ -345,7 +390,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
345
390
  - !ruby/object:Gem::Version
346
391
  version: '0'
347
392
  requirements: []
348
- rubygems_version: 3.0.3.1
393
+ rubygems_version: 3.3.4
349
394
  signing_key:
350
395
  specification_version: 4
351
396
  summary: A simple, powerful, zero dependency Rails admin framework
@@ -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,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