super 0.21.0 → 0.22.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +35 -47
- data/app/assets/javascripts/super/application.js +1201 -2092
- data/app/assets/stylesheets/super/application.css +54 -6569
- data/app/controllers/super/application_controller.rb +44 -30
- data/app/controllers/super/foundation_controller.rb +30 -0
- data/app/controllers/super/sitewide_controller.rb +6 -3
- data/app/controllers/super/substructure_controller.rb +40 -47
- data/app/controllers/super/view_controller.rb +5 -1
- data/app/views/layouts/super/application.html.erb +3 -3
- data/app/views/super/application/_batch_checkbox.csv.erb +1 -1
- data/app/views/super/application/_batch_checkbox.html.erb +1 -1
- data/app/views/super/application/_collection_header.html.erb +1 -1
- data/app/views/super/application/_csv_button.html.erb +1 -1
- data/app/views/super/application/_display_actions.html.erb +1 -1
- data/app/views/super/application/_display_rich_text.html.erb +1 -1
- data/app/views/super/application/_form.html.erb +1 -1
- data/app/views/super/application/_form_fieldset.html.erb +1 -1
- data/app/views/super/application/_form_has_many.html.erb +2 -2
- data/app/views/super/application/_form_has_one.html.erb +1 -1
- data/app/views/super/application/_layout.html.erb +6 -6
- data/app/views/super/application/_link.html.erb +1 -6
- data/app/views/super/application/_member_header.html.erb +1 -1
- data/app/views/super/application/_panel.html.erb +1 -1
- data/app/views/super/application/_query.html.erb +2 -2
- data/app/views/super/application/_site_header.html.erb +2 -2
- data/app/views/super/application/_sort.html.erb +2 -2
- data/app/views/super/application/_sort_expression.html.erb +1 -1
- data/app/views/super/application/_view_chain.html.erb +1 -24
- data/app/views/super/application/edit.html.erb +1 -1
- data/app/views/super/application/index.html.erb +1 -1
- data/app/views/super/application/new.html.erb +1 -1
- data/app/views/super/application/show.html.erb +1 -1
- data/frontend/super-frontend/dist/application.css +54 -6569
- data/frontend/super-frontend/dist/application.js +1201 -2092
- data/lib/super/action_inquirer.rb +28 -8
- data/lib/super/assets.rb +2 -2
- data/lib/super/badge.rb +8 -32
- data/lib/super/cheat.rb +6 -5
- data/lib/super/client_error.rb +4 -0
- data/lib/super/compatibility.rb +4 -0
- data/lib/super/configuration.rb +3 -0
- data/lib/super/display/schema_types.rb +38 -82
- data/lib/super/display.rb +13 -13
- data/lib/super/error.rb +14 -0
- data/lib/super/filter/form_object.rb +2 -2
- data/lib/super/filter/operator.rb +1 -1
- data/lib/super/filter/schema_types.rb +1 -1
- data/lib/super/form/field_transcript.rb +4 -0
- data/lib/super/form/schema_types.rb +2 -2
- data/lib/super/form/strong_params.rb +1 -1
- data/lib/super/form_builder/base_methods.rb +3 -9
- data/lib/super/form_builder/flatpickr_methods.rb +3 -3
- data/lib/super/form_builder.rb +19 -21
- data/lib/super/form_builder_helper.rb +3 -3
- data/lib/super/link.rb +15 -6
- data/lib/super/link_builder.rb +4 -4
- data/lib/super/navigation.rb +12 -8
- data/lib/super/partial.rb +0 -12
- data/lib/super/plugin.rb +2 -2
- data/lib/super/railtie.rb +1 -0
- data/lib/super/render_helper.rb +31 -0
- data/lib/super/reset.rb +1 -6
- data/lib/super/schema/guesser.rb +5 -5
- data/lib/super/schema.rb +2 -2
- data/lib/super/sort.rb +1 -1
- data/lib/super/useful/deprecations.rb +1 -3
- data/lib/super/useful/enum.rb +1 -1
- data/lib/super/useful/i19.rb +1 -1
- data/lib/super/version.rb +1 -1
- data/lib/super/view_chain.rb +19 -0
- data/lib/super.rb +1 -0
- metadata +4 -2
@@ -13,7 +13,7 @@ module Super
|
|
13
13
|
ActionView::Base.field_error_proc = FormBuilder::FIELD_ERROR_PROC
|
14
14
|
|
15
15
|
options[:builder] ||= FormBuilder
|
16
|
-
|
16
|
+
form_for(record, options, &block)
|
17
17
|
ensure
|
18
18
|
ActionView::Base.field_error_proc = original
|
19
19
|
end
|
@@ -24,7 +24,7 @@ module Super
|
|
24
24
|
ActionView::Base.field_error_proc = FormBuilder::FIELD_ERROR_PROC
|
25
25
|
|
26
26
|
options[:builder] ||= FormBuilder
|
27
|
-
|
27
|
+
form_with(**options, &block)
|
28
28
|
ensure
|
29
29
|
ActionView::Base.field_error_proc = original
|
30
30
|
end
|
@@ -35,7 +35,7 @@ module Super
|
|
35
35
|
ActionView::Base.field_error_proc = FormBuilder::FIELD_ERROR_PROC
|
36
36
|
|
37
37
|
options[:builder] ||= FormBuilder
|
38
|
-
|
38
|
+
fields_for(*args, **options, &block)
|
39
39
|
ensure
|
40
40
|
ActionView::Base.field_error_proc = original
|
41
41
|
end
|
data/lib/super/link.rb
CHANGED
@@ -26,24 +26,24 @@ module Super
|
|
26
26
|
@registry ||= {}.tap do |reg|
|
27
27
|
reg[:new] = LinkBuilder.new
|
28
28
|
.text { |params:| Super::Useful::I19.i18n_with_fallback("super", params[:controller].split("/"), "actions.new") }
|
29
|
-
.href { |params:| {
|
29
|
+
.href { |params:| {controller: params[:controller], action: :new, only_path: true} }
|
30
30
|
.freeze
|
31
31
|
reg[:index] = LinkBuilder.new
|
32
32
|
.text { |params:| Super::Useful::I19.i18n_with_fallback("super", params[:controller].split("/"), "actions.index") }
|
33
|
-
.href { |params:| {
|
33
|
+
.href { |params:| {controller: params[:controller], action: :index, only_path: true} }
|
34
34
|
.freeze
|
35
35
|
reg[:show] = LinkBuilder.new
|
36
36
|
.text { |params:, **| Super::Useful::I19.i18n_with_fallback("super", params[:controller].split("/"), "actions.show") }
|
37
|
-
.href { |params:, record:| {
|
37
|
+
.href { |params:, record:| {controller: params[:controller], action: :show, id: record, only_path: true} }
|
38
38
|
.freeze
|
39
39
|
reg[:edit] = LinkBuilder.new
|
40
40
|
.text { |params:, **| Super::Useful::I19.i18n_with_fallback("super", params[:controller].split("/"), "actions.edit") }
|
41
|
-
.href { |params:, record:| {
|
41
|
+
.href { |params:, record:| {controller: params[:controller], action: :edit, id: record, only_path: true} }
|
42
42
|
.freeze
|
43
43
|
reg[:destroy] = LinkBuilder.new
|
44
44
|
.text { |params:, **| Super::Useful::I19.i18n_with_fallback("super", params[:controller].split("/"), "actions.destroy") }
|
45
|
-
.href { |params:, record:| {
|
46
|
-
.options { |**| {
|
45
|
+
.href { |params:, record:| {controller: params[:controller], action: :destroy, id: record, only_path: true} }
|
46
|
+
.options { |**| {method: :delete, data: {confirm: "Really delete?"}} }
|
47
47
|
.freeze
|
48
48
|
end
|
49
49
|
end
|
@@ -91,6 +91,15 @@ module Super
|
|
91
91
|
@href = Super::Compatability.polymorphic_path_container.polymorphic_path(@href)
|
92
92
|
end
|
93
93
|
|
94
|
+
def to_link(template, local_assigns)
|
95
|
+
default_options = local_assigns.fetch(:default_options, {})
|
96
|
+
template.link_to(
|
97
|
+
text,
|
98
|
+
href,
|
99
|
+
default_options.deep_merge(options)
|
100
|
+
)
|
101
|
+
end
|
102
|
+
|
94
103
|
def to_partial_path
|
95
104
|
"link"
|
96
105
|
end
|
data/lib/super/link_builder.rb
CHANGED
@@ -20,10 +20,10 @@ module Super
|
|
20
20
|
raise Super::Error::IncompleteBuilder, "LinkBuilder requires that #text is set" if @text.nil?
|
21
21
|
raise Super::Error::IncompleteBuilder, "LinkBuilder requires that #href is set" if @href.nil?
|
22
22
|
|
23
|
-
@options ||= ->
|
24
|
-
@process_text ||= ->
|
25
|
-
@process_href ||= ->
|
26
|
-
@process_options ||= ->
|
23
|
+
@options ||= ->(**) { {} }
|
24
|
+
@process_text ||= ->(t) { t }
|
25
|
+
@process_href ||= ->(h) { h }
|
26
|
+
@process_options ||= ->(o) { o }
|
27
27
|
|
28
28
|
Super::Link.new(
|
29
29
|
@process_text.call(@text.call(**kwargs)),
|
data/lib/super/navigation.rb
CHANGED
@@ -4,10 +4,7 @@ module Super
|
|
4
4
|
class Navigation
|
5
5
|
def initialize
|
6
6
|
@builder = Builder.new
|
7
|
-
|
8
|
-
if result.is_a?(Array)
|
9
|
-
Useful::Deprecation["0.22"].deprecation_warning("returning an array", "calling a Super::Navigation builder method defines the navigation")
|
10
|
-
end
|
7
|
+
yield @builder
|
11
8
|
end
|
12
9
|
|
13
10
|
def definition
|
@@ -155,10 +152,17 @@ module Super
|
|
155
152
|
end
|
156
153
|
end
|
157
154
|
|
158
|
-
def header(routes)
|
159
|
-
|
160
|
-
|
161
|
-
def
|
155
|
+
def header(routes)
|
156
|
+
end
|
157
|
+
|
158
|
+
def no_routes(routes, filter)
|
159
|
+
end
|
160
|
+
|
161
|
+
def result
|
162
|
+
end
|
163
|
+
|
164
|
+
def section_title(title)
|
165
|
+
end
|
162
166
|
end
|
163
167
|
end
|
164
168
|
end
|
data/lib/super/partial.rb
CHANGED
@@ -2,18 +2,6 @@
|
|
2
2
|
|
3
3
|
module Super
|
4
4
|
class Partial
|
5
|
-
def self.render(partialish, template:)
|
6
|
-
if partialish.respond_to?(:to_partial_path)
|
7
|
-
if partialish.respond_to?(:locals)
|
8
|
-
template.render(partialish, partialish.locals)
|
9
|
-
else
|
10
|
-
template.render(partialish)
|
11
|
-
end
|
12
|
-
else
|
13
|
-
partialish
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
5
|
def initialize(path, locals: {})
|
18
6
|
@to_partial_path = path
|
19
7
|
@locals = locals
|
data/lib/super/plugin.rb
CHANGED
@@ -27,8 +27,8 @@ module Super
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def classes_ordered
|
30
|
-
each_node = ->
|
31
|
-
each_child = ->
|
30
|
+
each_node = ->(&b) { @ordering.each_key(&b) }
|
31
|
+
each_child = ->(cb, &b) { @ordering[cb].each(&b) }
|
32
32
|
|
33
33
|
TSort.tsort(each_node, each_child)
|
34
34
|
end
|
data/lib/super/railtie.rb
CHANGED
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# typed: false
|
3
|
+
|
4
|
+
module Super::RenderHelper
|
5
|
+
def super_render(*args, **kwargs, &block)
|
6
|
+
if args.size >= 1
|
7
|
+
renderable = args.first
|
8
|
+
|
9
|
+
case renderable
|
10
|
+
when ActiveSupport::SafeBuffer
|
11
|
+
return renderable
|
12
|
+
when Super::Partial
|
13
|
+
return render(*args, **kwargs, &block)
|
14
|
+
when Super::Link
|
15
|
+
return renderable.to_link(self, kwargs)
|
16
|
+
when Super::ViewChain
|
17
|
+
return renderable.handle_super_render(self, kwargs)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
render(*args, **kwargs, &block)
|
22
|
+
end
|
23
|
+
|
24
|
+
def super_resolve_renderable(renderable)
|
25
|
+
if renderable.is_a?(Symbol)
|
26
|
+
instance_variable_get(renderable)
|
27
|
+
else
|
28
|
+
renderable
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/super/reset.rb
CHANGED
@@ -10,12 +10,7 @@ module Super
|
|
10
10
|
_generate_paths_by_default: true,
|
11
11
|
|
12
12
|
# Defined in Super::SubstructureController
|
13
|
-
|
14
|
-
page_title: true,
|
15
|
-
|
16
|
-
# Defined in Super::ApplicationController
|
17
|
-
current_action: true,
|
18
|
-
with_current_action: true,
|
13
|
+
page_title: true
|
19
14
|
|
20
15
|
# Keep all of the ones in Super::SitewideController
|
21
16
|
}
|
data/lib/super/schema/guesser.rb
CHANGED
@@ -21,7 +21,7 @@ module Super
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def ignore_foreign_keys
|
24
|
-
@rejects.push(->
|
24
|
+
@rejects.push(->(attribute_name) { is_foreign_key[attribute_name] })
|
25
25
|
self
|
26
26
|
end
|
27
27
|
|
@@ -69,10 +69,10 @@ module Super
|
|
69
69
|
def is_foreign_key
|
70
70
|
@is_foreign_key ||=
|
71
71
|
@model
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
72
|
+
.reflect_on_all_associations
|
73
|
+
.select { |a| a.macro == :belongs_to }
|
74
|
+
.map { |a| [a.foreign_key, true] }
|
75
|
+
.to_h
|
76
76
|
end
|
77
77
|
end
|
78
78
|
end
|
data/lib/super/schema.rb
CHANGED
@@ -41,7 +41,7 @@ module Super
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def each(&block)
|
44
|
-
if
|
44
|
+
if block
|
45
45
|
return @backing.each(&block)
|
46
46
|
end
|
47
47
|
|
@@ -65,7 +65,7 @@ module Super
|
|
65
65
|
inside = {}
|
66
66
|
@backing = inside
|
67
67
|
yield
|
68
|
-
|
68
|
+
inside
|
69
69
|
ensure
|
70
70
|
@backing = outside
|
71
71
|
inside
|
data/lib/super/sort.rb
CHANGED
data/lib/super/useful/enum.rb
CHANGED
data/lib/super/useful/i19.rb
CHANGED
data/lib/super/version.rb
CHANGED
data/lib/super/view_chain.rb
CHANGED
@@ -26,6 +26,25 @@ module Super
|
|
26
26
|
chain.empty?
|
27
27
|
end
|
28
28
|
|
29
|
+
def handle_super_render(template, local_assigns, &block)
|
30
|
+
name, current = shift
|
31
|
+
current = template.super_resolve_renderable(current)
|
32
|
+
|
33
|
+
if !current
|
34
|
+
Rails.logger.warn do
|
35
|
+
"Super::ViewChain encountered a nil view: #{name.inspect}."
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
if empty?
|
40
|
+
template.super_render(current)
|
41
|
+
else
|
42
|
+
template.super_render(current) do
|
43
|
+
template.concat(template.super_render(self))
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
29
48
|
private
|
30
49
|
|
31
50
|
def chain
|
data/lib/super.rb
CHANGED
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.
|
4
|
+
version: 0.22.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:
|
11
|
+
date: 2023-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -212,6 +212,7 @@ files:
|
|
212
212
|
- app/assets/javascripts/super/application.js
|
213
213
|
- app/assets/stylesheets/super/application.css
|
214
214
|
- app/controllers/super/application_controller.rb
|
215
|
+
- app/controllers/super/foundation_controller.rb
|
215
216
|
- app/controllers/super/sitewide_controller.rb
|
216
217
|
- app/controllers/super/substructure_controller.rb
|
217
218
|
- app/controllers/super/view_controller.rb
|
@@ -312,6 +313,7 @@ files:
|
|
312
313
|
- lib/super/plugin.rb
|
313
314
|
- lib/super/query.rb
|
314
315
|
- lib/super/railtie.rb
|
316
|
+
- lib/super/render_helper.rb
|
315
317
|
- lib/super/reorderable_hash.rb
|
316
318
|
- lib/super/reset.rb
|
317
319
|
- lib/super/schema.rb
|