super 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/super/application.js +60 -10831
- data/app/assets/stylesheets/super/application.css +38267 -22475
- data/app/controllers/super/application_controller.rb +34 -30
- data/app/helpers/super/application_helper.rb +32 -0
- data/app/views/layouts/super/application.html.erb +6 -8
- data/app/views/super/application/_form.html.erb +13 -10
- data/app/views/super/application/_form_field__destroy.html.erb +2 -2
- data/app/views/super/application/_form_field_select.html.erb +6 -6
- data/app/views/super/application/_form_field_text.html.erb +3 -3
- data/app/views/super/application/_form_fieldset.html.erb +1 -1
- data/app/views/super/application/_form_has_many.html.erb +4 -4
- data/app/views/super/application/_index.html.erb +38 -53
- data/app/views/super/application/_resource_header.html.erb +16 -0
- data/app/views/super/application/_resources_header.html.erb +16 -0
- data/app/views/super/application/_show.html.erb +0 -2
- data/app/views/super/application/_super_layout.html.erb +34 -0
- data/app/views/super/application/_super_panel.html.erb +11 -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/frontend/super-frontend/build.js +12 -12
- data/frontend/super-frontend/dist/application.css +38267 -22475
- data/frontend/super-frontend/dist/application.js +60 -10831
- data/frontend/super-frontend/package.json +7 -3
- data/frontend/super-frontend/postcss.config.js +4 -4
- data/frontend/super-frontend/src/javascripts/super/application.ts +10 -5
- data/frontend/super-frontend/src/javascripts/super/apply_template_controller.ts +21 -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 +6 -4
- data/frontend/super-frontend/yarn.lock +115 -40
- data/lib/super.rb +6 -2
- data/lib/super/action.rb +22 -0
- data/lib/super/action/step.rb +36 -0
- data/lib/super/controls.rb +222 -2
- data/lib/super/error.rb +1 -0
- data/lib/super/form/schema_types.rb +1 -1
- data/lib/super/layout.rb +19 -0
- data/lib/super/link.rb +87 -0
- data/lib/super/pagination.rb +19 -8
- data/lib/super/panel.rb +17 -0
- data/lib/super/partial.rb +11 -0
- data/lib/super/test_support/copy_app_templates/controllers/members_controller.rb +17 -0
- data/lib/super/test_support/copy_app_templates/views/members/_favorite_things.html.erb +11 -0
- data/lib/super/test_support/generate_copy_app.rb +1 -0
- data/lib/super/version.rb +1 -1
- metadata +16 -5
- data/frontend/super-frontend/src/javascripts/super/nested_attributes_controller.ts +0 -33
- data/lib/super/inline_callback.rb +0 -82
- data/lib/super/view.rb +0 -25
@@ -1,11 +1,8 @@
|
|
1
1
|
module Super
|
2
2
|
# Provides a default implementation for each of the resourceful actions
|
3
3
|
class ApplicationController < ActionController::Base
|
4
|
-
include Super::InlineCallback
|
5
4
|
include Pluggable.new(:super_application_controller)
|
6
5
|
|
7
|
-
register_inline_callback(:index_paginate, on: :index, after: :yield)
|
8
|
-
|
9
6
|
helper_method :action_inquirer
|
10
7
|
helper_method :controls
|
11
8
|
|
@@ -35,13 +32,31 @@ module Super
|
|
35
32
|
end
|
36
33
|
|
37
34
|
def index
|
38
|
-
|
39
|
-
|
35
|
+
@super_action = controls.index
|
36
|
+
@super_action.steps.each do |step|
|
37
|
+
instance_exec(&step)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def show
|
42
|
+
@super_action = controls.show
|
43
|
+
@super_action.steps.each do |step|
|
44
|
+
instance_exec(&step)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def new
|
49
|
+
@super_action = controls.new
|
50
|
+
@super_action.steps.each do |step|
|
51
|
+
instance_exec(&step)
|
40
52
|
end
|
41
53
|
end
|
42
54
|
|
43
55
|
def create
|
44
|
-
@
|
56
|
+
@super_action = controls.create
|
57
|
+
@super_action.steps.each do |step|
|
58
|
+
instance_exec(&step)
|
59
|
+
end
|
45
60
|
|
46
61
|
if @resource.save
|
47
62
|
redirect_to polymorphic_path(Super.configuration.path_parts(@resource))
|
@@ -50,20 +65,18 @@ module Super
|
|
50
65
|
end
|
51
66
|
end
|
52
67
|
|
53
|
-
def new
|
54
|
-
@resource = controls.scope(action: action_inquirer).build
|
55
|
-
end
|
56
|
-
|
57
68
|
def edit
|
58
|
-
@
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
@resource = controls.scope(action: action_inquirer).find(params[:id])
|
69
|
+
@super_action = controls.edit
|
70
|
+
@super_action.steps.each do |step|
|
71
|
+
instance_exec(&step)
|
72
|
+
end
|
63
73
|
end
|
64
74
|
|
65
75
|
def update
|
66
|
-
@
|
76
|
+
@super_action = controls.update
|
77
|
+
@super_action.steps.each do |step|
|
78
|
+
instance_exec(&step)
|
79
|
+
end
|
67
80
|
|
68
81
|
if @resource.update(update_permitted_params)
|
69
82
|
redirect_to polymorphic_path(Super.configuration.path_parts(@resource))
|
@@ -73,7 +86,11 @@ module Super
|
|
73
86
|
end
|
74
87
|
|
75
88
|
def destroy
|
76
|
-
@
|
89
|
+
@super_action = controls.destroy
|
90
|
+
@super_action.steps.each do |step|
|
91
|
+
instance_exec(&step)
|
92
|
+
end
|
93
|
+
|
77
94
|
if @resource.destroy
|
78
95
|
redirect_to polymorphic_path(Super.configuration.path_parts(controls.model))
|
79
96
|
else
|
@@ -83,19 +100,6 @@ module Super
|
|
83
100
|
|
84
101
|
private
|
85
102
|
|
86
|
-
def index_paginate
|
87
|
-
@pagination = Pagination.new(
|
88
|
-
total_count: @resources.size,
|
89
|
-
limit: Super.configuration.index_resources_per_page,
|
90
|
-
query_params: request.GET,
|
91
|
-
page_query_param: :page
|
92
|
-
)
|
93
|
-
|
94
|
-
@resources = @resources
|
95
|
-
.limit(@pagination.limit)
|
96
|
-
.offset(@pagination.offset)
|
97
|
-
end
|
98
|
-
|
99
103
|
def controls
|
100
104
|
Super::Controls.new(new_controls)
|
101
105
|
end
|
@@ -0,0 +1,32 @@
|
|
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,5 +1,5 @@
|
|
1
1
|
<!DOCTYPE html>
|
2
|
-
<html class="bg-
|
2
|
+
<html class="bg-gray-100">
|
3
3
|
<head>
|
4
4
|
<title><%= Super.configuration.title %></title>
|
5
5
|
<%= csrf_meta_tags %>
|
@@ -7,6 +7,8 @@
|
|
7
7
|
<%= csp_meta_tag %>
|
8
8
|
<% end -%>
|
9
9
|
|
10
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
11
|
+
|
10
12
|
<% if Super.configuration.asset_handler.sprockets? %>
|
11
13
|
<%= stylesheet_link_tag "super/application", media: "all" %>
|
12
14
|
<%= javascript_include_tag "super/application" %>
|
@@ -16,10 +18,10 @@
|
|
16
18
|
<% end %>
|
17
19
|
</head>
|
18
20
|
|
19
|
-
<body class="font-sans
|
21
|
+
<body class="font-sans pb-4">
|
20
22
|
<div class="px-4">
|
21
23
|
<header class="pt-4">
|
22
|
-
<h1 class="text-
|
24
|
+
<h1 class="text-lg font-bold mr-6 mb-1"><%= Super.configuration.title %></h1>
|
23
25
|
<%
|
24
26
|
route_namespace = Super.configuration.route_namespace.map(&:to_s).join("/")
|
25
27
|
Super::Navigation::Automatic.new(route_namespace: route_namespace).each do |text, href| %>
|
@@ -29,11 +31,7 @@
|
|
29
31
|
|
30
32
|
<%= render "flash" %>
|
31
33
|
|
32
|
-
<div class="pt-
|
33
|
-
|
34
|
-
<% if content_for?(:header) %>
|
35
|
-
<%= yield :header %>
|
36
|
-
<% end %>
|
34
|
+
<div class="pt-4"></div>
|
37
35
|
|
38
36
|
<%= yield %>
|
39
37
|
</div>
|
@@ -1,14 +1,17 @@
|
|
1
1
|
<% schema = controls.form_schema(action: action_inquirer) %>
|
2
2
|
|
3
|
-
<%= form_for(Super.configuration.path_parts(resource)) do |f| %>
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
3
|
+
<%= form_for(Super.configuration.path_parts(@resource)) do |f| %>
|
4
|
+
<div class="max-w-3xl">
|
5
|
+
<% schema.fields.each do |field, type| %>
|
6
|
+
<%= render(
|
7
|
+
type,
|
8
|
+
form: f,
|
9
|
+
column: field
|
10
|
+
) %>
|
11
|
+
<% end %>
|
12
|
+
|
13
|
+
<div>
|
14
|
+
<%= f.submit class: "super-button super-button--fill-blue mt-2" %>
|
15
|
+
</div>
|
13
16
|
</div>
|
14
17
|
<% end %>
|
@@ -1,5 +1,5 @@
|
|
1
|
-
<div class="
|
2
|
-
<%= form.check_box(column, data: { action: "
|
1
|
+
<div class="super-field-group">
|
2
|
+
<%= form.check_box(column, data: { action: "toggle-pending-destruction#call" }) %>
|
3
3
|
<%= form.label(column) %>
|
4
4
|
<%= render "form_inline_errors", form: form, column: column %>
|
5
5
|
</div>
|
@@ -1,14 +1,14 @@
|
|
1
|
-
<div class="
|
2
|
-
<%= form.label(column) %>
|
3
|
-
<div class="
|
1
|
+
<div class="super-field-group">
|
2
|
+
<%= form.label(column, class: "block") %>
|
3
|
+
<div class="super-input-select mt-1">
|
4
4
|
<%= form.select(
|
5
5
|
column,
|
6
6
|
form_field_select[:collection],
|
7
7
|
{ include_blank: true }.merge(form_field_select[:options] || {}),
|
8
|
-
{ class: "
|
8
|
+
{ class: "super-input super-input-select-field" }
|
9
9
|
) %>
|
10
|
-
<div class="
|
11
|
-
<span class="
|
10
|
+
<div class="super-input-select-icon text-gray-700">
|
11
|
+
<span class="h-4 w-4">
|
12
12
|
<%= render "super/feather/chevron_down.svg" %>
|
13
13
|
</span>
|
14
14
|
</div>
|
@@ -1,5 +1,5 @@
|
|
1
|
-
<div class="
|
2
|
-
<%= form.label(column) %>
|
3
|
-
<%= form.text_field(column, class: "
|
1
|
+
<div class="super-field-group">
|
2
|
+
<%= form.label(column, class: "block") %>
|
3
|
+
<%= form.text_field(column, class: "super-input w-full mt-1") %>
|
4
4
|
<%= render "form_inline_errors", form: form, column: column %>
|
5
5
|
</div>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<fieldset class="border border-gray-300 rounded
|
1
|
+
<fieldset class="border border-gray-300 rounded pb-4 px-4 mt-4 shadow" data-controller="toggle-pending-destruction">
|
2
2
|
<% if form_fieldset.label.present? %>
|
3
3
|
<legend class="bg-white p-1 -mx-1"><%= form_fieldset.label %></legend>
|
4
4
|
<% end %>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<div data-controller="
|
1
|
+
<div data-controller="apply-template">
|
2
2
|
<%= form.fields_for(form_has_many.reader) do |ff| %>
|
3
3
|
<%= render "form_fieldset", form_fieldset: form_has_many, form: ff %>
|
4
4
|
<% end %>
|
@@ -7,15 +7,15 @@
|
|
7
7
|
form.fields_for(
|
8
8
|
form_has_many.reader,
|
9
9
|
form.object.public_send(form_has_many.reader).build,
|
10
|
-
child_index: "
|
10
|
+
child_index: "TEMPLATEINDEX"
|
11
11
|
) do |ff|
|
12
12
|
%>
|
13
|
-
<template data-target="
|
13
|
+
<template data-target="apply-template.template">
|
14
14
|
<%= render "form_fieldset", form_fieldset: form_has_many, form: ff %>
|
15
15
|
</template>
|
16
16
|
<% end %>
|
17
17
|
|
18
|
-
<button data-action="
|
18
|
+
<button data-action="apply-template#call" class="super-button super-button--fill-blue mt-2">
|
19
19
|
Add <%= form_has_many.label %>
|
20
20
|
</button>
|
21
21
|
</div>
|
@@ -1,60 +1,45 @@
|
|
1
1
|
<% schema = controls.display_schema(action: action_inquirer) %>
|
2
2
|
|
3
|
-
|
4
|
-
<
|
5
|
-
<
|
6
|
-
|
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" : "" %>" >
|
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">
|
27
7
|
<% schema.field_keys.each do |column| %>
|
28
|
-
<
|
8
|
+
<th class="p-2 first:pl-5"><%= column.to_s.humanize %></th>
|
29
9
|
<% end %>
|
30
|
-
<
|
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>
|
10
|
+
<th class="p-2 pr-5">Actions</th>
|
46
11
|
</tr>
|
47
|
-
|
48
|
-
|
49
|
-
|
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>
|
50
29
|
|
51
|
-
<% @pagination.
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
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>
|
60
45
|
<% end %>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<header class="flex justify-between content-end">
|
2
|
+
<h1 class="text-xl">
|
3
|
+
<%= controls.title %>
|
4
|
+
</h1>
|
5
|
+
<div>
|
6
|
+
<% controls.resource_actions(@resource, params: params, action: action_inquirer).each do |link| %>
|
7
|
+
<%= link_to(
|
8
|
+
link.text,
|
9
|
+
link.href,
|
10
|
+
link.options.reverse_merge(
|
11
|
+
class: "super-button super-button--border-blue super-button-sm inline-block ml-2"
|
12
|
+
)
|
13
|
+
) %>
|
14
|
+
<% end %>
|
15
|
+
</div>
|
16
|
+
</header>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<header class="flex justify-between content-end">
|
2
|
+
<h1 class="text-xl">
|
3
|
+
<%= controls.title %>
|
4
|
+
</h1>
|
5
|
+
<div>
|
6
|
+
<% controls.resources_actions(params: params, action: action_inquirer).each do |link| %>
|
7
|
+
<%= link_to(
|
8
|
+
link.text,
|
9
|
+
link.href,
|
10
|
+
link.options.reverse_merge(
|
11
|
+
class: "super-button super-button--border-blue super-button-sm inline-block ml-2"
|
12
|
+
)
|
13
|
+
) %>
|
14
|
+
<% end %>
|
15
|
+
</div>
|
16
|
+
</header>
|
@@ -0,0 +1,34 @@
|
|
1
|
+
<%
|
2
|
+
super_layout_headers = super_resolve_list_for_rendering(super_layout.headers)
|
3
|
+
super_layout_asides = super_resolve_list_for_rendering(super_layout.asides)
|
4
|
+
super_layout_mains = super_resolve_list_for_rendering(super_layout.mains)
|
5
|
+
super_layout_footers = super_resolve_list_for_rendering(super_layout.footers)
|
6
|
+
%>
|
7
|
+
|
8
|
+
<% super_layout_headers.each do |partial| %>
|
9
|
+
<%= super_render_partialish(partial) %>
|
10
|
+
<% end %>
|
11
|
+
|
12
|
+
<% if super_layout_asides.empty? %>
|
13
|
+
<% super_layout_mains.each do |partial| %>
|
14
|
+
<%= super_render_partialish(partial) %>
|
15
|
+
<% end %>
|
16
|
+
<% else %>
|
17
|
+
<div class="clearfix -mx-2">
|
18
|
+
<div class="md:float-left md:w-9/12 px-2">
|
19
|
+
<% super_layout_mains.each do |partial| %>
|
20
|
+
<%= super_render_partialish(partial) %>
|
21
|
+
<% end %>
|
22
|
+
</div>
|
23
|
+
|
24
|
+
<div class="md:float-right md:w-3/12 px-2">
|
25
|
+
<% super_layout_asides.each do |partial| %>
|
26
|
+
<%= super_render_partialish(partial) %>
|
27
|
+
<% end %>
|
28
|
+
</div>
|
29
|
+
</div>
|
30
|
+
<% end %>
|
31
|
+
|
32
|
+
<% super_layout_footers.each do |partial| %>
|
33
|
+
<%= super_render_partialish(partial) %>
|
34
|
+
<% end %>
|