katalyst-tables 3.4.2 → 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: 9b072cb596f235569c734c00f85602d8942c30fdf7352e67a07a3d7ed0470964
4
- data.tar.gz: 40b3eb109d0b752b82ab86e7f9b8335c17f076d229286be6edce7afcc07533ec
3
+ metadata.gz: 4dc2698abbad7fb7b3f49ead09af73c697bdef0f31371c6b2c0c69478ab0df5f
4
+ data.tar.gz: dea2e28dfed3ce6c39ccf61f607755915fa86e138f3ac59f55e926049c5ec34d
5
5
  SHA512:
6
- metadata.gz: dbd90a0224464a0961768428eac24df7b9242ca3805bddce60fbdb28fbcfb9e8271945ac623c478b655c502b115517dfc6609645eadccfa81c60f14bd2b35b7c
7
- data.tar.gz: d6f1697681c96fe1d9346e68044d799e95c6547e6936afddb396a5cd782e49890434696aaff9454aa32064960ba1e9af2bd4a84693145e5c3deb4c592d4d31d0
6
+ metadata.gz: 6ab5ffed559436e0ed73671445d653ab603e48be03f2099ae39e8b6e4bcbe2d2b503752dd2fa722b9673dbdc9a2309e52c45841dabbf6443f83a0e5dd9c57671
7
+ data.tar.gz: 832a7746ba587a059810117e215c5dd2011604d92e8f1be63e8842dce1b8d15153f789a41834a0a912dc6410356abda2eaa63d0574ee8c4fb372c9456146c3a2
@@ -72,8 +72,9 @@
72
72
  dl {
73
73
  display: grid;
74
74
  grid-auto-flow: row;
75
- grid-auto-rows: 1fr;
76
- grid-template-columns: 1fr 4fr;
75
+ grid-auto-rows: auto;
76
+ grid-template-columns: auto 1fr;
77
+ gap: 0 1rem;
77
78
  }
78
79
 
79
80
  dt {
@@ -85,11 +86,6 @@
85
86
  color: #666;
86
87
  }
87
88
 
88
- ul {
89
- list-style: none;
90
- padding-left: 0;
91
- }
92
-
93
89
  .error {
94
90
  background: #fff2f2;
95
91
  border-bottom: 1px solid #fdd3d3;
@@ -9,6 +9,7 @@ $row-border-color: $grey !default;
9
9
  $row-height: 48px !default;
10
10
  $cell-spacing: 0.5rem !default;
11
11
  $tag-color: $grey !default;
12
+ $on-tag-color: black !default;
12
13
 
13
14
  $width-small: 6rem !default;
14
15
  $width-medium: 12rem !default;
@@ -20,6 +21,7 @@ table {
20
21
  --table-header-color: #{$table-header-color};
21
22
  --row-border-color: #{$row-border-color};
22
23
  --tag-color: #{$tag-color};
24
+ --on-tag-color: #{$on-tag-color};
23
25
 
24
26
  --width-small: #{$width-small};
25
27
  --width-medium: #{$width-medium};
@@ -2,8 +2,14 @@
2
2
  width: var(--width-small);
3
3
  }
4
4
 
5
- :where(td.type-enum small) {
6
- background: var(--tag-color);
7
- border-radius: 0.25rem;
8
- padding: 0.25rem 0.5rem;
5
+ :where(td.type-enum) {
6
+ // ensure ellipsis is the correct color
7
+ color: var(--on-tag-color);
8
+
9
+ small {
10
+ background: var(--tag-color);
11
+ border-radius: 0.25rem;
12
+ padding: 0.25rem 0.5rem;
13
+ font-size: small;
14
+ }
9
15
  }
@@ -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)
@@ -24,7 +24,7 @@ module Katalyst
24
24
 
25
25
  def examples_for(scope, attribute)
26
26
  [
27
- *super(scope, attribute, limit: 6),
27
+ *super(scope, attribute, limit: 6, order: :desc),
28
28
  example(::Date.current.beginning_of_week.., "this week"),
29
29
  example(::Date.current.beginning_of_month.., "this month"),
30
30
  example(1.month.ago.all_month, "last month"),
@@ -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.2
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