katalyst-tables 3.0.0 → 3.2.0

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 (54) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -0
  3. data/README.md +17 -3
  4. data/app/assets/builds/katalyst/tables.esm.js +16 -0
  5. data/app/assets/builds/katalyst/tables.js +16 -0
  6. data/app/assets/builds/katalyst/tables.min.js +1 -1
  7. data/app/assets/builds/katalyst/tables.min.js.map +1 -1
  8. data/app/assets/stylesheets/katalyst/tables/_filter.scss +34 -0
  9. data/app/assets/stylesheets/katalyst/tables/_index.scss +2 -0
  10. data/app/assets/stylesheets/katalyst/tables/_select.scss +3 -0
  11. data/app/assets/stylesheets/katalyst/tables/_summary.scss +14 -0
  12. data/app/assets/stylesheets/katalyst/tables/_table.scss +3 -0
  13. data/app/assets/stylesheets/katalyst/tables/typed-columns/_boolean.scss +1 -1
  14. data/app/assets/stylesheets/katalyst/tables/typed-columns/_currency.scss +3 -0
  15. data/app/assets/stylesheets/katalyst/tables/typed-columns/_date.scss +1 -1
  16. data/app/assets/stylesheets/katalyst/tables/typed-columns/_datetime.scss +1 -1
  17. data/app/assets/stylesheets/katalyst/tables/typed-columns/_enum.scss +9 -0
  18. data/app/assets/stylesheets/katalyst/tables/typed-columns/_index.scss +1 -0
  19. data/app/assets/stylesheets/katalyst/tables/typed-columns/_number.scss +3 -0
  20. data/app/components/concerns/katalyst/tables/has_table_content.rb +2 -2
  21. data/app/components/concerns/katalyst/tables/row_renderer.rb +1 -1
  22. data/app/components/concerns/katalyst/tables/sortable.rb +1 -1
  23. data/app/components/katalyst/summary_table_component.html.erb +15 -0
  24. data/app/components/katalyst/summary_table_component.rb +44 -0
  25. data/app/components/katalyst/table_component.rb +28 -0
  26. data/app/components/katalyst/tables/cells/enum_component.rb +27 -0
  27. data/app/components/katalyst/tables/filter/modal_component.html.erb +25 -0
  28. data/app/components/katalyst/tables/filter/modal_component.rb +66 -0
  29. data/app/components/katalyst/tables/filter_component.html.erb +20 -0
  30. data/app/components/katalyst/tables/filter_component.rb +91 -0
  31. data/app/components/katalyst/tables/summary/body_component.html.erb +3 -0
  32. data/app/components/katalyst/tables/summary/body_component.rb +10 -0
  33. data/app/components/katalyst/tables/summary/header_component.html.erb +3 -0
  34. data/app/components/katalyst/tables/summary/header_component.rb +10 -0
  35. data/app/components/katalyst/tables/summary/row_component.html.erb +4 -0
  36. data/app/components/katalyst/tables/summary/row_component.rb +12 -0
  37. data/app/controllers/concerns/katalyst/tables/backend.rb +15 -0
  38. data/app/helpers/katalyst/tables/frontend.rb +27 -0
  39. data/app/javascript/tables/application.js +5 -0
  40. data/app/javascript/tables/filter/modal_controller.js +13 -0
  41. data/app/models/concerns/katalyst/tables/collection/core.rb +30 -0
  42. data/app/models/concerns/katalyst/tables/collection/filtering.rb +80 -9
  43. data/app/models/concerns/katalyst/tables/collection/pagination.rb +2 -2
  44. data/app/models/concerns/katalyst/tables/collection/query/array_value_parser.rb +56 -0
  45. data/app/models/concerns/katalyst/tables/collection/query/parser.rb +65 -0
  46. data/app/models/concerns/katalyst/tables/collection/query/single_value_parser.rb +24 -0
  47. data/app/models/concerns/katalyst/tables/collection/query/value_parser.rb +34 -0
  48. data/app/models/concerns/katalyst/tables/collection/query.rb +43 -0
  49. data/app/models/concerns/katalyst/tables/collection/sorting.rb +2 -2
  50. data/app/models/katalyst/tables/collection/array.rb +0 -1
  51. data/app/models/katalyst/tables/collection/base.rb +0 -5
  52. data/app/models/katalyst/tables/collection/filter.rb +2 -3
  53. data/config/importmap.rb +1 -0
  54. metadata +27 -4
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Katalyst
4
+ module Tables
5
+ module Collection
6
+ module Query # :nodoc:
7
+ extend ActiveSupport::Concern
8
+
9
+ include Filtering
10
+
11
+ included do
12
+ config_accessor :search_scope
13
+
14
+ attribute :query, :string, default: ""
15
+ attribute :search, :string, default: ""
16
+
17
+ # Note: this is defined inline so that we can overwrite query=
18
+ def query=(value)
19
+ query = super
20
+
21
+ parser = Parser.new(self).parse(query)
22
+
23
+ if searchable? && parser.untagged.any?
24
+ self.search = parser.untagged.join(" ")
25
+ end
26
+
27
+ query
28
+ end
29
+ end
30
+
31
+ # Returns true if the collection supports untagged searching. This
32
+ # requires config.search_scope to be set to the name of the scope to use
33
+ # in the target record for untagged text searches. If not set, untagged
34
+ # search terms will be silently ignored.
35
+ #
36
+ # @return [true, false]
37
+ def searchable?
38
+ config.search_scope.present?
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -45,10 +45,10 @@ module Katalyst
45
45
  attr_reader :default_sort
46
46
  end
47
47
 
48
- def initialize(sorting: config.sorting, **options)
48
+ def initialize(sorting: config.sorting, **)
49
49
  @default_sort = sorting.to_param if sorting.present?
50
50
 
51
- super(sort: @default_sort, **options) # set default sort based on config
51
+ super(sort: @default_sort, **) # set default sort based on config
52
52
  end
53
53
 
54
54
  def default_sort?
@@ -6,7 +6,6 @@ module Katalyst
6
6
  # Entry point for creating a collection from an array for use with table components.
7
7
  class Array
8
8
  include Core
9
- include Filtering
10
9
 
11
10
  def self.with_params(params)
12
11
  new.with_params(params)
@@ -23,7 +23,6 @@ module Katalyst
23
23
  # ````
24
24
  class Base
25
25
  include Core
26
- include Filtering
27
26
  include Pagination
28
27
  include Sorting
29
28
 
@@ -34,10 +33,6 @@ module Katalyst
34
33
  new.with_params(params)
35
34
  end
36
35
 
37
- def model
38
- items.model
39
- end
40
-
41
36
  def model_name
42
37
  @model_name ||= items.model_name.dup.tap do |name|
43
38
  name.param_key = ""
@@ -23,7 +23,6 @@ module Katalyst
23
23
  # ````
24
24
  class Filter
25
25
  include Core
26
- include Filtering
27
26
  include Pagination
28
27
  include Sorting
29
28
 
@@ -40,8 +39,8 @@ module Katalyst
40
39
 
41
40
  attr_reader :param_key
42
41
 
43
- def initialize(param_key: :filters, **options)
44
- super(**options)
42
+ def initialize(param_key: :filters, **)
43
+ super(**)
45
44
 
46
45
  @param_key = param_key.to_sym
47
46
  end
data/config/importmap.rb CHANGED
@@ -1,2 +1,3 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  pin "@katalyst/tables", to: "katalyst/tables.js"
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.0.0
4
+ version: 3.2.0
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-05-14 00:00:00.000000000 Z
11
+ date: 2024-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: katalyst-html-attributes
@@ -54,13 +54,17 @@ files:
54
54
  - app/assets/builds/katalyst/tables.min.js
55
55
  - app/assets/builds/katalyst/tables.min.js.map
56
56
  - app/assets/config/katalyst-tables.js
57
+ - app/assets/stylesheets/katalyst/tables/_filter.scss
57
58
  - app/assets/stylesheets/katalyst/tables/_index.scss
58
59
  - app/assets/stylesheets/katalyst/tables/_ordinal.scss
60
+ - app/assets/stylesheets/katalyst/tables/_select.scss
61
+ - app/assets/stylesheets/katalyst/tables/_summary.scss
59
62
  - app/assets/stylesheets/katalyst/tables/_table.scss
60
63
  - app/assets/stylesheets/katalyst/tables/typed-columns/_boolean.scss
61
64
  - app/assets/stylesheets/katalyst/tables/typed-columns/_currency.scss
62
65
  - app/assets/stylesheets/katalyst/tables/typed-columns/_date.scss
63
66
  - app/assets/stylesheets/katalyst/tables/typed-columns/_datetime.scss
67
+ - app/assets/stylesheets/katalyst/tables/typed-columns/_enum.scss
64
68
  - app/assets/stylesheets/katalyst/tables/typed-columns/_index.scss
65
69
  - app/assets/stylesheets/katalyst/tables/typed-columns/_number.scss
66
70
  - app/components/concerns/katalyst/tables/has_table_content.rb
@@ -69,6 +73,8 @@ files:
69
73
  - app/components/concerns/katalyst/tables/row_renderer.rb
70
74
  - app/components/concerns/katalyst/tables/selectable.rb
71
75
  - app/components/concerns/katalyst/tables/sortable.rb
76
+ - app/components/katalyst/summary_table_component.html.erb
77
+ - app/components/katalyst/summary_table_component.rb
72
78
  - app/components/katalyst/table_component.html.erb
73
79
  - app/components/katalyst/table_component.rb
74
80
  - app/components/katalyst/tables/body_row_component.html.erb
@@ -78,6 +84,7 @@ files:
78
84
  - app/components/katalyst/tables/cells/currency_component.rb
79
85
  - app/components/katalyst/tables/cells/date_component.rb
80
86
  - app/components/katalyst/tables/cells/date_time_component.rb
87
+ - app/components/katalyst/tables/cells/enum_component.rb
81
88
  - app/components/katalyst/tables/cells/number_component.rb
82
89
  - app/components/katalyst/tables/cells/ordinal_component.rb
83
90
  - app/components/katalyst/tables/cells/rich_text_component.rb
@@ -85,6 +92,10 @@ files:
85
92
  - app/components/katalyst/tables/data.rb
86
93
  - app/components/katalyst/tables/empty_caption_component.html.erb
87
94
  - app/components/katalyst/tables/empty_caption_component.rb
95
+ - app/components/katalyst/tables/filter/modal_component.html.erb
96
+ - app/components/katalyst/tables/filter/modal_component.rb
97
+ - app/components/katalyst/tables/filter_component.html.erb
98
+ - app/components/katalyst/tables/filter_component.rb
88
99
  - app/components/katalyst/tables/header_row_component.html.erb
89
100
  - app/components/katalyst/tables/header_row_component.rb
90
101
  - app/components/katalyst/tables/label.rb
@@ -92,9 +103,16 @@ files:
92
103
  - app/components/katalyst/tables/pagy_nav_component.rb
93
104
  - app/components/katalyst/tables/selectable/form_component.html.erb
94
105
  - app/components/katalyst/tables/selectable/form_component.rb
106
+ - app/components/katalyst/tables/summary/body_component.html.erb
107
+ - app/components/katalyst/tables/summary/body_component.rb
108
+ - app/components/katalyst/tables/summary/header_component.html.erb
109
+ - app/components/katalyst/tables/summary/header_component.rb
110
+ - app/components/katalyst/tables/summary/row_component.html.erb
111
+ - app/components/katalyst/tables/summary/row_component.rb
95
112
  - app/controllers/concerns/katalyst/tables/backend.rb
96
113
  - app/helpers/katalyst/tables/frontend.rb
97
114
  - app/javascript/tables/application.js
115
+ - app/javascript/tables/filter/modal_controller.js
98
116
  - app/javascript/tables/orderable/form_controller.js
99
117
  - app/javascript/tables/orderable/item_controller.js
100
118
  - app/javascript/tables/orderable/list_controller.js
@@ -104,6 +122,11 @@ files:
104
122
  - app/models/concerns/katalyst/tables/collection/filtering.rb
105
123
  - app/models/concerns/katalyst/tables/collection/has_params.rb
106
124
  - app/models/concerns/katalyst/tables/collection/pagination.rb
125
+ - app/models/concerns/katalyst/tables/collection/query.rb
126
+ - app/models/concerns/katalyst/tables/collection/query/array_value_parser.rb
127
+ - app/models/concerns/katalyst/tables/collection/query/parser.rb
128
+ - app/models/concerns/katalyst/tables/collection/query/single_value_parser.rb
129
+ - app/models/concerns/katalyst/tables/collection/query/value_parser.rb
107
130
  - app/models/concerns/katalyst/tables/collection/reducers.rb
108
131
  - app/models/concerns/katalyst/tables/collection/sorting.rb
109
132
  - app/models/katalyst/tables/collection/array.rb
@@ -131,14 +154,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
131
154
  requirements:
132
155
  - - ">="
133
156
  - !ruby/object:Gem::Version
134
- version: 3.2.0
157
+ version: 3.3.0
135
158
  required_rubygems_version: !ruby/object:Gem::Requirement
136
159
  requirements:
137
160
  - - ">="
138
161
  - !ruby/object:Gem::Version
139
162
  version: '0'
140
163
  requirements: []
141
- rubygems_version: 3.5.9
164
+ rubygems_version: 3.5.11
142
165
  signing_key:
143
166
  specification_version: 4
144
167
  summary: HTML table generator for Rails views