effective_resources 2.8.6 → 2.8.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 178c1c488f5f0118f506ae2979fedcac5beece6f9e8c6b9051f4670d4d94b8c9
4
- data.tar.gz: f5094d84a7c321db0086686627660cbd7d01785f7eb4bbf256bf805fd5278f59
3
+ metadata.gz: a583a70685ae3faf4811c49e750ae55c05aec5af0ed3f061662c80723575a2c9
4
+ data.tar.gz: acb81962352988b990db0d8b95ba4430d02bfad1bf04946d5724753bf10454ad
5
5
  SHA512:
6
- metadata.gz: 23e8f14788360f1e6153e3801ae8491e4b71b1782a7554d64cb1e4c2de5bb39434746520f4bfc61a626ced18e1c0740b9c485aa8a8cfb72ed33bab3f3a005a8e
7
- data.tar.gz: 170af0cb87afef70caccc3fcbfc5c4df52b59e4bd0dae3f71bef4688c6cd0e32b83ba69f909e08d57e488ea29839b35edb86f8917251d40bf9c3f6a26a6416f2
6
+ metadata.gz: 60bb0ff5c80356b24770eb98d9787a9a975368edf7fa3be6c5cd700c7937e3fce7a6ad1a5d8cf8670184c0b5feeaf0dd98577989948b5292a7f3f4fe09c3ed97
7
+ data.tar.gz: 1aa740c85b5a07a900e9cc68f97f38dfe0c57b1ca1fbfecf43f34a2b9be2aba8571e84d989a99957c319d33b437da061e56744999d49213d4a9dddf3795f30f4
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2019 Code and Effect Inc.
1
+ Copyright 2024 Code and Effect Inc.
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -19,9 +19,16 @@ module Effective
19
19
 
20
20
  self.resource ||= resource_scope.new
21
21
 
22
+ # Assign attributes from the query string
22
23
  to_assign = if view_context.respond_to?(:inline_datatable?) && view_context.inline_datatable?
23
24
  EffectiveDatatables.find(params[:_datatable_id], params[:_datatable_attributes]).attributes
24
- elsif params.present?
25
+ end
26
+
27
+ to_assign ||= if params[resource_name].present? && params[resource_name].respond_to?(:to_unsafe_h)
28
+ params[resource_name].to_unsafe_h
29
+ end
30
+
31
+ to_assign ||= if params.present?
25
32
  params.to_unsafe_h.except(:controller, :action, :id, :duplicate_id)
26
33
  end
27
34
 
@@ -5,8 +5,10 @@ module Effective
5
5
  module I18n
6
6
  def human_action_name(action)
7
7
  if klass.respond_to?(:model_name)
8
- value = ::I18n.t("activerecord.actions.#{klass.model_name.i18n_key}.#{action}")
9
- return value unless value.start_with?('translation missing:')
8
+ key = "activerecord.actions.#{klass.model_name.i18n_key}.#{action}"
9
+
10
+ value = ::I18n.t(key)
11
+ return value unless value.include?(key) # missing translation
10
12
  end
11
13
 
12
14
  if crud_actions.include?(action)
@@ -19,8 +21,10 @@ module Effective
19
21
 
20
22
  def human_action_confirm(action)
21
23
  if klass.respond_to?(:model_name)
22
- value = ::I18n.t("activerecord.actions.#{klass.model_name.i18n_key}.#{action}_confirm")
23
- return value unless value.start_with?('translation missing:')
24
+ key = "activerecord.actions.#{klass.model_name.i18n_key}.#{action}_confirm"
25
+
26
+ value = ::I18n.t(key)
27
+ return value unless value.include?(key) # missing translation
24
28
  end
25
29
 
26
30
  "Really #{human_action_name(action)} @resource?"
@@ -1,3 +1,3 @@
1
1
  module EffectiveResources
2
- VERSION = '2.8.6'.freeze
2
+ VERSION = '2.8.8'.freeze
3
3
  end
@@ -180,12 +180,13 @@ module EffectiveResources
180
180
  end
181
181
  end
182
182
 
183
+ # effective_translate
183
184
  def self.et(resource, attribute = nil)
184
185
  if resource.respond_to?(:datatable_name)
185
186
  resource.datatable_name
186
- elsif resource.respond_to?(:model_name) == false
187
+ elsif resource.respond_to?(:model_name) == false # Just a string. Fees will do this
187
188
  value = I18n.t(resource)
188
- raise("Missing translation: #{resource}") if value.start_with?('translation missing:')
189
+ raise StandardError.new("Missing translation: #{resource}") if value.include?(resource)
189
190
  value
190
191
  elsif attribute.blank?
191
192
  resource.model_name.human
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_resources
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.8.6
4
+ version: 2.8.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-07 00:00:00.000000000 Z
11
+ date: 2023-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails