superview 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -3
- data/Gemfile.lock +98 -149
- data/README.md +41 -5
- data/lib/superview/actions.rb +31 -15
- data/lib/superview/assignable.rb +27 -7
- data/lib/superview/components/table_component.rb +17 -6
- data/lib/superview/helpers/turbo/meta_tags.rb +2 -2
- data/lib/superview/helpers/turbo.rb +0 -11
- data/lib/superview/version.rb +1 -1
- metadata +11 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95b73938446d68225ef15422d94071e4cdf77856aedb64f9f9b96aca8dd75217
|
4
|
+
data.tar.gz: 27e686bdfacf05a9d265ba919cf5a2ad2d87a074975ccc33871f2f20498555df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e7ddd62b1cbb25eb2e5a3f45f1b161c2973bb8ba33af94469141d2bad9f27f6925d2f3d6af3e777f338e1b9943111277e8250ff56ad7a7ee255ed8ad416ca95
|
7
|
+
data.tar.gz: 14549c8278d4d55f0f497c27ef26a7b5208d83e7b3c9e4d3cb98a175856986713109d3f630ba8feada62ea6da269f4bc9b006a58c0ac00b62329f49feeb11974
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,189 +1,138 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
superview (0.1.
|
5
|
-
phlex-rails (
|
4
|
+
superview (0.1.3)
|
5
|
+
phlex-rails (>= 1.0, < 3.0)
|
6
6
|
zeitwerk (~> 2.0)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
|
12
|
-
|
13
|
-
activesupport (=
|
14
|
-
nio4r (~> 2.0)
|
15
|
-
websocket-driver (>= 0.6.1)
|
16
|
-
actionmailbox (7.0.7)
|
17
|
-
actionpack (= 7.0.7)
|
18
|
-
activejob (= 7.0.7)
|
19
|
-
activerecord (= 7.0.7)
|
20
|
-
activestorage (= 7.0.7)
|
21
|
-
activesupport (= 7.0.7)
|
22
|
-
mail (>= 2.7.1)
|
23
|
-
net-imap
|
24
|
-
net-pop
|
25
|
-
net-smtp
|
26
|
-
actionmailer (7.0.7)
|
27
|
-
actionpack (= 7.0.7)
|
28
|
-
actionview (= 7.0.7)
|
29
|
-
activejob (= 7.0.7)
|
30
|
-
activesupport (= 7.0.7)
|
31
|
-
mail (~> 2.5, >= 2.5.4)
|
32
|
-
net-imap
|
33
|
-
net-pop
|
34
|
-
net-smtp
|
35
|
-
rails-dom-testing (~> 2.0)
|
36
|
-
actionpack (7.0.7)
|
37
|
-
actionview (= 7.0.7)
|
38
|
-
activesupport (= 7.0.7)
|
39
|
-
rack (~> 2.0, >= 2.2.4)
|
40
|
-
rack-test (>= 0.6.3)
|
41
|
-
rails-dom-testing (~> 2.0)
|
42
|
-
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
43
|
-
actiontext (7.0.7)
|
44
|
-
actionpack (= 7.0.7)
|
45
|
-
activerecord (= 7.0.7)
|
46
|
-
activestorage (= 7.0.7)
|
47
|
-
activesupport (= 7.0.7)
|
48
|
-
globalid (>= 0.6.0)
|
11
|
+
actionpack (8.0.1)
|
12
|
+
actionview (= 8.0.1)
|
13
|
+
activesupport (= 8.0.1)
|
49
14
|
nokogiri (>= 1.8.5)
|
50
|
-
|
51
|
-
|
15
|
+
rack (>= 2.2.4)
|
16
|
+
rack-session (>= 1.0.1)
|
17
|
+
rack-test (>= 0.6.3)
|
18
|
+
rails-dom-testing (~> 2.2)
|
19
|
+
rails-html-sanitizer (~> 1.6)
|
20
|
+
useragent (~> 0.16)
|
21
|
+
actionview (8.0.1)
|
22
|
+
activesupport (= 8.0.1)
|
52
23
|
builder (~> 3.1)
|
53
|
-
erubi (~> 1.
|
54
|
-
rails-dom-testing (~> 2.
|
55
|
-
rails-html-sanitizer (~> 1.
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
activesupport (= 7.0.7)
|
64
|
-
activestorage (7.0.7)
|
65
|
-
actionpack (= 7.0.7)
|
66
|
-
activejob (= 7.0.7)
|
67
|
-
activerecord (= 7.0.7)
|
68
|
-
activesupport (= 7.0.7)
|
69
|
-
marcel (~> 1.0)
|
70
|
-
mini_mime (>= 1.1.0)
|
71
|
-
activesupport (7.0.7)
|
72
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
24
|
+
erubi (~> 1.11)
|
25
|
+
rails-dom-testing (~> 2.2)
|
26
|
+
rails-html-sanitizer (~> 1.6)
|
27
|
+
activesupport (8.0.1)
|
28
|
+
base64
|
29
|
+
benchmark (>= 0.3)
|
30
|
+
bigdecimal
|
31
|
+
concurrent-ruby (~> 1.0, >= 1.3.1)
|
32
|
+
connection_pool (>= 2.2.5)
|
33
|
+
drb
|
73
34
|
i18n (>= 1.6, < 2)
|
35
|
+
logger (>= 1.4.2)
|
74
36
|
minitest (>= 5.1)
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
37
|
+
securerandom (>= 0.3)
|
38
|
+
tzinfo (~> 2.0, >= 2.0.5)
|
39
|
+
uri (>= 0.13.1)
|
40
|
+
base64 (0.2.0)
|
41
|
+
benchmark (0.4.0)
|
42
|
+
bigdecimal (3.1.8)
|
43
|
+
builder (3.3.0)
|
44
|
+
concurrent-ruby (1.3.4)
|
45
|
+
connection_pool (2.4.1)
|
79
46
|
crass (1.0.6)
|
80
|
-
date (3.
|
81
|
-
diff-lcs (1.5.
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
globalid (1.1.0)
|
86
|
-
activesupport (>= 5.0)
|
87
|
-
i18n (1.14.1)
|
47
|
+
date (3.4.1)
|
48
|
+
diff-lcs (1.5.1)
|
49
|
+
drb (2.2.1)
|
50
|
+
erubi (1.13.0)
|
51
|
+
i18n (1.14.6)
|
88
52
|
concurrent-ruby (~> 1.0)
|
89
|
-
|
53
|
+
io-console (0.8.0)
|
54
|
+
irb (1.14.2)
|
55
|
+
rdoc (>= 4.0.0)
|
56
|
+
reline (>= 0.4.2)
|
57
|
+
logger (1.6.3)
|
58
|
+
loofah (2.23.1)
|
90
59
|
crass (~> 1.0.2)
|
91
60
|
nokogiri (>= 1.12.0)
|
92
|
-
|
93
|
-
|
94
|
-
net-imap
|
95
|
-
net-pop
|
96
|
-
net-smtp
|
97
|
-
marcel (1.0.2)
|
98
|
-
method_source (1.0.0)
|
99
|
-
mini_mime (1.1.5)
|
100
|
-
mini_portile2 (2.8.5)
|
101
|
-
minitest (5.19.0)
|
102
|
-
net-imap (0.3.7)
|
103
|
-
date
|
104
|
-
net-protocol
|
105
|
-
net-pop (0.1.2)
|
106
|
-
net-protocol
|
107
|
-
net-protocol (0.2.1)
|
108
|
-
timeout
|
109
|
-
net-smtp (0.3.3)
|
110
|
-
net-protocol
|
111
|
-
nio4r (2.5.9)
|
112
|
-
nokogiri (1.15.4)
|
113
|
-
mini_portile2 (~> 2.8.2)
|
61
|
+
minitest (5.25.4)
|
62
|
+
nokogiri (1.17.2-arm64-darwin)
|
114
63
|
racc (~> 1.4)
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
64
|
+
nokogiri (1.17.2-x86_64-linux)
|
65
|
+
racc (~> 1.4)
|
66
|
+
phlex (1.11.0)
|
67
|
+
phlex-rails (1.2.2)
|
68
|
+
phlex (>= 1.10, < 2)
|
69
|
+
railties (>= 6.1, < 9)
|
70
|
+
psych (5.2.1)
|
71
|
+
date
|
72
|
+
stringio
|
73
|
+
racc (1.8.1)
|
74
|
+
rack (3.1.8)
|
75
|
+
rack-session (2.0.0)
|
76
|
+
rack (>= 3.0.0)
|
125
77
|
rack-test (2.1.0)
|
126
78
|
rack (>= 1.3)
|
127
|
-
|
128
|
-
|
129
|
-
actionmailbox (= 7.0.7)
|
130
|
-
actionmailer (= 7.0.7)
|
131
|
-
actionpack (= 7.0.7)
|
132
|
-
actiontext (= 7.0.7)
|
133
|
-
actionview (= 7.0.7)
|
134
|
-
activejob (= 7.0.7)
|
135
|
-
activemodel (= 7.0.7)
|
136
|
-
activerecord (= 7.0.7)
|
137
|
-
activestorage (= 7.0.7)
|
138
|
-
activesupport (= 7.0.7)
|
139
|
-
bundler (>= 1.15.0)
|
140
|
-
railties (= 7.0.7)
|
79
|
+
rackup (2.2.1)
|
80
|
+
rack (>= 3)
|
141
81
|
rails-dom-testing (2.2.0)
|
142
82
|
activesupport (>= 5.0.0)
|
143
83
|
minitest
|
144
84
|
nokogiri (>= 1.6)
|
145
|
-
rails-html-sanitizer (1.6.
|
85
|
+
rails-html-sanitizer (1.6.2)
|
146
86
|
loofah (~> 2.21)
|
147
|
-
nokogiri (
|
148
|
-
railties (
|
149
|
-
actionpack (=
|
150
|
-
activesupport (=
|
151
|
-
|
87
|
+
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
|
88
|
+
railties (8.0.1)
|
89
|
+
actionpack (= 8.0.1)
|
90
|
+
activesupport (= 8.0.1)
|
91
|
+
irb (~> 1.13)
|
92
|
+
rackup (>= 1.0.0)
|
152
93
|
rake (>= 12.2)
|
153
|
-
thor (~> 1.0)
|
154
|
-
zeitwerk (~> 2.
|
155
|
-
rake (13.
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
rspec-core (3.
|
161
|
-
rspec-support (~> 3.
|
162
|
-
rspec-expectations (3.
|
94
|
+
thor (~> 1.0, >= 1.2.2)
|
95
|
+
zeitwerk (~> 2.6)
|
96
|
+
rake (13.2.1)
|
97
|
+
rdoc (6.9.0)
|
98
|
+
psych (>= 4.0.0)
|
99
|
+
reline (0.5.12)
|
100
|
+
io-console (~> 0.5)
|
101
|
+
rspec-core (3.13.2)
|
102
|
+
rspec-support (~> 3.13.0)
|
103
|
+
rspec-expectations (3.13.3)
|
163
104
|
diff-lcs (>= 1.2.0, < 2.0)
|
164
|
-
rspec-support (~> 3.
|
165
|
-
rspec-mocks (3.
|
105
|
+
rspec-support (~> 3.13.0)
|
106
|
+
rspec-mocks (3.13.2)
|
166
107
|
diff-lcs (>= 1.2.0, < 2.0)
|
167
|
-
rspec-support (~> 3.
|
168
|
-
rspec-
|
169
|
-
|
170
|
-
|
108
|
+
rspec-support (~> 3.13.0)
|
109
|
+
rspec-rails (7.1.0)
|
110
|
+
actionpack (>= 7.0)
|
111
|
+
activesupport (>= 7.0)
|
112
|
+
railties (>= 7.0)
|
113
|
+
rspec-core (~> 3.13)
|
114
|
+
rspec-expectations (~> 3.13)
|
115
|
+
rspec-mocks (~> 3.13)
|
116
|
+
rspec-support (~> 3.13)
|
117
|
+
rspec-support (3.13.2)
|
118
|
+
securerandom (0.4.0)
|
119
|
+
stringio (3.1.2)
|
120
|
+
thor (1.3.2)
|
171
121
|
tzinfo (2.0.6)
|
172
122
|
concurrent-ruby (~> 1.0)
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
zeitwerk (2.6.11)
|
123
|
+
uri (1.0.2)
|
124
|
+
useragent (0.16.11)
|
125
|
+
zeitwerk (2.7.1)
|
177
126
|
|
178
127
|
PLATFORMS
|
179
128
|
arm64-darwin-22
|
180
129
|
arm64-darwin-23
|
130
|
+
arm64-darwin-24
|
181
131
|
x86_64-linux
|
182
132
|
|
183
133
|
DEPENDENCIES
|
184
|
-
rails (~> 7.0)
|
185
134
|
rake (~> 13.0)
|
186
|
-
rspec (~>
|
135
|
+
rspec-rails (~> 7.0)
|
187
136
|
superview!
|
188
137
|
|
189
138
|
BUNDLED WITH
|
data/README.md
CHANGED
@@ -11,7 +11,7 @@ class PostsController < ApplicationController
|
|
11
11
|
class Show < ApplicationComponent
|
12
12
|
attr_accessor :post
|
13
13
|
|
14
|
-
def
|
14
|
+
def view_template(&)
|
15
15
|
h1 { @post.title }
|
16
16
|
div(class: "prose") { @post.body }
|
17
17
|
end
|
@@ -56,7 +56,7 @@ class PostsController < ApplicationController
|
|
56
56
|
class Show < ApplicationComponent
|
57
57
|
attr_accessor :post
|
58
58
|
|
59
|
-
def
|
59
|
+
def view_template(&)
|
60
60
|
h1 { @post.title }
|
61
61
|
div(class: "prose") { @post.body }
|
62
62
|
end
|
@@ -80,7 +80,7 @@ class PostsController < ApplicationController
|
|
80
80
|
class Show < ApplicationComponent
|
81
81
|
attr_accessor :post
|
82
82
|
|
83
|
-
def
|
83
|
+
def view_template(&)
|
84
84
|
h1 { @post.title }
|
85
85
|
div(class: "prose") { @post.body }
|
86
86
|
end
|
@@ -88,7 +88,12 @@ class PostsController < ApplicationController
|
|
88
88
|
|
89
89
|
def show
|
90
90
|
respond_to do |format|
|
91
|
-
format.html { render
|
91
|
+
format.html { render phlex }
|
92
|
+
# These would also work...
|
93
|
+
# format.html { render Show.new.tap { _1.post = @post } }
|
94
|
+
# format.html { render phlex Show.new }
|
95
|
+
# format.html { render phlex Show }
|
96
|
+
# format.html { render phlex :show }
|
92
97
|
format.json { render json: @post }
|
93
98
|
end
|
94
99
|
end
|
@@ -100,6 +105,37 @@ class PostsController < ApplicationController
|
|
100
105
|
end
|
101
106
|
```
|
102
107
|
|
108
|
+
### Rendering other Phlex actions from different actions
|
109
|
+
|
110
|
+
It's common to have to render form actions from other actions when forms are saved. In this example the `create` method renders the `phlex New` view when the form is invalid.
|
111
|
+
|
112
|
+
```ruby
|
113
|
+
class PostsController < ApplicationController
|
114
|
+
include Superview::Actions
|
115
|
+
|
116
|
+
def create
|
117
|
+
@post = Post.new(post_params)
|
118
|
+
|
119
|
+
if @post.save
|
120
|
+
redirect_to @post
|
121
|
+
else
|
122
|
+
render phlex New
|
123
|
+
# These would also work...
|
124
|
+
# render New.new.tap { _1.post = @post }
|
125
|
+
# render phlex New.new
|
126
|
+
# render phlex New
|
127
|
+
# render phlex :new
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
private
|
132
|
+
def load_post
|
133
|
+
@post = Post.find(params[:id])
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
```
|
138
|
+
|
103
139
|
### Extracting inline views into the `./app/views` folder
|
104
140
|
|
105
141
|
Inline views are an amazingly productive way of prototyping apps, but as it matures you might be inclined to extract these views into the `./app/views` folders for organizational purposes or so you can share them between controllers.
|
@@ -112,7 +148,7 @@ module Posts
|
|
112
148
|
class Show < ApplicationComponent
|
113
149
|
attr_accessor :post
|
114
150
|
|
115
|
-
def
|
151
|
+
def view_template(&)
|
116
152
|
h1 { @post.title }
|
117
153
|
div(class: "prose") { @post.body }
|
118
154
|
end
|
data/lib/superview/actions.rb
CHANGED
@@ -16,7 +16,7 @@ module Superview
|
|
16
16
|
# class Show < ApplicationComponent
|
17
17
|
# attr_accessor :post
|
18
18
|
#
|
19
|
-
# def
|
19
|
+
# def view_template(&)
|
20
20
|
# h1 { @post.title }
|
21
21
|
# div(class: "prose") { @post.body }
|
22
22
|
# end
|
@@ -49,8 +49,8 @@ module Superview
|
|
49
49
|
# on Phlex. For example, if a controller defines @users and a Phlex class has
|
50
50
|
# `attr_writer :users`, `attr_accessor :user`, or `def users=`, it will be automatically
|
51
51
|
# set by this method.
|
52
|
-
def assign_phlex_accessors(
|
53
|
-
|
52
|
+
def assign_phlex_accessors(view)
|
53
|
+
view.tap do |view|
|
54
54
|
view_assigns.each do |variable, value|
|
55
55
|
attr_writer_name = "#{variable}="
|
56
56
|
view.send attr_writer_name, value if view.respond_to? attr_writer_name
|
@@ -58,24 +58,40 @@ module Superview
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
-
# Initializers a Phlex view based on the action name
|
62
|
-
# to the view.
|
61
|
+
# Initializers a Phlex view based on the action name and assigns accessors
|
63
62
|
def phlex_action(action)
|
64
|
-
|
63
|
+
phlex_view self.class.phlex_action_class(action: action)
|
64
|
+
end
|
65
|
+
|
66
|
+
# Initializes a phlex view class and assigns accessors.
|
67
|
+
def phlex_view(view_class)
|
68
|
+
assign_phlex_accessors view_class.new
|
65
69
|
end
|
66
70
|
|
67
71
|
# Phlex action for the current action.
|
68
|
-
def phlex
|
69
|
-
|
72
|
+
def phlex(target = action_name)
|
73
|
+
case target
|
74
|
+
when Phlex::HTML
|
75
|
+
assign_phlex_accessors target
|
76
|
+
when Symbol, String
|
77
|
+
phlex_action target
|
78
|
+
when Class
|
79
|
+
phlex_view target
|
80
|
+
end
|
70
81
|
end
|
71
82
|
|
72
|
-
#
|
73
|
-
|
74
|
-
|
83
|
+
# Checks if a Phlex class name is present for a controller action name
|
84
|
+
def phlex_action_exists?(action)
|
85
|
+
self.class.phlex_action_class(action: action).present?
|
86
|
+
end
|
87
|
+
|
88
|
+
# This is a built-in Rails method resolves the method to call for an action.
|
89
|
+
# If it resolves a Phlex class in the controller, it will render that. If it's
|
90
|
+
# not found it continues with Rails method of resolving action names.
|
75
91
|
def method_for_action(action_name)
|
76
|
-
super || if
|
77
|
-
|
78
|
-
|
92
|
+
super || if phlex_action_exists? action_name
|
93
|
+
"default_phlex_render"
|
94
|
+
end
|
79
95
|
end
|
80
96
|
|
81
97
|
# Renders a Phlex view for the given action, if it's present.
|
@@ -83,4 +99,4 @@ module Superview
|
|
83
99
|
render phlex
|
84
100
|
end
|
85
101
|
end
|
86
|
-
end
|
102
|
+
end
|
data/lib/superview/assignable.rb
CHANGED
@@ -53,9 +53,9 @@ module Superview
|
|
53
53
|
class_attribute :model, :parent_model, :context_method_name
|
54
54
|
|
55
55
|
before_action :assign_parent_collection, if: :has_parent_model?
|
56
|
-
before_action :assign_parent_member, if: :
|
57
|
-
before_action :assign_collection
|
58
|
-
before_action :assign_member
|
56
|
+
before_action :assign_parent_member, if: :has_parent_model_instance?
|
57
|
+
before_action :assign_collection, if: :has_model?
|
58
|
+
before_action :assign_member, if: :has_model?
|
59
59
|
end
|
60
60
|
|
61
61
|
protected
|
@@ -68,19 +68,31 @@ module Superview
|
|
68
68
|
instance_variable_set "@#{parent_model.model_name.plural}", parent_model_scope
|
69
69
|
end
|
70
70
|
|
71
|
-
def
|
72
|
-
if
|
71
|
+
def model_association
|
72
|
+
if has_parent_model_instance?
|
73
73
|
parent_model_instance.association(model.model_name.collection)
|
74
74
|
elsif has_assignable_context?
|
75
|
-
assignable_context.association(model.model_name.collection)
|
75
|
+
assignable_context.association(model.model_name.collection)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def model_scope
|
80
|
+
if association = model_association
|
81
|
+
association.scope
|
76
82
|
else
|
77
83
|
model.scope_for_association
|
78
84
|
end
|
79
85
|
end
|
80
86
|
|
81
|
-
def
|
87
|
+
def parent_model_association
|
82
88
|
if has_assignable_context?
|
83
89
|
assignable_context.association(parent_model.model_name.collection)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def parent_model_scope
|
94
|
+
if association = parent_model_association
|
95
|
+
association.scope
|
84
96
|
else
|
85
97
|
parent_model.scope_for_association
|
86
98
|
end
|
@@ -98,6 +110,14 @@ module Superview
|
|
98
110
|
parent_model.present?
|
99
111
|
end
|
100
112
|
|
113
|
+
def has_parent_model_instance?
|
114
|
+
has_parent_model? && params.key?(parent_model_param_key)
|
115
|
+
end
|
116
|
+
|
117
|
+
def has_model?
|
118
|
+
model.present?
|
119
|
+
end
|
120
|
+
|
101
121
|
def assign_member
|
102
122
|
instance_variable_set "@#{model.model_name.singular}", model_instance
|
103
123
|
end
|
@@ -3,7 +3,7 @@ module Superview::Components
|
|
3
3
|
# collection of the table.
|
4
4
|
#
|
5
5
|
# ```ruby
|
6
|
-
# render TableComponent.new(
|
6
|
+
# render TableComponent.new(@posts) do |table|
|
7
7
|
# # This is how you'd usually render a table.
|
8
8
|
# table.column("Title") { show(_1, :title) }
|
9
9
|
#
|
@@ -19,8 +19,18 @@ module Superview::Components
|
|
19
19
|
# end
|
20
20
|
# end
|
21
21
|
# ```
|
22
|
+
|
22
23
|
class TableComponent < ApplicationComponent
|
23
|
-
|
24
|
+
if Phlex.const_defined?(:DeferredRender)
|
25
|
+
# Phlex 1.0
|
26
|
+
include Phlex::DeferredRender
|
27
|
+
else
|
28
|
+
# Phlex 2.0
|
29
|
+
def before_template(&)
|
30
|
+
vanish(&)
|
31
|
+
super
|
32
|
+
end
|
33
|
+
end
|
24
34
|
|
25
35
|
class Column
|
26
36
|
attr_accessor :title_template, :item_template
|
@@ -41,13 +51,14 @@ module Superview::Components
|
|
41
51
|
end
|
42
52
|
end
|
43
53
|
|
44
|
-
def initialize(items
|
54
|
+
def initialize(items = [], **attributes)
|
45
55
|
@items = items
|
56
|
+
@attributes = attributes
|
46
57
|
@columns = []
|
47
58
|
end
|
48
59
|
|
49
|
-
def
|
50
|
-
table do
|
60
|
+
def view_template(&)
|
61
|
+
table(**@attributes) do
|
51
62
|
thead do
|
52
63
|
tr do
|
53
64
|
@columns.each do |column|
|
@@ -75,4 +86,4 @@ module Superview::Components
|
|
75
86
|
end
|
76
87
|
end
|
77
88
|
end
|
78
|
-
end
|
89
|
+
end
|
@@ -20,7 +20,7 @@ module Superview
|
|
20
20
|
@page_requires_reload = page_requires_reload
|
21
21
|
end
|
22
22
|
|
23
|
-
def
|
23
|
+
def view_template
|
24
24
|
meta(name: "turbo-refresh-method", content: @method)
|
25
25
|
meta(name: "turbo-refresh-scroll", content: @scroll)
|
26
26
|
meta(name: "turbo-cache-control", content: "no-cache") if @exempts_page_from_cache
|
@@ -45,4 +45,4 @@ module Superview
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
48
|
-
end
|
48
|
+
end
|
@@ -7,17 +7,6 @@ module Superview
|
|
7
7
|
register_element :turbo_cable_stream_source
|
8
8
|
end
|
9
9
|
|
10
|
-
class_methods do
|
11
|
-
def turbo(*args, **kwargs, &block)
|
12
|
-
@turbo_meta_tags = MetaTags.new(*args, **kwargs)
|
13
|
-
define_method(:turbo, &block) if block
|
14
|
-
end
|
15
|
-
|
16
|
-
def turbo_meta_tags
|
17
|
-
@turbo_meta_tags ||= MetaTags.new
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
10
|
def turbo_stream_from(*streamables, **attributes)
|
22
11
|
attributes[:channel] = attributes[:channel]&.to_s || "Turbo::StreamsChannel"
|
23
12
|
attributes[:"signed-stream-name"] = ::Turbo::StreamsChannel.signed_stream_name(streamables)
|
data/lib/superview/version.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: superview
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brad Gessler
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: phlex-rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.0'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '3.0'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '1.0'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '3.0'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: zeitwerk
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -85,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
91
|
- !ruby/object:Gem::Version
|
86
92
|
version: '0'
|
87
93
|
requirements: []
|
88
|
-
rubygems_version: 3.5.
|
94
|
+
rubygems_version: 3.5.16
|
89
95
|
signing_key:
|
90
96
|
specification_version: 4
|
91
97
|
summary: Build Rails applications entirely out of Phlex components.
|