super 0.0.1 → 0.0.6
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/README.md +64 -78
- data/Rakefile +3 -1
- data/app/assets/config/super_manifest.js +2 -1
- data/app/assets/javascripts/super/application.js +1252 -316
- data/app/assets/stylesheets/super/application.css +102704 -17321
- data/app/controllers/super/application_controller.rb +50 -42
- data/app/helpers/super/application_helper.rb +39 -0
- data/app/views/layouts/super/application.html.erb +11 -7
- data/app/views/super/application/_collection_header.html.erb +15 -0
- data/app/views/super/application/_flash.html.erb +17 -0
- data/app/views/super/application/_form_field__destroy.html.erb +9 -0
- data/app/views/super/application/_form_field_select.html.erb +23 -0
- data/app/views/super/application/_form_field_text.html.erb +13 -0
- data/app/views/super/application/_form_fieldset.html.erb +8 -0
- data/app/views/super/application/_form_has_many.html.erb +21 -0
- data/app/views/super/application/_form_has_one.html.erb +11 -0
- data/app/views/super/application/_form_inline_errors.html.erb +10 -0
- 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_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 +39 -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 +4 -5
- data/app/views/super/application/index.html.erb +6 -1
- data/app/views/super/application/new.html.erb +4 -5
- data/app/views/super/application/nothing.html.erb +0 -0
- data/app/views/super/application/show.html.erb +6 -10
- 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 +14 -12
- data/frontend/super-frontend/dist/application.css +102704 -17321
- data/frontend/super-frontend/dist/application.js +1252 -316
- data/frontend/super-frontend/package.json +11 -4
- data/frontend/super-frontend/postcss.config.js +4 -4
- data/frontend/super-frontend/src/javascripts/super/application.ts +18 -0
- 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 -0
- 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/tsconfig.json +13 -0
- data/frontend/super-frontend/yarn.lock +1891 -1798
- data/lib/generators/super/install/USAGE +4 -2
- data/lib/generators/super/install/install_generator.rb +18 -3
- data/lib/generators/super/resource/USAGE +1 -2
- data/lib/generators/super/resource/resource_generator.rb +0 -2
- data/lib/generators/super/resource/templates/resources_controller.rb.tt +38 -2
- data/lib/generators/super/webpacker/webpacker_generator.rb +8 -0
- data/lib/super.rb +10 -5
- data/lib/super/action_inquirer.rb +101 -0
- data/lib/super/assets.rb +1 -0
- data/lib/super/client_error.rb +43 -0
- data/lib/super/compatibility.rb +13 -0
- data/lib/super/configuration.rb +60 -45
- data/lib/super/controls.rb +26 -15
- data/lib/super/controls/optional.rb +65 -0
- data/lib/super/controls/required.rb +41 -0
- data/lib/super/controls/steps.rb +115 -0
- data/lib/super/display/schema_types.rb +60 -18
- data/lib/super/engine.rb +1 -0
- data/lib/super/error.rb +10 -1
- data/lib/super/form.rb +48 -0
- data/lib/super/form/schema_types.rb +96 -21
- data/lib/super/layout.rb +47 -0
- data/lib/super/link.rb +110 -0
- data/lib/super/navigation/automatic.rb +2 -0
- data/lib/super/pagination.rb +19 -8
- data/lib/super/panel.rb +30 -0
- data/lib/super/partial.rb +11 -0
- data/lib/super/partial/resolving.rb +24 -0
- data/lib/super/schema.rb +64 -1
- data/lib/super/version.rb +1 -1
- data/lib/super/view_helper.rb +43 -0
- metadata +145 -38
- data/app/views/super/application/_form.html.erb +0 -13
- data/app/views/super/application/_form_field.html.erb +0 -7
- data/app/views/super/application/_form_generic_select.html.erb +0 -19
- data/app/views/super/application/_form_generic_text.html.erb +0 -7
- data/app/views/super/application/_index.html.erb +0 -58
- data/frontend/super-frontend/src/javascripts/super/application.js +0 -11
- data/lib/generators/super/resource/templates/resource_dashboard.rb.tt +0 -65
- data/lib/super/display.rb +0 -9
- data/lib/super/inline_callback.rb +0 -82
- 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/setup.rb +0 -79
- data/lib/super/test_support/starfleet_seeder.rb +0 -49
- data/lib/super/test_support/templates/20190216224956_create_members.rb +0 -11
- data/lib/super/test_support/templates/20190803143320_create_ships.rb +0 -11
- data/lib/super/test_support/templates/20190806014121_add_ship_to_members.rb +0 -5
- data/lib/super/test_support/templates/admin/members_controller.rb +0 -9
- data/lib/super/test_support/templates/admin/ships_controller.rb +0 -9
- data/lib/super/test_support/templates/admin_controller.rb +0 -2
- data/lib/super/test_support/templates/member.rb +0 -16
- data/lib/super/test_support/templates/member_dashboard.rb +0 -90
- data/lib/super/test_support/templates/routes.rb +0 -10
- data/lib/super/test_support/templates/seeds.rb +0 -2
- data/lib/super/test_support/templates/ship.rb +0 -3
- data/lib/super/test_support/templates/ship_dashboard.rb +0 -79
- data/lib/super/view.rb +0 -25
- data/lib/tasks/super_tasks.rake +0 -4
@@ -1,79 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "fileutils"
|
4
|
-
require "pathname"
|
5
|
-
|
6
|
-
def help!
|
7
|
-
puts "usage: #{$0} path/to/dest/app"
|
8
|
-
exit
|
9
|
-
end
|
10
|
-
|
11
|
-
def assert(message)
|
12
|
-
if !yield
|
13
|
-
puts message
|
14
|
-
exit(1)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def act(message, if_not:)
|
19
|
-
if !if_not.call
|
20
|
-
yield
|
21
|
-
puts message
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
if ARGV.size != 1
|
26
|
-
help!
|
27
|
-
end
|
28
|
-
|
29
|
-
dest = ARGV.first
|
30
|
-
dest = File.expand_path(dest, Dir.pwd)
|
31
|
-
dest = Pathname.new(dest)
|
32
|
-
|
33
|
-
src = File.expand_path("templates", __dir__)
|
34
|
-
src = Pathname.new(src)
|
35
|
-
|
36
|
-
assert("Path doesn't exist: #{dest.join("app")}") do
|
37
|
-
dest.join("app").exist?
|
38
|
-
end
|
39
|
-
|
40
|
-
assert("Path doesn't exist: #{dest.join("app/models")}") do
|
41
|
-
dest.join("app/models").exist?
|
42
|
-
end
|
43
|
-
|
44
|
-
FileUtils.cp(src.join("member.rb"), dest.join("app/models/member.rb"))
|
45
|
-
FileUtils.cp(src.join("ship.rb"), dest.join("app/models/ship.rb"))
|
46
|
-
|
47
|
-
assert("Path doesn't exist: #{dest.join("app/controllers")}") do
|
48
|
-
dest.join("app/controllers").exist?
|
49
|
-
end
|
50
|
-
|
51
|
-
FileUtils.cp(src.join("admin_controller.rb"), dest.join("app/controllers/admin_controller.rb"))
|
52
|
-
|
53
|
-
act "Created #{dest.join("app/controllers/admin")}", if_not: -> { dest.join("app/controllers/admin").exist? } do
|
54
|
-
FileUtils.mkdir(dest.join("app/controllers/admin"))
|
55
|
-
end
|
56
|
-
|
57
|
-
FileUtils.cp(src.join("admin/members_controller.rb"), dest.join("app/controllers/admin/members_controller.rb"))
|
58
|
-
FileUtils.cp(src.join("admin/ships_controller.rb"), dest.join("app/controllers/admin/ships_controller.rb"))
|
59
|
-
|
60
|
-
act "Created #{dest.join("app/super")}", if_not: -> { dest.join("app/super").exist? } do
|
61
|
-
FileUtils.mkdir(dest.join("app/super"))
|
62
|
-
end
|
63
|
-
|
64
|
-
FileUtils.cp(src.join("member_dashboard.rb"), dest.join("app/super/member_dashboard.rb"))
|
65
|
-
FileUtils.cp(src.join("ship_dashboard.rb"), dest.join("app/super/ship_dashboard.rb"))
|
66
|
-
|
67
|
-
act "Created #{dest.join("db/migrate")}", if_not: -> { dest.join("db/migrate").exist? } do
|
68
|
-
FileUtils.mkdir(dest.join("db/migrate"))
|
69
|
-
end
|
70
|
-
|
71
|
-
FileUtils.cp(src.join("20190216224956_create_members.rb"), dest.join("db/migrate/20190216224956_create_members.rb"))
|
72
|
-
FileUtils.cp(src.join("20190803143320_create_ships.rb"), dest.join("db/migrate/20190803143320_create_ships.rb"))
|
73
|
-
FileUtils.cp(src.join("20190806014121_add_ship_to_members.rb"), dest.join("db/migrate/20190806014121_add_ship_to_members.rb"))
|
74
|
-
|
75
|
-
FileUtils.cp(src.join("seeds.rb"), dest.join("db/seeds.rb"))
|
76
|
-
|
77
|
-
FileUtils.cp(src.join("routes.rb"), dest.join("config/routes.rb"))
|
78
|
-
|
79
|
-
puts "Done!"
|
@@ -1,49 +0,0 @@
|
|
1
|
-
class StarfleetSeeder
|
2
|
-
def self.seed
|
3
|
-
seeder = StarfleetSeeder.new
|
4
|
-
seeder.seed_from_fixture("ships", Ship)
|
5
|
-
seeder.seed_from_fixture("members", Member)
|
6
|
-
end
|
7
|
-
|
8
|
-
def initialize
|
9
|
-
@seeded = {}
|
10
|
-
@association_reflections = {}
|
11
|
-
end
|
12
|
-
|
13
|
-
def seed(basename, key, klass, value)
|
14
|
-
@seeded[basename] ||= {}
|
15
|
-
puts "--> #{key} (#{value})"
|
16
|
-
@association_reflections[klass] ||= klass.reflect_on_all_associations
|
17
|
-
|
18
|
-
@association_reflections[klass].each do |ar|
|
19
|
-
ar_name = ar.name.to_s
|
20
|
-
ar_plural_name = ar.plural_name.to_s
|
21
|
-
|
22
|
-
if value.key?(ar_name)
|
23
|
-
value[ar_name] = @seeded.fetch(ar_plural_name).fetch(value[ar_name])
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
@seeded[basename][key] = klass.find_or_create_by(value)
|
28
|
-
puts " success!"
|
29
|
-
rescue => e
|
30
|
-
puts " failure (#{e.message})"
|
31
|
-
end
|
32
|
-
|
33
|
-
def seed_from_fixture(basename, klass)
|
34
|
-
puts "==> #{basename}"
|
35
|
-
fixtures(basename).each do |key, value|
|
36
|
-
seed(basename, key, klass, value)
|
37
|
-
end
|
38
|
-
|
39
|
-
nil
|
40
|
-
end
|
41
|
-
|
42
|
-
private
|
43
|
-
|
44
|
-
def fixtures(basename)
|
45
|
-
@fixtures_dir ||= Pathname.new("./fixtures").expand_path(__dir__)
|
46
|
-
|
47
|
-
YAML.load_file(@fixtures_dir.join("#{basename}.yml"))
|
48
|
-
end
|
49
|
-
end
|
@@ -1,16 +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
|
-
|
14
|
-
validates :name, presence: true
|
15
|
-
validates :rank, presence: true
|
16
|
-
end
|
@@ -1,90 +0,0 @@
|
|
1
|
-
class MemberDashboard
|
2
|
-
def title
|
3
|
-
Member.name.pluralize
|
4
|
-
end
|
5
|
-
|
6
|
-
def model
|
7
|
-
Member
|
8
|
-
end
|
9
|
-
|
10
|
-
def index_scope
|
11
|
-
Member.all
|
12
|
-
end
|
13
|
-
|
14
|
-
def index_schema
|
15
|
-
Super::Schema.new(Super::Display::SchemaTypes.new) do |fields, type|
|
16
|
-
fields[:name] = type.dynamic { |name| name }
|
17
|
-
fields[:rank] = type.dynamic { |rank| rank }
|
18
|
-
fields[:position] = type.dynamic { |position| position }
|
19
|
-
fields[:ship] = type.dynamic { |ship| "#{ship.name} (Ship ##{ship.id})" }
|
20
|
-
fields[:created_at] = type.dynamic(&:iso8601)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def create_scope
|
25
|
-
Member.all
|
26
|
-
end
|
27
|
-
|
28
|
-
def create_permitted_params(params)
|
29
|
-
params.require(:member).permit(:name, :rank, :position, :ship_id)
|
30
|
-
end
|
31
|
-
|
32
|
-
def new_scope
|
33
|
-
Member.all
|
34
|
-
end
|
35
|
-
|
36
|
-
def new_schema
|
37
|
-
Super::Schema.new(Super::Form::SchemaTypes.new) do |fields, type|
|
38
|
-
fields[:name] = type.generic("form_generic_text")
|
39
|
-
fields[:rank] = type.generic("form_generic_select", collection: Member.ranks.keys)
|
40
|
-
fields[:position] = type.generic("form_generic_text")
|
41
|
-
fields[:ship_id] = type.generic(
|
42
|
-
"form_generic_select",
|
43
|
-
collection: Ship.all.map { |s| ["#{s.name} (Ship ##{s.id})", s.id] },
|
44
|
-
)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def edit_scope
|
49
|
-
Member.all
|
50
|
-
end
|
51
|
-
|
52
|
-
def edit_schema
|
53
|
-
Super::Schema.new(Super::Form::SchemaTypes.new) do |fields, type|
|
54
|
-
fields[:name] = type.generic("form_generic_text")
|
55
|
-
fields[:rank] = type.generic("form_generic_select", collection: Member.ranks.keys)
|
56
|
-
fields[:position] = type.generic("form_generic_text")
|
57
|
-
fields[:ship_id] = type.generic(
|
58
|
-
"form_generic_select",
|
59
|
-
collection: Ship.all.map { |s| ["#{s.name} (Ship ##{s.id})", s.id] },
|
60
|
-
)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def show_scope
|
65
|
-
Member.all
|
66
|
-
end
|
67
|
-
|
68
|
-
def show_schema
|
69
|
-
Super::Schema.new(Super::Display::SchemaTypes.new) do |fields, type|
|
70
|
-
fields[:name] = type.dynamic { |name| name }
|
71
|
-
fields[:rank] = type.dynamic { |rank| rank }
|
72
|
-
fields[:position] = type.dynamic { |position| position }
|
73
|
-
fields[:ship] = type.dynamic { |ship| "#{ship.name} (Ship ##{ship.id})" }
|
74
|
-
fields[:created_at] = type.dynamic(&:iso8601)
|
75
|
-
fields[:updated_at] = type.dynamic(&:iso8601)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
def update_scope
|
80
|
-
Member.all
|
81
|
-
end
|
82
|
-
|
83
|
-
def update_permitted_params(params)
|
84
|
-
params.require(:member).permit(:name, :rank, :position, :ship_id)
|
85
|
-
end
|
86
|
-
|
87
|
-
def destroy_scope
|
88
|
-
Member.all
|
89
|
-
end
|
90
|
-
end
|
@@ -1,79 +0,0 @@
|
|
1
|
-
class ShipDashboard
|
2
|
-
def title
|
3
|
-
Ship.name.pluralize
|
4
|
-
end
|
5
|
-
|
6
|
-
def model
|
7
|
-
Ship
|
8
|
-
end
|
9
|
-
|
10
|
-
def index_scope
|
11
|
-
Ship.all
|
12
|
-
end
|
13
|
-
|
14
|
-
def index_schema
|
15
|
-
Super::Schema.new(Super::Display::SchemaTypes.new) do |fields, type|
|
16
|
-
fields[:name] = type.dynamic { |name| name }
|
17
|
-
fields[:registry] = type.dynamic { |registry| registry }
|
18
|
-
fields[:class_name] = type.dynamic { |class_name| class_name }
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def create_scope
|
23
|
-
Ship.all
|
24
|
-
end
|
25
|
-
|
26
|
-
def create_permitted_params(params)
|
27
|
-
params.require(:ship).permit(:name, :registry, :class_name)
|
28
|
-
end
|
29
|
-
|
30
|
-
def new_scope
|
31
|
-
Ship.all
|
32
|
-
end
|
33
|
-
|
34
|
-
def new_schema
|
35
|
-
Super::Schema.new(Super::Form::SchemaTypes.new) do |fields, type|
|
36
|
-
fields[:name] = type.generic("form_generic_text")
|
37
|
-
fields[:registry] = type.generic("form_generic_text")
|
38
|
-
fields[:class_name] = type.generic("form_generic_text")
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def edit_scope
|
43
|
-
Ship.all
|
44
|
-
end
|
45
|
-
|
46
|
-
def edit_schema
|
47
|
-
Super::Schema.new(Super::Form::SchemaTypes.new) do |fields, type|
|
48
|
-
fields[:name] = type.generic("form_generic_text")
|
49
|
-
fields[:registry] = type.generic("form_generic_text")
|
50
|
-
fields[:class_name] = type.generic("form_generic_text")
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def show_scope
|
55
|
-
Ship.all
|
56
|
-
end
|
57
|
-
|
58
|
-
def show_schema
|
59
|
-
Super::Schema.new(Super::Display::SchemaTypes.new) do |fields, type|
|
60
|
-
fields[:name] = type.dynamic { |name| name }
|
61
|
-
fields[:registry] = type.dynamic { |registry| registry }
|
62
|
-
fields[:class_name] = type.dynamic { |class_name| class_name }
|
63
|
-
fields[:created_at] = type.dynamic(&:iso8601)
|
64
|
-
fields[:updated_at] = type.dynamic(&:iso8601)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
def update_scope
|
69
|
-
Ship.all
|
70
|
-
end
|
71
|
-
|
72
|
-
def update_permitted_params(params)
|
73
|
-
params.require(:ship).permit(:name, :registry, :class_name)
|
74
|
-
end
|
75
|
-
|
76
|
-
def destroy_scope
|
77
|
-
Ship.all
|
78
|
-
end
|
79
|
-
end
|
data/lib/super/view.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
module Super
|
2
|
-
module View
|
3
|
-
module_function
|
4
|
-
|
5
|
-
def gutter_h(pm, positive = true)
|
6
|
-
if pm == :p
|
7
|
-
if positive
|
8
|
-
"px-2"
|
9
|
-
else
|
10
|
-
raise Error::InvalidStyle, "invalid style: -px-2"
|
11
|
-
end
|
12
|
-
else
|
13
|
-
if positive
|
14
|
-
"mx-2"
|
15
|
-
else
|
16
|
-
"-mx-2"
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def classes(*list)
|
22
|
-
list.flatten.select(&:present?).join(" ")
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
data/lib/tasks/super_tasks.rake
DELETED