mensa 0.2.2 → 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e79f4a4d3a4be038ed02e0f7dd30fee1abf0b6945b1a5817f05103928c288296
4
- data.tar.gz: 888bdc7e9aeead37ec6f0461b7bcedd4a63905eaad8a75a4f57b698c88d8a05f
3
+ metadata.gz: d7cb98df22a002a08d25141f67df7807ebf5f2eb102831db09614f7de86b8772
4
+ data.tar.gz: 301c827f9ed63c1acb745359202021723df9142e03ee190a75312b01f6642fe1
5
5
  SHA512:
6
- metadata.gz: 2b8d4acf77c6ed877a58ad145cd522fa50fccf770336f13e657c312c7d04a2a1e0b9eb37c9d6d7a16745c17924d3969deb6777921280834e31fa4a45cd29d644
7
- data.tar.gz: b8053f1def913871788a7f3e2530e4ff7946e241af8c258d1a392b637aabad9bc3c40eaa0b71ab34c7454d2b1091346e2683b1a93e1f299af11845e28aecc886
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,9 +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
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.1)
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)
@@ -154,11 +138,13 @@ GEM
154
138
  pp (>= 0.6.0)
155
139
  rdoc (>= 4.0.0)
156
140
  reline (>= 0.4.2)
157
- json (2.15.2)
141
+ json (2.16.0)
158
142
  jsonb_accessor (1.4)
159
143
  activerecord (>= 6.1)
160
144
  activesupport (>= 6.1)
161
145
  pg (>= 0.18.1)
146
+ language_server-protocol (3.17.0.5)
147
+ lint_roller (1.1.0)
162
148
  logger (1.7.0)
163
149
  loofah (2.24.1)
164
150
  crass (~> 1.0.2)
@@ -173,7 +159,7 @@ GEM
173
159
  matrix (0.4.3)
174
160
  method_source (1.1.0)
175
161
  mini_mime (1.1.5)
176
- minitest (5.26.0)
162
+ minitest (5.26.1)
177
163
  net-imap (0.5.12)
178
164
  date
179
165
  net-protocol
@@ -200,9 +186,18 @@ GEM
200
186
  racc (~> 1.4)
201
187
  nokogiri (1.18.10-x86_64-linux-musl)
202
188
  racc (~> 1.4)
203
- 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)
204
195
  json
205
196
  yaml
197
+ parallel (1.27.0)
198
+ parser (3.3.10.0)
199
+ ast (~> 2.4.1)
200
+ racc
206
201
  pg (1.6.2)
207
202
  pg (1.6.2-aarch64-linux)
208
203
  pg (1.6.2-aarch64-linux-musl)
@@ -213,6 +208,7 @@ GEM
213
208
  pp (0.6.3)
214
209
  prettyprint
215
210
  prettyprint (0.2.0)
211
+ prism (1.6.0)
216
212
  pry (0.15.2)
217
213
  coderay (~> 1.1)
218
214
  method_source (~> 1.0)
@@ -231,20 +227,20 @@ GEM
231
227
  rack (>= 1.3)
232
228
  rackup (2.2.1)
233
229
  rack (>= 3)
234
- rails (8.1.1)
235
- actioncable (= 8.1.1)
236
- actionmailbox (= 8.1.1)
237
- actionmailer (= 8.1.1)
238
- actionpack (= 8.1.1)
239
- actiontext (= 8.1.1)
240
- actionview (= 8.1.1)
241
- activejob (= 8.1.1)
242
- activemodel (= 8.1.1)
243
- activerecord (= 8.1.1)
244
- activestorage (= 8.1.1)
245
- 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)
246
242
  bundler (>= 1.15.0)
247
- railties (= 8.1.1)
243
+ railties (= 8.0.4)
248
244
  rails-dom-testing (2.3.0)
249
245
  activesupport (>= 5.0.0)
250
246
  minitest
@@ -252,25 +248,69 @@ GEM
252
248
  rails-html-sanitizer (1.6.2)
253
249
  loofah (~> 2.21)
254
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)
255
- railties (8.1.1)
256
- actionpack (= 8.1.1)
257
- activesupport (= 8.1.1)
251
+ railties (8.0.4)
252
+ actionpack (= 8.0.4)
253
+ activesupport (= 8.0.4)
258
254
  irb (~> 1.13)
259
255
  rackup (>= 1.0.0)
260
256
  rake (>= 12.2)
261
257
  thor (~> 1.0, >= 1.2.2)
262
258
  tsort (>= 0.2)
263
259
  zeitwerk (~> 2.6)
260
+ rainbow (3.1.1)
264
261
  rake (13.3.1)
262
+ rbs (3.9.5)
263
+ logger
265
264
  rdoc (6.15.1)
266
265
  erb
267
266
  psych (>= 4.0.0)
268
267
  tsort
269
268
  regexp_parser (2.11.3)
270
- reline (0.6.2)
269
+ reline (0.6.3)
271
270
  io-console (~> 0.5)
272
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)
273
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
274
314
  securerandom (0.4.1)
275
315
  selenium-webdriver (4.38.0)
276
316
  base64 (~> 0.2)
@@ -297,6 +337,18 @@ GEM
297
337
  sqlite3 (2.8.0-x86_64-darwin)
298
338
  sqlite3 (2.8.0-x86_64-linux-gnu)
299
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)
300
352
  stimulus-rails (1.3.4)
301
353
  railties (>= 6.0.0)
302
354
  stringio (3.1.7)
@@ -320,11 +372,15 @@ GEM
320
372
  railties (>= 7.1.0)
321
373
  tzinfo (2.0.6)
322
374
  concurrent-ruby (~> 1.0)
375
+ unicode-display_width (3.2.0)
376
+ unicode-emoji (~> 4.1)
377
+ unicode-emoji (4.1.0)
323
378
  uri (1.1.1)
324
379
  useragent (0.16.11)
325
- view_component (4.1.0)
326
- activesupport (>= 7.1.0, < 8.2)
380
+ view_component (3.23.2)
381
+ activesupport (>= 5.2.0, < 8.1)
327
382
  concurrent-ruby (~> 1)
383
+ method_source (~> 1.0)
328
384
  websocket (1.2.11)
329
385
  websocket-driver (0.8.0)
330
386
  base64
@@ -351,13 +407,18 @@ DEPENDENCIES
351
407
  capybara (~> 3.40)
352
408
  debug
353
409
  mensa!
410
+ overmind
354
411
  pry
355
412
  puma
356
- satis (~> 2)!
413
+ rubocop-rails
414
+ ruby-lsp
415
+ ruby-lsp-rails
416
+ satis (~> 2)
357
417
  selenium-webdriver (~> 4.17)
358
418
  slim (~> 5.2)
359
419
  sprockets-rails
360
420
  sqlite3 (~> 2.8)
421
+ standard
361
422
 
362
423
  BUNDLED WITH
363
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,27 +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)
11
- - [ ] column sorting
12
14
  - [x] filtering of multiple columns
15
+ - [X] Hide filter icon in case there are no filters
16
+
17
+ Still to do:
18
+ - [ ] column sorting
13
19
  - [ ] editing of existing filters
14
20
  - [ ] view selection and exports per view
21
+ - [ ] multiple selection of rows
15
22
 
16
- optionally:
23
+ Optionally:
17
24
 
18
25
  - [ ] group by
19
26
  - [ ] sum/max/min
20
27
  - [ ] tables backed by arrays (of ActiveModel)
21
28
 
22
- Todo:
29
+ Todo/Fixme:
23
30
 
24
- - [X] Hide filter icon in case there are no filters
25
- - [ ] Search only works on table columns
31
+ - [ ] Search only works on table text columns
26
32
 
27
33
  ## Usage
28
34
 
@@ -67,6 +73,15 @@ class UserTable < ApplicationTable
67
73
  view_columns_sorting false # Disabled for now
68
74
  view_condensed false # Default false
69
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
70
85
  end
71
86
  end
72
87
  ```
@@ -78,9 +93,12 @@ You can show your tables on the page using the following:
78
93
  = sts.table :users
79
94
  ```
80
95
 
81
- #### 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:
82
101
 
83
- Initial support for views is there, but pretty rudimentary:
84
102
  `Mensa::TableView.create(table: "users", name: "Guests", data: {filters: {role: {value: "guest"}}})`
85
103
 
86
104
  ### Fast
@@ -95,6 +113,36 @@ column :age do
95
113
  end
96
114
  ```
97
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
+
98
146
  ## Installation
99
147
 
100
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';
@@ -1,6 +1,6 @@
1
1
  .mensa-table {
2
2
  .paging {
3
- @apply flex items-center justify-between border-t border-gray-100 dark:border-gray-600 bg-white dark:bg-gray-800 px-4 py-3 sm:px-6;
3
+ @apply flex items-center justify-between border-t border-gray-100 dark:border-gray-600 bg-white dark:bg-gray-800 px-4 py-3 sm:px-6 text-sm;
4
4
 
5
5
  .pagy {
6
6
  @apply isolate inline-flex -space-x-px text-gray-500 dark:text-gray-400;
@@ -1,4 +1,4 @@
1
- .mensa-table__views data-mensa-table-target="views"
1
+ .mensa-table__views data-mensa-table-target="views" data-controller="mensa-views"
2
2
  .sm:hidden
3
3
  label.sr-only[for="tabs"]
4
4
  | Select a tab
@@ -9,7 +9,7 @@
9
9
  nav.flex.justify-between[aria-label="Tabs"]
10
10
  .flex.space-x-2.overflow-x-auto.whitespace-nowrap.scroll-p-0
11
11
  - table.all_views.each.with_index do |view, index|
12
- = link_to(table.path(table_view_id: view.id, turbo_frame_id: table.table_id), "data-turbo-frame": table.table_id, class: "view #{(view == table.table_view) || (!view.persisted? && table.table_view.blank?) ? 'selected' : ''}") do
12
+ = link_to(table.path(table_view_id: view.id, turbo_frame_id: table.table_id), "data-turbo-frame": table.table_id, class: "view #{(view.id == table.table_view&.id || view.id == :all && table.table_view.blank?) ? 'selected' : ''}", data: {"mensa-views-target": "view", action: "mensa-views#select"}) do
13
13
  = view.name
14
14
 
15
15
  - if table.supports_custom_views?
@@ -11,4 +11,4 @@ module Mensa
11
11
  end
12
12
  end
13
13
  end
14
- end
14
+ end
@@ -0,0 +1,13 @@
1
+ import ApplicationController from 'mensa/controllers/application_controller'
2
+
3
+ export default class ViewsComponentController extends ApplicationController {
4
+ static targets = [
5
+ 'view',
6
+ ]
7
+
8
+ select(event) {
9
+ this.viewTargets.forEach((element) => {
10
+ (element === event.target) ? element.classList.add('selected') : element.classList.remove('selected')
11
+ })
12
+ }
13
+ }
@@ -2,17 +2,15 @@ module Mensa
2
2
  class TablesController < ::ApplicationController
3
3
  layout :decide_layout
4
4
 
5
- def index
6
- render layout: 'mensa/application'
7
- end
8
-
9
5
  def show
10
- config = if params[:table_view_id]
11
- @view = Mensa::TableView.find_by(table_name: params[:id], id: params[:table_view_id])
12
- @view&.data || {}
13
- else
14
- {}
15
- end
6
+ @table = Mensa.for_name(params[:id])
7
+
8
+ config = {}
9
+ if params[:table_view_id]
10
+ @view = Mensa::TableView.find_by(table_name: params[:id], id: params[:table_view_id])
11
+ @view ||= @table.system_views.find { |v| v.id == params[:table_view_id].to_sym }
12
+ config = @view&.data
13
+ end
16
14
 
17
15
  config = config.merge(params.permit!.to_h)
18
16
  config = config.merge(params.permit(:format, :query, :id, :page, :table_view_id, :turbo_frame_id, order: {}, filters: {}).to_h)
@@ -33,7 +31,7 @@ module Mensa
33
31
  end
34
32
 
35
33
  def decide_layout
36
- return false if params[:turbo_frame_id]
34
+ false if params[:turbo_frame_id]
37
35
  end
38
36
  end
39
37
  end
@@ -18,6 +18,9 @@ application.register("mensa-search", SearchComponentController);
18
18
  import TableComponentController from 'mensa/components/table/component_controller'
19
19
  application.register("mensa-table", TableComponentController);
20
20
 
21
+ import ViewsComponentController from 'mensa/components/views/component_controller'
22
+ application.register("mensa-views", ViewsComponentController);
23
+
21
24
  // Eager load all controllers defined in the import map under controllers/**/*_controller
22
25
  // import { eagerLoadControllersFrom } from "@hotwired/stimulus-loading"
23
26
  // eagerLoadControllersFrom("controllers", application)
@@ -10,6 +10,7 @@ module Mensa
10
10
  # end
11
11
  class Action
12
12
  include ConfigReaders
13
+
13
14
  attr_reader :name, :table, :config
14
15
 
15
16
  def initialize(name, config:, table:)
@@ -23,6 +24,5 @@ module Mensa
23
24
  config_reader :link_attributes
24
25
  config_reader :icon
25
26
  config_reader :show, call: false
26
-
27
27
  end
28
28
  end