super 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +22 -13
- data/app/assets/javascripts/super/application.js +10970 -64
- data/app/assets/stylesheets/super/application.css +33270 -14020
- data/app/controllers/super/application_controller.rb +1 -0
- data/app/views/super/application/_form.html.erb +1 -2
- data/app/views/super/application/_form_field__destroy.html.erb +5 -0
- data/app/views/super/application/{_form_generic_select.html.erb → _form_field_select.html.erb} +3 -5
- data/app/views/super/application/{_form_generic_text.html.erb → _form_field_text.html.erb} +1 -3
- 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/frontend/super-frontend/build.js +3 -1
- data/frontend/super-frontend/dist/application.css +33270 -14020
- data/frontend/super-frontend/dist/application.js +10970 -64
- data/frontend/super-frontend/package.json +5 -2
- data/frontend/super-frontend/src/javascripts/super/{application.js → application.ts} +3 -1
- data/frontend/super-frontend/src/javascripts/super/nested_attributes_controller.ts +33 -0
- data/frontend/super-frontend/src/javascripts/super/rails__ujs.d.ts +1 -0
- data/frontend/super-frontend/tsconfig.json +13 -0
- data/frontend/super-frontend/yarn.lock +1559 -1523
- data/lib/super/action_inquirer.rb +13 -0
- data/lib/super/assets.rb +1 -0
- data/lib/super/configuration.rb +59 -44
- data/lib/super/controls.rb +31 -15
- data/lib/super/display/schema_types.rb +15 -16
- data/lib/super/engine.rb +1 -0
- data/lib/super/error.rb +1 -0
- data/lib/super/form/schema_types.rb +89 -21
- data/lib/super/navigation/automatic.rb +2 -0
- data/lib/super/schema.rb +50 -1
- data/lib/super/test_support/copy_app_templates/controllers/favorite_things_controller.rb +50 -0
- data/lib/super/test_support/copy_app_templates/{members_controller.rb → controllers/members_controller.rb} +10 -5
- data/lib/super/test_support/copy_app_templates/{ships_controller.rb → controllers/ships_controller.rb} +3 -3
- data/lib/super/test_support/copy_app_templates/{20190216224956_create_members.rb → migrations/20190216224956_create_members.rb} +0 -0
- data/lib/super/test_support/copy_app_templates/{20190803143320_create_ships.rb → migrations/20190803143320_create_ships.rb} +0 -0
- data/lib/super/test_support/copy_app_templates/{20190806014121_add_ship_to_members.rb → migrations/20190806014121_add_ship_to_members.rb} +0 -0
- data/lib/super/test_support/copy_app_templates/migrations/20191126050453_create_favorite_things.rb +10 -0
- data/lib/super/test_support/copy_app_templates/models/favorite_thing.rb +7 -0
- data/lib/super/test_support/copy_app_templates/{member.rb → models/member.rb} +7 -0
- data/lib/super/test_support/copy_app_templates/{ship.rb → models/ship.rb} +0 -0
- data/lib/super/test_support/copy_app_templates/routes.rb +1 -0
- data/lib/super/test_support/fixtures/favorite_things.yml +9 -0
- data/lib/super/test_support/generate_copy_app.rb +5 -16
- data/lib/super/test_support/generate_dummy.rb +0 -1
- data/lib/super/test_support/starfleet_seeder.rb +1 -0
- data/lib/super/version.rb +1 -1
- metadata +25 -14
- data/app/views/super/application/_form_field.html.erb +0 -7
@@ -0,0 +1,50 @@
|
|
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
|
@@ -20,7 +20,7 @@ module Admin
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def permitted_params(params, action:)
|
23
|
-
params.require(:member).permit(:name, :rank, :position, :ship_id)
|
23
|
+
params.require(:member).permit(:name, :rank, :position, :ship_id, favorite_things_attributes: [:id, :name, :_destroy])
|
24
24
|
end
|
25
25
|
|
26
26
|
def display_schema(action:)
|
@@ -38,13 +38,18 @@ module Admin
|
|
38
38
|
|
39
39
|
def form_schema(action:)
|
40
40
|
Super::Schema.new(Super::Form::SchemaTypes.new) do |fields, type|
|
41
|
-
fields[:name] = type.generic("
|
42
|
-
fields[:rank] = type.generic("
|
43
|
-
fields[:position] = type.generic("
|
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
44
|
fields[:ship_id] = type.generic(
|
45
|
-
"
|
45
|
+
"form_field_select",
|
46
46
|
collection: Ship.all.map { |s| ["#{s.name} (Ship ##{s.id})", s.id] },
|
47
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
|
48
53
|
end
|
49
54
|
end
|
50
55
|
end
|
@@ -37,9 +37,9 @@ module Admin
|
|
37
37
|
|
38
38
|
def form_schema(action:)
|
39
39
|
Super::Schema.new(Super::Form::SchemaTypes.new) do |fields, type|
|
40
|
-
fields[:name] = type.generic("
|
41
|
-
fields[:registry] = type.generic("
|
42
|
-
fields[:class_name] = type.generic("
|
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
43
|
end
|
44
44
|
end
|
45
45
|
end
|
File without changes
|
File without changes
|
File without changes
|
@@ -10,6 +10,13 @@ class Member < ApplicationRecord
|
|
10
10
|
}
|
11
11
|
|
12
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
|
+
)
|
13
20
|
|
14
21
|
validates :name, presence: true
|
15
22
|
validates :rank, presence: true
|
File without changes
|
@@ -1,6 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require "rails/generators"
|
4
|
+
require_relative "../../generators/super/install/install_generator"
|
4
5
|
|
5
6
|
class SuperCopyAppGenerator < Rails::Generators::Base
|
6
7
|
source_root(File.expand_path("copy_app_templates", __dir__))
|
@@ -19,28 +20,16 @@ class SuperCopyAppGenerator < Rails::Generators::Base
|
|
19
20
|
end
|
20
21
|
|
21
22
|
def install_super
|
22
|
-
|
23
|
+
Super::InstallGenerator.start([], destination_root: destination_root)
|
23
24
|
end
|
24
25
|
|
25
26
|
def copy_app
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
copy_file "ships_controller.rb", "app/controllers/admin/ships_controller.rb"
|
30
|
-
copy_file "members_controller.rb", "app/controllers/admin/members_controller.rb"
|
27
|
+
directory "models", "app/models"
|
28
|
+
directory "controllers", "app/controllers/admin"
|
31
29
|
end
|
32
30
|
|
33
31
|
def copy_db
|
34
|
-
migrations
|
35
|
-
"20190216224956_create_members.rb",
|
36
|
-
"20190803143320_create_ships.rb",
|
37
|
-
"20190806014121_add_ship_to_members.rb",
|
38
|
-
]
|
39
|
-
|
40
|
-
migrations.each do |migration|
|
41
|
-
copy_file migration, "db/migrate/#{migration}"
|
42
|
-
end
|
43
|
-
|
32
|
+
directory "migrations", "db/migrate"
|
44
33
|
copy_file "seeds.rb", "db/seeds.rb"
|
45
34
|
end
|
46
35
|
|
data/lib/super/version.rb
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.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zach Ahn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -139,9 +139,13 @@ files:
|
|
139
139
|
- app/views/layouts/super/application.html.erb
|
140
140
|
- app/views/super/application/_flash.html.erb
|
141
141
|
- app/views/super/application/_form.html.erb
|
142
|
-
- app/views/super/application/
|
143
|
-
- app/views/super/application/
|
144
|
-
- app/views/super/application/
|
142
|
+
- app/views/super/application/_form_field__destroy.html.erb
|
143
|
+
- app/views/super/application/_form_field_select.html.erb
|
144
|
+
- app/views/super/application/_form_field_text.html.erb
|
145
|
+
- app/views/super/application/_form_fieldset.html.erb
|
146
|
+
- app/views/super/application/_form_has_many.html.erb
|
147
|
+
- app/views/super/application/_form_has_one.html.erb
|
148
|
+
- app/views/super/application/_form_inline_errors.html.erb
|
145
149
|
- app/views/super/application/_index.html.erb
|
146
150
|
- app/views/super/application/_show.html.erb
|
147
151
|
- app/views/super/application/edit.html.erb
|
@@ -157,9 +161,12 @@ files:
|
|
157
161
|
- frontend/super-frontend/dist/application.js
|
158
162
|
- frontend/super-frontend/package.json
|
159
163
|
- frontend/super-frontend/postcss.config.js
|
160
|
-
- frontend/super-frontend/src/javascripts/super/application.
|
164
|
+
- frontend/super-frontend/src/javascripts/super/application.ts
|
165
|
+
- frontend/super-frontend/src/javascripts/super/nested_attributes_controller.ts
|
166
|
+
- frontend/super-frontend/src/javascripts/super/rails__ujs.d.ts
|
161
167
|
- frontend/super-frontend/src/stylesheets/super/application.css
|
162
168
|
- frontend/super-frontend/tailwind.config.js
|
169
|
+
- frontend/super-frontend/tsconfig.json
|
163
170
|
- frontend/super-frontend/yarn.lock
|
164
171
|
- lib/generators/super/install/USAGE
|
165
172
|
- lib/generators/super/install/install_generator.rb
|
@@ -186,15 +193,19 @@ files:
|
|
186
193
|
- lib/super/pagination.rb
|
187
194
|
- lib/super/plugin.rb
|
188
195
|
- lib/super/schema.rb
|
189
|
-
- lib/super/test_support/copy_app_templates/
|
190
|
-
- lib/super/test_support/copy_app_templates/
|
191
|
-
- lib/super/test_support/copy_app_templates/
|
192
|
-
- lib/super/test_support/copy_app_templates/
|
193
|
-
- lib/super/test_support/copy_app_templates/
|
196
|
+
- lib/super/test_support/copy_app_templates/controllers/favorite_things_controller.rb
|
197
|
+
- lib/super/test_support/copy_app_templates/controllers/members_controller.rb
|
198
|
+
- lib/super/test_support/copy_app_templates/controllers/ships_controller.rb
|
199
|
+
- lib/super/test_support/copy_app_templates/migrations/20190216224956_create_members.rb
|
200
|
+
- lib/super/test_support/copy_app_templates/migrations/20190803143320_create_ships.rb
|
201
|
+
- lib/super/test_support/copy_app_templates/migrations/20190806014121_add_ship_to_members.rb
|
202
|
+
- lib/super/test_support/copy_app_templates/migrations/20191126050453_create_favorite_things.rb
|
203
|
+
- lib/super/test_support/copy_app_templates/models/favorite_thing.rb
|
204
|
+
- lib/super/test_support/copy_app_templates/models/member.rb
|
205
|
+
- lib/super/test_support/copy_app_templates/models/ship.rb
|
194
206
|
- lib/super/test_support/copy_app_templates/routes.rb
|
195
207
|
- lib/super/test_support/copy_app_templates/seeds.rb
|
196
|
-
- lib/super/test_support/
|
197
|
-
- lib/super/test_support/copy_app_templates/ships_controller.rb
|
208
|
+
- lib/super/test_support/fixtures/favorite_things.yml
|
198
209
|
- lib/super/test_support/fixtures/members.yml
|
199
210
|
- lib/super/test_support/fixtures/ships.yml
|
200
211
|
- lib/super/test_support/generate_copy_app.rb
|
@@ -225,5 +236,5 @@ requirements: []
|
|
225
236
|
rubygems_version: 3.0.3
|
226
237
|
signing_key:
|
227
238
|
specification_version: 4
|
228
|
-
summary: A simple, powerful,
|
239
|
+
summary: A simple, powerful, zero* dependency Rails admin framework
|
229
240
|
test_files: []
|
@@ -1,7 +0,0 @@
|
|
1
|
-
<div class="lg:w-1/3">
|
2
|
-
<%= f.label column %>
|
3
|
-
<%= f.text_field column, class: "appearance-none border rounded w-full py-2 px-2 text-gray-900 leading-tight border border-gray-400 focus:border-blue-400 mt-2" %>
|
4
|
-
<% resource.errors.full_messages_for(column).each do |error_message| %>
|
5
|
-
<p class="text-red-400 text-xs italic pt-1"><%= error_message %></p>
|
6
|
-
<% end %>
|
7
|
-
</div>
|