katalyst-tables 3.3.1 → 3.3.3

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.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/app/assets/builds/katalyst/tables.esm.js +332 -6
  4. data/app/assets/builds/katalyst/tables.js +332 -6
  5. data/app/assets/builds/katalyst/tables.min.js +1 -1
  6. data/app/assets/builds/katalyst/tables.min.js.map +1 -1
  7. data/app/assets/stylesheets/katalyst/tables/_index.scss +1 -1
  8. data/app/assets/stylesheets/katalyst/tables/_query.scss +109 -0
  9. data/app/assets/stylesheets/katalyst/tables/typed-columns/_date.scss +1 -1
  10. data/app/assets/stylesheets/katalyst/tables/typed-columns/_datetime.scss +1 -1
  11. data/app/components/katalyst/table_component.rb +13 -2
  12. data/app/components/katalyst/tables/cells/currency_component.rb +21 -2
  13. data/app/components/katalyst/tables/cells/number_component.rb +31 -1
  14. data/app/components/katalyst/tables/query/input_component.html.erb +13 -0
  15. data/app/components/katalyst/tables/query/input_component.rb +50 -0
  16. data/app/components/katalyst/tables/query/modal_component.html.erb +33 -0
  17. data/app/components/katalyst/tables/query/modal_component.rb +89 -0
  18. data/app/components/katalyst/tables/query_component.html.erb +8 -0
  19. data/app/components/katalyst/tables/{filter_component.rb → query_component.rb} +37 -30
  20. data/app/controllers/concerns/katalyst/tables/backend.rb +14 -0
  21. data/app/helpers/katalyst/tables/frontend.rb +14 -8
  22. data/app/javascript/tables/application.js +8 -3
  23. data/app/javascript/tables/query_controller.js +108 -0
  24. data/app/javascript/tables/query_input_controller.js +228 -0
  25. data/app/models/concerns/katalyst/tables/collection/core.rb +2 -2
  26. data/app/models/concerns/katalyst/tables/collection/query/array_value_parser.rb +13 -26
  27. data/app/models/concerns/katalyst/tables/collection/query/parser.rb +16 -13
  28. data/app/models/concerns/katalyst/tables/collection/query/single_value_parser.rb +11 -3
  29. data/app/models/concerns/katalyst/tables/collection/query/value_parser.rb +10 -5
  30. data/app/models/concerns/katalyst/tables/collection/query.rb +42 -5
  31. data/app/models/concerns/katalyst/tables/collection/sorting.rb +11 -1
  32. data/app/models/katalyst/tables/collection/base.rb +10 -0
  33. data/app/models/katalyst/tables/collection/filter.rb +10 -0
  34. data/config/locales/tables.en.yml +2 -0
  35. data/{app/models → lib}/katalyst/tables/collection/type/boolean.rb +11 -1
  36. data/lib/katalyst/tables/collection/type/date.rb +57 -0
  37. data/lib/katalyst/tables/collection/type/enum.rb +32 -0
  38. data/lib/katalyst/tables/collection/type/float.rb +21 -0
  39. data/lib/katalyst/tables/collection/type/helpers/delegate.rb +32 -0
  40. data/{app/models → lib}/katalyst/tables/collection/type/helpers/extensions.rb +14 -0
  41. data/lib/katalyst/tables/collection/type/helpers/multiple.rb +60 -0
  42. data/lib/katalyst/tables/collection/type/helpers/range.rb +59 -0
  43. data/lib/katalyst/tables/collection/type/integer.rb +21 -0
  44. data/{app/models → lib}/katalyst/tables/collection/type/value.rb +22 -2
  45. data/{app/models → lib}/katalyst/tables/collection/type.rb +16 -0
  46. data/lib/katalyst/tables/collection.rb +11 -0
  47. data/lib/katalyst/tables.rb +6 -0
  48. metadata +26 -21
  49. data/app/assets/stylesheets/katalyst/tables/_filter.scss +0 -43
  50. data/app/components/katalyst/tables/filter/modal_component.html.erb +0 -25
  51. data/app/components/katalyst/tables/filter/modal_component.rb +0 -112
  52. data/app/components/katalyst/tables/filter_component.html.erb +0 -18
  53. data/app/javascript/tables/filter/modal_controller.js +0 -13
  54. data/app/models/katalyst/tables/collection/type/date.rb +0 -60
  55. data/app/models/katalyst/tables/collection/type/enum.rb +0 -21
  56. data/app/models/katalyst/tables/collection/type/float.rb +0 -57
  57. data/app/models/katalyst/tables/collection/type/helpers/delegate.rb +0 -50
  58. data/app/models/katalyst/tables/collection/type/helpers/multiple.rb +0 -30
  59. data/app/models/katalyst/tables/collection/type/integer.rb +0 -57
  60. /data/{app/models → lib}/katalyst/tables/collection/type/query.rb +0 -0
  61. /data/{app/models → lib}/katalyst/tables/collection/type/search.rb +0 -0
  62. /data/{app/models → lib}/katalyst/tables/collection/type/string.rb +0 -0
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Katalyst
4
- module Tables
5
- module Collection
6
- module Type
7
- class Enum < Value
8
- include Helpers::Multiple
9
-
10
- def initialize(multiple: true, **)
11
- super
12
- end
13
-
14
- def type
15
- :enum
16
- end
17
- end
18
- end
19
- end
20
- end
21
- end
@@ -1,57 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Katalyst
4
- module Tables
5
- module Collection
6
- module Type
7
- class Float < Value
8
- include Helpers::Delegate
9
- include Helpers::Multiple
10
-
11
- def initialize(**)
12
- super(**, delegate: ActiveModel::Type::Float)
13
- end
14
-
15
- def serialize(value)
16
- if value.is_a?(Range)
17
- if value.begin.nil?
18
- "<#{super(value.end)}"
19
- elsif value.end.nil?
20
- ">#{super(value.begin)}"
21
- else
22
- "#{super(value.begin)}..#{super(value.end)}"
23
- end
24
- else
25
- super
26
- end
27
- end
28
-
29
- private
30
-
31
- FLOAT = /(-?\d+(?:\.\d+)?)/
32
- SINGLE_VALUE = /\A#{FLOAT}\z/
33
- LOWER_BOUND = /\A>#{FLOAT}\z/
34
- UPPER_BOUND = /\A<#{FLOAT}\z/
35
- BOUNDED = /\A#{FLOAT}\.\.#{FLOAT}\z/
36
-
37
- def cast_value(value)
38
- case value
39
- when ::Range, ::Integer
40
- value
41
- when SINGLE_VALUE
42
- super($1)
43
- when LOWER_BOUND
44
- ((super($1))..)
45
- when UPPER_BOUND
46
- (..(super($1)))
47
- when BOUNDED
48
- ((super($1))..(super($2)))
49
- else
50
- super
51
- end
52
- end
53
- end
54
- end
55
- end
56
- end
57
- end
@@ -1,50 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Katalyst
4
- module Tables
5
- module Collection
6
- module Type
7
- module Helpers
8
- # Lifts a delegating type from value to arrays of values
9
- module Delegate
10
- delegate :type, to: :@delegate
11
-
12
- def initialize(delegate:, **arguments)
13
- super(**arguments)
14
-
15
- @delegate = delegate.new(**arguments.except(:filter, :multiple, :scope))
16
- end
17
-
18
- using Extensions
19
-
20
- def deserialize(value)
21
- if multiple? && value.is_a?(::Array)
22
- value.map { |v| @delegate.deserialize(v) }
23
- else
24
- @delegate.deserialize(value)
25
- end
26
- end
27
-
28
- def serialize(value)
29
- if multiple? && value.is_a?(::Array)
30
- value.map { |v| @delegate.serialize(v) }
31
- else
32
- @delegate.serialize(value)
33
- end
34
- end
35
-
36
- private
37
-
38
- def cast_value(value)
39
- if multiple? && value.is_a?(::Array)
40
- value.map { |v| @delegate.cast(v) }
41
- else
42
- @delegate.cast(value)
43
- end
44
- end
45
- end
46
- end
47
- end
48
- end
49
- end
50
- end
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Katalyst
4
- module Tables
5
- module Collection
6
- module Type
7
- module Helpers
8
- # Adds support for multiple: true
9
- module Multiple
10
- def initialize(multiple: false, **)
11
- super(**)
12
-
13
- @multiple = multiple
14
- end
15
-
16
- def multiple?
17
- @multiple
18
- end
19
-
20
- using Extensions
21
-
22
- def default_value
23
- multiple? ? [] : super
24
- end
25
- end
26
- end
27
- end
28
- end
29
- end
30
- end
@@ -1,57 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Katalyst
4
- module Tables
5
- module Collection
6
- module Type
7
- class Integer < Value
8
- include Helpers::Delegate
9
- include Helpers::Multiple
10
-
11
- def initialize(**)
12
- super(**, delegate: ActiveModel::Type::Integer)
13
- end
14
-
15
- def serialize(value)
16
- if value.is_a?(Range)
17
- if value.begin.nil?
18
- "<#{super(value.end)}"
19
- elsif value.end.nil?
20
- ">#{super(value.begin)}"
21
- else
22
- "#{super(value.begin)}..#{super(value.end)}"
23
- end
24
- else
25
- super
26
- end
27
- end
28
-
29
- private
30
-
31
- INTEGER = /(-?\d+)/
32
- SINGLE_VALUE = /\A#{INTEGER}\z/
33
- LOWER_BOUND = /\A>#{INTEGER}\z/
34
- UPPER_BOUND = /\A<#{INTEGER}\z/
35
- BOUNDED = /\A#{INTEGER}\.\.#{INTEGER}\z/
36
-
37
- def cast_value(value)
38
- case value
39
- when ::Range, ::Integer
40
- value
41
- when SINGLE_VALUE
42
- super($1)
43
- when LOWER_BOUND
44
- ((super($1))..)
45
- when UPPER_BOUND
46
- (..(super($1)))
47
- when BOUNDED
48
- ((super($1))..(super($2)))
49
- else
50
- super
51
- end
52
- end
53
- end
54
- end
55
- end
56
- end
57
- end