super 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/super/application.js +60 -10831
  3. data/app/assets/stylesheets/super/application.css +38267 -22475
  4. data/app/controllers/super/application_controller.rb +34 -30
  5. data/app/helpers/super/application_helper.rb +32 -0
  6. data/app/views/layouts/super/application.html.erb +6 -8
  7. data/app/views/super/application/_form.html.erb +13 -10
  8. data/app/views/super/application/_form_field__destroy.html.erb +2 -2
  9. data/app/views/super/application/_form_field_select.html.erb +6 -6
  10. data/app/views/super/application/_form_field_text.html.erb +3 -3
  11. data/app/views/super/application/_form_fieldset.html.erb +1 -1
  12. data/app/views/super/application/_form_has_many.html.erb +4 -4
  13. data/app/views/super/application/_index.html.erb +38 -53
  14. data/app/views/super/application/_resource_header.html.erb +16 -0
  15. data/app/views/super/application/_resources_header.html.erb +16 -0
  16. data/app/views/super/application/_show.html.erb +0 -2
  17. data/app/views/super/application/_super_layout.html.erb +34 -0
  18. data/app/views/super/application/_super_panel.html.erb +11 -0
  19. data/app/views/super/application/edit.html.erb +1 -6
  20. data/app/views/super/application/index.html.erb +1 -1
  21. data/app/views/super/application/new.html.erb +1 -6
  22. data/app/views/super/application/show.html.erb +1 -1
  23. data/frontend/super-frontend/build.js +12 -12
  24. data/frontend/super-frontend/dist/application.css +38267 -22475
  25. data/frontend/super-frontend/dist/application.js +60 -10831
  26. data/frontend/super-frontend/package.json +7 -3
  27. data/frontend/super-frontend/postcss.config.js +4 -4
  28. data/frontend/super-frontend/src/javascripts/super/application.ts +10 -5
  29. data/frontend/super-frontend/src/javascripts/super/apply_template_controller.ts +21 -0
  30. data/frontend/super-frontend/src/javascripts/super/rails__ujs.d.ts +1 -1
  31. data/frontend/super-frontend/src/javascripts/super/toggle_pending_destruction_controller.ts +15 -0
  32. data/frontend/super-frontend/src/stylesheets/super/application.css +63 -0
  33. data/frontend/super-frontend/tailwind.config.js +6 -4
  34. data/frontend/super-frontend/yarn.lock +115 -40
  35. data/lib/super.rb +6 -2
  36. data/lib/super/action.rb +22 -0
  37. data/lib/super/action/step.rb +36 -0
  38. data/lib/super/controls.rb +222 -2
  39. data/lib/super/error.rb +1 -0
  40. data/lib/super/form/schema_types.rb +1 -1
  41. data/lib/super/layout.rb +19 -0
  42. data/lib/super/link.rb +87 -0
  43. data/lib/super/pagination.rb +19 -8
  44. data/lib/super/panel.rb +17 -0
  45. data/lib/super/partial.rb +11 -0
  46. data/lib/super/test_support/copy_app_templates/controllers/members_controller.rb +17 -0
  47. data/lib/super/test_support/copy_app_templates/views/members/_favorite_things.html.erb +11 -0
  48. data/lib/super/test_support/generate_copy_app.rb +1 -0
  49. data/lib/super/version.rb +1 -1
  50. metadata +16 -5
  51. data/frontend/super-frontend/src/javascripts/super/nested_attributes_controller.ts +0 -33
  52. data/lib/super/inline_callback.rb +0 -82
  53. data/lib/super/view.rb +0 -25
@@ -29,19 +29,15 @@ module Super
29
29
  end
30
30
  end
31
31
 
32
+ def necessary?
33
+ pages > 1
34
+ end
35
+
32
36
  def each
33
37
  if !block_given?
34
38
  return enum_for(:each)
35
39
  end
36
40
 
37
- quotient, remainder = @total_count.divmod(@limit)
38
- pages =
39
- if remainder.zero?
40
- quotient
41
- else
42
- quotient + 1
43
- end
44
-
45
41
  (1..pages).each do |pageno|
46
42
  is_current_page = pageno == current_pageno
47
43
  display = pageno.to_s
@@ -55,5 +51,20 @@ module Super
55
51
  yield(page_query_params, is_current_page, display)
56
52
  end
57
53
  end
54
+
55
+ private
56
+
57
+ def pages
58
+ @pages ||=
59
+ begin
60
+ quotient, remainder = @total_count.divmod(@limit)
61
+
62
+ if remainder.zero?
63
+ quotient
64
+ else
65
+ quotient + 1
66
+ end
67
+ end
68
+ end
58
69
  end
59
70
  end
@@ -0,0 +1,17 @@
1
+ module Super
2
+ class Panel
3
+ def initialize(*parts)
4
+ if block_given?
5
+ @parts = Array.new(yield)
6
+ end
7
+
8
+ @parts = parts
9
+ end
10
+
11
+ attr_reader :parts
12
+
13
+ def to_partial_path
14
+ "super_panel"
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,11 @@
1
+ module Super
2
+ class Partial
3
+ def initialize(path, locals: {})
4
+ @to_partial_path = path
5
+ @locals = locals
6
+ end
7
+
8
+ attr_reader :to_partial_path
9
+ attr_reader :locals
10
+ end
11
+ end
@@ -19,6 +19,23 @@ module Admin
19
19
  Member.all
20
20
  end
21
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
+
22
39
  def permitted_params(params, action:)
23
40
  params.require(:member).permit(:name, :rank, :position, :ship_id, favorite_things_attributes: [:id, :name, :_destroy])
24
41
  end
@@ -0,0 +1,11 @@
1
+ <% if @resource.favorite_things.any? %>
2
+ <%= render(Super::Panel.new) do %>
3
+ <h1 class="text-xl">Favorite Things</h1>
4
+
5
+ <ul class="list-disc list-outside mt-4">
6
+ <% @resource.favorite_things.each do |favorite_thing| %>
7
+ <li class="ml-6"><%= favorite_thing.name %></li>
8
+ <% end %>
9
+ </ul>
10
+ <% end %>
11
+ <% end %>
@@ -26,6 +26,7 @@ class SuperCopyAppGenerator < Rails::Generators::Base
26
26
  def copy_app
27
27
  directory "models", "app/models"
28
28
  directory "controllers", "app/controllers/admin"
29
+ directory "views/members", "app/views/admin/members"
29
30
  end
30
31
 
31
32
  def copy_db
data/lib/super/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Super
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
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.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zach Ahn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-25 00:00:00.000000000 Z
11
+ date: 2020-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -136,6 +136,7 @@ files:
136
136
  - app/assets/javascripts/super/application.js
137
137
  - app/assets/stylesheets/super/application.css
138
138
  - app/controllers/super/application_controller.rb
139
+ - app/helpers/super/application_helper.rb
139
140
  - app/views/layouts/super/application.html.erb
140
141
  - app/views/super/application/_flash.html.erb
141
142
  - app/views/super/application/_form.html.erb
@@ -147,7 +148,11 @@ files:
147
148
  - app/views/super/application/_form_has_one.html.erb
148
149
  - app/views/super/application/_form_inline_errors.html.erb
149
150
  - app/views/super/application/_index.html.erb
151
+ - app/views/super/application/_resource_header.html.erb
152
+ - app/views/super/application/_resources_header.html.erb
150
153
  - app/views/super/application/_show.html.erb
154
+ - app/views/super/application/_super_layout.html.erb
155
+ - app/views/super/application/_super_panel.html.erb
151
156
  - app/views/super/application/edit.html.erb
152
157
  - app/views/super/application/index.html.erb
153
158
  - app/views/super/application/new.html.erb
@@ -162,8 +167,9 @@ files:
162
167
  - frontend/super-frontend/package.json
163
168
  - frontend/super-frontend/postcss.config.js
164
169
  - frontend/super-frontend/src/javascripts/super/application.ts
165
- - frontend/super-frontend/src/javascripts/super/nested_attributes_controller.ts
170
+ - frontend/super-frontend/src/javascripts/super/apply_template_controller.ts
166
171
  - frontend/super-frontend/src/javascripts/super/rails__ujs.d.ts
172
+ - frontend/super-frontend/src/javascripts/super/toggle_pending_destruction_controller.ts
167
173
  - frontend/super-frontend/src/stylesheets/super/application.css
168
174
  - frontend/super-frontend/tailwind.config.js
169
175
  - frontend/super-frontend/tsconfig.json
@@ -179,6 +185,8 @@ files:
179
185
  - lib/generators/super/webpacker/templates/pack_super_application.js.erb.tt
180
186
  - lib/generators/super/webpacker/webpacker_generator.rb
181
187
  - lib/super.rb
188
+ - lib/super/action.rb
189
+ - lib/super/action/step.rb
182
190
  - lib/super/action_inquirer.rb
183
191
  - lib/super/assets.rb
184
192
  - lib/super/configuration.rb
@@ -188,9 +196,12 @@ files:
188
196
  - lib/super/engine.rb
189
197
  - lib/super/error.rb
190
198
  - lib/super/form/schema_types.rb
191
- - lib/super/inline_callback.rb
199
+ - lib/super/layout.rb
200
+ - lib/super/link.rb
192
201
  - lib/super/navigation/automatic.rb
193
202
  - lib/super/pagination.rb
203
+ - lib/super/panel.rb
204
+ - lib/super/partial.rb
194
205
  - lib/super/plugin.rb
195
206
  - lib/super/schema.rb
196
207
  - lib/super/test_support/copy_app_templates/controllers/favorite_things_controller.rb
@@ -205,6 +216,7 @@ files:
205
216
  - lib/super/test_support/copy_app_templates/models/ship.rb
206
217
  - lib/super/test_support/copy_app_templates/routes.rb
207
218
  - lib/super/test_support/copy_app_templates/seeds.rb
219
+ - lib/super/test_support/copy_app_templates/views/members/_favorite_things.html.erb
208
220
  - lib/super/test_support/fixtures/favorite_things.yml
209
221
  - lib/super/test_support/fixtures/members.yml
210
222
  - lib/super/test_support/fixtures/ships.yml
@@ -212,7 +224,6 @@ files:
212
224
  - lib/super/test_support/generate_dummy.rb
213
225
  - lib/super/test_support/starfleet_seeder.rb
214
226
  - lib/super/version.rb
215
- - lib/super/view.rb
216
227
  - lib/tasks/super_tasks.rake
217
228
  homepage:
218
229
  licenses:
@@ -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
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