super 0.0.4 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +13 -0
- data/CONTRIBUTING.md +56 -0
- data/README.md +60 -85
- data/STABILITY.md +50 -0
- data/app/assets/javascripts/super/application.js +1169 -359
- data/app/assets/stylesheets/super/application.css +86648 -30707
- data/app/controllers/super/application_controller.rb +44 -71
- data/app/views/layouts/super/application.html.erb +26 -6
- data/app/views/super/application/{_resources_header.html.erb → _collection_header.html.erb} +5 -6
- data/app/views/super/application/_display_rich_text.html.erb +1 -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 +6 -2
- data/app/views/super/application/_form_field_checkbox.html.erb +15 -0
- data/app/views/super/application/_form_field_generic.html.erb +19 -0
- data/app/views/super/application/_form_field_rich_text_area.html.erb +13 -0
- data/app/views/super/application/_form_field_select.html.erb +11 -5
- data/app/views/super/application/_form_field_text.html.erb +13 -5
- data/app/views/super/application/_form_has_many.html.erb +3 -3
- data/app/views/super/application/_form_inline_errors.html.erb +1 -1
- data/app/views/super/application/{_resource_header.html.erb → _member_header.html.erb} +6 -6
- data/app/views/super/application/_super_layout.html.erb +12 -17
- data/app/views/super/application/_super_pagination.html.erb +16 -0
- data/app/views/super/application/_super_panel.html.erb +3 -7
- 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/{_form.html.erb → _super_schema_form.html.erb} +2 -4
- 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/app/views/super/feather/{_chevron_down.svg → _chevron_down.html} +0 -0
- data/config/locales/en.yml +5 -0
- data/docs/README.md +8 -0
- data/docs/action_text.md +48 -0
- data/docs/cheat.md +41 -0
- data/docs/faq.md +44 -0
- data/docs/installation.md +21 -0
- data/docs/quick_start.md +30 -0
- data/docs/webpacker.md +25 -0
- data/docs/yard_customizations.rb +41 -0
- data/frontend/super-frontend/build.js +1 -1
- data/frontend/super-frontend/dist/application.css +86648 -30707
- data/frontend/super-frontend/dist/application.js +1169 -359
- data/frontend/super-frontend/package.json +2 -3
- data/frontend/super-frontend/src/javascripts/super/{application.ts → application.js} +5 -8
- data/frontend/super-frontend/src/javascripts/super/apply_template_controller.js +17 -0
- data/frontend/super-frontend/src/javascripts/super/{toggle_pending_destruction_controller.ts → toggle_pending_destruction_controller.js} +2 -2
- data/frontend/super-frontend/tailwind.config.js +7 -1
- data/frontend/super-frontend/yarn.lock +1368 -1391
- data/lib/generators/super/action_text/USAGE +23 -0
- data/lib/generators/super/action_text/action_text_generator.rb +30 -0
- data/lib/generators/super/action_text/templates/pack_super_action_text.css +23 -0
- data/lib/generators/super/action_text/templates/pack_super_action_text.js +4 -0
- 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/USAGE +5 -4
- data/lib/generators/super/webpacker/webpacker_generator.rb +10 -1
- data/lib/super.rb +22 -5
- data/lib/super/action_inquirer.rb +2 -2
- data/lib/super/assets.rb +112 -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 -257
- 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 +61 -25
- data/lib/super/engine.rb +7 -1
- data/lib/super/error.rb +8 -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 +29 -22
- data/lib/super/form/strong_params.rb +29 -0
- data/lib/super/layout.rb +28 -0
- data/lib/super/link.rb +55 -32
- data/lib/super/pagination.rb +55 -0
- data/lib/super/panel.rb +13 -0
- data/lib/super/partial.rb +12 -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 +138 -41
- data/app/helpers/super/application_helper.rb +0 -32
- data/app/views/super/application/_index.html.erb +0 -45
- data/app/views/super/application/_show.html.erb +0 -10
- data/frontend/super-frontend/src/javascripts/super/apply_template_controller.ts +0 -21
- data/frontend/super-frontend/src/javascripts/super/rails__ujs.d.ts +0 -1
- data/frontend/super-frontend/tsconfig.json +0 -13
- data/lib/super/action.rb +0 -22
- data/lib/super/action/step.rb +0 -36
- 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 -74
- 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/copy_app_templates/views/members/_favorite_things.html.erb +0 -11
- 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 -42
- data/lib/super/test_support/generate_dummy.rb +0 -93
- data/lib/super/test_support/starfleet_seeder.rb +0 -50
- data/lib/tasks/super_tasks.rake +0 -4
@@ -1,32 +0,0 @@
|
|
1
|
-
module Super
|
2
|
-
module ApplicationHelper
|
3
|
-
def super_resolve_list_for_rendering(partials, block = -> {})
|
4
|
-
block_result = block.call
|
5
|
-
if block_result.present?
|
6
|
-
partials = [block_result, *partials]
|
7
|
-
end
|
8
|
-
|
9
|
-
partials = partials.map do |partial|
|
10
|
-
if partial.is_a?(Symbol)
|
11
|
-
instance_variable_get(partial)
|
12
|
-
else
|
13
|
-
partial
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
partials.compact
|
18
|
-
end
|
19
|
-
|
20
|
-
def super_render_partialish(partialish)
|
21
|
-
if partialish.respond_to?(:to_partial_path)
|
22
|
-
if partialish.is_a?(Super::Partial)
|
23
|
-
render(partialish, partialish.locals)
|
24
|
-
else
|
25
|
-
render(partialish)
|
26
|
-
end
|
27
|
-
else
|
28
|
-
partialish
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
<% schema = controls.display_schema(action: action_inquirer) %>
|
2
|
-
|
3
|
-
<div class="mt-4 -mx-5">
|
4
|
-
<table class="w-full">
|
5
|
-
<thead>
|
6
|
-
<tr class="text-left text-sm uppercase font-bold tracking-wide">
|
7
|
-
<% schema.field_keys.each do |column| %>
|
8
|
-
<th class="p-2 first:pl-5"><%= column.to_s.humanize %></th>
|
9
|
-
<% end %>
|
10
|
-
<th class="p-2 pr-5">Actions</th>
|
11
|
-
</tr>
|
12
|
-
</thead>
|
13
|
-
<tbody class="border-gray-400 border-solid border-t-2">
|
14
|
-
<% @resources.each.with_index do |resource, index| %>
|
15
|
-
<tr id="resource-pk-<%= resource.id %>" class="border-b border-gray-400">
|
16
|
-
<% schema.field_keys.each do |column| %>
|
17
|
-
<td class="p-2 first:pl-5"><%= Super::Display.format(schema, resource, column) %></td>
|
18
|
-
<% end %>
|
19
|
-
<td class="p-2 pr-5" style="word-spacing: 0.25rem">
|
20
|
-
<% controls.resource_actions(resource, params: params, action: action_inquirer).each do |link| %>
|
21
|
-
<%= link_to(link.text, link.href, link.options) %>
|
22
|
-
<% end %>
|
23
|
-
</td>
|
24
|
-
</tr>
|
25
|
-
<% end %>
|
26
|
-
</tbody>
|
27
|
-
</table>
|
28
|
-
</div>
|
29
|
-
|
30
|
-
<% if @pagination.necessary? %>
|
31
|
-
<div class="flex justify-end mr-2">
|
32
|
-
<div class="mt-4">
|
33
|
-
<% @pagination.each do |page_query_params, is_current_page, display| %>
|
34
|
-
<%= link_to(
|
35
|
-
display,
|
36
|
-
polymorphic_path(
|
37
|
-
Super.configuration.path_parts(controls.model),
|
38
|
-
page_query_params
|
39
|
-
),
|
40
|
-
class: "inline-block ml-2 text-lg #{is_current_page ? " text-gray-900" : ""}"
|
41
|
-
) %>
|
42
|
-
<% end %>
|
43
|
-
</div>
|
44
|
-
</div>
|
45
|
-
<% end %>
|
@@ -1,10 +0,0 @@
|
|
1
|
-
<% schema = controls.display_schema(action: action_inquirer) %>
|
2
|
-
|
3
|
-
<table class="max-w-full leading-loose mt-4">
|
4
|
-
<% schema.field_keys.each do |column| %>
|
5
|
-
<tr>
|
6
|
-
<th class="text-right px-4"><%= column.to_s.humanize %></th>
|
7
|
-
<td><%= Super::Display.format(schema, @resource, column) %></td>
|
8
|
-
</tr>
|
9
|
-
<% end %>
|
10
|
-
</table>
|
@@ -1,21 +0,0 @@
|
|
1
|
-
import { Controller } from "stimulus";
|
2
|
-
|
3
|
-
export default class extends Controller {
|
4
|
-
templateTarget: Element | undefined;
|
5
|
-
|
6
|
-
static targets = ["template"];
|
7
|
-
|
8
|
-
call(event: Event) {
|
9
|
-
event.preventDefault();
|
10
|
-
|
11
|
-
if (this.templateTarget) {
|
12
|
-
const unixtime = new Date().getTime();
|
13
|
-
let content = this.templateTarget.innerHTML.replace(
|
14
|
-
/TEMPLATEINDEX/g,
|
15
|
-
unixtime.toString()
|
16
|
-
);
|
17
|
-
|
18
|
-
this.templateTarget.insertAdjacentHTML("beforebegin", content);
|
19
|
-
}
|
20
|
-
}
|
21
|
-
}
|
@@ -1 +0,0 @@
|
|
1
|
-
declare module "@rails/ujs";
|
data/lib/super/action.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
module Super
|
2
|
-
class Action
|
3
|
-
def initialize(steps:, page:)
|
4
|
-
@steps = steps
|
5
|
-
@page = page
|
6
|
-
end
|
7
|
-
|
8
|
-
attr_reader :page
|
9
|
-
|
10
|
-
def steps
|
11
|
-
resolved_steps = @steps.map do |step|
|
12
|
-
if step.respond_to?(:call)
|
13
|
-
step
|
14
|
-
elsif self.class.steps.key?(step)
|
15
|
-
self.class.steps[step]
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
resolved_steps.compact
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
data/lib/super/action/step.rb
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
module Super
|
2
|
-
class Action
|
3
|
-
def self.steps
|
4
|
-
@steps ||= {}
|
5
|
-
end
|
6
|
-
|
7
|
-
steps[:new_resource] = proc do
|
8
|
-
@resource = controls.scope(action: action_inquirer).build
|
9
|
-
end
|
10
|
-
|
11
|
-
steps[:create_resource] = proc do
|
12
|
-
@resource = controls.scope(action: action_inquirer).build(create_permitted_params)
|
13
|
-
end
|
14
|
-
|
15
|
-
steps[:load_resource] = proc do
|
16
|
-
@resource = controls.scope(action: action_inquirer).find(params[:id])
|
17
|
-
end
|
18
|
-
|
19
|
-
steps[:load_resources] = proc do
|
20
|
-
@resources = controls.scope(action: action_inquirer)
|
21
|
-
end
|
22
|
-
|
23
|
-
steps[:paginate] = proc do
|
24
|
-
@pagination = Pagination.new(
|
25
|
-
total_count: @resources.size,
|
26
|
-
limit: Super.configuration.index_resources_per_page,
|
27
|
-
query_params: request.GET,
|
28
|
-
page_query_param: :page
|
29
|
-
)
|
30
|
-
|
31
|
-
@resources = @resources
|
32
|
-
.limit(@pagination.limit)
|
33
|
-
.offset(@pagination.offset)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
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,74 +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 show
|
23
|
-
Super::Action.new(
|
24
|
-
steps: [
|
25
|
-
:load_resource,
|
26
|
-
],
|
27
|
-
page: Super::Layout.new(
|
28
|
-
mains: [
|
29
|
-
Super::Panel.new(
|
30
|
-
Super::Partial.new("resource_header"),
|
31
|
-
Super::Partial.new("show")
|
32
|
-
),
|
33
|
-
Super::Partial.new("favorite_things")
|
34
|
-
]
|
35
|
-
)
|
36
|
-
)
|
37
|
-
end
|
38
|
-
|
39
|
-
def permitted_params(params, action:)
|
40
|
-
params.require(:member).permit(:name, :rank, :position, :ship_id, favorite_things_attributes: [:id, :name, :_destroy])
|
41
|
-
end
|
42
|
-
|
43
|
-
def display_schema(action:)
|
44
|
-
Super::Schema.new(Super::Display::SchemaTypes.new) do |fields, type|
|
45
|
-
fields[:name] = type.dynamic(&:itself)
|
46
|
-
fields[:rank] = type.dynamic(&:itself)
|
47
|
-
fields[:position] = type.dynamic(&:itself)
|
48
|
-
fields[:ship] = type.dynamic { |ship| "#{ship.name} (Ship ##{ship.id})" }
|
49
|
-
fields[:created_at] = type.dynamic(&:iso8601)
|
50
|
-
if action.show?
|
51
|
-
fields[:updated_at] = type.dynamic(&:iso8601)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def form_schema(action:)
|
57
|
-
Super::Schema.new(Super::Form::SchemaTypes.new) do |fields, type|
|
58
|
-
fields[:name] = type.generic("form_field_text")
|
59
|
-
fields[:rank] = type.generic("form_field_select", collection: Member.ranks.keys)
|
60
|
-
fields[:position] = type.generic("form_field_text")
|
61
|
-
fields[:ship_id] = type.generic(
|
62
|
-
"form_field_select",
|
63
|
-
collection: Ship.all.map { |s| ["#{s.name} (Ship ##{s.id})", s.id] },
|
64
|
-
)
|
65
|
-
|
66
|
-
fields[:favorite_things_attributes] = type.has_many(:favorite_things) do
|
67
|
-
fields[:name] = type.generic("form_field_text")
|
68
|
-
fields[:_destroy] = type._destroy
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
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
|