katalyst-tables 3.4.4 → 3.4.5

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: 4dc2698abbad7fb7b3f49ead09af73c697bdef0f31371c6b2c0c69478ab0df5f
4
- data.tar.gz: dea2e28dfed3ce6c39ccf61f607755915fa86e138f3ac59f55e926049c5ec34d
3
+ metadata.gz: dc68e986f0047e4a30844861ec4cf0222649fa9635ca59a466846862090033da
4
+ data.tar.gz: fc12160c9acca555b6d5041ef49170af9630e8f6e67f81d6bec32564105e963a
5
5
  SHA512:
6
- metadata.gz: 6ab5ffed559436e0ed73671445d653ab603e48be03f2099ae39e8b6e4bcbe2d2b503752dd2fa722b9673dbdc9a2309e52c45841dabbf6443f83a0e5dd9c57671
7
- data.tar.gz: 832a7746ba587a059810117e215c5dd2011604d92e8f1be63e8842dce1b8d15153f789a41834a0a912dc6410356abda2eaa63d0574ee8c4fb372c9456146c3a2
6
+ metadata.gz: 9d4334a6bb9b7edd4092ff131cc59a6e43ee9ce66c48c29c6aa5725585914da6c6b94e9e8cb9aa3babd8bcdaf35f24b3fc83f3d861f04e2a6294af6a8f8e3de0
7
+ data.tar.gz: 4a4a96c779a4ad08d0a5e1a4b415b465eb85a22b071d40321dd85f49856b372b63fd5a64ad41719a38d8bd282146eedb11982ca7821237f8ade93271b6de19d5
@@ -9,7 +9,11 @@
9
9
  small {
10
10
  background: var(--tag-color);
11
11
  border-radius: 0.25rem;
12
- padding: 0.25rem 0.5rem;
12
+ padding: 0.25rem;
13
13
  font-size: small;
14
14
  }
15
15
  }
16
+
17
+ table td.type-enum {
18
+ text-overflow: unset;
19
+ }
@@ -26,15 +26,30 @@ module Katalyst
26
26
  keys = keys.select { |key| key.include?(attribute.value_before_type_cast.last) }
27
27
  end
28
28
 
29
- keys.map { |key| example(key, describe_key(model, attribute.name, key)) }
29
+ keys.map { |key| example(key, describe_key(model, attribute, key)) }
30
30
  end
31
31
 
32
32
  private
33
33
 
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
+ def cast_value(value)
35
+ value.to_s
36
+ end
37
+
38
+ def describe_key(model, attribute, key)
39
+ label = model.human_attribute_name(attribute.name).downcase
40
+ value = model.human_attribute_name("#{attribute.name}.#{key}").downcase
41
+
42
+ description = "#{model.model_name.human} #{label} is #{value}"
43
+ description += " (default)" if default?(attribute, key)
44
+ description
45
+ end
46
+
47
+ def default?(attribute, value)
48
+ if multiple?
49
+ attribute.original_value&.intersection(cast(value))&.any?
50
+ else
51
+ attribute.default_value.eql?(cast(value))
52
+ end
38
53
  end
39
54
  end
40
55
  end
@@ -48,7 +48,10 @@ module Katalyst
48
48
  def examples_for(scope, attribute, limit: 10, order: :asc)
49
49
  scope, model, column = model_and_column_for(scope, attribute)
50
50
 
51
- return unless model.attribute_types.has_key?(column)
51
+ unless model.attribute_types.has_key?(column)
52
+ raise(ArgumentError, "Unknown column '#{column}' for #{model}. " \
53
+ "Consider defining '#{attribute.name.parameterize.underscore}_examples'")
54
+ end
52
55
 
53
56
  column = model.arel_table[column]
54
57
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: katalyst-tables
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.4
4
+ version: 3.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Katalyst Interactive