super 0.0.11 → 0.0.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +0 -9
- data/README.md +42 -54
- data/app/assets/javascripts/super/application.js +5617 -3806
- data/app/assets/stylesheets/super/application.css +114687 -71486
- data/app/controllers/super/application_controller.rb +41 -47
- data/app/controllers/super/substructure_controller.rb +265 -0
- data/app/helpers/super/form_builder_helper.rb +7 -0
- data/app/views/layouts/super/application.html.erb +4 -21
- data/app/views/super/application/_collection_header.html.erb +2 -2
- data/app/views/super/application/{_super_schema_display_actions.html.erb → _display_actions.html.erb} +1 -1
- data/app/views/super/application/{_super_schema_display_index.html.erb → _display_index.html.erb} +5 -5
- data/app/views/super/application/_display_show.html.erb +8 -0
- data/app/views/super/application/_filter_type_select.html.erb +1 -1
- data/app/views/super/application/_filter_type_text.html.erb +1 -1
- data/app/views/super/application/_filter_type_timestamp.html.erb +3 -3
- data/app/views/super/application/{_super_schema_form.html.erb → _form.html.erb} +2 -2
- data/app/views/super/application/_form_field.html.erb +5 -0
- data/app/views/super/application/{_super_layout.html.erb → _layout.html.erb} +8 -8
- data/app/views/super/application/_member_header.html.erb +2 -2
- data/app/views/super/application/{_super_pagination.html.erb → _pagination.html.erb} +1 -1
- data/app/views/super/application/{_super_panel.html.erb → _panel.html.erb} +2 -2
- data/app/views/super/application/_site_footer.html.erb +3 -0
- data/app/views/super/application/_site_header.html.erb +17 -0
- data/app/views/super/feather/README.md +0 -1
- data/frontend/super-frontend/dist/application.css +114687 -71486
- data/frontend/super-frontend/dist/application.js +5617 -3806
- data/lib/generators/super/install/install_generator.rb +16 -23
- data/lib/generators/super/install/templates/base_controller.rb.tt +1 -1
- data/lib/generators/super/install/templates/initializer.rb.tt +9 -2
- data/lib/generators/super/resource/resource_generator.rb +105 -30
- data/lib/generators/super/resource/templates/resources_controller.rb.tt +4 -10
- data/lib/generators/super/webpacker/webpacker_generator.rb +9 -5
- data/lib/super.rb +6 -2
- data/lib/super/action_inquirer.rb +18 -3
- data/lib/super/assets.rb +44 -23
- data/lib/super/badge.rb +60 -0
- data/lib/super/cheat.rb +17 -0
- data/lib/super/compatibility.rb +19 -0
- data/lib/super/configuration.rb +14 -23
- data/lib/super/display.rb +16 -8
- data/lib/super/display/guesser.rb +2 -0
- data/lib/super/display/schema_types.rb +116 -29
- data/lib/super/error.rb +7 -0
- data/lib/super/form.rb +1 -1
- data/lib/super/form/builder.rb +107 -27
- data/lib/super/form/guesser.rb +10 -1
- data/lib/super/form/schema_types.rb +73 -7
- data/lib/super/layout.rb +1 -1
- data/lib/super/link.rb +42 -31
- data/lib/super/link_builder.rb +58 -0
- data/lib/super/navigation.rb +164 -0
- data/lib/super/pagination.rb +3 -45
- data/lib/super/panel.rb +1 -1
- data/lib/super/reset.rb +22 -0
- data/lib/super/useful/builder.rb +25 -0
- data/lib/super/useful/enum.rb +63 -0
- data/lib/super/version.rb +1 -1
- data/lib/tasks/super/cheat.rake +9 -0
- metadata +27 -31
- data/CONTRIBUTING.md +0 -56
- data/Rakefile +0 -36
- data/STABILITY.md +0 -50
- data/app/views/super/application/_form_field_checkbox.html.erb +0 -1
- data/app/views/super/application/_form_field_rich_text_area.html.erb +0 -1
- data/app/views/super/application/_form_field_text.html.erb +0 -1
- data/app/views/super/application/_super_schema_display_show.html.erb +0 -8
- data/app/views/super/feather/_chevron_down.html +0 -1
- data/docs/README.md +0 -8
- data/docs/action_text.md +0 -48
- data/docs/cheat.md +0 -41
- data/docs/faq.md +0 -44
- data/docs/installation.md +0 -21
- data/docs/quick_start.md +0 -30
- data/docs/webpacker.md +0 -25
- data/docs/yard_customizations.rb +0 -43
- data/lib/super/controls.rb +0 -17
- data/lib/super/controls/optional.rb +0 -112
- data/lib/super/controls/required.rb +0 -15
- data/lib/super/controls/steps.rb +0 -106
- data/lib/super/controls/view.rb +0 -55
- data/lib/super/navigation/automatic.rb +0 -73
data/lib/super/controls/steps.rb
DELETED
@@ -1,106 +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
|
-
end
|
105
|
-
end
|
106
|
-
end
|
data/lib/super/controls/view.rb
DELETED
@@ -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,73 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Super
|
4
|
-
class Navigation
|
5
|
-
# Traverses the defined Rails Routes and attempts to build a list of links.
|
6
|
-
# This is used for building the nav bar on each admin page.
|
7
|
-
class Automatic
|
8
|
-
def initialize(route_namespace:)
|
9
|
-
route_namespace = route_namespace.to_s
|
10
|
-
|
11
|
-
if route_namespace.include?("/")
|
12
|
-
raise "Can't be nested namespace"
|
13
|
-
end
|
14
|
-
|
15
|
-
@route_namespace = route_namespace
|
16
|
-
end
|
17
|
-
|
18
|
-
def each
|
19
|
-
if !block_given?
|
20
|
-
return enum_for(:each)
|
21
|
-
end
|
22
|
-
|
23
|
-
navigable_namespace_routes = Rails.application.routes.routes.select do |route|
|
24
|
-
path_spec = route.path.spec
|
25
|
-
|
26
|
-
next if route.verb != "GET"
|
27
|
-
next if !path_spec.respond_to?(:right)
|
28
|
-
next if path_spec.right.left.to_s != @route_namespace
|
29
|
-
next if route.required_parts.any?
|
30
|
-
next if route.defaults.empty?
|
31
|
-
|
32
|
-
true
|
33
|
-
end
|
34
|
-
|
35
|
-
navigable_defaults = navigable_namespace_routes.map do |route|
|
36
|
-
controller_name = route.defaults[:controller] + "_controller"
|
37
|
-
_controller =
|
38
|
-
begin
|
39
|
-
controller_name.camelize.constantize
|
40
|
-
rescue NameError
|
41
|
-
warn("[super] Couldn't find controller: #{controller_name}")
|
42
|
-
next
|
43
|
-
end
|
44
|
-
|
45
|
-
route.defaults
|
46
|
-
end
|
47
|
-
|
48
|
-
grouped_navigable_defaults =
|
49
|
-
navigable_defaults.compact.uniq.group_by { |d| d[:controller] }
|
50
|
-
|
51
|
-
grouped_navigable_defaults.each do |controller, defaults|
|
52
|
-
actions = defaults.map { |d| [d[:action], d[:action]] }.to_h
|
53
|
-
action = actions["index"] || actions["show"]
|
54
|
-
|
55
|
-
next if action.nil?
|
56
|
-
|
57
|
-
path =
|
58
|
-
begin
|
59
|
-
Rails.application.routes.url_for(
|
60
|
-
controller: controller,
|
61
|
-
action: action,
|
62
|
-
only_path: true
|
63
|
-
)
|
64
|
-
rescue ActionController::UrlGenerationError
|
65
|
-
next
|
66
|
-
end
|
67
|
-
|
68
|
-
yield(controller.split("/").last.humanize, path)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|