mensa 0.2.1 → 0.2.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 (51) hide show
  1. checksums.yaml +4 -4
  2. data/.devcontainer/compose.yaml +1 -1
  3. data/.devcontainer/devcontainer.json +1 -1
  4. data/.gitignore +2 -0
  5. data/Gemfile +10 -1
  6. data/Gemfile.lock +155 -81
  7. data/Procfile +2 -2
  8. data/README.md +61 -9
  9. data/app/assets/stylesheets/mensa/application.css +1 -1
  10. data/app/components/mensa/add_filter/component_controller.js +12 -8
  11. data/app/components/mensa/filter/component_controller.js +12 -0
  12. data/app/components/mensa/{filters → filter_list}/component.html.slim +2 -2
  13. data/app/components/mensa/{filters → filter_list}/component.rb +2 -2
  14. data/app/components/mensa/{filters → filter_list}/component_controller.js +2 -2
  15. data/app/components/mensa/row_action/component.html.slim +1 -1
  16. data/app/components/mensa/table/component.html.slim +2 -2
  17. data/app/components/mensa/table/component_controller.js +8 -6
  18. data/app/components/mensa/view/paging.css +1 -1
  19. data/app/components/mensa/views/component.html.slim +2 -2
  20. data/app/components/mensa/views/component.rb +1 -1
  21. data/app/components/mensa/views/component_controller.js +13 -0
  22. data/app/controllers/mensa/tables_controller.rb +9 -11
  23. data/app/javascript/mensa/controllers/index.js +8 -2
  24. data/app/tables/mensa/action.rb +4 -2
  25. data/app/tables/mensa/base.rb +14 -8
  26. data/app/tables/mensa/column.rb +10 -2
  27. data/app/tables/mensa/config/action_dsl.rb +3 -0
  28. data/app/tables/mensa/config/column_dsl.rb +4 -4
  29. data/app/tables/mensa/config/dsl_logic.rb +7 -1
  30. data/app/tables/mensa/config/filter_dsl.rb +2 -0
  31. data/app/tables/mensa/config/table_dsl.rb +10 -3
  32. data/app/tables/mensa/config/view_dsl.rb +8 -0
  33. data/app/tables/mensa/config_readers.rb +3 -3
  34. data/app/tables/mensa/filter.rb +33 -4
  35. data/app/tables/mensa/scope.rb +3 -18
  36. data/app/tables/mensa/system_view.rb +26 -0
  37. data/app/views/mensa/tables/show.html.slim +0 -3
  38. data/app/views/mensa/tables/show.turbo_stream.slim +1 -1
  39. data/bin/overmind +27 -0
  40. data/bin/setup +5 -2
  41. data/docs/filters.png +0 -0
  42. data/docs/table.png +0 -0
  43. data/lib/mensa/version.rb +1 -1
  44. data/mensa.gemspec +23 -20
  45. data/package-lock.json +4967 -0
  46. data/package.json +2 -2
  47. data/rubocop.yml +94 -0
  48. metadata +43 -8
  49. data/app/views/mensa/tables/index.html.slim +0 -93
  50. data/yarn.lock +0 -837
  51. /data/app/components/mensa/{filters → filter_list}/component.css +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7393ecb783abf8a65f707744bc94c3dda05fc62b3c607eba3c3700b1ce93fa28
4
- data.tar.gz: ad6f2d96a68cac83adb19d9e9cb62f9dd0de72d830306a1420b6fbc14e2f71d9
3
+ metadata.gz: d7cb98df22a002a08d25141f67df7807ebf5f2eb102831db09614f7de86b8772
4
+ data.tar.gz: 301c827f9ed63c1acb745359202021723df9142e03ee190a75312b01f6642fe1
5
5
  SHA512:
6
- metadata.gz: 4935b9ade5b6a239f40bf81a051c772e469f6abf5ee3d619949940bee52e9ccd54d5c1ab6cb9113dc837e6a196977a6c8cb7bdad72438f5519a9eb5d66a9c1a5
7
- data.tar.gz: 5a2edf045417c7a48b1fb1ee07291221221b89857f6c94592f9dc8297d40db1fdbe39829f4d7b86cfc8b980d36d5df236cd402bf9c4cb0e18cc7c597bd108a21
6
+ metadata.gz: a0886a37e4ac9a8d75e083d0cbd3f5ff7475990d1d8dbff823f61bfcca19485834e58e108b203061442350e5ddef3ab4fec1b9c5550c05c9bea33c4457051998
7
+ data.tar.gz: 1452161b4a0b0f257c715171bb1bd1a129ffcb8cff2591d6cf0e67fee42bb01f67ef81cb36e98755f5537308c30f9dd840965016311439120e1ff4fc3b724090
@@ -1,7 +1,7 @@
1
1
  name: "mensa"
2
2
 
3
3
  services:
4
- rails-app:
4
+ app:
5
5
  cpu_count: 2
6
6
  build:
7
7
  context: ..
@@ -3,7 +3,7 @@
3
3
  {
4
4
  "name": "mensa",
5
5
  "dockerComposeFile": "compose.yaml",
6
- "service": "rails-app",
6
+ "service": "app",
7
7
  "workspaceFolder": "/workspaces/mensa",
8
8
  // Features to add to the dev container. More info: https://containers.dev/features.
9
9
  "features": {
data/.gitignore CHANGED
@@ -17,4 +17,6 @@ test/dummy/app/assets/stylesheets/application.tailwind.css
17
17
  config/tailwind.config.js
18
18
  app/assets/builds
19
19
  test/dummy/config/tailwind.config.js
20
+ .envrc
20
21
 
22
+ **/**/.DS_Store
data/Gemfile CHANGED
@@ -7,8 +7,17 @@ gemspec
7
7
 
8
8
  gem "puma"
9
9
  gem "sprockets-rails"
10
- gem "satis", "~> 2", entdec: "satis", branch: "main"
10
+ gem "satis", "~> 2"
11
11
  gem "pry"
12
12
  gem "capybara", "~> 3.40"
13
13
  gem "selenium-webdriver", "~> 4.17"
14
14
  gem "slim", "~> 5.2"
15
+ gem "debug"
16
+ gem "overmind", require: false
17
+
18
+ group :development, :test do
19
+ gem "standard", require: false
20
+ gem "rubocop-rails", require: false
21
+ gem "ruby-lsp", require: false
22
+ gem "ruby-lsp-rails", require: false
23
+ end
data/Gemfile.lock CHANGED
@@ -1,23 +1,7 @@
1
- GIT
2
- remote: git@github.com:entdec/satis.git
3
- revision: 1ef5f70700a755f01ed49168929200b2aaec792d
4
- branch: main
5
- specs:
6
- satis (2.2.1)
7
- browser
8
- diffy
9
- importmap-rails
10
- jsonb_accessor (~> 1.4)
11
- rails (>= 6)
12
- stimulus-rails
13
- tailwindcss-rails
14
- turbo-rails
15
- view_component
16
-
17
1
  PATH
18
2
  remote: .
19
3
  specs:
20
- mensa (0.2.0)
4
+ mensa (0.2.2)
21
5
  caxlsx_rails (~> 0)
22
6
  importmap-rails
23
7
  pagy (>= 43)
@@ -27,35 +11,34 @@ PATH
27
11
  tailwindcss-rails (~> 3.3)
28
12
  textacular (>= 5)
29
13
  turbo-rails
14
+ view_component (~> 3.11)
30
15
 
31
16
  GEM
32
17
  remote: https://rubygems.org/
33
18
  specs:
34
- action_text-trix (2.1.15)
35
- railties
36
- actioncable (8.1.1)
37
- actionpack (= 8.1.1)
38
- activesupport (= 8.1.1)
19
+ actioncable (8.0.4)
20
+ actionpack (= 8.0.4)
21
+ activesupport (= 8.0.4)
39
22
  nio4r (~> 2.0)
40
23
  websocket-driver (>= 0.6.1)
41
24
  zeitwerk (~> 2.6)
42
- actionmailbox (8.1.1)
43
- actionpack (= 8.1.1)
44
- activejob (= 8.1.1)
45
- activerecord (= 8.1.1)
46
- activestorage (= 8.1.1)
47
- activesupport (= 8.1.1)
25
+ actionmailbox (8.0.4)
26
+ actionpack (= 8.0.4)
27
+ activejob (= 8.0.4)
28
+ activerecord (= 8.0.4)
29
+ activestorage (= 8.0.4)
30
+ activesupport (= 8.0.4)
48
31
  mail (>= 2.8.0)
49
- actionmailer (8.1.1)
50
- actionpack (= 8.1.1)
51
- actionview (= 8.1.1)
52
- activejob (= 8.1.1)
53
- activesupport (= 8.1.1)
32
+ actionmailer (8.0.4)
33
+ actionpack (= 8.0.4)
34
+ actionview (= 8.0.4)
35
+ activejob (= 8.0.4)
36
+ activesupport (= 8.0.4)
54
37
  mail (>= 2.8.0)
55
38
  rails-dom-testing (~> 2.2)
56
- actionpack (8.1.1)
57
- actionview (= 8.1.1)
58
- activesupport (= 8.1.1)
39
+ actionpack (8.0.4)
40
+ actionview (= 8.0.4)
41
+ activesupport (= 8.0.4)
59
42
  nokogiri (>= 1.8.5)
60
43
  rack (>= 2.2.4)
61
44
  rack-session (>= 1.0.1)
@@ -63,43 +46,42 @@ GEM
63
46
  rails-dom-testing (~> 2.2)
64
47
  rails-html-sanitizer (~> 1.6)
65
48
  useragent (~> 0.16)
66
- actiontext (8.1.1)
67
- action_text-trix (~> 2.1.15)
68
- actionpack (= 8.1.1)
69
- activerecord (= 8.1.1)
70
- activestorage (= 8.1.1)
71
- activesupport (= 8.1.1)
49
+ actiontext (8.0.4)
50
+ actionpack (= 8.0.4)
51
+ activerecord (= 8.0.4)
52
+ activestorage (= 8.0.4)
53
+ activesupport (= 8.0.4)
72
54
  globalid (>= 0.6.0)
73
55
  nokogiri (>= 1.8.5)
74
- actionview (8.1.1)
75
- activesupport (= 8.1.1)
56
+ actionview (8.0.4)
57
+ activesupport (= 8.0.4)
76
58
  builder (~> 3.1)
77
59
  erubi (~> 1.11)
78
60
  rails-dom-testing (~> 2.2)
79
61
  rails-html-sanitizer (~> 1.6)
80
- activejob (8.1.1)
81
- activesupport (= 8.1.1)
62
+ activejob (8.0.4)
63
+ activesupport (= 8.0.4)
82
64
  globalid (>= 0.3.6)
83
- activemodel (8.1.1)
84
- activesupport (= 8.1.1)
85
- activerecord (8.1.1)
86
- activemodel (= 8.1.1)
87
- activesupport (= 8.1.1)
65
+ activemodel (8.0.4)
66
+ activesupport (= 8.0.4)
67
+ activerecord (8.0.4)
68
+ activemodel (= 8.0.4)
69
+ activesupport (= 8.0.4)
88
70
  timeout (>= 0.4.0)
89
- activestorage (8.1.1)
90
- actionpack (= 8.1.1)
91
- activejob (= 8.1.1)
92
- activerecord (= 8.1.1)
93
- activesupport (= 8.1.1)
71
+ activestorage (8.0.4)
72
+ actionpack (= 8.0.4)
73
+ activejob (= 8.0.4)
74
+ activerecord (= 8.0.4)
75
+ activesupport (= 8.0.4)
94
76
  marcel (~> 1.0)
95
- activesupport (8.1.1)
77
+ activesupport (8.0.4)
96
78
  base64
79
+ benchmark (>= 0.3)
97
80
  bigdecimal
98
81
  concurrent-ruby (~> 1.0, >= 1.3.1)
99
82
  connection_pool (>= 2.2.5)
100
83
  drb
101
84
  i18n (>= 1.6, < 2)
102
- json
103
85
  logger (>= 1.4.2)
104
86
  minitest (>= 5.1)
105
87
  securerandom (>= 0.3)
@@ -107,7 +89,9 @@ GEM
107
89
  uri (>= 0.13.1)
108
90
  addressable (2.8.7)
109
91
  public_suffix (>= 2.0.2, < 7.0)
92
+ ast (2.4.3)
110
93
  base64 (0.3.0)
94
+ benchmark (0.5.0)
111
95
  bigdecimal (3.3.1)
112
96
  browser (6.2.0)
113
97
  builder (3.3.0)
@@ -133,6 +117,9 @@ GEM
133
117
  connection_pool (2.5.4)
134
118
  crass (1.0.6)
135
119
  date (3.5.0)
120
+ debug (1.11.0)
121
+ irb (~> 1.10)
122
+ reline (>= 0.3.8)
136
123
  diffy (3.4.4)
137
124
  drb (2.2.3)
138
125
  erb (5.1.3)
@@ -151,11 +138,13 @@ GEM
151
138
  pp (>= 0.6.0)
152
139
  rdoc (>= 4.0.0)
153
140
  reline (>= 0.4.2)
154
- json (2.15.2)
141
+ json (2.16.0)
155
142
  jsonb_accessor (1.4)
156
143
  activerecord (>= 6.1)
157
144
  activesupport (>= 6.1)
158
145
  pg (>= 0.18.1)
146
+ language_server-protocol (3.17.0.5)
147
+ lint_roller (1.1.0)
159
148
  logger (1.7.0)
160
149
  loofah (2.24.1)
161
150
  crass (~> 1.0.2)
@@ -170,7 +159,7 @@ GEM
170
159
  matrix (0.4.3)
171
160
  method_source (1.1.0)
172
161
  mini_mime (1.1.5)
173
- minitest (5.26.0)
162
+ minitest (5.26.1)
174
163
  net-imap (0.5.12)
175
164
  date
176
165
  net-protocol
@@ -197,9 +186,18 @@ GEM
197
186
  racc (~> 1.4)
198
187
  nokogiri (1.18.10-x86_64-linux-musl)
199
188
  racc (~> 1.4)
200
- pagy (43.0.0)
189
+ overmind (2.5.1)
190
+ overmind (2.5.1-aarch64-linux)
191
+ overmind (2.5.1-arm-linux)
192
+ overmind (2.5.1-arm64-darwin)
193
+ overmind (2.5.1-x86_64-darwin)
194
+ pagy (43.0.2)
201
195
  json
202
196
  yaml
197
+ parallel (1.27.0)
198
+ parser (3.3.10.0)
199
+ ast (~> 2.4.1)
200
+ racc
203
201
  pg (1.6.2)
204
202
  pg (1.6.2-aarch64-linux)
205
203
  pg (1.6.2-aarch64-linux-musl)
@@ -210,6 +208,7 @@ GEM
210
208
  pp (0.6.3)
211
209
  prettyprint
212
210
  prettyprint (0.2.0)
211
+ prism (1.6.0)
213
212
  pry (0.15.2)
214
213
  coderay (~> 1.1)
215
214
  method_source (~> 1.0)
@@ -228,20 +227,20 @@ GEM
228
227
  rack (>= 1.3)
229
228
  rackup (2.2.1)
230
229
  rack (>= 3)
231
- rails (8.1.1)
232
- actioncable (= 8.1.1)
233
- actionmailbox (= 8.1.1)
234
- actionmailer (= 8.1.1)
235
- actionpack (= 8.1.1)
236
- actiontext (= 8.1.1)
237
- actionview (= 8.1.1)
238
- activejob (= 8.1.1)
239
- activemodel (= 8.1.1)
240
- activerecord (= 8.1.1)
241
- activestorage (= 8.1.1)
242
- activesupport (= 8.1.1)
230
+ rails (8.0.4)
231
+ actioncable (= 8.0.4)
232
+ actionmailbox (= 8.0.4)
233
+ actionmailer (= 8.0.4)
234
+ actionpack (= 8.0.4)
235
+ actiontext (= 8.0.4)
236
+ actionview (= 8.0.4)
237
+ activejob (= 8.0.4)
238
+ activemodel (= 8.0.4)
239
+ activerecord (= 8.0.4)
240
+ activestorage (= 8.0.4)
241
+ activesupport (= 8.0.4)
243
242
  bundler (>= 1.15.0)
244
- railties (= 8.1.1)
243
+ railties (= 8.0.4)
245
244
  rails-dom-testing (2.3.0)
246
245
  activesupport (>= 5.0.0)
247
246
  minitest
@@ -249,25 +248,69 @@ GEM
249
248
  rails-html-sanitizer (1.6.2)
250
249
  loofah (~> 2.21)
251
250
  nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
252
- railties (8.1.1)
253
- actionpack (= 8.1.1)
254
- activesupport (= 8.1.1)
251
+ railties (8.0.4)
252
+ actionpack (= 8.0.4)
253
+ activesupport (= 8.0.4)
255
254
  irb (~> 1.13)
256
255
  rackup (>= 1.0.0)
257
256
  rake (>= 12.2)
258
257
  thor (~> 1.0, >= 1.2.2)
259
258
  tsort (>= 0.2)
260
259
  zeitwerk (~> 2.6)
260
+ rainbow (3.1.1)
261
261
  rake (13.3.1)
262
+ rbs (3.9.5)
263
+ logger
262
264
  rdoc (6.15.1)
263
265
  erb
264
266
  psych (>= 4.0.0)
265
267
  tsort
266
268
  regexp_parser (2.11.3)
267
- reline (0.6.2)
269
+ reline (0.6.3)
268
270
  io-console (~> 0.5)
269
271
  rexml (3.4.4)
272
+ rubocop (1.80.2)
273
+ json (~> 2.3)
274
+ language_server-protocol (~> 3.17.0.2)
275
+ lint_roller (~> 1.1.0)
276
+ parallel (~> 1.10)
277
+ parser (>= 3.3.0.2)
278
+ rainbow (>= 2.2.2, < 4.0)
279
+ regexp_parser (>= 2.9.3, < 3.0)
280
+ rubocop-ast (>= 1.46.0, < 2.0)
281
+ ruby-progressbar (~> 1.7)
282
+ unicode-display_width (>= 2.4.0, < 4.0)
283
+ rubocop-ast (1.48.0)
284
+ parser (>= 3.3.7.2)
285
+ prism (~> 1.4)
286
+ rubocop-performance (1.25.0)
287
+ lint_roller (~> 1.1)
288
+ rubocop (>= 1.75.0, < 2.0)
289
+ rubocop-ast (>= 1.38.0, < 2.0)
290
+ rubocop-rails (2.33.4)
291
+ activesupport (>= 4.2.0)
292
+ lint_roller (~> 1.1)
293
+ rack (>= 1.1)
294
+ rubocop (>= 1.75.0, < 2.0)
295
+ rubocop-ast (>= 1.44.0, < 2.0)
296
+ ruby-lsp (0.26.2)
297
+ language_server-protocol (~> 3.17.0)
298
+ prism (>= 1.2, < 2.0)
299
+ rbs (>= 3, < 5)
300
+ ruby-lsp-rails (0.4.8)
301
+ ruby-lsp (>= 0.26.0, < 0.27.0)
302
+ ruby-progressbar (1.13.0)
270
303
  rubyzip (3.2.2)
304
+ satis (2.3.0)
305
+ browser
306
+ diffy
307
+ importmap-rails
308
+ jsonb_accessor (~> 1.4)
309
+ rails (>= 6)
310
+ stimulus-rails
311
+ tailwindcss-rails
312
+ turbo-rails
313
+ view_component
271
314
  securerandom (0.4.1)
272
315
  selenium-webdriver (4.38.0)
273
316
  base64 (~> 0.2)
@@ -286,6 +329,26 @@ GEM
286
329
  actionpack (>= 6.1)
287
330
  activesupport (>= 6.1)
288
331
  sprockets (>= 3.0.0)
332
+ sqlite3 (2.8.0-aarch64-linux-gnu)
333
+ sqlite3 (2.8.0-aarch64-linux-musl)
334
+ sqlite3 (2.8.0-arm-linux-gnu)
335
+ sqlite3 (2.8.0-arm-linux-musl)
336
+ sqlite3 (2.8.0-arm64-darwin)
337
+ sqlite3 (2.8.0-x86_64-darwin)
338
+ sqlite3 (2.8.0-x86_64-linux-gnu)
339
+ sqlite3 (2.8.0-x86_64-linux-musl)
340
+ standard (1.51.1)
341
+ language_server-protocol (~> 3.17.0.2)
342
+ lint_roller (~> 1.0)
343
+ rubocop (~> 1.80.2)
344
+ standard-custom (~> 1.0.0)
345
+ standard-performance (~> 1.8)
346
+ standard-custom (1.0.2)
347
+ lint_roller (~> 1.0)
348
+ rubocop (~> 1.50)
349
+ standard-performance (1.8.0)
350
+ lint_roller (~> 1.1)
351
+ rubocop-performance (~> 1.25.0)
289
352
  stimulus-rails (1.3.4)
290
353
  railties (>= 6.0.0)
291
354
  stringio (3.1.7)
@@ -309,11 +372,15 @@ GEM
309
372
  railties (>= 7.1.0)
310
373
  tzinfo (2.0.6)
311
374
  concurrent-ruby (~> 1.0)
375
+ unicode-display_width (3.2.0)
376
+ unicode-emoji (~> 4.1)
377
+ unicode-emoji (4.1.0)
312
378
  uri (1.1.1)
313
379
  useragent (0.16.11)
314
- view_component (4.1.0)
315
- activesupport (>= 7.1.0, < 8.2)
380
+ view_component (3.23.2)
381
+ activesupport (>= 5.2.0, < 8.1)
316
382
  concurrent-ruby (~> 1)
383
+ method_source (~> 1.0)
317
384
  websocket (1.2.11)
318
385
  websocket-driver (0.8.0)
319
386
  base64
@@ -338,13 +405,20 @@ PLATFORMS
338
405
 
339
406
  DEPENDENCIES
340
407
  capybara (~> 3.40)
408
+ debug
341
409
  mensa!
410
+ overmind
342
411
  pry
343
412
  puma
344
- satis (~> 2)!
413
+ rubocop-rails
414
+ ruby-lsp
415
+ ruby-lsp-rails
416
+ satis (~> 2)
345
417
  selenium-webdriver (~> 4.17)
346
418
  slim (~> 5.2)
347
419
  sprockets-rails
420
+ sqlite3 (~> 2.8)
421
+ standard
348
422
 
349
423
  BUNDLED WITH
350
424
  2.6.2
data/Procfile CHANGED
@@ -1,2 +1,2 @@
1
- web: bin/rails server
2
- css: bin/rails app:tailwind_watch
1
+ web: bin/rails server -p 3000 -b 0.0.0.0
2
+ css: cd test/dummy && bin/rails tailwindcss:watch
data/README.md CHANGED
@@ -2,23 +2,33 @@
2
2
 
3
3
  Fast and awesome tables, with pagination, sorting, filtering and custom views.
4
4
 
5
- Wanted features:
5
+ ![table](./docs/table.png)
6
+ ![filters](./docs/filters.png)
7
+
8
+ Features:
6
9
 
7
10
  - [x] very fast
8
11
  - [x] row-links
9
12
  - [x] sorting
10
13
  - [x] tables without headers (and without most of the above)
14
+ - [x] filtering of multiple columns
15
+ - [X] Hide filter icon in case there are no filters
16
+
17
+ Still to do:
11
18
  - [ ] column sorting
12
- - [ ] filtering (of multiple columns, single is done)
19
+ - [ ] editing of existing filters
13
20
  - [ ] view selection and exports per view
21
+ - [ ] multiple selection of rows
22
+
23
+ Optionally:
24
+
14
25
  - [ ] group by
15
26
  - [ ] sum/max/min
16
27
  - [ ] tables backed by arrays (of ActiveModel)
17
28
 
18
- Todo:
29
+ Todo/Fixme:
19
30
 
20
- - [X] Hide filter icon in case there are no filters
21
- - [ ] Search only works on table columns
31
+ - [ ] Search only works on table text columns
22
32
 
23
33
  ## Usage
24
34
 
@@ -37,7 +47,6 @@ class UserTable < ApplicationTable
37
47
  sortable true
38
48
  sanitize true
39
49
  internal false
40
- method nil
41
50
  visible true
42
51
  filter do
43
52
  collection -> { }
@@ -51,6 +60,7 @@ class UserTable < ApplicationTable
51
60
 
52
61
  # You can add one or more actions to a row
53
62
  action :delete do
63
+ title "Delete row"
54
64
  link { |user| user_path(user) }
55
65
  icon "fa-regular fa-trash"
56
66
  link_attributes data: {"turbo-confirm": "Are you sure you want to delete the user?", "turbo-method": :delete}
@@ -63,6 +73,15 @@ class UserTable < ApplicationTable
63
73
  view_columns_sorting false # Disabled for now
64
74
  view_condensed false # Default false
65
75
  view_condensed_toggle true # Whether to show the toggle, default true
76
+
77
+ # Add system views
78
+ view :concept do
79
+ name "Concept"
80
+ filter :state do
81
+ operator :equals
82
+ value "concept"
83
+ end
84
+ end
66
85
  end
67
86
  end
68
87
  ```
@@ -74,10 +93,13 @@ You can show your tables on the page using the following:
74
93
  = sts.table :users
75
94
  ```
76
95
 
77
- #### Views
96
+ #### Custom views
97
+
98
+ Custom views are views not defined by the developer (SystemViews) but by the end-user by adding/removing filters.
99
+
100
+ Initial support for custom-views is there, but pretty rudimentary:
78
101
 
79
- Initial support for views is there, but pretty rudimentary:
80
- `Mensa::TableView.create(table: "users", name: "Guests", data: {filters: {role: "guest"}})`
102
+ `Mensa::TableView.create(table: "users", name: "Guests", data: {filters: {role: {value: "guest"}}})`
81
103
 
82
104
  ### Fast
83
105
 
@@ -91,6 +113,36 @@ column :age do
91
113
  end
92
114
  ```
93
115
 
116
+ ## Development
117
+
118
+ ### Coding
119
+
120
+ - Checkout this repo
121
+ - Setup your direnv, add the following to your `.envrc`:
122
+
123
+ ```
124
+ export BUNDLE_RUBYGEMS__PKG__GITHUB__COM=ghp_xxxxxxw
125
+ export RBENV_VERSION=$(cat .ruby-version)
126
+ ```
127
+ - Run `direnv allow`
128
+ - Open with Visual Studio Code (or with any other editor) and reopen in container.
129
+ - Run `bin/overmind s`
130
+
131
+ ### Docs
132
+
133
+ Using the following in your view will render Mensa::Table::Component
134
+ ```slim
135
+ = sts.table :users
136
+ ```
137
+
138
+ The Mensa::Table::Component will render:
139
+ - Mensa::Search::Component
140
+ - Mensa::FilterList::Component
141
+ - Mensa::Views::Component
142
+ - renders a views list
143
+ - Mensa::ControlBar::Component
144
+ - turbo-frame with the actual table you see (which is rendered by Mensa::View::Component)
145
+
94
146
  ## Installation
95
147
 
96
148
  Add this line to your application's Gemfile:
@@ -1,7 +1,7 @@
1
1
  @import '../../../components/mensa/add_filter/component.css';
2
2
  @import '../../../components/mensa/cell/component.css';
3
3
  @import '../../../components/mensa/control_bar/component.css';
4
- @import '../../../components/mensa/filters/component.css';
4
+ @import '../../../components/mensa/filter_list/component.css';
5
5
  @import '../../../components/mensa/header/component.css';
6
6
  @import '../../../components/mensa/row_action/component.css';
7
7
  @import '../../../components/mensa/search/component.css';
@@ -16,7 +16,7 @@ export default class AddFilterComponentController extends ApplicationController
16
16
  supportsViews: Boolean
17
17
  }
18
18
 
19
- connect () {
19
+ connect() {
20
20
  super.connect()
21
21
 
22
22
  // this.filterValueEntered = debounce(this.filterValueEntered, 500).bind(this)
@@ -25,12 +25,12 @@ export default class AddFilterComponentController extends ApplicationController
25
25
  }
26
26
 
27
27
  // Called when you click add-filter
28
- toggle (event) {
28
+ toggle(event) {
29
29
  this.filterListTarget.classList.toggle('hidden')
30
30
  }
31
31
 
32
32
  // Called when you selected a column
33
- openValuePopover (event) {
33
+ openValuePopover(event) {
34
34
  let url = this.ourUrl
35
35
  url.pathname += `/filters/${this.selectedFilterColumn}`
36
36
  url.searchParams.append('target', this.valuePopoverTarget.id)
@@ -43,7 +43,7 @@ export default class AddFilterComponentController extends ApplicationController
43
43
  }
44
44
 
45
45
  // Called when you select a column from the "dropdown"
46
- selectColumn (event) {
46
+ selectColumn(event) {
47
47
  this.filterListItemTargets.forEach((lt) => {
48
48
  let check = lt.querySelector('.check')
49
49
  check.classList.add('hidden')
@@ -60,22 +60,26 @@ export default class AddFilterComponentController extends ApplicationController
60
60
  }
61
61
 
62
62
  // Called when you entered/selected a filter value
63
- filterValueEntered (event) {
63
+ filterValueEntered(event) {
64
64
  this.valuePopoverTarget.classList.add('hidden')
65
65
 
66
66
  let url = this.ourUrl
67
67
 
68
68
  let filters = url.searchParams.get('filters') || {}
69
+ this.mensaTableOutlet.mensaFilterOutlets.forEach((filterOutlet) => {
70
+ url.searchParams.append(`filters[${filterOutlet.columnNameValue}][value]`, filterOutlet.valueValue)
71
+ url.searchParams.append(`filters[${filterOutlet.columnNameValue}][operator]`, filterOutlet.operatorValue)
72
+ })
69
73
  // FIXME: Needs better way of getting value
70
- url.searchParams.append(`filters[${this.selectedFilterColumn}]`, event.target.value)
74
+ url.searchParams.append(`filters[${this.selectedFilterColumn}][value]`, event.target.value)
71
75
 
72
76
  get(url, {
73
77
  responseKind: 'turbo-stream'
74
78
  }).then(() => {
75
79
  // FIXME: There should be a better way to do this, possibly using
76
- // this.mensaTableOutlet.filtersTarget.addEventListener("turbo:after-stream-render", this.unhide.bind(this)) ?
80
+ // this.mensaTableOutlet.filterListTarget.addEventListener("turbo:after-stream-render", this.unhide.bind(this)) ?
77
81
  setTimeout(() => {
78
- this.mensaTableOutlet.filtersTarget.classList.remove('hidden')
82
+ this.mensaTableOutlet.filterListTarget.classList.remove('hidden')
79
83
  }, 50)
80
84
  })
81
85
  event.preventDefault()
@@ -0,0 +1,12 @@
1
+ import ApplicationController from 'mensa/controllers/application_controller'
2
+
3
+ export default class FilterComponentController extends ApplicationController {
4
+ static values = {
5
+ columnName: String,
6
+ operator: String,
7
+ value: String,
8
+ };
9
+
10
+ connect() {
11
+ }
12
+ }
@@ -1,10 +1,10 @@
1
- .mensa-table__filters.hidden data-mensa-table-target="filters"
1
+ .mensa-table__filters.hidden data-mensa-table-target="filterList"
2
2
  .block
3
3
  nav
4
4
  .flex.space-x-2.overflow-none.whitespace-nowrap.scroll-p-0[aria-label="Tabs"]
5
5
  / existing filters first
6
6
  - table.active_filters.each do |filter|
7
- .relative
7
+ .relative data-controller="mensa-filter" data-mensa-filter-column-name-value=filter.column.name data-mensa-filter-value-value=filter.value data-mensa-filter-operator-value=filter.operator
8
8
  button.relative.w-full.cursor-default.rounded-md.bg-white.dark:bg-gray-800.py-1.5.pl-3.text-left.text-gray-900.dark:text-gray-400.shadow-sm.ring-1.ring-inset.ring-gray-300.dark:ring-gray-600.focus:outline-none.focus:ring-2.focus:ring-primary-600.sm:text-sm.sm:leading-6[type="button" aria-haspopup="listbox" aria-expanded="true" aria-labelledby="listbox-label"]
9
9
  span.block.truncate.pr-6
10
10
  = filter