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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2e26eb141c7aa72e012ef8da05dec36206a4a1a622246618df646728f3836aad
4
- data.tar.gz: 2162c0f6c799b8f893aa97df1f9c6f87e9ac9a6745775bac2b98f9e7b30f9a1a
3
+ metadata.gz: 4c904c62f1b45ea08ee47e01988ac1ee43dce828b5182b88c3dc4025460e317b
4
+ data.tar.gz: e1fb21c582cd54eaedd8bbf25a62b9bdfe92d5b5e9b0167094d7b7e790e7227a
5
5
  SHA512:
6
- metadata.gz: cb9b5e61fdd9e1f6e46de7caf9eac86ccf05cfc4e56ffa8545da6efb557375af0ffeed7f9727cb004734ac659558a0da9d41c20702a952bd0c24b510bce27342
7
- data.tar.gz: 9c54fcf1359fbbfa66ce7305f967584e794f28a0e293fba5d1a643d8e72e130f746022dcf682ebc38515cc3e741ffb6bb19d564af5503d754f60a5032b2ab7d2
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
- Rails.logger.debug "Permitted attributes: #{permitted_attrs}"
473
- result = params.require(@resource_class.param_key).permit(*permitted_attrs)
474
- Rails.logger.debug "Record params after permit: #{result}"
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 file storage in development)
36
- config.storage = Rack::MiniProfiler::FileStore
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?
@@ -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
- resource_name.humanize.pluralize
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
- resource_name.humanize
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$/, '').downcase.pluralize
6
+ route_key = resource_class.name.demodulize.gsub(/Resource$/, '').underscore.pluralize
7
7
  @@resources[route_key] = resource_class
8
8
  end
9
9
 
@@ -1,3 +1,3 @@
1
1
  module EasyAdmin
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easy-admin-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Slaurmagan