super 0.0.3 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +11 -0
- data/CONTRIBUTING.md +56 -0
- data/README.md +65 -76
- data/STABILITY.md +50 -0
- data/app/assets/javascripts/super/application.js +1186 -11151
- data/app/assets/stylesheets/super/application.css +93514 -27381
- data/app/controllers/super/application_controller.rb +49 -72
- data/app/views/layouts/super/application.html.erb +24 -14
- data/app/views/super/application/_collection_header.html.erb +15 -0
- data/app/views/super/application/_filter.html.erb +14 -0
- data/app/views/super/application/_filter_type_select.html.erb +31 -0
- data/app/views/super/application/_filter_type_text.html.erb +22 -0
- data/app/views/super/application/_filter_type_timestamp.html.erb +35 -0
- data/app/views/super/application/_flash.html.erb +13 -13
- data/app/views/super/application/_form_field__destroy.html.erb +7 -3
- data/app/views/super/application/_form_field_select.html.erb +14 -8
- data/app/views/super/application/_form_field_text.html.erb +13 -5
- data/app/views/super/application/_form_fieldset.html.erb +1 -1
- data/app/views/super/application/_form_has_many.html.erb +5 -5
- data/app/views/super/application/_form_inline_errors.html.erb +1 -1
- data/app/views/super/application/_member_header.html.erb +16 -0
- data/app/views/super/application/_super_layout.html.erb +29 -0
- data/app/views/super/application/_super_pagination.html.erb +16 -0
- data/app/views/super/application/_super_panel.html.erb +7 -0
- data/app/views/super/application/_super_schema_display_actions.html.erb +5 -0
- data/app/views/super/application/_super_schema_display_index.html.erb +24 -0
- data/app/views/super/application/_super_schema_display_show.html.erb +8 -0
- data/app/views/super/application/_super_schema_form.html.erb +15 -0
- data/app/views/super/application/edit.html.erb +1 -6
- data/app/views/super/application/index.html.erb +1 -1
- data/app/views/super/application/new.html.erb +1 -6
- data/app/views/super/application/show.html.erb +1 -1
- data/app/views/super/feather/{_chevron_down.svg → _chevron_down.html} +0 -0
- data/config/locales/en.yml +5 -0
- data/docs/README.md +6 -0
- data/docs/cheat.md +41 -0
- data/docs/faq.md +44 -0
- data/docs/quick_start.md +45 -0
- data/docs/webpacker.md +17 -0
- data/docs/yard_customizations.rb +41 -0
- data/frontend/super-frontend/build.js +12 -12
- data/frontend/super-frontend/dist/application.css +93514 -27381
- data/frontend/super-frontend/dist/application.js +1186 -11151
- data/frontend/super-frontend/package.json +8 -4
- data/frontend/super-frontend/postcss.config.js +4 -4
- data/frontend/super-frontend/src/javascripts/super/application.ts +11 -9
- data/frontend/super-frontend/src/javascripts/super/apply_template_controller.ts +19 -0
- data/frontend/super-frontend/src/javascripts/super/rails__ujs.d.ts +1 -1
- data/frontend/super-frontend/src/javascripts/super/toggle_pending_destruction_controller.ts +15 -0
- data/frontend/super-frontend/src/stylesheets/super/application.css +63 -0
- data/frontend/super-frontend/tailwind.config.js +12 -4
- data/frontend/super-frontend/yarn.lock +1429 -1372
- data/lib/generators/super/install/install_generator.rb +16 -0
- data/lib/generators/super/resource/templates/resources_controller.rb.tt +1 -31
- data/lib/generators/super/webpacker/webpacker_generator.rb +10 -1
- data/lib/super.rb +26 -5
- data/lib/super/action_inquirer.rb +2 -2
- data/lib/super/assets.rb +108 -38
- data/lib/super/client_error.rb +43 -0
- data/lib/super/compatibility.rb +25 -0
- data/lib/super/configuration.rb +21 -69
- data/lib/super/controls.rb +9 -37
- data/lib/super/controls/optional.rb +79 -0
- data/lib/super/controls/required.rb +13 -0
- data/lib/super/controls/steps.rb +114 -0
- data/lib/super/display.rb +66 -3
- data/lib/super/display/guesser.rb +34 -0
- data/lib/super/display/schema_types.rb +55 -25
- data/lib/super/engine.rb +7 -1
- data/lib/super/error.rb +9 -9
- data/lib/super/filter.rb +12 -0
- data/lib/super/filter/form_object.rb +97 -0
- data/lib/super/filter/guesser.rb +30 -0
- data/lib/super/filter/operator.rb +103 -0
- data/lib/super/filter/plugin.rb +47 -0
- data/lib/super/filter/schema_types.rb +112 -0
- data/lib/super/form.rb +35 -0
- data/lib/super/form/builder.rb +48 -0
- data/lib/super/form/guesser.rb +27 -0
- data/lib/super/form/schema_types.rb +20 -23
- data/lib/super/form/strong_params.rb +29 -0
- data/lib/super/layout.rb +47 -0
- data/lib/super/link.rb +110 -0
- data/lib/super/pagination.rb +74 -8
- data/lib/super/panel.rb +30 -0
- data/lib/super/partial.rb +23 -0
- data/lib/super/partial/resolving.rb +24 -0
- data/lib/super/plugin.rb +34 -63
- data/lib/super/schema.rb +12 -22
- data/lib/super/schema/common.rb +25 -0
- data/lib/super/schema/guesser.rb +77 -0
- data/lib/super/version.rb +1 -1
- data/lib/super/view_helper.rb +43 -0
- metadata +133 -33
- data/app/views/super/application/_form.html.erb +0 -14
- data/app/views/super/application/_index.html.erb +0 -60
- data/app/views/super/application/_show.html.erb +0 -12
- data/frontend/super-frontend/src/javascripts/super/nested_attributes_controller.ts +0 -33
- data/lib/super/inline_callback.rb +0 -82
- data/lib/super/test_support/copy_app_templates/controllers/favorite_things_controller.rb +0 -50
- data/lib/super/test_support/copy_app_templates/controllers/members_controller.rb +0 -57
- data/lib/super/test_support/copy_app_templates/controllers/ships_controller.rb +0 -47
- data/lib/super/test_support/copy_app_templates/migrations/20190216224956_create_members.rb +0 -11
- data/lib/super/test_support/copy_app_templates/migrations/20190803143320_create_ships.rb +0 -11
- data/lib/super/test_support/copy_app_templates/migrations/20190806014121_add_ship_to_members.rb +0 -5
- data/lib/super/test_support/copy_app_templates/migrations/20191126050453_create_favorite_things.rb +0 -10
- data/lib/super/test_support/copy_app_templates/models/favorite_thing.rb +0 -7
- data/lib/super/test_support/copy_app_templates/models/member.rb +0 -23
- data/lib/super/test_support/copy_app_templates/models/ship.rb +0 -3
- data/lib/super/test_support/copy_app_templates/routes.rb +0 -11
- data/lib/super/test_support/copy_app_templates/seeds.rb +0 -2
- data/lib/super/test_support/fixtures/favorite_things.yml +0 -9
- data/lib/super/test_support/fixtures/members.yml +0 -336
- data/lib/super/test_support/fixtures/ships.yml +0 -10
- data/lib/super/test_support/generate_copy_app.rb +0 -41
- data/lib/super/test_support/generate_dummy.rb +0 -93
- data/lib/super/test_support/starfleet_seeder.rb +0 -50
- data/lib/super/view.rb +0 -25
- data/lib/tasks/super_tasks.rake +0 -4
@@ -1,14 +0,0 @@
|
|
1
|
-
<% schema = controls.form_schema(action: action_inquirer) %>
|
2
|
-
|
3
|
-
<%= form_for(Super.configuration.path_parts(resource)) do |f| %>
|
4
|
-
<% schema.fields.each do |field, type| %>
|
5
|
-
<%= render(
|
6
|
-
type,
|
7
|
-
form: f,
|
8
|
-
column: field
|
9
|
-
) %>
|
10
|
-
<% end %>
|
11
|
-
<div>
|
12
|
-
<%= f.submit class: "bg-blue-700 hover:bg-blue-800 text-white py-2 px-4 rounded mt-2" %>
|
13
|
-
</div>
|
14
|
-
<% end %>
|
@@ -1,60 +0,0 @@
|
|
1
|
-
<% schema = controls.display_schema(action: action_inquirer) %>
|
2
|
-
|
3
|
-
<% content_for(:header) do %>
|
4
|
-
<header>
|
5
|
-
<h1 class="text-3xl inline-block">
|
6
|
-
<%= controls.title %>
|
7
|
-
</h1>
|
8
|
-
<%= link_to(
|
9
|
-
"New #{controls.model.name}",
|
10
|
-
new_polymorphic_path(Super.configuration.path_parts(controls.model.new)),
|
11
|
-
class: "inline-block"
|
12
|
-
) %>
|
13
|
-
</header>
|
14
|
-
<% end %>
|
15
|
-
|
16
|
-
<table class="w-full leading-loose mt-4">
|
17
|
-
<thead class="border-gray-400 border-solid">
|
18
|
-
<tr>
|
19
|
-
<% (schema.field_keys + ["Actions"]).each do |column| %>
|
20
|
-
<th class="text-left"><%= column.to_s.humanize %></th>
|
21
|
-
<% end %>
|
22
|
-
</tr>
|
23
|
-
</thead>
|
24
|
-
<tbody>
|
25
|
-
<% @resources.each.with_index do |resource, index| %>
|
26
|
-
<tr id="resource-pk-<%= resource.id %>" class="<%= index.even? ? "bg-gray-100" : "" %>" >
|
27
|
-
<% schema.field_keys.each do |column| %>
|
28
|
-
<td><%= Super::Display.format(schema, resource, column) %></td>
|
29
|
-
<% end %>
|
30
|
-
<td>
|
31
|
-
<%= link_to(
|
32
|
-
"View",
|
33
|
-
polymorphic_path(Super.configuration.path_parts(resource))
|
34
|
-
) %>
|
35
|
-
<%= link_to(
|
36
|
-
"Edit",
|
37
|
-
edit_polymorphic_path(Super.configuration.path_parts(resource))
|
38
|
-
) %>
|
39
|
-
<%= link_to(
|
40
|
-
"Delete",
|
41
|
-
polymorphic_path(Super.configuration.path_parts(resource)),
|
42
|
-
method: :delete,
|
43
|
-
data: { confirm: "Really delete?" }
|
44
|
-
) %>
|
45
|
-
</td>
|
46
|
-
</tr>
|
47
|
-
<% end %>
|
48
|
-
</tbody>
|
49
|
-
</table>
|
50
|
-
|
51
|
-
<% @pagination.each do |page_query_params, is_current_page, display| %>
|
52
|
-
<%= link_to(
|
53
|
-
display,
|
54
|
-
polymorphic_path(
|
55
|
-
Super.configuration.path_parts(controls.model),
|
56
|
-
page_query_params
|
57
|
-
),
|
58
|
-
class: "#{is_current_page ? " text-gray-900" : ""}"
|
59
|
-
) %>
|
60
|
-
<% end %>
|
@@ -1,12 +0,0 @@
|
|
1
|
-
<% schema = controls.display_schema(action: action_inquirer) %>
|
2
|
-
|
3
|
-
<h1 class="text-3xl"><%= controls.title %></h1>
|
4
|
-
|
5
|
-
<table class="max-w-full leading-loose mt-4">
|
6
|
-
<% schema.field_keys.each do |column| %>
|
7
|
-
<tr>
|
8
|
-
<th class="text-right px-4"><%= column.to_s.humanize %></th>
|
9
|
-
<td><%= Super::Display.format(schema, @resource, column) %></td>
|
10
|
-
</tr>
|
11
|
-
<% end %>
|
12
|
-
</table>
|
@@ -1,33 +0,0 @@
|
|
1
|
-
import { Controller } from 'stimulus'
|
2
|
-
import $ from 'jquery'
|
3
|
-
|
4
|
-
export default class extends Controller {
|
5
|
-
templateTarget: Element | undefined
|
6
|
-
|
7
|
-
static targets = ['template']
|
8
|
-
|
9
|
-
add(event: Event) {
|
10
|
-
event.preventDefault()
|
11
|
-
|
12
|
-
if (this.templateTarget) {
|
13
|
-
const unixtime = (new Date()).getTime();
|
14
|
-
let $content = $(this.templateTarget.innerHTML.replace(/TEMPLATE/g, unixtime.toString()))
|
15
|
-
var $templateTarget = $(this.templateTarget)
|
16
|
-
|
17
|
-
$templateTarget.before($content)
|
18
|
-
}
|
19
|
-
}
|
20
|
-
|
21
|
-
toggleDestruction(event: Event) {
|
22
|
-
if (event.target) {
|
23
|
-
let $eventTarget = $(event.target)
|
24
|
-
let $fieldset = $eventTarget.closest("fieldset")
|
25
|
-
|
26
|
-
if ($eventTarget.is(":checked")) {
|
27
|
-
$fieldset.addClass('opacity-75 bg-gray-100')
|
28
|
-
} else {
|
29
|
-
$fieldset.removeClass('opacity-75 bg-gray-100')
|
30
|
-
}
|
31
|
-
}
|
32
|
-
}
|
33
|
-
}
|
@@ -1,82 +0,0 @@
|
|
1
|
-
module Super
|
2
|
-
module InlineCallback
|
3
|
-
extend ActiveSupport::Concern
|
4
|
-
|
5
|
-
included do
|
6
|
-
register_inline_callback(:yield, on: :index)
|
7
|
-
end
|
8
|
-
|
9
|
-
class_methods do
|
10
|
-
def inline_callback_registry
|
11
|
-
@inline_callback_registry ||= {}
|
12
|
-
end
|
13
|
-
|
14
|
-
def inline_callback_defined?(action)
|
15
|
-
action = action.to_sym
|
16
|
-
|
17
|
-
inline_callback_registry.key?(action)
|
18
|
-
end
|
19
|
-
|
20
|
-
def inline_callbacks_for(action, check_ancestors = true)
|
21
|
-
action = action.to_sym
|
22
|
-
|
23
|
-
inline_callback_registry[action] ||= {}
|
24
|
-
|
25
|
-
if check_ancestors
|
26
|
-
ancestors.each do |ancestor|
|
27
|
-
if ancestor.respond_to?(:inline_callback_defined?)
|
28
|
-
if ancestor.inline_callback_defined?(action)
|
29
|
-
parent_class_callbacks = ancestor.inline_callbacks_for(action, false)
|
30
|
-
inline_callback_registry[action] = parent_class_callbacks.merge(inline_callback_registry[action])
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
if ancestor == Super::ApplicationController
|
35
|
-
break
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
inline_callback_registry[action]
|
41
|
-
end
|
42
|
-
|
43
|
-
def register_inline_callback(callback, on:, after: nil)
|
44
|
-
action = on.to_sym
|
45
|
-
after = after.to_sym if after.respond_to?(:to_sym)
|
46
|
-
|
47
|
-
callbacks = inline_callbacks_for(action)
|
48
|
-
if !callbacks.key?(callback)
|
49
|
-
callbacks[callback] = []
|
50
|
-
end
|
51
|
-
|
52
|
-
if after
|
53
|
-
callbacks[callback].push(after)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def with_inline_callbacks
|
59
|
-
action = params[:action].to_sym
|
60
|
-
|
61
|
-
callbacks = self.class.inline_callbacks_for(action)
|
62
|
-
|
63
|
-
each_node = -> (&b) { callbacks.each_key(&b) }
|
64
|
-
each_child = -> (cb, &b) { callbacks[cb].each(&b) }
|
65
|
-
|
66
|
-
yield_called = false
|
67
|
-
|
68
|
-
TSort.tsort_each(each_node, each_child) do |callback|
|
69
|
-
if callback == :yield
|
70
|
-
yield_called = true
|
71
|
-
yield
|
72
|
-
else
|
73
|
-
send(callback)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
if !yield_called
|
78
|
-
yield
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
module Admin
|
2
|
-
class FavoriteThingsController < AdminController
|
3
|
-
private
|
4
|
-
|
5
|
-
def new_controls
|
6
|
-
Controls.new
|
7
|
-
end
|
8
|
-
|
9
|
-
class Controls
|
10
|
-
def title
|
11
|
-
FavoriteThing.name.pluralize
|
12
|
-
end
|
13
|
-
|
14
|
-
def model
|
15
|
-
FavoriteThing
|
16
|
-
end
|
17
|
-
|
18
|
-
def scope(action:)
|
19
|
-
FavoriteThing.all
|
20
|
-
end
|
21
|
-
|
22
|
-
def permitted_params(params, action:)
|
23
|
-
params.require(:favorite_thing).permit(:name, member_attributes: [:id, :name, :rank, :position, :ship_id])
|
24
|
-
end
|
25
|
-
|
26
|
-
def display_schema(action:)
|
27
|
-
Super::Schema.new(Super::Display::SchemaTypes.new) do |fields, type|
|
28
|
-
fields[:name] = type.dynamic(&:itself)
|
29
|
-
fields[:member] = type.dynamic { |member| "#{member.name} (member ##{member.id})" }
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def form_schema(action:)
|
34
|
-
Super::Schema.new(Super::Form::SchemaTypes.new) do |fields, type|
|
35
|
-
fields[:name] = type.generic("form_field_text")
|
36
|
-
|
37
|
-
fields[:member_attributes] = type.belongs_to(:member) do
|
38
|
-
fields[:name] = type.generic("form_field_text")
|
39
|
-
fields[:rank] = type.generic("form_field_select", collection: Member.ranks.keys)
|
40
|
-
fields[:position] = type.generic("form_field_text")
|
41
|
-
fields[:ship_id] = type.generic(
|
42
|
-
"form_field_select",
|
43
|
-
collection: Ship.all.map { |s| ["#{s.name} (Ship ##{s.id})", s.id] },
|
44
|
-
)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
module Admin
|
2
|
-
class MembersController < AdminController
|
3
|
-
private
|
4
|
-
|
5
|
-
def new_controls
|
6
|
-
Controls.new
|
7
|
-
end
|
8
|
-
|
9
|
-
class Controls
|
10
|
-
def title
|
11
|
-
Member.name.pluralize
|
12
|
-
end
|
13
|
-
|
14
|
-
def model
|
15
|
-
Member
|
16
|
-
end
|
17
|
-
|
18
|
-
def scope(action:)
|
19
|
-
Member.all
|
20
|
-
end
|
21
|
-
|
22
|
-
def permitted_params(params, action:)
|
23
|
-
params.require(:member).permit(:name, :rank, :position, :ship_id, favorite_things_attributes: [:id, :name, :_destroy])
|
24
|
-
end
|
25
|
-
|
26
|
-
def display_schema(action:)
|
27
|
-
Super::Schema.new(Super::Display::SchemaTypes.new) do |fields, type|
|
28
|
-
fields[:name] = type.dynamic(&:itself)
|
29
|
-
fields[:rank] = type.dynamic(&:itself)
|
30
|
-
fields[:position] = type.dynamic(&:itself)
|
31
|
-
fields[:ship] = type.dynamic { |ship| "#{ship.name} (Ship ##{ship.id})" }
|
32
|
-
fields[:created_at] = type.dynamic(&:iso8601)
|
33
|
-
if action.show?
|
34
|
-
fields[:updated_at] = type.dynamic(&:iso8601)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def form_schema(action:)
|
40
|
-
Super::Schema.new(Super::Form::SchemaTypes.new) do |fields, type|
|
41
|
-
fields[:name] = type.generic("form_field_text")
|
42
|
-
fields[:rank] = type.generic("form_field_select", collection: Member.ranks.keys)
|
43
|
-
fields[:position] = type.generic("form_field_text")
|
44
|
-
fields[:ship_id] = type.generic(
|
45
|
-
"form_field_select",
|
46
|
-
collection: Ship.all.map { |s| ["#{s.name} (Ship ##{s.id})", s.id] },
|
47
|
-
)
|
48
|
-
|
49
|
-
fields[:favorite_things_attributes] = type.has_many(:favorite_things) do
|
50
|
-
fields[:name] = type.generic("form_field_text")
|
51
|
-
fields[:_destroy] = type._destroy
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
module Admin
|
2
|
-
class ShipsController < AdminController
|
3
|
-
private
|
4
|
-
|
5
|
-
def new_controls
|
6
|
-
Controls.new
|
7
|
-
end
|
8
|
-
|
9
|
-
class Controls
|
10
|
-
def title
|
11
|
-
Ship.name.pluralize
|
12
|
-
end
|
13
|
-
|
14
|
-
def model
|
15
|
-
Ship
|
16
|
-
end
|
17
|
-
|
18
|
-
def scope(action:)
|
19
|
-
Ship.all
|
20
|
-
end
|
21
|
-
|
22
|
-
def permitted_params(params, action:)
|
23
|
-
params.require(:ship).permit(:name, :registry, :class_name)
|
24
|
-
end
|
25
|
-
|
26
|
-
def display_schema(action:)
|
27
|
-
Super::Schema.new(Super::Display::SchemaTypes.new) do |fields, type|
|
28
|
-
fields[:name] = type.dynamic(&:itself)
|
29
|
-
fields[:registry] = type.dynamic(&:itself)
|
30
|
-
fields[:class_name] = type.dynamic(&:itself)
|
31
|
-
if action.show?
|
32
|
-
fields[:created_at] = type.dynamic(&:iso8601)
|
33
|
-
fields[:updated_at] = type.dynamic(&:iso8601)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def form_schema(action:)
|
39
|
-
Super::Schema.new(Super::Form::SchemaTypes.new) do |fields, type|
|
40
|
-
fields[:name] = type.generic("form_field_text")
|
41
|
-
fields[:registry] = type.generic("form_field_text")
|
42
|
-
fields[:class_name] = type.generic("form_field_text")
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
class Member < ApplicationRecord
|
2
|
-
enum rank: {
|
3
|
-
captain: "Captain",
|
4
|
-
commander: "Commander",
|
5
|
-
lieutenant_commander: "Lieutenant Commander",
|
6
|
-
lieutenant: "Lieutenant",
|
7
|
-
lieutenant_junior_grade: "Lieutenant Junior Grade",
|
8
|
-
ensign: "Ensign",
|
9
|
-
nco: "NCO",
|
10
|
-
}
|
11
|
-
|
12
|
-
belongs_to :ship
|
13
|
-
has_many :favorite_things, dependent: :delete_all
|
14
|
-
|
15
|
-
accepts_nested_attributes_for(
|
16
|
-
:favorite_things,
|
17
|
-
allow_destroy: true,
|
18
|
-
reject_if: -> (record) { record[:name].blank? }
|
19
|
-
)
|
20
|
-
|
21
|
-
validates :name, presence: true
|
22
|
-
validates :rank, presence: true
|
23
|
-
end
|