avo 3.5.0 → 3.5.1

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: cff3e9f78fc82e1a9a80221261f1aa29fec6f2efc670d590d8837c5a9224e1af
4
- data.tar.gz: fd5fb058686183dd40daeeaf5a112648e4a6162668056ce871ced723a1471fc6
3
+ metadata.gz: 9baf34b45ec14d817690a0c2a48fc25132b1cce6b80e8b1542b082325d1af656
4
+ data.tar.gz: f49d287883c66fa87c5ef3cc0be4f307c79ffead8737e25e24bc707ce15d3b2c
5
5
  SHA512:
6
- metadata.gz: 89b46f1776ec508ca2f11343dfeb77cce80863ffbf984f4535281a22f5fa129721b819abaeca0fc3c83a95121aed822f27ef78abbe43326a13bb6d23b3e175bf
7
- data.tar.gz: 18e81a302f60c0eac7717d62e71cb6a18bcceb6108a3b60bacd92ec17b5c2b99fe898453759213abcf52be79d6212f34483697a98ec1b25aaf1ad6cf560359c6
6
+ metadata.gz: debc97692363a7d08ea51571350fea336c9f5201b343e8d2a15e936dbd99685b7b96fb4b74079348846a650eb177a7a008adb1dbebd61140140bd25acfc54704
7
+ data.tar.gz: 150853cce487de3315d29a66d8f09b837263c4277e7b86c32cc09951e12824e3ed67e9e1adb1d851ac47730199b1c7355a3a333465d5d48ee941476f56b66551
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- avo (3.5.0)
4
+ avo (3.5.1)
5
5
  actionview (>= 6.1)
6
6
  active_link_to
7
7
  activerecord (>= 6.1)
@@ -177,24 +177,27 @@ module Avo
177
177
  end
178
178
 
179
179
  def name
180
- default = class_name.underscore.humanize
181
-
182
- if translation_key
183
- t(translation_key, count: 1, default: default).humanize
184
- else
185
- default
186
- end
180
+ name_from_translation_key(count: 1, default: class_name.underscore.humanize)
187
181
  end
188
182
  alias_method :singular_name, :name
189
183
 
190
184
  def plural_name
191
- default = name.pluralize
192
-
193
- if translation_key
194
- t(translation_key, count: 2, default: default).humanize
195
- else
196
- default
197
- end
185
+ name_from_translation_key(count: 2, default: name.pluralize)
186
+ end
187
+
188
+ # Get the name from the translation_key and fallback to default
189
+ # It can raise I18n::InvalidPluralizationData when using only resource_translation without pluralization keys like: one, two or other key
190
+ # Example:
191
+ # ---
192
+ # en:
193
+ # avo:
194
+ # resource_translations:
195
+ # product:
196
+ # save: "Save product"
197
+ def name_from_translation_key(count:, default:)
198
+ t(translation_key, count:, default:).humanize
199
+ rescue I18n::InvalidPluralizationData
200
+ default
198
201
  end
199
202
 
200
203
  def underscore_name
@@ -16,7 +16,7 @@ module Avo
16
16
  end
17
17
 
18
18
  def render_edit_controls
19
- [BackButton.new(label: I18n.t("avo.cancel").capitalize), DeleteButton.new, ActionsList.new, SaveButton.new]
19
+ [BackButton.new(label: I18n.t("avo.cancel").capitalize), DeleteButton.new, ActionsList.new, SaveButton.new(resource: self)]
20
20
  end
21
21
 
22
22
  def render_index_controls(item:)
@@ -5,7 +5,10 @@ module Avo
5
5
  def initialize(**args)
6
6
  super(**args)
7
7
 
8
- @label = args[:label] || I18n.t("avo.save").capitalize
8
+ @label = args[:label] || I18n.t(
9
+ "#{args[:resource].translation_key}.save",
10
+ default: I18n.t("avo.save")
11
+ ).capitalize
9
12
  end
10
13
  end
11
14
  end
data/lib/avo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Avo
2
- VERSION = "3.5.0" unless const_defined?(:VERSION)
2
+ VERSION = "3.5.1" unless const_defined?(:VERSION)
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avo
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.0
4
+ version: 3.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrian Marin
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2024-03-13 00:00:00.000000000 Z
13
+ date: 2024-03-14 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord