plutonium 0.20.0 → 0.20.3
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/generators/pu/core/assets/templates/tailwind.config.js +2 -2
- data/lib/plutonium/action/base.rb +3 -0
- data/lib/plutonium/core/controller.rb +28 -1
- data/lib/plutonium/lib/bit_flags.rb +13 -0
- data/lib/plutonium/ui/component/methods.rb +1 -0
- data/lib/plutonium/ui/page_header.rb +2 -1
- data/lib/plutonium/ui/table/resource.rb +2 -9
- data/lib/plutonium/version.rb +1 -1
- data/src/css/plutonium.css +0 -2
- data/src/css/plutonium.entry.css +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 545bfd12db25550638b5a2e1bd63f238490416df72cb799385561c28792684a4
|
4
|
+
data.tar.gz: 8658bb44139a602f1b8adcd66a888ee4c98a708bcec45e6aafc4afea328438e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0e4767510da8df48a19ad7450c377afa7b138b32dc04bdbc5de076d0600555b5a811df2b9161b5cede2b2ffad03c8ffd5faf3512cbaabfafc537e5abf9691dd
|
7
|
+
data.tar.gz: 48205cfc48b3ecac7b073ccd05629f839489ae9a923a1f79961a9cf1cf863b8c6e3b74344e6418ec9bd67b2dfed6a8673bf5768d755d3af28b1d287282e58440
|
@@ -18,13 +18,13 @@ module.exports = {
|
|
18
18
|
}
|
19
19
|
})),
|
20
20
|
theme: plutoniumTailwindConfig.merge(
|
21
|
+
plutoniumTailwindConfig.theme,
|
21
22
|
{
|
23
|
+
// define your custom theme here
|
22
24
|
},
|
23
|
-
plutoniumTailwindConfig.theme
|
24
25
|
),
|
25
26
|
content: [
|
26
27
|
`${__dirname}/app/**/*.{erb,haml,html,slim,rb}`,
|
27
|
-
`${__dirname}/app/assets/stylesheets/**/*.css`,
|
28
28
|
`${__dirname}/app/javascript/**/*.js`,
|
29
29
|
`${__dirname}/packages/**/app/**/*.{erb,haml,html,slim,rb}`,
|
30
30
|
].concat(plutoniumTailwindConfig.content),
|
@@ -17,7 +17,7 @@ module Plutonium
|
|
17
17
|
|
18
18
|
helper Plutonium::Helpers
|
19
19
|
helper_method :make_page_title, :resource_url_for,
|
20
|
-
:resource_url_args_for, :root_path, :app_name
|
20
|
+
:resource_url_args_for, :root_path, :app_name, :route_options_to_url
|
21
21
|
|
22
22
|
append_view_path File.expand_path("app/views", Plutonium.root)
|
23
23
|
layout -> { turbo_frame_request? ? false : "resource" }
|
@@ -111,6 +111,33 @@ module Plutonium
|
|
111
111
|
def registered_resources
|
112
112
|
current_engine.resource_register.resources
|
113
113
|
end
|
114
|
+
|
115
|
+
# Converts RouteOptions into a URL using the appropriate URL resolver.
|
116
|
+
#
|
117
|
+
# This method takes a RouteOptions object and generates a URL based on the url_resolver
|
118
|
+
# specified within the RouteOptions. It supports different resolution strategies:
|
119
|
+
# - If the route_options responds to :to_proc, executes it as a Proc in the current instance context
|
120
|
+
# - For :resource_url_for resolver, generates a URL using the provided subject
|
121
|
+
# - For :url_for resolver, generates a URL using only the url_options from route_options
|
122
|
+
#
|
123
|
+
# @param [RouteOptions, #to_proc] route_options The RouteOptions object or callable to convert to a URL
|
124
|
+
# @param [Object] subject The subject to use when generating URLs with :resource_url_for
|
125
|
+
# @return [String] The generated URL
|
126
|
+
# @raise [NotImplementedError] If an unsupported url_resolver is specified
|
127
|
+
def route_options_to_url(route_options, subject = nil)
|
128
|
+
url_resolver = route_options.url_resolver
|
129
|
+
|
130
|
+
if url_resolver == :resource_url_for
|
131
|
+
raise ArgumentError, "subject is required when url_resolver is: :resource_url_for" unless subject
|
132
|
+
resource_url_for(subject, *route_options.url_args, **route_options.url_options)
|
133
|
+
elsif url_resolver == :url_for
|
134
|
+
url_for(**route_options.url_options)
|
135
|
+
elsif url_resolver.respond_to?(:to_proc)
|
136
|
+
instance_exec(subject, &url_resolver)
|
137
|
+
else
|
138
|
+
raise NotImplementedError, "url_resolver: #{url_resolver}"
|
139
|
+
end
|
140
|
+
end
|
114
141
|
end
|
115
142
|
end
|
116
143
|
end
|
@@ -44,6 +44,19 @@ module Plutonium
|
|
44
44
|
value & check == check
|
45
45
|
end
|
46
46
|
|
47
|
+
# Sets the specified flags in the given value.
|
48
|
+
#
|
49
|
+
# @param value [Integer] The original value to modify.
|
50
|
+
# @param flags [Array<Symbol, String>] The flags to set.
|
51
|
+
# @return [Integer] A new value with the specified flags set.
|
52
|
+
# @example
|
53
|
+
# flags.set!(2, :read, :execute) # => 6
|
54
|
+
def set!(value, *flags)
|
55
|
+
normalized_flags = normalize_flags(flags)
|
56
|
+
bits_to_set = bits(*normalized_flags)
|
57
|
+
value | bits_to_set
|
58
|
+
end
|
59
|
+
|
47
60
|
# Extracts the flags that are set in the given value.
|
48
61
|
#
|
49
62
|
# @param value [Integer] The value to extract flags from.
|
@@ -40,7 +40,8 @@ module Plutonium
|
|
40
40
|
|
41
41
|
def render_actions
|
42
42
|
@actions.each do |action|
|
43
|
-
|
43
|
+
subject = resource_record? || resource_class
|
44
|
+
url = route_options_to_url(action.route_options, subject)
|
44
45
|
ActionButton(action, url:)
|
45
46
|
end
|
46
47
|
end
|
@@ -35,7 +35,7 @@ module Plutonium
|
|
35
35
|
EmptyCard("No #{resource_name_plural(resource_class)} match your query") {
|
36
36
|
action = resource_definition.defined_actions[:new]
|
37
37
|
if action&.permitted_by?(current_policy)
|
38
|
-
url =
|
38
|
+
url = route_options_to_url(action.route_options, resource_class)
|
39
39
|
ActionButton(action, url:)
|
40
40
|
end
|
41
41
|
}
|
@@ -85,14 +85,7 @@ module Plutonium
|
|
85
85
|
.select { |k, a| a.collection_record_action? && policy.allowed_to?(:"#{k}?") }
|
86
86
|
.values
|
87
87
|
.each do |action|
|
88
|
-
|
89
|
-
url = case action.route_options.url_resolver
|
90
|
-
when :resource_url_for
|
91
|
-
resource_url_for(record, *action.route_options.url_args, **action.route_options.url_options)
|
92
|
-
else
|
93
|
-
raise NotImplementedError, "url_resolver: #{action.route_options.url_resolver}"
|
94
|
-
end
|
95
|
-
|
88
|
+
url = route_options_to_url(action.route_options, record)
|
96
89
|
ActionButton(action, url:, variant: :table)
|
97
90
|
end
|
98
91
|
end
|
data/lib/plutonium/version.rb
CHANGED
data/src/css/plutonium.css
CHANGED
data/src/css/plutonium.entry.css
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.20.
|
4
|
+
version: 0.20.3
|
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-03-
|
11
|
+
date: 2025-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: zeitwerk
|