plutonium 0.21.1 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/active_model/validations/attached_validator.rb +1 -1
- data/lib/active_model/validations/url_validator.rb +1 -1
- data/lib/plutonium/resource/controllers/crud_actions/index_action.rb +1 -1
- data/lib/plutonium/ui/component/behaviour.rb +2 -0
- data/lib/plutonium/ui/component/kit.rb +1 -1
- data/lib/plutonium/ui/component/tokens.rb +58 -0
- data/lib/plutonium/ui/display/components/markdown.rb +1 -1
- data/lib/plutonium/ui/dyna_frame/content.rb +1 -1
- data/lib/plutonium/ui/form/base.rb +1 -0
- data/lib/plutonium/ui/form/resource.rb +27 -24
- data/lib/plutonium/ui/layout/base.rb +1 -1
- data/lib/plutonium/ui/layout/resource_layout.rb +2 -2
- data/lib/plutonium/ui/page/edit.rb +1 -1
- data/lib/plutonium/ui/page/index.rb +1 -1
- data/lib/plutonium/ui/page/interactive_action.rb +1 -1
- data/lib/plutonium/ui/page/new.rb +1 -1
- data/lib/plutonium/ui/page/show.rb +1 -1
- data/lib/plutonium/ui/panel.rb +9 -2
- data/lib/plutonium/ui/table/components/pagy_info.rb +0 -8
- data/lib/plutonium/version.rb +1 -1
- metadata +35 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b6106e6479856651cc2e5b632cb05004392cd1643a3eb157e1f88a84de06103
|
4
|
+
data.tar.gz: 57389cece65e0f035f5001c279bdbc910d03812ec055a6ed118b087e27ed0c0f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 013ca5e147764f6dd8181b63aac505d09559561b012fd53f104dcb4259a48a11859eb0c8d1aff05e1c90caf7374b598c186bf1eb55533d0440aab94a1ca45a86
|
7
|
+
data.tar.gz: 7e9fd22ffb966a36045b97eb413d54b58e4523fb2faa9fae90aec803a6e62fc45cc125dae8bfd1b488831a1fd4d767dd2e70c938d82406820f374983a3459442
|
@@ -10,7 +10,7 @@ module ActiveModel
|
|
10
10
|
#
|
11
11
|
class AttachedValidator < EachValidator
|
12
12
|
def validate_each(record, attribute, value)
|
13
|
-
record.errors.add(attribute,
|
13
|
+
record.errors.add(attribute, options[:message] || "must be attached") unless value.attached?
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -43,7 +43,7 @@ module ActiveModel
|
|
43
43
|
return true unless options[:image].present?
|
44
44
|
return true unless FastImage.type(value).nil?
|
45
45
|
|
46
|
-
record.errors.add(attribute,
|
46
|
+
record.errors.add(attribute, options[:message] || "is not a valid image URL")
|
47
47
|
false
|
48
48
|
end
|
49
49
|
end
|
@@ -14,7 +14,7 @@ module Plutonium
|
|
14
14
|
def filtered_resource_collection
|
15
15
|
query_params = current_definition
|
16
16
|
.query_form.new(nil, query_object: current_query_object, page_size: nil)
|
17
|
-
.extract_input(params)[:q]
|
17
|
+
.extract_input(params, view_context:)[:q]
|
18
18
|
|
19
19
|
base_query = current_authorized_scope
|
20
20
|
current_query_object.apply(base_query, query_params)
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Plutonium
|
4
|
+
module UI
|
5
|
+
module Component
|
6
|
+
module Tokens
|
7
|
+
def classes(*tokens, **conditional_tokens)
|
8
|
+
tokens = self.tokens(*tokens, **conditional_tokens)
|
9
|
+
|
10
|
+
if tokens.empty?
|
11
|
+
{}
|
12
|
+
else
|
13
|
+
{class: tokens}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def tokens(*tokens, **conditional_tokens)
|
18
|
+
conditional_tokens.each do |condition, token|
|
19
|
+
truthy = case condition
|
20
|
+
when Symbol then send(condition)
|
21
|
+
when Proc then condition.call
|
22
|
+
else raise ArgumentError, "The class condition must be a Symbol or a Proc."
|
23
|
+
end
|
24
|
+
|
25
|
+
if truthy
|
26
|
+
case token
|
27
|
+
when Hash then __append_token__(tokens, token[:then])
|
28
|
+
else __append_token__(tokens, token)
|
29
|
+
end
|
30
|
+
else
|
31
|
+
case token
|
32
|
+
when Hash then __append_token__(tokens, token[:else])
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
tokens = tokens.select(&:itself).join(" ")
|
38
|
+
tokens.strip!
|
39
|
+
tokens.gsub!(/\s+/, " ")
|
40
|
+
tokens
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def __append_token__(tokens, token)
|
46
|
+
case token
|
47
|
+
when nil then nil
|
48
|
+
when String then tokens << token
|
49
|
+
when Symbol then tokens << token.name
|
50
|
+
when Array then tokens.concat(token)
|
51
|
+
else raise ArgumentError,
|
52
|
+
"Conditional classes must be Symbols, Strings, or Arrays of Symbols or Strings."
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -61,36 +61,39 @@ module Plutonium
|
|
61
61
|
input_definition = definition.defined_inputs[name] || {}
|
62
62
|
input_options = input_definition[:options] || {}
|
63
63
|
|
64
|
-
condition = input_options[:condition] || field_options[:condition]
|
65
|
-
return if condition && !instance_exec(&condition)
|
66
|
-
|
67
64
|
tag = input_options[:as] || field_options[:as]
|
68
|
-
tag_attributes =
|
69
|
-
input_options.except(:wrapper, :as, :pre_submit, :condition)
|
65
|
+
tag_attributes = input_options.except(:wrapper, :as, :pre_submit, :condition)
|
70
66
|
if input_options[:pre_submit]
|
71
|
-
tag_attributes[
|
72
|
-
"data-action"
|
73
|
-
] = "change->form#preSubmit"
|
67
|
+
tag_attributes["data-action"] = "change->form#preSubmit"
|
74
68
|
end
|
75
|
-
tag_block =
|
76
|
-
|
77
|
-
|
78
|
-
tag ||= f.inferred_field_component
|
79
|
-
f.send(:"#{tag}_tag", **tag_attributes)
|
80
|
-
end
|
81
|
-
|
82
|
-
wrapper_options = input_options[:wrapper] || {}
|
83
|
-
if !wrapper_options[:class] || !wrapper_options[:class].include?("col-span")
|
84
|
-
# temp hack to allow col span overrides
|
85
|
-
# TODO: remove once we complete theming, which will support merges
|
86
|
-
wrapper_options[:class] = tokens("col-span-full", wrapper_options[:class])
|
69
|
+
tag_block = input_definition[:block] || ->(f) do
|
70
|
+
tag ||= f.inferred_field_component
|
71
|
+
f.send(:"#{tag}_tag", **tag_attributes)
|
87
72
|
end
|
88
73
|
|
89
74
|
field_options = field_options.except(:as, :condition)
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
75
|
+
|
76
|
+
condition = input_options[:condition] || field_options[:condition]
|
77
|
+
conditionally_hidden = condition && !instance_exec(&condition)
|
78
|
+
if conditionally_hidden
|
79
|
+
# Do not render the field, but still create field
|
80
|
+
# Phlexi form will record it without rendering it, allowing us to extract its value
|
81
|
+
form.field(name, **field_options) do |f|
|
82
|
+
instance_exec(f, &tag_block)
|
83
|
+
end
|
84
|
+
else
|
85
|
+
wrapper_options = input_options[:wrapper] || {}
|
86
|
+
if !wrapper_options[:class] || !wrapper_options[:class].include?("col-span")
|
87
|
+
# temp hack to allow col span overrides
|
88
|
+
# TODO: remove once we complete theming, which will support merges
|
89
|
+
wrapper_options[:class] = tokens("col-span-full", wrapper_options[:class])
|
90
|
+
end
|
91
|
+
|
92
|
+
render form.field(name, **field_options).wrapped(
|
93
|
+
**wrapper_options
|
94
|
+
) do |f|
|
95
|
+
render instance_exec(f, &tag_block)
|
96
|
+
end
|
94
97
|
end
|
95
98
|
end
|
96
99
|
|
data/lib/plutonium/ui/panel.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
module Plutonium
|
2
2
|
module UI
|
3
3
|
class Panel < Plutonium::UI::Component::Base
|
4
|
-
include Phlex::DeferredRender
|
5
|
-
|
6
4
|
def initialize
|
7
5
|
@items = []
|
8
6
|
end
|
@@ -19,6 +17,15 @@ module Plutonium
|
|
19
17
|
@content = content
|
20
18
|
end
|
21
19
|
|
20
|
+
def before_template
|
21
|
+
vanish do
|
22
|
+
@items.each do |item|
|
23
|
+
render item
|
24
|
+
end
|
25
|
+
end
|
26
|
+
super
|
27
|
+
end
|
28
|
+
|
22
29
|
def view_template
|
23
30
|
wrapped do
|
24
31
|
render_toolbar if render_toolbar?
|
@@ -34,11 +34,6 @@ module Plutonium
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def per_page_selector
|
37
|
-
original_attributes = Phlex::HTML::EVENT_ATTRIBUTES
|
38
|
-
temp_attributes = Phlex::HTML::EVENT_ATTRIBUTES.dup
|
39
|
-
temp_attributes.delete("onchange")
|
40
|
-
Phlex::HTML.const_set(:EVENT_ATTRIBUTES, temp_attributes)
|
41
|
-
|
42
37
|
div(
|
43
38
|
class: "flex items-center space-x-2 mt-2 md:mt-0",
|
44
39
|
data_controller: "select-navigator"
|
@@ -55,9 +50,6 @@ module Plutonium
|
|
55
50
|
end
|
56
51
|
end
|
57
52
|
end
|
58
|
-
ensure
|
59
|
-
# TODO: remove this once Phlex adds support for SafeValues
|
60
|
-
Phlex::HTML.const_set(:EVENT_ATTRIBUTES, original_attributes)
|
61
53
|
end
|
62
54
|
|
63
55
|
def select_classes
|
data/lib/plutonium/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: plutonium
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.23.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan Froelich
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-05-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: zeitwerk
|
@@ -156,14 +156,14 @@ dependencies:
|
|
156
156
|
requirements:
|
157
157
|
- - "~>"
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version: '
|
159
|
+
version: '2.0'
|
160
160
|
type: :runtime
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
164
|
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
|
-
version: '
|
166
|
+
version: '2.0'
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
168
|
name: phlex-rails
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -192,62 +192,76 @@ dependencies:
|
|
192
192
|
- - ">="
|
193
193
|
- !ruby/object:Gem::Version
|
194
194
|
version: '0'
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: phlexi-field
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - "~>"
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: 0.2.0
|
202
|
+
type: :runtime
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - "~>"
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: 0.2.0
|
195
209
|
- !ruby/object:Gem::Dependency
|
196
210
|
name: phlexi-form
|
197
211
|
requirement: !ruby/object:Gem::Requirement
|
198
212
|
requirements:
|
199
|
-
- - "
|
213
|
+
- - "~>"
|
200
214
|
- !ruby/object:Gem::Version
|
201
|
-
version:
|
215
|
+
version: 0.10.0
|
202
216
|
type: :runtime
|
203
217
|
prerelease: false
|
204
218
|
version_requirements: !ruby/object:Gem::Requirement
|
205
219
|
requirements:
|
206
|
-
- - "
|
220
|
+
- - "~>"
|
207
221
|
- !ruby/object:Gem::Version
|
208
|
-
version:
|
222
|
+
version: 0.10.0
|
209
223
|
- !ruby/object:Gem::Dependency
|
210
224
|
name: phlexi-table
|
211
225
|
requirement: !ruby/object:Gem::Requirement
|
212
226
|
requirements:
|
213
|
-
- - "
|
227
|
+
- - "~>"
|
214
228
|
- !ruby/object:Gem::Version
|
215
|
-
version:
|
229
|
+
version: 0.2.0
|
216
230
|
type: :runtime
|
217
231
|
prerelease: false
|
218
232
|
version_requirements: !ruby/object:Gem::Requirement
|
219
233
|
requirements:
|
220
|
-
- - "
|
234
|
+
- - "~>"
|
221
235
|
- !ruby/object:Gem::Version
|
222
|
-
version:
|
236
|
+
version: 0.2.0
|
223
237
|
- !ruby/object:Gem::Dependency
|
224
238
|
name: phlexi-display
|
225
239
|
requirement: !ruby/object:Gem::Requirement
|
226
240
|
requirements:
|
227
|
-
- - "
|
241
|
+
- - "~>"
|
228
242
|
- !ruby/object:Gem::Version
|
229
|
-
version:
|
243
|
+
version: 0.2.0
|
230
244
|
type: :runtime
|
231
245
|
prerelease: false
|
232
246
|
version_requirements: !ruby/object:Gem::Requirement
|
233
247
|
requirements:
|
234
|
-
- - "
|
248
|
+
- - "~>"
|
235
249
|
- !ruby/object:Gem::Version
|
236
|
-
version:
|
250
|
+
version: 0.2.0
|
237
251
|
- !ruby/object:Gem::Dependency
|
238
252
|
name: phlexi-menu
|
239
253
|
requirement: !ruby/object:Gem::Requirement
|
240
254
|
requirements:
|
241
|
-
- - "
|
255
|
+
- - "~>"
|
242
256
|
- !ruby/object:Gem::Version
|
243
|
-
version:
|
257
|
+
version: 0.4.0
|
244
258
|
type: :runtime
|
245
259
|
prerelease: false
|
246
260
|
version_requirements: !ruby/object:Gem::Requirement
|
247
261
|
requirements:
|
248
|
-
- - "
|
262
|
+
- - "~>"
|
249
263
|
- !ruby/object:Gem::Version
|
250
|
-
version:
|
264
|
+
version: 0.4.0
|
251
265
|
- !ruby/object:Gem::Dependency
|
252
266
|
name: tailwind_merge
|
253
267
|
requirement: !ruby/object:Gem::Requirement
|
@@ -811,6 +825,7 @@ files:
|
|
811
825
|
- lib/plutonium/ui/component/behaviour.rb
|
812
826
|
- lib/plutonium/ui/component/kit.rb
|
813
827
|
- lib/plutonium/ui/component/methods.rb
|
828
|
+
- lib/plutonium/ui/component/tokens.rb
|
814
829
|
- lib/plutonium/ui/display/base.rb
|
815
830
|
- lib/plutonium/ui/display/components/association.rb
|
816
831
|
- lib/plutonium/ui/display/components/attachment.rb
|