plutonium 0.15.5 → 0.15.6
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/app/assets/plutonium.css +1 -1
- data/app/assets/plutonium.ico +0 -0
- data/app/assets/plutonium.png +0 -0
- data/docs/.vitepress/config.ts +61 -0
- data/docs/.vitepress/theme/custom.css +61 -0
- data/docs/.vitepress/theme/index.ts +4 -0
- data/docs/api-examples.md +49 -0
- data/docs/guide/getting-started/authorization.md +296 -0
- data/docs/guide/getting-started/core-concepts.md +432 -0
- data/docs/guide/getting-started/index.md +18 -0
- data/docs/guide/getting-started/installation.md +269 -0
- data/docs/guide/getting-started/resources.md +254 -0
- data/docs/guide/what-is-plutonium.md +211 -0
- data/docs/index.md +43 -0
- data/docs/markdown-examples.md +85 -0
- data/docs/public/android-chrome-192x192.png +0 -0
- data/docs/public/android-chrome-512x512.png +0 -0
- data/docs/public/apple-touch-icon.png +0 -0
- data/docs/public/favicon-16x16.png +0 -0
- data/docs/public/favicon-32x32.png +0 -0
- data/docs/public/favicon.ico +0 -0
- data/docs/public/plutonium.png +0 -0
- data/docs/public/site.webmanifest +1 -0
- data/docs/public/templates/plutonium.rb +21 -0
- data/lib/generators/pu/core/assets/assets_generator.rb +2 -3
- data/lib/generators/pu/core/assets/templates/tailwind.config.js +2 -2
- data/lib/generators/pu/core/install/install_generator.rb +9 -1
- data/lib/generators/pu/core/install/templates/config/initializers/plutonium.rb +0 -1
- data/lib/plutonium/core/controllers/authorizable.rb +1 -1
- data/lib/plutonium/railtie.rb +0 -10
- data/lib/plutonium/resource/controllers/crud_actions.rb +1 -1
- data/lib/plutonium/resource/policy.rb +4 -5
- data/lib/plutonium/resource/register.rb +3 -0
- data/lib/plutonium/ui/action_button.rb +34 -19
- data/lib/plutonium/ui/form/resource.rb +2 -1
- data/lib/plutonium/ui/table/components/search_bar.rb +1 -1
- data/lib/plutonium/version.rb +1 -1
- data/package-lock.json +5767 -1851
- data/package.json +10 -4
- data/src/js/core.js +0 -1
- data/tailwind.options.js +89 -11
- metadata +27 -11
- data/app/assets/plutonium-original.png +0 -0
- data/app/assets/plutonium-white.png +0 -0
- data/public/plutonium-assets/fonts/bootstrap-icons.woff +0 -0
- data/public/plutonium-assets/fonts/bootstrap-icons.woff2 +0 -0
- /data/{templates → docs/public/templates}/base.rb +0 -0
@@ -9,7 +9,7 @@ module Plutonium
|
|
9
9
|
|
10
10
|
included do
|
11
11
|
authorize :user, through: :current_user
|
12
|
-
authorize :
|
12
|
+
authorize :entity_scope, through: :entity_scope_for_authorize
|
13
13
|
|
14
14
|
helper_method :policy_for, :authorized_resource_scope
|
15
15
|
end
|
data/lib/plutonium/railtie.rb
CHANGED
@@ -53,10 +53,6 @@ module Plutonium
|
|
53
53
|
extend_action_dispatch
|
54
54
|
end
|
55
55
|
|
56
|
-
initializer "plutonium.active_record_extensions" do
|
57
|
-
extend_active_record
|
58
|
-
end
|
59
|
-
|
60
56
|
initializer "plutonium.phlexi_themes" do
|
61
57
|
setup_phlexi_themes
|
62
58
|
end
|
@@ -114,11 +110,5 @@ module Plutonium
|
|
114
110
|
ActionDispatch::Routing::RouteSet.prepend Plutonium::Routing::RouteSetExtensions
|
115
111
|
Rails::Engine.include Plutonium::Routing::ResourceRegistration
|
116
112
|
end
|
117
|
-
|
118
|
-
def extend_active_record
|
119
|
-
ActiveSupport.on_load(:active_record) do
|
120
|
-
include Plutonium::Resource::Record
|
121
|
-
end
|
122
|
-
end
|
123
113
|
end
|
124
114
|
end
|
@@ -7,13 +7,12 @@ module Plutonium
|
|
7
7
|
# and to retrieve permitted attributes for these actions.
|
8
8
|
class Policy < ActionPolicy::Base
|
9
9
|
authorize :user, allow_nil: false
|
10
|
-
authorize :
|
10
|
+
authorize :entity_scope, allow_nil: true
|
11
11
|
|
12
12
|
relation_scope do |relation|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
relation
|
13
|
+
next relation unless entity_scope
|
14
|
+
|
15
|
+
relation.associated_with(entity_scope)
|
17
16
|
end
|
18
17
|
|
19
18
|
# Sends a method and raises an error if the method is not implemented.
|
@@ -21,6 +21,9 @@ module Plutonium
|
|
21
21
|
# @return [void]
|
22
22
|
def register(resource)
|
23
23
|
raise FrozenRegisterError, "Cannot modify frozen resource register" if @frozen
|
24
|
+
unless resource.include?(Plutonium::Resource::Record)
|
25
|
+
raise ArgumentError, "#{resource} must include Plutonium::Resource::Record before being registered"
|
26
|
+
end
|
24
27
|
|
25
28
|
@resources.add(resource.to_s)
|
26
29
|
end
|
@@ -80,7 +80,7 @@ module Plutonium
|
|
80
80
|
if @variant == :table
|
81
81
|
"h-4 w-4 mr-1"
|
82
82
|
else
|
83
|
-
"h-3.5 w-3.5
|
83
|
+
"h-3.5 w-3.5 -ml-1"
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
@@ -91,35 +91,50 @@ module Plutonium
|
|
91
91
|
def color_classes
|
92
92
|
case @action.color || @action.category.to_sym
|
93
93
|
when :primary
|
94
|
-
|
95
|
-
"bg-primary-
|
96
|
-
"bg-primary-
|
94
|
+
variant_class(
|
95
|
+
"bg-primary-700 text-white hover:bg-primary-800 focus:ring-primary-300 dark:bg-primary-600 dark:hover:bg-primary-700 dark:focus:ring-primary-800",
|
96
|
+
table: "bg-primary-100 text-primary-700 hover:bg-primary-200 focus:ring-primary-300 dark:bg-primary-700 dark:text-primary-100 dark:hover:bg-primary-600 dark:focus:ring-primary-600"
|
97
|
+
)
|
98
|
+
when :success
|
99
|
+
variant_class(
|
100
|
+
"bg-success-700 text-white hover:bg-success-800 focus:ring-success-300 dark:bg-success-600 dark:hover:bg-success-700 dark:focus:ring-success-800",
|
101
|
+
table: "bg-success-100 text-success-700 hover:bg-success-200 focus:ring-success-300 dark:bg-success-700 dark:text-success-100 dark:hover:bg-success-600 dark:focus:ring-success-600"
|
102
|
+
)
|
103
|
+
when :info
|
104
|
+
variant_class(
|
105
|
+
"bg-info-700 text-white hover:bg-info-800 focus:ring-info-300 dark:bg-info-600 dark:hover:bg-info-700 dark:focus:ring-info-800",
|
106
|
+
table: "bg-info-100 text-info-700 hover:bg-info-200 focus:ring-info-300 dark:bg-info-700 dark:text-info-100 dark:hover:bg-info-600 dark:focus:ring-info-600"
|
97
107
|
)
|
98
108
|
when :warning
|
99
|
-
|
100
|
-
"bg-
|
101
|
-
"bg-
|
109
|
+
variant_class(
|
110
|
+
"bg-warning-700 text-white hover:bg-warning-800 focus:ring-warning-300 dark:bg-warning-600 dark:hover:bg-warning-700 dark:focus:ring-warning-800",
|
111
|
+
table: "bg-warning-100 text-warning-700 hover:bg-warning-200 focus:ring-warning-300 dark:bg-warning-700 dark:text-warning-100 dark:hover:bg-warning-600 dark:focus:ring-warning-600"
|
102
112
|
)
|
103
113
|
when :danger
|
104
|
-
|
105
|
-
"bg-
|
106
|
-
"bg-
|
114
|
+
variant_class(
|
115
|
+
"bg-danger-700 text-white hover:bg-danger-800 focus:ring-danger-300 dark:bg-danger-600 dark:hover:bg-danger-700 dark:focus:ring-danger-800",
|
116
|
+
table: "bg-danger-100 text-danger-700 hover:bg-danger-200 focus:ring-danger-300 dark:bg-danger-700 dark:text-danger-100 dark:hover:bg-danger-600 dark:focus:ring-danger-600"
|
107
117
|
)
|
108
|
-
when :
|
109
|
-
|
110
|
-
"bg-
|
111
|
-
"bg-
|
118
|
+
when :accent
|
119
|
+
variant_class(
|
120
|
+
"bg-accent-700 text-white hover:bg-accent-800 focus:ring-accent-300 dark:bg-accent-600 dark:hover:bg-accent-700 dark:focus:ring-accent-800",
|
121
|
+
table: "bg-accent-100 text-accent-700 hover:bg-accent-200 focus:ring-accent-300 dark:bg-accent-700 dark:text-accent-100 dark:hover:bg-accent-600 dark:focus:ring-accent-600"
|
112
122
|
)
|
113
123
|
else
|
114
|
-
|
115
|
-
"bg-
|
116
|
-
"
|
124
|
+
variant_class(
|
125
|
+
"bg-secondary-700 text-white hover:bg-secondary-800 focus:ring-secondary-300 dark:bg-secondary-600 dark:hover:bg-secondary-700 dark:focus:ring-secondary-800",
|
126
|
+
table: "bg-secondary-100 text-secondary-700 hover:bg-secondary-200 focus:ring-secondary-300 dark:bg-secondary-700 dark:text-secondary-100 dark:hover:bg-secondary-600 dark:focus:ring-secondary-600"
|
117
127
|
)
|
118
128
|
end
|
119
129
|
end
|
120
130
|
|
121
|
-
def
|
122
|
-
|
131
|
+
def variant_class(default, table:)
|
132
|
+
case @variant
|
133
|
+
when :table
|
134
|
+
table
|
135
|
+
else
|
136
|
+
default
|
137
|
+
end
|
123
138
|
end
|
124
139
|
end
|
125
140
|
end
|
@@ -57,11 +57,12 @@ module Plutonium
|
|
57
57
|
|
58
58
|
field_options = field_options.except(:as)
|
59
59
|
wrapper_options = input_options.except(:tag, :as)
|
60
|
-
if !wrapper_options[:class] || wrapper_options[:class].include?("col-span")
|
60
|
+
if !wrapper_options[:class] || !wrapper_options[:class].include?("col-span")
|
61
61
|
# temp hack to allow col span overrides
|
62
62
|
# TODO: remove once we complete theming, which will support merges
|
63
63
|
wrapper_options[:class] = tokens("col-span-full", wrapper_options[:class])
|
64
64
|
end
|
65
|
+
|
65
66
|
render field(name, **field_options).wrapped(**wrapper_options) do |f|
|
66
67
|
render tag_block.call(f)
|
67
68
|
end
|
@@ -16,7 +16,7 @@ module Plutonium
|
|
16
16
|
private
|
17
17
|
|
18
18
|
def render?
|
19
|
-
current_query_object.filter_definitions.present? && current_policy.allowed_to?(:search?)
|
19
|
+
(current_query_object.search_filter.present? || current_query_object.filter_definitions.present?) && current_policy.allowed_to?(:search?)
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
data/lib/plutonium/version.rb
CHANGED