katalyst-tables 3.4.3 → 3.4.4

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: 3759aa46548e98b88f6528c449ae5daff86785c9511a4637bbb17c692b3c7c04
4
- data.tar.gz: 3982b2749ec6c19b4a7deb279ebc78ef8415c04be64d5949d9730d55b0999474
3
+ metadata.gz: 4dc2698abbad7fb7b3f49ead09af73c697bdef0f31371c6b2c0c69478ab0df5f
4
+ data.tar.gz: dea2e28dfed3ce6c39ccf61f607755915fa86e138f3ac59f55e926049c5ec34d
5
5
  SHA512:
6
- metadata.gz: 550c46bcbfec02a42c019a6f52c9339f1fb0e0046ad1368c1c2651201fc7179fb92b9f40bbb2176be27e23fff49cd7910276ea44ce19338cc8500470cb97a3cd
7
- data.tar.gz: 7d56c07e0755a26d05a9b8dbe38b33f649a185ac4491961dc0130e29e5a2478860e9fb4625ddbf2844106297f13d2989e23f1d7f51a4a49e5e6d4bd9ddf8f52e
6
+ metadata.gz: 6ab5ffed559436e0ed73671445d653ab603e48be03f2099ae39e8b6e4bcbe2d2b503752dd2fa722b9673dbdc9a2309e52c45841dabbf6443f83a0e5dd9c57671
7
+ data.tar.gz: 832a7746ba587a059810117e215c5dd2011604d92e8f1be63e8842dce1b8d15153f789a41834a0a912dc6410356abda2eaa63d0574ee8c4fb372c9456146c3a2
@@ -7,7 +7,7 @@ module Katalyst
7
7
  class EnumComponent < CellComponent
8
8
  def rendered_value
9
9
  if (value = self.value).present?
10
- label = t(i18n_enum_label_key(value), default: value)
10
+ label = collection.model.human_attribute_name("#{column}.#{value}")
11
11
  content_tag(:small, label, data: { enum: column, value: })
12
12
  end
13
13
  end
@@ -17,10 +17,6 @@ module Katalyst
17
17
  def default_html_attributes
18
18
  { class: "type-enum" }
19
19
  end
20
-
21
- def i18n_enum_label_key(value)
22
- "active_record.attributes.#{collection.model_name.i18n_key}/#{column}.#{value}"
23
- end
24
20
  end
25
21
  end
26
22
  end
@@ -64,7 +64,14 @@ module Katalyst
64
64
  end
65
65
 
66
66
  def examples_for(key)
67
- collection.examples_for(key)&.reject { |e| e.value.to_s.blank? } || []
67
+ collection.examples_for(key).filter_map do |example|
68
+ case example
69
+ when Collection::Type::Example
70
+ example if example.value.to_s.present?
71
+ else
72
+ raise ArgumentError, "Invalid example #{example.inspect} for #{collection.model_name}.#{key}"
73
+ end
74
+ end
68
75
  end
69
76
 
70
77
  def format_value(value)
@@ -17,7 +17,10 @@ module Katalyst
17
17
 
18
18
  def examples_for(scope, attribute)
19
19
  _, model, column = model_and_column_for(scope, attribute)
20
- keys = model.defined_enums[column]&.keys
20
+
21
+ raise ArgumentError, "Unknown enum #{column} for #{model}" unless model.defined_enums.has_key?(column)
22
+
23
+ keys = model.defined_enums[column].keys
21
24
 
22
25
  if attribute.value_before_type_cast.present?
23
26
  keys = keys.select { |key| key.include?(attribute.value_before_type_cast.last) }
@@ -28,9 +31,10 @@ module Katalyst
28
31
 
29
32
  private
30
33
 
31
- def describe_key(model, attribute, key)
32
- key = I18n.t("active_record.attributes.#{model.model_name.i18n_key}/#{key}", default: key.to_s.titleize)
33
- "#{model.model_name.human} #{model.human_attribute_name(attribute).downcase} is #{key}"
34
+ def describe_key(model, name, key)
35
+ label = model.human_attribute_name(name).downcase
36
+ value = model.human_attribute_name("#{name}.#{key}").downcase
37
+ "#{model.model_name.human} #{label} is #{value}"
34
38
  end
35
39
  end
36
40
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: katalyst-tables
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.3
4
+ version: 3.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Katalyst Interactive
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-03 00:00:00.000000000 Z
11
+ date: 2024-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: katalyst-html-attributes