super 0.0.14 → 0.18.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 +2 -2
- data/app/assets/javascripts/super/application.js +148 -15
- data/app/assets/stylesheets/super/application.css +15 -22
- data/app/controllers/super/application_controller.rb +44 -42
- data/app/controllers/super/substructure_controller.rb +313 -0
- data/app/helpers/super/form_builder_helper.rb +7 -0
- data/app/views/layouts/super/application.html.erb +3 -21
- data/app/views/super/application/_collection_header.html.erb +2 -2
- data/app/views/super/application/_display_actions.html.erb +1 -1
- data/app/views/super/application/_display_index.html.erb +2 -2
- data/app/views/super/application/_display_show.html.erb +1 -1
- data/app/views/super/application/_filter.html.erb +62 -2
- data/app/views/super/application/_form_field.html.erb +5 -0
- data/app/views/super/application/_member_header.html.erb +2 -2
- data/app/views/super/application/_pagination.html.erb +1 -1
- 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/application/_sort_expression.html.erb +2 -2
- data/app/views/super/application/index.csv.erb +14 -0
- data/app/views/super/feather/README.md +0 -1
- data/frontend/super-frontend/dist/application.css +15 -22
- data/frontend/super-frontend/dist/application.js +148 -15
- data/lib/generators/super/install/install_generator.rb +0 -16
- data/lib/generators/super/install/templates/base_controller.rb.tt +0 -8
- data/lib/generators/super/resource/templates/resources_controller.rb.tt +4 -4
- data/lib/super/action_inquirer.rb +18 -3
- data/lib/super/badge.rb +60 -0
- data/lib/super/cheat.rb +6 -6
- data/lib/super/display/guesser.rb +1 -1
- data/lib/super/display/schema_types.rb +49 -1
- data/lib/super/display.rb +2 -1
- data/lib/super/error.rb +3 -0
- data/lib/super/filter/form_object.rb +74 -48
- data/lib/super/filter/guesser.rb +2 -0
- data/lib/super/filter/operator.rb +90 -64
- data/lib/super/filter/schema_types.rb +63 -80
- data/lib/super/filter.rb +1 -1
- data/lib/super/form/builder.rb +30 -39
- data/lib/super/form/field_transcript.rb +43 -0
- data/lib/super/form/guesser.rb +4 -4
- data/lib/super/form/schema_types.rb +66 -22
- data/lib/super/link.rb +2 -2
- data/lib/super/pagination.rb +2 -44
- data/lib/super/reset.rb +25 -0
- data/lib/super/schema.rb +4 -0
- data/lib/super/useful/builder.rb +4 -4
- data/lib/super/version.rb +1 -1
- data/lib/super.rb +3 -1
- data/lib/tasks/super/cheat.rake +1 -1
- metadata +25 -19
- data/app/views/super/application/_filter_type_select.html.erb +0 -21
- data/app/views/super/application/_filter_type_text.html.erb +0 -18
- data/app/views/super/application/_filter_type_timestamp.html.erb +0 -24
- data/app/views/super/application/_form_field_checkbox.html.erb +0 -1
- data/app/views/super/application/_form_field_flatpickr_date.html.erb +0 -8
- data/app/views/super/application/_form_field_flatpickr_datetime.html.erb +0 -8
- data/app/views/super/application/_form_field_flatpickr_time.html.erb +0 -8
- data/app/views/super/application/_form_field_rich_text_area.html.erb +0 -1
- data/app/views/super/application/_form_field_select.html.erb +0 -1
- data/app/views/super/application/_form_field_text.html.erb +0 -1
- data/app/views/super/feather/_chevron_down.html +0 -1
- data/docs/cheat.md +0 -41
- data/lib/super/controls/optional.rb +0 -113
- data/lib/super/controls/steps.rb +0 -106
- data/lib/super/controls/view.rb +0 -55
- data/lib/super/controls.rb +0 -22
data/lib/super/link.rb
CHANGED
@@ -82,7 +82,7 @@ module Super
|
|
82
82
|
|
83
83
|
def self.polymorphic_parts(*parts_tail)
|
84
84
|
parts_head = Super.configuration.path.strip.gsub(%r{\A/+}, "").gsub(%r{/+\z}, "").strip.split("/")
|
85
|
-
parts_head + parts_tail
|
85
|
+
parts_head.map { |part| part.is_a?(String) ? part.to_sym : part } + parts_tail
|
86
86
|
end
|
87
87
|
|
88
88
|
def initialize(text, href, **options)
|
@@ -107,7 +107,7 @@ module Super
|
|
107
107
|
@href = Super::Compatability.polymorphic_path_container.polymorphic_path(@href)
|
108
108
|
end
|
109
109
|
|
110
|
-
def to_s(default_options: nil)
|
110
|
+
def to_s(default_options: nil, **)
|
111
111
|
default_options ||= {}
|
112
112
|
ActionController::Base.helpers.link_to(
|
113
113
|
text,
|
data/lib/super/pagination.rb
CHANGED
@@ -76,52 +76,10 @@ module Super
|
|
76
76
|
module ControllerMethods
|
77
77
|
def index
|
78
78
|
super
|
79
|
-
@pagination =
|
80
|
-
@records =
|
79
|
+
@pagination = initialize_pagination
|
80
|
+
@records = paginate_records
|
81
81
|
@view.mains.first.parts.push(:@pagination)
|
82
82
|
end
|
83
83
|
end
|
84
84
|
end
|
85
|
-
|
86
|
-
class Controls
|
87
|
-
module Optional
|
88
|
-
# Specifies how many records to show per page
|
89
|
-
#
|
90
|
-
# @param action [ActionInquirer]
|
91
|
-
# @param query_params [Hash]
|
92
|
-
# @return [ActiveRecord::Relation]
|
93
|
-
def records_per_page(action:, query_params:)
|
94
|
-
Super.configuration.index_records_per_page
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
module Steps
|
99
|
-
# Sets up pagination
|
100
|
-
#
|
101
|
-
# @param action [ActionInquirer]
|
102
|
-
# @param records [ActiveRecord::Relation]
|
103
|
-
# @param query_params [Hash]
|
104
|
-
# @return [Pagination]
|
105
|
-
def initialize_pagination(action:, records:, query_params:)
|
106
|
-
Pagination.new(
|
107
|
-
total_count: records.size,
|
108
|
-
limit: records_per_page(action: action, query_params: query_params),
|
109
|
-
query_params: query_params,
|
110
|
-
page_query_param: :page
|
111
|
-
)
|
112
|
-
end
|
113
|
-
|
114
|
-
# Paginates
|
115
|
-
#
|
116
|
-
# @param action [ActionInquirer]
|
117
|
-
# @param records [ActiveRecord::Relation]
|
118
|
-
# @param pagination [Pagination]
|
119
|
-
# @return [ActiveRecord::Relation]
|
120
|
-
def paginate_records(action:, records:, pagination:)
|
121
|
-
records
|
122
|
-
.limit(pagination.limit)
|
123
|
-
.offset(pagination.offset)
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end
|
127
85
|
end
|
data/lib/super/reset.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Super
|
4
|
+
module Reset
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
included do
|
8
|
+
undef_method :index
|
9
|
+
undef_method :show
|
10
|
+
undef_method :new
|
11
|
+
undef_method :create
|
12
|
+
undef_method :edit
|
13
|
+
undef_method :update
|
14
|
+
undef_method :destroy
|
15
|
+
|
16
|
+
Super::SubstructureController.private_instance_methods(false).each do |imethod|
|
17
|
+
next if imethod == :_layout
|
18
|
+
next if imethod == :_generate_paths_by_default
|
19
|
+
next if imethod == :navigation
|
20
|
+
next if imethod == :page_title
|
21
|
+
undef_method imethod
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/super/schema.rb
CHANGED
data/lib/super/useful/builder.rb
CHANGED
@@ -6,8 +6,8 @@ module Super
|
|
6
6
|
def builder(method_name)
|
7
7
|
alias_method("original_#{method_name}", method_name)
|
8
8
|
|
9
|
-
define_method(method_name) do
|
10
|
-
send("original_#{method_name}")
|
9
|
+
define_method(method_name) do |*args|
|
10
|
+
send("original_#{method_name}", *args)
|
11
11
|
self
|
12
12
|
end
|
13
13
|
end
|
@@ -15,8 +15,8 @@ module Super
|
|
15
15
|
def builder_with_block(method_name)
|
16
16
|
alias_method("original_#{method_name}", method_name)
|
17
17
|
|
18
|
-
define_method(method_name) do
|
19
|
-
send("original_#{method_name}", &block)
|
18
|
+
define_method(method_name) do |*args, &block|
|
19
|
+
send("original_#{method_name}", *args, &block)
|
20
20
|
self
|
21
21
|
end
|
22
22
|
end
|
data/lib/super/version.rb
CHANGED
data/lib/super.rb
CHANGED
@@ -10,10 +10,10 @@ require "super/useful/enum"
|
|
10
10
|
|
11
11
|
require "super/action_inquirer"
|
12
12
|
require "super/assets"
|
13
|
+
require "super/badge"
|
13
14
|
require "super/client_error"
|
14
15
|
require "super/compatibility"
|
15
16
|
require "super/configuration"
|
16
|
-
require "super/controls"
|
17
17
|
require "super/display"
|
18
18
|
require "super/display/guesser"
|
19
19
|
require "super/display/schema_types"
|
@@ -25,6 +25,7 @@ require "super/filter/operator"
|
|
25
25
|
require "super/filter/schema_types"
|
26
26
|
require "super/form"
|
27
27
|
require "super/form/builder"
|
28
|
+
require "super/form/field_transcript"
|
28
29
|
require "super/form/guesser"
|
29
30
|
require "super/form/inline_errors"
|
30
31
|
require "super/form/schema_types"
|
@@ -38,6 +39,7 @@ require "super/panel"
|
|
38
39
|
require "super/partial"
|
39
40
|
require "super/plugin"
|
40
41
|
require "super/query/form_object"
|
42
|
+
require "super/reset"
|
41
43
|
require "super/schema"
|
42
44
|
require "super/schema/guesser"
|
43
45
|
require "super/sort"
|
data/lib/tasks/super/cheat.rake
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.0
|
4
|
+
version: 0.18.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-
|
11
|
+
date: 2021-08-27 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,20 @@ 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'
|
215
229
|
description:
|
216
230
|
email:
|
217
231
|
- engineering@zachahn.com
|
@@ -226,6 +240,7 @@ files:
|
|
226
240
|
- app/assets/javascripts/super/application.js
|
227
241
|
- app/assets/stylesheets/super/application.css
|
228
242
|
- app/controllers/super/application_controller.rb
|
243
|
+
- app/controllers/super/substructure_controller.rb
|
229
244
|
- app/helpers/super/form_builder_helper.rb
|
230
245
|
- app/views/layouts/super/application.html.erb
|
231
246
|
- app/views/super/application/_collection_header.html.erb
|
@@ -234,19 +249,10 @@ files:
|
|
234
249
|
- app/views/super/application/_display_rich_text.html.erb
|
235
250
|
- app/views/super/application/_display_show.html.erb
|
236
251
|
- app/views/super/application/_filter.html.erb
|
237
|
-
- app/views/super/application/_filter_type_select.html.erb
|
238
|
-
- app/views/super/application/_filter_type_text.html.erb
|
239
|
-
- app/views/super/application/_filter_type_timestamp.html.erb
|
240
252
|
- app/views/super/application/_flash.html.erb
|
241
253
|
- app/views/super/application/_form.html.erb
|
254
|
+
- app/views/super/application/_form_field.html.erb
|
242
255
|
- app/views/super/application/_form_field__destroy.html.erb
|
243
|
-
- app/views/super/application/_form_field_checkbox.html.erb
|
244
|
-
- app/views/super/application/_form_field_flatpickr_date.html.erb
|
245
|
-
- app/views/super/application/_form_field_flatpickr_datetime.html.erb
|
246
|
-
- app/views/super/application/_form_field_flatpickr_time.html.erb
|
247
|
-
- app/views/super/application/_form_field_rich_text_area.html.erb
|
248
|
-
- app/views/super/application/_form_field_select.html.erb
|
249
|
-
- app/views/super/application/_form_field_text.html.erb
|
250
256
|
- app/views/super/application/_form_fieldset.html.erb
|
251
257
|
- app/views/super/application/_form_has_many.html.erb
|
252
258
|
- app/views/super/application/_form_has_one.html.erb
|
@@ -255,19 +261,20 @@ files:
|
|
255
261
|
- app/views/super/application/_pagination.html.erb
|
256
262
|
- app/views/super/application/_panel.html.erb
|
257
263
|
- app/views/super/application/_query.html.erb
|
264
|
+
- app/views/super/application/_site_footer.html.erb
|
265
|
+
- app/views/super/application/_site_header.html.erb
|
258
266
|
- app/views/super/application/_sort.html.erb
|
259
267
|
- app/views/super/application/_sort_expression.html.erb
|
260
268
|
- app/views/super/application/edit.html.erb
|
269
|
+
- app/views/super/application/index.csv.erb
|
261
270
|
- app/views/super/application/index.html.erb
|
262
271
|
- app/views/super/application/new.html.erb
|
263
272
|
- app/views/super/application/nothing.html.erb
|
264
273
|
- app/views/super/application/show.html.erb
|
265
274
|
- app/views/super/feather/README.md
|
266
|
-
- app/views/super/feather/_chevron_down.html
|
267
275
|
- app/views/super/feather/_x.html
|
268
276
|
- config/locales/en.yml
|
269
277
|
- config/routes.rb
|
270
|
-
- docs/cheat.md
|
271
278
|
- frontend/super-frontend/dist/application.css
|
272
279
|
- frontend/super-frontend/dist/application.js
|
273
280
|
- lib/generators/super/action_text/USAGE
|
@@ -287,14 +294,11 @@ files:
|
|
287
294
|
- lib/super.rb
|
288
295
|
- lib/super/action_inquirer.rb
|
289
296
|
- lib/super/assets.rb
|
297
|
+
- lib/super/badge.rb
|
290
298
|
- lib/super/cheat.rb
|
291
299
|
- lib/super/client_error.rb
|
292
300
|
- lib/super/compatibility.rb
|
293
301
|
- lib/super/configuration.rb
|
294
|
-
- lib/super/controls.rb
|
295
|
-
- lib/super/controls/optional.rb
|
296
|
-
- lib/super/controls/steps.rb
|
297
|
-
- lib/super/controls/view.rb
|
298
302
|
- lib/super/display.rb
|
299
303
|
- lib/super/display/guesser.rb
|
300
304
|
- lib/super/display/schema_types.rb
|
@@ -307,6 +311,7 @@ files:
|
|
307
311
|
- lib/super/filter/schema_types.rb
|
308
312
|
- lib/super/form.rb
|
309
313
|
- lib/super/form/builder.rb
|
314
|
+
- lib/super/form/field_transcript.rb
|
310
315
|
- lib/super/form/guesser.rb
|
311
316
|
- lib/super/form/inline_errors.rb
|
312
317
|
- lib/super/form/schema_types.rb
|
@@ -321,6 +326,7 @@ files:
|
|
321
326
|
- lib/super/partial/resolving.rb
|
322
327
|
- lib/super/plugin.rb
|
323
328
|
- lib/super/query/form_object.rb
|
329
|
+
- lib/super/reset.rb
|
324
330
|
- lib/super/schema.rb
|
325
331
|
- lib/super/schema/common.rb
|
326
332
|
- lib/super/schema/guesser.rb
|
@@ -1,21 +0,0 @@
|
|
1
|
-
<div class="super-field-group" data-controller="clean-filter-param">
|
2
|
-
<%= form.fields_for(filter_type_select.field_name, filter_type_select) do |form_field| %>
|
3
|
-
<%= form_field.label(:q, filter_type_select.humanized_field_name) %>
|
4
|
-
<div class="relative inline-block">
|
5
|
-
<%= form_field.super.select(
|
6
|
-
:op,
|
7
|
-
filter_type_select.operators,
|
8
|
-
{ include_blank: false },
|
9
|
-
data: { clean_filter_param_target: "candidate" }
|
10
|
-
) %>
|
11
|
-
</div>
|
12
|
-
<div class="mt-3">
|
13
|
-
<%= form_field.super.select(
|
14
|
-
:q,
|
15
|
-
filter_type_select.field_type.collection,
|
16
|
-
{},
|
17
|
-
data: { clean_filter_param_target: "control candidate" }
|
18
|
-
) %>
|
19
|
-
</div>
|
20
|
-
<% end %>
|
21
|
-
</div>
|
@@ -1,18 +0,0 @@
|
|
1
|
-
<div class="super-field-group" data-controller="clean-filter-param">
|
2
|
-
<%= form.fields_for(filter_type_text.field_name, filter_type_text) do |form_field| %>
|
3
|
-
<%= form_field.label(:q, filter_type_text.humanized_field_name) %>
|
4
|
-
<div class="relative inline-block">
|
5
|
-
<%= form_field.super.select(
|
6
|
-
:op,
|
7
|
-
filter_type_text.operators,
|
8
|
-
{ include_blank: false },
|
9
|
-
data: { clean_filter_param_target: "candidate" }
|
10
|
-
) %>
|
11
|
-
</div>
|
12
|
-
<%= form_field.super.text_field(
|
13
|
-
:q,
|
14
|
-
class: "mt-3",
|
15
|
-
data: { clean_filter_param_target: "control candidate" }
|
16
|
-
) %>
|
17
|
-
<% end %>
|
18
|
-
</div>
|
@@ -1,24 +0,0 @@
|
|
1
|
-
<div class="super-field-group" data-controller="clean-filter-param">
|
2
|
-
<%= form.fields_for(filter_type_timestamp.field_name, filter_type_timestamp) do |form_field| %>
|
3
|
-
<%= form_field.label(:q0, filter_type_timestamp.humanized_field_name) %>
|
4
|
-
<div class="relative inline-block mt-2">
|
5
|
-
<%= form_field.super.select(
|
6
|
-
:op,
|
7
|
-
filter_type_timestamp.operators,
|
8
|
-
{ include_blank: false },
|
9
|
-
data: { clean_filter_param_target: "candidate" }
|
10
|
-
) %>
|
11
|
-
</div>
|
12
|
-
<div class="flex items-center mt-3">
|
13
|
-
<div class="flex-initial">
|
14
|
-
<%= form_field.super.flatpickr_datetime(:q0, data: { clean_filter_param_target: "control candidate" }) %>
|
15
|
-
</div>
|
16
|
-
<div class="flex-initial px-2">
|
17
|
-
–
|
18
|
-
</div>
|
19
|
-
<div class="flex-initial">
|
20
|
-
<%= form_field.super.flatpickr_datetime(:q1, data: { clean_filter_param_target: "control candidate" }) %>
|
21
|
-
</div>
|
22
|
-
</div>
|
23
|
-
<% end %>
|
24
|
-
</div>
|
@@ -1 +0,0 @@
|
|
1
|
-
<%= form.super.check_box!(column) %>
|
@@ -1 +0,0 @@
|
|
1
|
-
<%= form.super.rich_text_area!(column) %>
|
@@ -1 +0,0 @@
|
|
1
|
-
<%= form.super.select!(column, form_field_select[:collection]) %>
|
@@ -1 +0,0 @@
|
|
1
|
-
<%= form.super.text_field!(column) %>
|
@@ -1 +0,0 @@
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-chevron-down"><polyline points="6 9 12 15 18 9"></polyline></svg>
|
data/docs/cheat.md
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
<!--
|
2
|
-
# @title Cheat sheet
|
3
|
-
-->
|
4
|
-
|
5
|
-
# Cheat sheet
|
6
|
-
|
7
|
-
## Controls
|
8
|
-
|
9
|
-
You can configure most of your admin page's behavior by editing Controls.
|
10
|
-
They only work with ActiveRecord models
|
11
|
-
|
12
|
-
Controls have several required and optional methods. Note that all arguments
|
13
|
-
must be defined, even if they are ignored.
|
14
|
-
|
15
|
-
|
16
|
-
### Required methods
|
17
|
-
|
18
|
-
The following are the methods that must be defined in the `Controls` class.
|
19
|
-
|
20
|
-
* **`#model()`**
|
21
|
-
The model that your controller is working with
|
22
|
-
|
23
|
-
|
24
|
-
### Optional methods
|
25
|
-
|
26
|
-
The following are the methods that can be defined in the `Controls` class.
|
27
|
-
|
28
|
-
* **`#title()`**
|
29
|
-
The title to show on the main panel
|
30
|
-
* **`#collection_actions(action:)`**
|
31
|
-
The list of collection-level links
|
32
|
-
* **`#member_actions(action:)`**
|
33
|
-
The list of member-level links and `#show` pages
|
34
|
-
* **`#scope(action:)`**
|
35
|
-
The starting point of the query/relation. Defaults to `#all`
|
36
|
-
* **`#display_schema(action:)`**
|
37
|
-
The display schema definition for the `#index` and `#show` pages
|
38
|
-
* **`#form_schema(action:)`**
|
39
|
-
The form schema definition for the `#new` and `#edit` pages
|
40
|
-
* **`#permitted_params(params, action:)`**
|
41
|
-
The strong parameters definition
|