super 0.0.10 → 0.0.11
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.
- checksums.yaml +4 -4
- data/Rakefile +16 -14
- data/app/assets/javascripts/super/application.js +191 -1
- data/app/controllers/super/application_controller.rb +14 -8
- data/app/helpers/super/form_builder_helper.rb +2 -0
- data/app/views/super/application/_filter.html.erb +5 -13
- data/app/views/super/application/_filter_type_select.html.erb +4 -1
- data/app/views/super/application/_filter_type_text.html.erb +5 -3
- data/app/views/super/application/_filter_type_timestamp.html.erb +5 -4
- data/app/views/super/application/_query.html.erb +18 -0
- data/app/views/super/application/_sort.html.erb +18 -0
- data/app/views/super/application/_sort_expression.html.erb +25 -0
- data/app/views/super/feather/README.md +1 -0
- data/app/views/super/feather/_x.html +15 -0
- data/config/routes.rb +2 -0
- data/docs/action_text.md +1 -1
- data/docs/yard_customizations.rb +2 -0
- data/frontend/super-frontend/dist/application.js +191 -1
- data/lib/generators/super/action_text/action_text_generator.rb +2 -0
- data/lib/generators/super/install/install_generator.rb +2 -0
- data/lib/generators/super/resource/resource_generator.rb +2 -0
- data/lib/generators/super/webpacker/webpacker_generator.rb +2 -0
- data/lib/super.rb +4 -1
- data/lib/super/action_inquirer.rb +2 -0
- data/lib/super/assets.rb +2 -0
- data/lib/super/client_error.rb +2 -0
- data/lib/super/compatibility.rb +2 -0
- data/lib/super/configuration.rb +2 -1
- data/lib/super/controls.rb +4 -0
- data/lib/super/controls/optional.rb +34 -1
- data/lib/super/controls/required.rb +2 -0
- data/lib/super/controls/steps.rb +27 -35
- data/lib/super/controls/view.rb +55 -0
- data/lib/super/display.rb +13 -5
- data/lib/super/display/guesser.rb +2 -0
- data/lib/super/display/schema_types.rb +2 -0
- data/lib/super/engine.rb +2 -0
- data/lib/super/error.rb +5 -0
- data/lib/super/filter.rb +2 -0
- data/lib/super/filter/form_object.rb +5 -8
- data/lib/super/filter/guesser.rb +2 -0
- data/lib/super/filter/operator.rb +2 -0
- data/lib/super/filter/schema_types.rb +2 -0
- data/lib/super/form.rb +2 -0
- data/lib/super/form/builder.rb +2 -0
- data/lib/super/form/guesser.rb +2 -0
- data/lib/super/form/inline_errors.rb +2 -0
- data/lib/super/form/schema_types.rb +2 -0
- data/lib/super/form/strong_params.rb +2 -0
- data/lib/super/layout.rb +2 -0
- data/lib/super/link.rb +2 -0
- data/lib/super/navigation/automatic.rb +2 -0
- data/lib/super/pagination.rb +2 -0
- data/lib/super/panel.rb +2 -0
- data/lib/super/partial.rb +2 -0
- data/lib/super/partial/resolving.rb +2 -0
- data/lib/super/plugin.rb +2 -0
- data/lib/super/query/form_object.rb +48 -0
- data/lib/super/schema.rb +2 -0
- data/lib/super/schema/common.rb +2 -0
- data/lib/super/schema/guesser.rb +2 -0
- data/lib/super/sort.rb +110 -0
- data/lib/super/version.rb +3 -1
- data/lib/super/view_helper.rb +2 -0
- metadata +23 -3
- data/lib/super/filter/plugin.rb +0 -47
data/lib/super/controls/steps.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Super
|
2
4
|
class Controls
|
3
5
|
# Methods that are called by controller actions. All of these methods have
|
@@ -66,48 +68,38 @@ module Super
|
|
66
68
|
record.destroy
|
67
69
|
end
|
68
70
|
|
69
|
-
def
|
70
|
-
Super::
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
),
|
76
|
-
]
|
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
77
|
)
|
78
78
|
end
|
79
79
|
|
80
|
-
def
|
81
|
-
|
82
|
-
mains: [
|
83
|
-
Super::Panel.new(
|
84
|
-
Super::Partial.new("member_header"),
|
85
|
-
:@display
|
86
|
-
),
|
87
|
-
]
|
88
|
-
)
|
80
|
+
def apply_queries(query_form:, records:)
|
81
|
+
query_form.apply_changes(records)
|
89
82
|
end
|
90
83
|
|
91
|
-
def
|
92
|
-
|
93
|
-
|
94
|
-
Super::
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
)
|
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
|
100
92
|
end
|
101
93
|
|
102
|
-
def
|
103
|
-
|
104
|
-
|
105
|
-
Super::
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
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
|
111
103
|
end
|
112
104
|
end
|
113
105
|
end
|
@@ -0,0 +1,55 @@
|
|
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
|
data/lib/super/display.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Super
|
2
4
|
# This schema type is meant to be used for +#index+ or +#show+ actions to
|
3
5
|
# transform database fields into something that is human friendly.
|
@@ -23,20 +25,26 @@ module Super
|
|
23
25
|
class Display
|
24
26
|
include Schema::Common
|
25
27
|
|
26
|
-
def initialize
|
27
|
-
@action_inquirer = action
|
28
|
+
def initialize
|
28
29
|
@fields = Super::Schema::Fields.new
|
29
30
|
@schema_types = SchemaTypes.new(fields: @fields)
|
30
31
|
|
31
32
|
yield(@fields, @schema_types)
|
33
|
+
end
|
32
34
|
|
33
|
-
|
34
|
-
|
35
|
+
def apply(action:)
|
36
|
+
@action_inquirer = action
|
37
|
+
return self if !@action_inquirer.index?
|
38
|
+
return self if @schema_types.actions_called?
|
35
39
|
@fields[:actions] = @schema_types.actions
|
40
|
+
self
|
36
41
|
end
|
37
42
|
|
38
43
|
def to_partial_path
|
39
|
-
if @action_inquirer.
|
44
|
+
if @action_inquirer.nil?
|
45
|
+
raise Super::Error::Initalization,
|
46
|
+
"You must call the `#apply` method after instantiating Super::Display"
|
47
|
+
elsif @action_inquirer.index?
|
40
48
|
"super_schema_display_index"
|
41
49
|
elsif @action_inquirer.show?
|
42
50
|
"super_schema_display_show"
|
data/lib/super/engine.rb
CHANGED
data/lib/super/error.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Super
|
2
4
|
# A container class for all internal errors thrown by this library
|
3
5
|
#
|
@@ -22,5 +24,8 @@ module Super
|
|
22
24
|
)
|
23
25
|
end
|
24
26
|
end
|
27
|
+
# Error raised when something wasn't initalized correctly, and if there isn't
|
28
|
+
# a more specific error
|
29
|
+
class Initalization < Error; end
|
25
30
|
end
|
26
31
|
end
|
data/lib/super/filter.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Super
|
2
4
|
class Filter
|
3
5
|
class FormObject
|
@@ -42,11 +44,10 @@ module Super
|
|
42
44
|
end
|
43
45
|
end
|
44
46
|
|
45
|
-
def initialize(model:,
|
47
|
+
def initialize(model:, params:, schema:)
|
46
48
|
@model = model
|
47
|
-
@url = url
|
48
|
-
@schema = schema
|
49
49
|
@params = params
|
50
|
+
@schema = schema
|
50
51
|
|
51
52
|
@form_fields = {}
|
52
53
|
end
|
@@ -57,15 +58,11 @@ module Super
|
|
57
58
|
end
|
58
59
|
end
|
59
60
|
|
60
|
-
def url
|
61
|
-
@url
|
62
|
-
end
|
63
|
-
|
64
61
|
def to_partial_path
|
65
62
|
"filter"
|
66
63
|
end
|
67
64
|
|
68
|
-
def
|
65
|
+
def apply_changes(relation)
|
69
66
|
each_field do |form_field|
|
70
67
|
next if form_field.specified_values.values.map(&:to_s).map(&:strip).all? { |specified_value| specified_value == "" }
|
71
68
|
next if !Super::Filter::Operator.registry.key?(form_field.op)
|
data/lib/super/filter/guesser.rb
CHANGED
data/lib/super/form.rb
CHANGED
data/lib/super/form/builder.rb
CHANGED
data/lib/super/form/guesser.rb
CHANGED
data/lib/super/layout.rb
CHANGED
data/lib/super/link.rb
CHANGED
data/lib/super/pagination.rb
CHANGED
data/lib/super/panel.rb
CHANGED
data/lib/super/partial.rb
CHANGED
data/lib/super/plugin.rb
CHANGED
@@ -0,0 +1,48 @@
|
|
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
|
data/lib/super/schema.rb
CHANGED