easy-admin-rails 0.1.1 → 0.1.4
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/controllers/easy_admin/resources_controller.rb +13 -3
- data/config/initializers/rack_mini_profiler.rb +2 -3
- data/lib/easy_admin/configuration.rb +3 -2
- data/lib/easy_admin/resource.rb +19 -3
- data/lib/easy_admin/resource_registry.rb +1 -1
- data/lib/easy_admin/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4c904c62f1b45ea08ee47e01988ac1ee43dce828b5182b88c3dc4025460e317b
|
4
|
+
data.tar.gz: e1fb21c582cd54eaedd8bbf25a62b9bdfe92d5b5e9b0167094d7b7e790e7227a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: afb7da1a4049b97669797fdf865a05de60d78a5df4f5c1dd85389f69dc2c0bc1c3e0313abb05c57c7d7e6ca542afc49cef1fe9143b9131d5dc3935969d5973a1
|
7
|
+
data.tar.gz: 5b75b26c35a4b5ea84e7085247ea1c321c333badc67b32863c338c8681b4e560e18f418375fb417881153c5df39677570572d9163b8be7688bf3c973abdee916
|
@@ -469,9 +469,19 @@ module EasyAdmin
|
|
469
469
|
|
470
470
|
def record_params
|
471
471
|
permitted_attrs = get_permitted_attributes(@resource_class)
|
472
|
-
|
473
|
-
|
474
|
-
|
472
|
+
|
473
|
+
# Try resource param_key first, then fall back to model's natural param key
|
474
|
+
param_key = if params.key?(@resource_class.param_key)
|
475
|
+
@resource_class.param_key
|
476
|
+
elsif params.key?(@resource_class.model_class.model_name.param_key)
|
477
|
+
@resource_class.model_class.model_name.param_key
|
478
|
+
else
|
479
|
+
# Handle namespaced models that use slash format (e.g., "catalog/payment_method")
|
480
|
+
namespaced_param_key = @resource_class.model_class.name.underscore
|
481
|
+
params.key?(namespaced_param_key) ? namespaced_param_key : @resource_class.param_key
|
482
|
+
end
|
483
|
+
|
484
|
+
result = params.require(param_key).permit(*permitted_attrs)
|
475
485
|
result
|
476
486
|
end
|
477
487
|
|
@@ -32,9 +32,8 @@ if defined?(Rack::MiniProfiler)
|
|
32
32
|
# Show SQL queries by default
|
33
33
|
config.enable_advanced_debugging_tools = true
|
34
34
|
|
35
|
-
# Storage (use
|
36
|
-
config.storage = Rack::MiniProfiler::
|
37
|
-
config.storage_options = { path: Rails.root.join('tmp', 'miniprofiler') }
|
35
|
+
# Storage (use memory storage to avoid file path issues)
|
36
|
+
config.storage = Rack::MiniProfiler::MemoryStore
|
38
37
|
|
39
38
|
# Only profile requests that take longer than this (in milliseconds)
|
40
39
|
config.flamegraph_sample_rate = 0.5
|
@@ -24,12 +24,13 @@ module EasyAdmin
|
|
24
24
|
@current_group = nil
|
25
25
|
end
|
26
26
|
|
27
|
-
def item(label, path = nil, icon: nil, active: false, &block)
|
27
|
+
def item(label, path = nil, icon: nil, active: false, resource: nil, &block)
|
28
28
|
item_config = {
|
29
29
|
label: label,
|
30
30
|
path: path,
|
31
31
|
icon: icon,
|
32
|
-
active: active
|
32
|
+
active: active,
|
33
|
+
resource: resource
|
33
34
|
}
|
34
35
|
|
35
36
|
if block_given?
|
data/lib/easy_admin/resource.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module EasyAdmin
|
2
2
|
class Resource
|
3
|
-
class_attribute :model_class_name, :resource_name, :fields_config, :form_tabs_config, :show_layout_config, :scopes_config, :pagination_config, :includes_config, :batch_actions_config, :batch_actions_enabled, :row_actions_config
|
3
|
+
class_attribute :model_class_name, :resource_name, :fields_config, :form_tabs_config, :show_layout_config, :scopes_config, :pagination_config, :includes_config, :batch_actions_config, :batch_actions_enabled, :row_actions_config, :custom_title
|
4
4
|
|
5
5
|
def self.inherited(subclass)
|
6
6
|
super
|
@@ -28,6 +28,16 @@ module EasyAdmin
|
|
28
28
|
EasyAdmin::ResourceRegistry.register(subclass)
|
29
29
|
end
|
30
30
|
|
31
|
+
# DSL for setting custom model name
|
32
|
+
def self.model(model_name)
|
33
|
+
self.model_class_name = model_name.to_s
|
34
|
+
end
|
35
|
+
|
36
|
+
# DSL for setting custom title
|
37
|
+
def self.resource_title(title_name)
|
38
|
+
self.custom_title = title_name.to_s
|
39
|
+
end
|
40
|
+
|
31
41
|
# DSL for defining fields
|
32
42
|
def self.field(name, type = :string, **options)
|
33
43
|
self.fields_config += [{
|
@@ -164,11 +174,13 @@ module EasyAdmin
|
|
164
174
|
|
165
175
|
# Get resource title/name
|
166
176
|
def self.title
|
167
|
-
|
177
|
+
return custom_title.pluralize if custom_title.present?
|
178
|
+
resource_name.underscore.humanize.pluralize
|
168
179
|
end
|
169
180
|
|
170
181
|
def self.singular_title
|
171
|
-
|
182
|
+
return custom_title.singularize if custom_title.present?
|
183
|
+
resource_name.underscore.humanize
|
172
184
|
end
|
173
185
|
|
174
186
|
# Get fields for different contexts
|
@@ -363,6 +375,10 @@ module EasyAdmin
|
|
363
375
|
def file_field(name, **options)
|
364
376
|
field(name, :file, **options)
|
365
377
|
end
|
378
|
+
|
379
|
+
def json_field(name, **options)
|
380
|
+
field(name, :json, **options)
|
381
|
+
end
|
366
382
|
end
|
367
383
|
|
368
384
|
class ShowBuilder
|
@@ -3,7 +3,7 @@ module EasyAdmin
|
|
3
3
|
@@resources = {}
|
4
4
|
|
5
5
|
def self.register(resource_class)
|
6
|
-
route_key = resource_class.name.demodulize.gsub(/Resource$/, '').
|
6
|
+
route_key = resource_class.name.demodulize.gsub(/Resource$/, '').underscore.pluralize
|
7
7
|
@@resources[route_key] = resource_class
|
8
8
|
end
|
9
9
|
|
data/lib/easy_admin/version.rb
CHANGED