eventsimple 1.2.1 → 1.2.3

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: 985c47a587ea7f6476248e8c5b6257d51482f41832bb6055e6da514e4dbd8914
4
- data.tar.gz: 809b1c8d0b3f21b4d4765cd06530e4dedea076ebd3c07b5a027d7822f5bb226f
3
+ metadata.gz: c19b9d4481185e75ebfbb32cde09d5e1cf27b4ce79dac12eaa9693ad0f3888df
4
+ data.tar.gz: 8907efcfdc5e08f43fa0e2f0682b3937d8866e16eaf22bf5ec34589e1d3ca8cf
5
5
  SHA512:
6
- metadata.gz: 86d4bb8d7a529d14f287ad54242b2e3c7b305fb6092981e84412b9854bc8c76566d781e122147f9522a7a40da77d57d82a60757e441bedf307a8b72697f36727
7
- data.tar.gz: 0e18b342e6ad42462e35101ff10a9890962cd540a3142c8d7cd8d9f87e2ee862d89fb8d9e52a01695728099f526caf14331a2ab4d9b1dd87bc517cb77af42821
6
+ metadata.gz: f2a911cfa42750ec24803938cdee68982c7456f845b78958e6a4970f37701749e647419baafb8c80a1bafd0d061abe12f409dee6456a50a1738fbd0436c09a1f
7
+ data.tar.gz: dd1f22f67d7d9d9ad88849c7e55db009e2a49b15f0a20a66387768ff03ef34e1ca100a23db829b3b09c99f978a3c7386636a2f0bd6e737743c602856cda1afa0
data/CHANGELOG.md CHANGED
@@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## Unreleased
8
8
 
9
+ ## 1.2.3 - 2024-01-11
10
+ ### Changed
11
+ - Fix rendering of deleted events
12
+
13
+ ## 1.2.2 - 2023-11-29
14
+ ### Changed
15
+ - Add support for filtering events by aggregate model attributes.
16
+
9
17
  ## 1.2.1 - 2023-11-18
10
18
  ### Changed
11
19
  - Allow timestamp data in events to override default timestamps update.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- eventsimple (1.2.1)
4
+ eventsimple (1.2.3)
5
5
  dry-struct (~> 1.6)
6
6
  dry-types (~> 1.7)
7
7
  pg (~> 1.4)
@@ -11,75 +11,85 @@ PATH
11
11
  GEM
12
12
  remote: https://rubygems.org/
13
13
  specs:
14
- actioncable (7.0.8)
15
- actionpack (= 7.0.8)
16
- activesupport (= 7.0.8)
14
+ actioncable (7.1.2)
15
+ actionpack (= 7.1.2)
16
+ activesupport (= 7.1.2)
17
17
  nio4r (~> 2.0)
18
18
  websocket-driver (>= 0.6.1)
19
- actionmailbox (7.0.8)
20
- actionpack (= 7.0.8)
21
- activejob (= 7.0.8)
22
- activerecord (= 7.0.8)
23
- activestorage (= 7.0.8)
24
- activesupport (= 7.0.8)
19
+ zeitwerk (~> 2.6)
20
+ actionmailbox (7.1.2)
21
+ actionpack (= 7.1.2)
22
+ activejob (= 7.1.2)
23
+ activerecord (= 7.1.2)
24
+ activestorage (= 7.1.2)
25
+ activesupport (= 7.1.2)
25
26
  mail (>= 2.7.1)
26
27
  net-imap
27
28
  net-pop
28
29
  net-smtp
29
- actionmailer (7.0.8)
30
- actionpack (= 7.0.8)
31
- actionview (= 7.0.8)
32
- activejob (= 7.0.8)
33
- activesupport (= 7.0.8)
30
+ actionmailer (7.1.2)
31
+ actionpack (= 7.1.2)
32
+ actionview (= 7.1.2)
33
+ activejob (= 7.1.2)
34
+ activesupport (= 7.1.2)
34
35
  mail (~> 2.5, >= 2.5.4)
35
36
  net-imap
36
37
  net-pop
37
38
  net-smtp
38
- rails-dom-testing (~> 2.0)
39
- actionpack (7.0.8)
40
- actionview (= 7.0.8)
41
- activesupport (= 7.0.8)
42
- rack (~> 2.0, >= 2.2.4)
39
+ rails-dom-testing (~> 2.2)
40
+ actionpack (7.1.2)
41
+ actionview (= 7.1.2)
42
+ activesupport (= 7.1.2)
43
+ nokogiri (>= 1.8.5)
44
+ racc
45
+ rack (>= 2.2.4)
46
+ rack-session (>= 1.0.1)
43
47
  rack-test (>= 0.6.3)
44
- rails-dom-testing (~> 2.0)
45
- rails-html-sanitizer (~> 1.0, >= 1.2.0)
46
- actiontext (7.0.8)
47
- actionpack (= 7.0.8)
48
- activerecord (= 7.0.8)
49
- activestorage (= 7.0.8)
50
- activesupport (= 7.0.8)
48
+ rails-dom-testing (~> 2.2)
49
+ rails-html-sanitizer (~> 1.6)
50
+ actiontext (7.1.2)
51
+ actionpack (= 7.1.2)
52
+ activerecord (= 7.1.2)
53
+ activestorage (= 7.1.2)
54
+ activesupport (= 7.1.2)
51
55
  globalid (>= 0.6.0)
52
56
  nokogiri (>= 1.8.5)
53
- actionview (7.0.8)
54
- activesupport (= 7.0.8)
57
+ actionview (7.1.2)
58
+ activesupport (= 7.1.2)
55
59
  builder (~> 3.1)
56
- erubi (~> 1.4)
57
- rails-dom-testing (~> 2.0)
58
- rails-html-sanitizer (~> 1.1, >= 1.2.0)
59
- activejob (7.0.8)
60
- activesupport (= 7.0.8)
60
+ erubi (~> 1.11)
61
+ rails-dom-testing (~> 2.2)
62
+ rails-html-sanitizer (~> 1.6)
63
+ activejob (7.1.2)
64
+ activesupport (= 7.1.2)
61
65
  globalid (>= 0.3.6)
62
- activemodel (7.0.8)
63
- activesupport (= 7.0.8)
64
- activerecord (7.0.8)
65
- activemodel (= 7.0.8)
66
- activesupport (= 7.0.8)
67
- activestorage (7.0.8)
68
- actionpack (= 7.0.8)
69
- activejob (= 7.0.8)
70
- activerecord (= 7.0.8)
71
- activesupport (= 7.0.8)
66
+ activemodel (7.1.2)
67
+ activesupport (= 7.1.2)
68
+ activerecord (7.1.2)
69
+ activemodel (= 7.1.2)
70
+ activesupport (= 7.1.2)
71
+ timeout (>= 0.4.0)
72
+ activestorage (7.1.2)
73
+ actionpack (= 7.1.2)
74
+ activejob (= 7.1.2)
75
+ activerecord (= 7.1.2)
76
+ activesupport (= 7.1.2)
72
77
  marcel (~> 1.0)
73
- mini_mime (>= 1.1.0)
74
- activesupport (7.0.8)
78
+ activesupport (7.1.2)
79
+ base64
80
+ bigdecimal
75
81
  concurrent-ruby (~> 1.0, >= 1.0.2)
82
+ connection_pool (>= 2.2.5)
83
+ drb
76
84
  i18n (>= 1.6, < 2)
77
85
  minitest (>= 5.1)
86
+ mutex_m
78
87
  tzinfo (~> 2.0)
79
- addressable (2.8.5)
88
+ addressable (2.8.6)
80
89
  public_suffix (>= 2.0.2, < 6.0)
81
90
  ast (2.4.2)
82
- base64 (0.1.1)
91
+ base64 (0.2.0)
92
+ bigdecimal (3.1.5)
83
93
  builder (3.2.4)
84
94
  bundle-audit (0.1.0)
85
95
  bundler-audit
@@ -88,9 +98,12 @@ GEM
88
98
  thor (~> 1.0)
89
99
  coderay (1.1.3)
90
100
  concurrent-ruby (1.2.2)
101
+ connection_pool (2.4.1)
91
102
  crass (1.0.6)
92
103
  date (3.3.4)
93
104
  diff-lcs (1.5.0)
105
+ drb (2.2.0)
106
+ ruby2_keywords
94
107
  dry-core (1.0.1)
95
108
  concurrent-ruby (~> 1.0)
96
109
  zeitwerk (~> 2.6)
@@ -104,19 +117,20 @@ GEM
104
117
  dry-types (>= 1.7, < 2)
105
118
  ice_nine (~> 0.11)
106
119
  zeitwerk (~> 2.6)
107
- dry-types (1.7.1)
120
+ dry-types (1.7.2)
121
+ bigdecimal (~> 3.0)
108
122
  concurrent-ruby (~> 1.0)
109
123
  dry-core (~> 1.0)
110
124
  dry-inflector (~> 1.0)
111
125
  dry-logic (~> 1.4)
112
126
  zeitwerk (~> 2.6)
113
127
  erubi (1.12.0)
114
- ffi (1.16.2)
128
+ ffi (1.16.3)
115
129
  formatador (1.1.0)
116
130
  fuubar (2.5.1)
117
131
  rspec-core (~> 3.0)
118
132
  ruby-progressbar (~> 1.4)
119
- git (1.18.0)
133
+ git (1.19.1)
120
134
  addressable (~> 2.8)
121
135
  rchardet (~> 1.8)
122
136
  globalid (1.2.1)
@@ -138,16 +152,20 @@ GEM
138
152
  i18n (1.14.1)
139
153
  concurrent-ruby (~> 1.0)
140
154
  ice_nine (0.11.2)
141
- json (2.6.3)
155
+ io-console (0.7.1)
156
+ irb (1.11.1)
157
+ rdoc
158
+ reline (>= 0.4.2)
159
+ json (2.7.1)
142
160
  language_server-protocol (3.17.0.3)
143
161
  lint_roller (1.1.0)
144
162
  listen (3.8.0)
145
163
  rb-fsevent (~> 0.10, >= 0.10.3)
146
164
  rb-inotify (~> 0.9, >= 0.9.10)
147
- loofah (2.21.3)
165
+ loofah (2.22.0)
148
166
  crass (~> 1.0.2)
149
167
  nokogiri (>= 1.12.0)
150
- lumberjack (1.2.9)
168
+ lumberjack (1.2.10)
151
169
  mail (2.8.1)
152
170
  mini_mime (>= 0.1.1)
153
171
  net-imap
@@ -156,29 +174,30 @@ GEM
156
174
  marcel (1.0.2)
157
175
  method_source (1.0.0)
158
176
  mini_mime (1.1.5)
159
- minitest (5.20.0)
177
+ minitest (5.21.1)
178
+ mutex_m (0.2.0)
160
179
  nenv (0.3.0)
161
- net-imap (0.4.5)
180
+ net-imap (0.4.9.1)
162
181
  date
163
182
  net-protocol
164
183
  net-pop (0.1.2)
165
184
  net-protocol
166
185
  net-protocol (0.2.2)
167
186
  timeout
168
- net-smtp (0.4.0)
187
+ net-smtp (0.4.0.1)
169
188
  net-protocol
170
- nio4r (2.5.9)
171
- nokogiri (1.15.4-arm64-darwin)
189
+ nio4r (2.7.0)
190
+ nokogiri (1.16.0-arm64-darwin)
172
191
  racc (~> 1.4)
173
- nokogiri (1.15.4-x86_64-linux)
192
+ nokogiri (1.16.0-x86_64-linux)
174
193
  racc (~> 1.4)
175
194
  notiffany (0.1.3)
176
195
  nenv (~> 0.1)
177
196
  shellany (~> 0.0)
178
- parallel (1.23.0)
197
+ parallel (1.24.0)
179
198
  parse_a_changelog (1.3.0)
180
199
  treetop (~> 1.6)
181
- parser (3.2.2.3)
200
+ parser (3.3.0.3)
182
201
  ast (~> 2.4.1)
183
202
  racc
184
203
  pg (1.5.4)
@@ -186,27 +205,34 @@ GEM
186
205
  pry (0.14.2)
187
206
  coderay (~> 1.1)
188
207
  method_source (~> 1.0)
189
- public_suffix (5.0.3)
190
- puma (6.4.0)
208
+ psych (5.1.2)
209
+ stringio
210
+ public_suffix (5.0.4)
211
+ puma (6.4.2)
191
212
  nio4r (~> 2.0)
192
- racc (1.7.1)
193
- rack (2.2.8)
213
+ racc (1.7.3)
214
+ rack (3.0.8)
215
+ rack-session (2.0.0)
216
+ rack (>= 3.0.0)
194
217
  rack-test (2.1.0)
195
218
  rack (>= 1.3)
196
- rails (7.0.8)
197
- actioncable (= 7.0.8)
198
- actionmailbox (= 7.0.8)
199
- actionmailer (= 7.0.8)
200
- actionpack (= 7.0.8)
201
- actiontext (= 7.0.8)
202
- actionview (= 7.0.8)
203
- activejob (= 7.0.8)
204
- activemodel (= 7.0.8)
205
- activerecord (= 7.0.8)
206
- activestorage (= 7.0.8)
207
- activesupport (= 7.0.8)
219
+ rackup (2.1.0)
220
+ rack (>= 3)
221
+ webrick (~> 1.8)
222
+ rails (7.1.2)
223
+ actioncable (= 7.1.2)
224
+ actionmailbox (= 7.1.2)
225
+ actionmailer (= 7.1.2)
226
+ actionpack (= 7.1.2)
227
+ actiontext (= 7.1.2)
228
+ actionview (= 7.1.2)
229
+ activejob (= 7.1.2)
230
+ activemodel (= 7.1.2)
231
+ activerecord (= 7.1.2)
232
+ activestorage (= 7.1.2)
233
+ activesupport (= 7.1.2)
208
234
  bundler (>= 1.15.0)
209
- railties (= 7.0.8)
235
+ railties (= 7.1.2)
210
236
  rails-dom-testing (2.2.0)
211
237
  activesupport (>= 5.0.0)
212
238
  minitest
@@ -214,20 +240,25 @@ GEM
214
240
  rails-html-sanitizer (1.6.0)
215
241
  loofah (~> 2.21)
216
242
  nokogiri (~> 1.14)
217
- railties (7.0.8)
218
- actionpack (= 7.0.8)
219
- activesupport (= 7.0.8)
220
- method_source
243
+ railties (7.1.2)
244
+ actionpack (= 7.1.2)
245
+ activesupport (= 7.1.2)
246
+ irb
247
+ rackup (>= 1.0.0)
221
248
  rake (>= 12.2)
222
- thor (~> 1.0)
223
- zeitwerk (~> 2.5)
249
+ thor (~> 1.0, >= 1.2.2)
250
+ zeitwerk (~> 2.6)
224
251
  rainbow (3.1.1)
225
- rake (13.0.6)
252
+ rake (13.1.0)
226
253
  rb-fsevent (0.11.2)
227
254
  rb-inotify (0.10.1)
228
255
  ffi (~> 1.0)
229
256
  rchardet (1.8.0)
230
- regexp_parser (2.8.1)
257
+ rdoc (6.6.2)
258
+ psych (>= 4.0.0)
259
+ regexp_parser (2.9.0)
260
+ reline (0.4.2)
261
+ io-console (~> 0.5)
231
262
  retriable (3.1.2)
232
263
  rexml (3.2.6)
233
264
  rspec (3.12.0)
@@ -242,7 +273,7 @@ GEM
242
273
  rspec-mocks (3.12.6)
243
274
  diff-lcs (>= 1.2.0, < 2.0)
244
275
  rspec-support (~> 3.12.0)
245
- rspec-rails (6.0.3)
276
+ rspec-rails (6.1.0)
246
277
  actionpack (>= 6.1)
247
278
  activesupport (>= 6.1)
248
279
  railties (>= 6.1)
@@ -251,65 +282,68 @@ GEM
251
282
  rspec-mocks (~> 3.12)
252
283
  rspec-support (~> 3.12)
253
284
  rspec-support (3.12.1)
254
- rubocop (1.56.3)
255
- base64 (~> 0.1.1)
285
+ rubocop (1.59.0)
256
286
  json (~> 2.3)
257
287
  language_server-protocol (>= 3.17.0)
258
288
  parallel (~> 1.10)
259
- parser (>= 3.2.2.3)
289
+ parser (>= 3.2.2.4)
260
290
  rainbow (>= 2.2.2, < 4.0)
261
291
  regexp_parser (>= 1.8, < 3.0)
262
292
  rexml (>= 3.2.5, < 4.0)
263
- rubocop-ast (>= 1.28.1, < 2.0)
293
+ rubocop-ast (>= 1.30.0, < 2.0)
264
294
  ruby-progressbar (~> 1.7)
265
295
  unicode-display_width (>= 2.4.0, < 3.0)
266
- rubocop-ast (1.29.0)
296
+ rubocop-ast (1.30.0)
267
297
  parser (>= 3.2.1.0)
268
- rubocop-capybara (2.19.0)
298
+ rubocop-capybara (2.20.0)
299
+ rubocop (~> 1.41)
300
+ rubocop-factory_bot (2.25.1)
269
301
  rubocop (~> 1.41)
270
- rubocop-factory_bot (2.24.0)
271
- rubocop (~> 1.33)
272
- rubocop-performance (1.19.1)
273
- rubocop (>= 1.7.0, < 2.0)
274
- rubocop-ast (>= 0.4.0)
275
- rubocop-rails (2.20.2)
302
+ rubocop-performance (1.20.2)
303
+ rubocop (>= 1.48.1, < 2.0)
304
+ rubocop-ast (>= 1.30.0, < 2.0)
305
+ rubocop-rails (2.23.1)
276
306
  activesupport (>= 4.2.0)
277
307
  rack (>= 1.1)
278
308
  rubocop (>= 1.33.0, < 2.0)
279
- rubocop-rspec (2.24.1)
280
- rubocop (~> 1.33)
309
+ rubocop-ast (>= 1.30.0, < 2.0)
310
+ rubocop-rspec (2.26.1)
311
+ rubocop (~> 1.40)
281
312
  rubocop-capybara (~> 2.17)
282
313
  rubocop-factory_bot (~> 2.22)
283
- rubocop-vendor (0.12.1)
314
+ rubocop-vendor (0.13.0)
284
315
  rubocop
285
316
  ruby-progressbar (1.13.0)
317
+ ruby2_keywords (0.0.5)
286
318
  shellany (0.0.1)
287
- standard (1.31.1)
319
+ standard (1.33.0)
288
320
  language_server-protocol (~> 3.17.0.2)
289
321
  lint_roller (~> 1.0)
290
- rubocop (~> 1.56.2)
322
+ rubocop (~> 1.59.0)
291
323
  standard-custom (~> 1.0.0)
292
- standard-performance (~> 1.2)
324
+ standard-performance (~> 1.3)
293
325
  standard-custom (1.0.2)
294
326
  lint_roller (~> 1.0)
295
327
  rubocop (~> 1.50)
296
- standard-performance (1.2.0)
328
+ standard-performance (1.3.1)
297
329
  lint_roller (~> 1.1)
298
- rubocop-performance (~> 1.19.0)
299
- standard-rails (0.2.0)
330
+ rubocop-performance (~> 1.20.2)
331
+ standard-rails (1.0.2)
300
332
  lint_roller (~> 1.0)
301
- rubocop-rails (~> 2.20.2)
302
- thor (1.2.2)
333
+ rubocop-rails (~> 2.23.1)
334
+ stringio (3.1.0)
335
+ thor (1.3.0)
303
336
  timeout (0.4.1)
304
337
  treetop (1.6.12)
305
338
  polyglot (~> 0.3)
306
339
  tzinfo (2.0.6)
307
340
  concurrent-ruby (~> 1.0)
308
- unicode-display_width (2.4.2)
341
+ unicode-display_width (2.5.0)
342
+ webrick (1.8.1)
309
343
  websocket-driver (0.7.6)
310
344
  websocket-extensions (>= 0.1.0)
311
345
  websocket-extensions (0.1.5)
312
- ws-style (7.2.0)
346
+ ws-style (7.3.0)
313
347
  rubocop-rspec (>= 2.2.0)
314
348
  rubocop-vendor (>= 0.11)
315
349
  standard (>= 1.30.1)
@@ -8,6 +8,10 @@ module Eventsimple
8
8
  @event_id = params[:e] || -1
9
9
  @tab_id = (params[:t] == 'event') ? 'event' : 'entity'
10
10
 
11
+ filter_columns = @model_class._filter_attributes
12
+ params_filters = params.permit(filters: {})[:filters] || {}
13
+ @filters = filter_columns.to_h { |column| [column, params_filters[column]] }
14
+
11
15
  primary_key = @model_class.event_class._aggregate_id
12
16
  @entity = @model_class.find_by!(primary_key => @aggregate_id)
13
17
  @entity_event_history = @entity.events.reverse
@@ -2,9 +2,44 @@ module Eventsimple
2
2
  class ModelsController < ApplicationController
3
3
  def show
4
4
  @model_name = params[:name]
5
+ model_class = event_classes.find { |d| d.name == @model_name }
5
6
 
6
- model_event_class = event_classes.find { |d| d.name == @model_name }.event_class
7
- @latest_entities = model_event_class.last(20).reverse
7
+ scope = apply_filter(model_class, model_class.event_class)
8
+
9
+ @latest_entities = scope.last(20).reverse
10
+
11
+ check_redirect_to_entity
12
+ end
13
+
14
+ private
15
+
16
+ def apply_filter(model_class, model_event_class)
17
+ filter_columns = model_class._filter_attributes
18
+
19
+ params_filters = params.permit(filters: {})[:filters] || {}
20
+ @filters = filter_columns.to_h { |column| [column, params_filters[column]] }
21
+
22
+ return model_event_class unless @filters.any?
23
+
24
+ aggregate_class_symbol = model_event_class._aggregate_klass.model_name.element.to_sym
25
+ model_event_class = model_event_class.joins(aggregate_class_symbol)
26
+ @filters.each do |key, value|
27
+ next if value.blank?
28
+ key = model_event_class._aggregate_id if key == :aggregate_id
29
+ model_event_class = model_event_class.where({ aggregate_class_symbol => { key => value } })
30
+ end
31
+
32
+ model_event_class
33
+ end
34
+
35
+ def check_redirect_to_entity
36
+ return unless @latest_entities.any?
37
+
38
+ first_aggregate_id = @latest_entities.first.aggregate_id
39
+
40
+ return unless @latest_entities.all? { |entity| entity.aggregate_id == first_aggregate_id }
41
+
42
+ redirect_to model_entity_path(@model_name, first_aggregate_id, filters: @filters)
8
43
  end
9
44
  end
10
45
  end
@@ -61,7 +61,7 @@
61
61
  <th scope="row" colspan="2">Data</th>
62
62
  </tr>
63
63
  <% if @selected_event.data.present? %>
64
- <% @selected_event.data.attributes.each do |attr_name, attr_value| %>
64
+ <% @selected_event.data.to_hash.each do |attr_name, attr_value| %>
65
65
  <tr>
66
66
  <td>&nbsp;&nbsp;&nbsp;&nbsp;<%= attr_name %></td>
67
67
  <td><code class="entity-property"><%= attr_value %></code></td>
@@ -72,7 +72,7 @@
72
72
  <tr>
73
73
  <th scope="row" colspan="2">Metadata</th>
74
74
  </tr>
75
- <% @selected_event.metadata.attributes.each do |attr_name, attr_value| %>
75
+ <% @selected_event.metadata.to_hash.each do |attr_name, attr_value| %>
76
76
  <tr>
77
77
  <td>&nbsp;&nbsp;&nbsp;&nbsp;<%= attr_name %></td>
78
78
  <td><code class="entity-property">: <%= attr_value %></code></td>
@@ -1,26 +1,20 @@
1
1
  <!-- Header Search Start -->
2
2
  <header class="container mb-4">
3
- <div class="row">
4
- <div class="col col-sm-3">
5
- <select id="form-search-model-name" class="form-select" aria-label="Model select" onchange="document.location.href=this.value" required>
6
- <option value="">Choose event source model</option>
7
- <% event_class_names.each do |klass| %>
8
- <% is_active = klass === @model_name ? 'selected' : '' %>
9
- <option value="<%= model_path(klass) %>" <%= is_active %>><%= klass %></option>
10
- <% end %>
11
- </select>
12
- </div>
13
-
14
- <% if @model_name %>
15
- <div class="col col-sm-7">
16
- <%= form_with url: model_entity_path(@model_name, ''), id: 'model-search' do |f| %>
17
- <%= f.search_field :event_id, class: 'form-control', placeholder: 'Canonical identifier', value: @aggregate_id, required: true, aria: { label: 'Entity canonical identifier' } %>
3
+ <% if @model_name %>
4
+ <%= form_with scope: :filters, url: model_path(@model_name), method: :get, id: 'model-filter' do |f| %>
5
+ <div class="row">
6
+ <label for="filters_keys[keys]" class="col-sm-2 col-form-label">Filter attribute</label>
7
+ <div class="form-group col-sm-3">
8
+ <%= select :filters_keys, :keys, @filters.keys, { selected: @filters.compact.keys&.first }, { class:"form-select", onchange: "document.getElementById('model-filter-value').name=`filters[${this.value}]`" } %>
18
9
  </div>
19
- <div class="col col-sm-2">
10
+ <div class="form-group col-sm-5">
11
+ <%= f.search_field @filters.compact.keys&.first || @filters.keys.first, id: 'model-filter-value', value: @filters.compact.values&.first, class:"form-control", placeholder: "Filter value" %>
12
+ </div>
13
+ <div class="form-group col-sm-2">
20
14
  <%= f.submit 'Search', class: 'btn btn-primary' %>
21
- <% end %>
15
+ </div>
22
16
  </div>
23
17
  <% end %>
24
- </div>
18
+ <% end %>
25
19
  </header>
26
20
  <!-- Header Search End -->
@@ -62,12 +62,6 @@
62
62
  query.set(param, value);
63
63
  link.attr("href",window.location.pathname + '?' + query.toString());
64
64
  });
65
-
66
- $('#model-search').on('submit', (event) => {
67
- event.preventDefault();
68
- const form = $(event.currentTarget);
69
- window.location = form.attr('action') + form.children('#event_id').val();
70
- });
71
65
  });
72
66
  </script>
73
67
 
@@ -2,7 +2,7 @@ module Eventsimple
2
2
  module Entity
3
3
  DEFAULT_IGNORE_PROPS = %w[id lock_version].freeze
4
4
 
5
- def event_driven_by(event_klass, aggregate_id:)
5
+ def event_driven_by(event_klass, aggregate_id:, filter_attributes: [])
6
6
  has_many :events, class_name: event_klass.name.to_s,
7
7
  foreign_key: :aggregate_id,
8
8
  primary_key: aggregate_id,
@@ -13,6 +13,9 @@ module Eventsimple
13
13
 
14
14
  class_attribute :ignored_for_projection, default: []
15
15
 
16
+ class_attribute :_filter_attributes
17
+ self._filter_attributes = [aggregate_id] | Array.wrap(filter_attributes)
18
+
16
19
  # disable automatic timestamp updates
17
20
  self.record_timestamps = false
18
21
 
@@ -104,7 +104,7 @@ module Eventsimple
104
104
  end
105
105
 
106
106
  def aggregate=(aggregate)
107
- public_send("#{_aggregate_klass.model_name.element}=", aggregate)
107
+ public_send(:"#{_aggregate_klass.model_name.element}=", aggregate)
108
108
  end
109
109
  end
110
110
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Eventsimple
4
- VERSION = '1.2.1'
4
+ VERSION = '1.2.3'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eventsimple
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zulfiqar Ali
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-18 00:00:00.000000000 Z
11
+ date: 2024-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-struct