mensa 0.1.0 → 0.1.4

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 (110) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/gem-push.yml +11 -0
  3. data/.gitignore +12 -0
  4. data/Gemfile +10 -8
  5. data/Gemfile.lock +299 -0
  6. data/MIT-LICENSE +20 -0
  7. data/Procfile +2 -0
  8. data/README.md +76 -18
  9. data/Rakefile +5 -13
  10. data/app/assets/config/mensa_manifest.js +5 -0
  11. data/app/assets/images/mensa/.keep +0 -0
  12. data/app/assets/stylesheets/mensa/application.css +11 -0
  13. data/app/components/mensa/add_filter/component.css +13 -0
  14. data/app/components/mensa/add_filter/component.html.slim +16 -0
  15. data/app/components/mensa/add_filter/component.rb +13 -0
  16. data/app/components/mensa/add_filter/component_controller.js +84 -0
  17. data/app/components/mensa/application_component.rb +12 -0
  18. data/app/components/mensa/cell/component.css +0 -0
  19. data/app/components/mensa/cell/component.html.slim +1 -0
  20. data/app/components/mensa/cell/component.rb +15 -0
  21. data/app/components/mensa/control_bar/component.css +5 -0
  22. data/app/components/mensa/control_bar/component.html.slim +15 -0
  23. data/app/components/mensa/control_bar/component.rb +21 -0
  24. data/app/components/mensa/filters/component.css +14 -0
  25. data/app/components/mensa/filters/component.html.slim +14 -0
  26. data/app/components/mensa/filters/component.rb +13 -0
  27. data/app/components/mensa/filters/component_controller.js +14 -0
  28. data/app/components/mensa/header/component.css +54 -0
  29. data/app/components/mensa/header/component.html.slim +8 -0
  30. data/app/components/mensa/header/component.rb +19 -0
  31. data/app/components/mensa/row_action/component.css +0 -0
  32. data/app/components/mensa/row_action/component.html.slim +6 -0
  33. data/app/components/mensa/row_action/component.rb +19 -0
  34. data/app/components/mensa/search/component.css +13 -0
  35. data/app/components/mensa/search/component.html.slim +17 -0
  36. data/app/components/mensa/search/component.rb +13 -0
  37. data/app/components/mensa/search/component_controller.js +62 -0
  38. data/app/components/mensa/table/component.css +0 -0
  39. data/app/components/mensa/table/component.html.slim +7 -0
  40. data/app/components/mensa/table/component.rb +16 -0
  41. data/app/components/mensa/table/component_controller.js +72 -0
  42. data/app/components/mensa/table_row/component.css +0 -0
  43. data/app/components/mensa/table_row/component.html.slim +6 -0
  44. data/app/components/mensa/table_row/component.rb +19 -0
  45. data/app/components/mensa/view/component.css +78 -0
  46. data/app/components/mensa/view/component.html.slim +17 -0
  47. data/app/components/mensa/view/component.rb +16 -0
  48. data/app/components/mensa/views/component.css +13 -0
  49. data/app/components/mensa/views/component.html.slim +18 -0
  50. data/app/components/mensa/views/component.rb +14 -0
  51. data/app/controllers/concerns/.keep +0 -0
  52. data/app/controllers/mensa/application_controller.rb +4 -0
  53. data/app/controllers/mensa/tables/filters_controller.rb +29 -0
  54. data/app/controllers/mensa/tables_controller.rb +37 -0
  55. data/app/helpers/mensa/application_helper.rb +5 -0
  56. data/app/helpers/mensa/tables_helper.rb +5 -0
  57. data/app/javascript/mensa/application.js +3 -0
  58. data/app/javascript/mensa/controllers/alert_controller.js +7 -0
  59. data/app/javascript/mensa/controllers/application.js +8 -0
  60. data/app/javascript/mensa/controllers/application_controller.js +57 -0
  61. data/app/javascript/mensa/controllers/index.js +24 -0
  62. data/app/jobs/mensa/application_job.rb +7 -0
  63. data/app/jobs/mensa/export_job.rb +91 -0
  64. data/app/models/concerns/.keep +0 -0
  65. data/app/models/mensa/application_record.rb +5 -0
  66. data/app/models/mensa/table_view.rb +5 -0
  67. data/app/tables/mensa/action.rb +26 -0
  68. data/app/tables/mensa/base.rb +103 -0
  69. data/app/tables/mensa/cell.rb +50 -0
  70. data/app/tables/mensa/column.rb +85 -0
  71. data/app/tables/mensa/config/action_dsl.rb +12 -0
  72. data/app/tables/mensa/config/column_dsl.rb +23 -0
  73. data/app/tables/mensa/config/dsl_logic.rb +90 -0
  74. data/app/tables/mensa/config/filter_dsl.rb +8 -0
  75. data/app/tables/mensa/config/render_dsl.rb +8 -0
  76. data/app/tables/mensa/config/table_dsl.rb +71 -0
  77. data/app/tables/mensa/config_readers.rb +13 -0
  78. data/app/tables/mensa/filter.rb +31 -0
  79. data/app/tables/mensa/row.rb +36 -0
  80. data/app/tables/mensa/scope.rb +99 -0
  81. data/app/views/layouts/mensa/application.html.slim +11 -0
  82. data/app/views/mensa/tables/filters/show.turbo_stream.slim +8 -0
  83. data/app/views/mensa/tables/index.html.slim +93 -0
  84. data/app/views/mensa/tables/show.html.slim +5 -0
  85. data/app/views/mensa/tables/show.turbo_stream.slim +5 -0
  86. data/bin/importmap +4 -0
  87. data/bin/rails +14 -0
  88. data/config/importmap.rb +8 -0
  89. data/config/locales/en.yml +8 -0
  90. data/config/locales/nl.yml +11 -0
  91. data/config/routes.rb +7 -0
  92. data/db/migrate/20240201184752_create_mensa_table_views.rb +15 -0
  93. data/lib/generators/mensa/install_generator.rb +24 -0
  94. data/lib/generators/mensa/tailwind_config_generator.rb +24 -0
  95. data/lib/generators/mensa/templates/config/initializers/mensa.rb +22 -0
  96. data/lib/mensa/configuration.rb +90 -0
  97. data/lib/mensa/engine.rb +37 -0
  98. data/lib/mensa/version.rb +1 -3
  99. data/lib/mensa.rb +24 -5
  100. data/lib/tasks/mensa_tasks.rake +13 -0
  101. data/mensa.gemspec +42 -0
  102. data/package.json +10 -0
  103. data/vendor/javascript/@rails--request.js.js +2 -0
  104. data/yarn.lock +837 -0
  105. metadata +245 -18
  106. data/.rubocop.yml +0 -13
  107. data/CHANGELOG.md +0 -5
  108. data/CODE_OF_CONDUCT.md +0 -84
  109. data/LICENSE.txt +0 -21
  110. data/sig/mensa.rbs +0 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 693824396fcaa092255839aa58efe3d4d1ac6bd8c4fd875083a99441b19a0808
4
- data.tar.gz: 4c0c129bb20e3da24502c6638ff7087e6ed15d4a7b8f8c9728fe3dcb36eb4941
3
+ metadata.gz: 0e3a373d1a2e96d1d452ac526820d62e81bd6c1c208bf20d70cccd89a78adf8e
4
+ data.tar.gz: eb242b5290916cd776c12921f99ee0b36ccc2d7b54befb655ddebd0b969d84f9
5
5
  SHA512:
6
- metadata.gz: f5f697e9fec2812b30037075ce0e66ddfd6921b6fda769726fb2681b9b422f7884af2c0c34d2c21983e35ca1e10f31d6894ef04892b01d398182614f200608f6
7
- data.tar.gz: ee763404f5311c4a20dd09839e4b702a4f6fbedbe6d518b6d4d5e09553dae325f006d7bf4fd57121a85961b2f9e248c6eba90154cc2ed25e1248933d61e5853f
6
+ metadata.gz: 23db6e11b7621c2cec3ae2b74d52e468aeb554ba02d05a05b2a22aca198ac6199048a64b8411e8f8db5585fab26cd0a8b6162b94e3743bb405bbe84120509f81
7
+ data.tar.gz: ee314cf9ffde839f95ef505698adf5cefa42bad750d2684092ace87d09baa0a898b4e5ff68a77267b17726cd95899d78769df1bbd2af86b08c48be547a808de2
@@ -0,0 +1,11 @@
1
+ name: Rubygem Push
2
+ on:
3
+ push:
4
+ tags:
5
+ - "*"
6
+ jobs:
7
+ build:
8
+ uses: entdec/_workflows/.github/workflows/gem-push.yml@main
9
+ with:
10
+ public: true
11
+ secrets: inherit
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /doc/
3
+ /log/*.log
4
+ /pkg/
5
+ /tmp/
6
+ /test/dummy/db/*.sqlite3
7
+ /test/dummy/db/*.sqlite3-*
8
+ /test/dummy/log/*.log
9
+ /test/dummy/storage/
10
+ /test/dummy/app/assets/builds/
11
+ /test/dummy/tmp/
12
+ /node_modules/
data/Gemfile CHANGED
@@ -1,12 +1,14 @@
1
- # frozen_string_literal: true
2
-
3
1
  source "https://rubygems.org"
2
+ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3
+ git_source(:entdec) { |repo_name| "git@github.com:entdec/#{repo_name}.git" }
4
4
 
5
- # Specify your gem's dependencies in mensa.gemspec
5
+ # Specify your gem's dependencies in mensa.gemspec.
6
6
  gemspec
7
7
 
8
- gem "rake", "~> 13.0"
9
-
10
- gem "minitest", "~> 5.0"
11
-
12
- gem "rubocop", "~> 1.21"
8
+ gem "puma"
9
+ gem "sprockets-rails"
10
+ gem "satis", "~> 1", entdec: "satis", branch: "main"
11
+ gem "pry"
12
+ gem "capybara", "~> 3.40"
13
+ gem "selenium-webdriver", "~> 4.17"
14
+ gem "slim", "~> 5.2"
data/Gemfile.lock ADDED
@@ -0,0 +1,299 @@
1
+ GIT
2
+ remote: git@github.com:entdec/satis.git
3
+ revision: b065f7cebc4d8d28448e75c743fa88da643e3e03
4
+ branch: main
5
+ specs:
6
+ satis (1.0.136)
7
+ ar_doc_store (~> 2.1)
8
+ browser
9
+ diffy
10
+ rails (>= 6)
11
+ view_component
12
+
13
+ PATH
14
+ remote: .
15
+ specs:
16
+ mensa (0.1.0)
17
+ caxlsx_rails (~> 0)
18
+ importmap-rails
19
+ pagy (>= 6)
20
+ rails (>= 7.1)
21
+ slim
22
+ stimulus-rails
23
+ tailwindcss-rails
24
+ textacular (>= 5)
25
+ turbo-rails
26
+
27
+ GEM
28
+ remote: https://rubygems.org/
29
+ specs:
30
+ actioncable (7.1.2)
31
+ actionpack (= 7.1.2)
32
+ activesupport (= 7.1.2)
33
+ nio4r (~> 2.0)
34
+ websocket-driver (>= 0.6.1)
35
+ zeitwerk (~> 2.6)
36
+ actionmailbox (7.1.2)
37
+ actionpack (= 7.1.2)
38
+ activejob (= 7.1.2)
39
+ activerecord (= 7.1.2)
40
+ activestorage (= 7.1.2)
41
+ activesupport (= 7.1.2)
42
+ mail (>= 2.7.1)
43
+ net-imap
44
+ net-pop
45
+ net-smtp
46
+ actionmailer (7.1.2)
47
+ actionpack (= 7.1.2)
48
+ actionview (= 7.1.2)
49
+ activejob (= 7.1.2)
50
+ activesupport (= 7.1.2)
51
+ mail (~> 2.5, >= 2.5.4)
52
+ net-imap
53
+ net-pop
54
+ net-smtp
55
+ rails-dom-testing (~> 2.2)
56
+ actionpack (7.1.2)
57
+ actionview (= 7.1.2)
58
+ activesupport (= 7.1.2)
59
+ nokogiri (>= 1.8.5)
60
+ racc
61
+ rack (>= 2.2.4)
62
+ rack-session (>= 1.0.1)
63
+ rack-test (>= 0.6.3)
64
+ rails-dom-testing (~> 2.2)
65
+ rails-html-sanitizer (~> 1.6)
66
+ actiontext (7.1.2)
67
+ actionpack (= 7.1.2)
68
+ activerecord (= 7.1.2)
69
+ activestorage (= 7.1.2)
70
+ activesupport (= 7.1.2)
71
+ globalid (>= 0.6.0)
72
+ nokogiri (>= 1.8.5)
73
+ actionview (7.1.2)
74
+ activesupport (= 7.1.2)
75
+ builder (~> 3.1)
76
+ erubi (~> 1.11)
77
+ rails-dom-testing (~> 2.2)
78
+ rails-html-sanitizer (~> 1.6)
79
+ activejob (7.1.2)
80
+ activesupport (= 7.1.2)
81
+ globalid (>= 0.3.6)
82
+ activemodel (7.1.2)
83
+ activesupport (= 7.1.2)
84
+ activerecord (7.1.2)
85
+ activemodel (= 7.1.2)
86
+ activesupport (= 7.1.2)
87
+ timeout (>= 0.4.0)
88
+ activestorage (7.1.2)
89
+ actionpack (= 7.1.2)
90
+ activejob (= 7.1.2)
91
+ activerecord (= 7.1.2)
92
+ activesupport (= 7.1.2)
93
+ marcel (~> 1.0)
94
+ activesupport (7.1.2)
95
+ base64
96
+ bigdecimal
97
+ concurrent-ruby (~> 1.0, >= 1.0.2)
98
+ connection_pool (>= 2.2.5)
99
+ drb
100
+ i18n (>= 1.6, < 2)
101
+ minitest (>= 5.1)
102
+ mutex_m
103
+ tzinfo (~> 2.0)
104
+ addressable (2.8.6)
105
+ public_suffix (>= 2.0.2, < 6.0)
106
+ ar_doc_store (2.1.3)
107
+ activerecord (>= 6.1)
108
+ pg
109
+ base64 (0.2.0)
110
+ bigdecimal (3.1.5)
111
+ browser (5.3.1)
112
+ builder (3.2.4)
113
+ capybara (3.40.0)
114
+ addressable
115
+ matrix
116
+ mini_mime (>= 0.1.3)
117
+ nokogiri (~> 1.11)
118
+ rack (>= 1.6.0)
119
+ rack-test (>= 0.6.3)
120
+ regexp_parser (>= 1.5, < 3.0)
121
+ xpath (~> 3.2)
122
+ caxlsx (3.4.1)
123
+ htmlentities (~> 4.3, >= 4.3.4)
124
+ marcel (~> 1.0)
125
+ nokogiri (~> 1.10, >= 1.10.4)
126
+ rubyzip (>= 1.3.0, < 3)
127
+ caxlsx_rails (0.6.3)
128
+ actionpack (>= 3.1)
129
+ caxlsx (>= 3.0)
130
+ coderay (1.1.3)
131
+ concurrent-ruby (1.2.2)
132
+ connection_pool (2.4.1)
133
+ crass (1.0.6)
134
+ date (3.3.4)
135
+ diffy (3.4.2)
136
+ drb (2.2.0)
137
+ ruby2_keywords
138
+ erubi (1.12.0)
139
+ globalid (1.2.1)
140
+ activesupport (>= 6.1)
141
+ htmlentities (4.3.4)
142
+ i18n (1.14.1)
143
+ concurrent-ruby (~> 1.0)
144
+ importmap-rails (2.0.1)
145
+ actionpack (>= 6.0.0)
146
+ activesupport (>= 6.0.0)
147
+ railties (>= 6.0.0)
148
+ io-console (0.7.1)
149
+ irb (1.11.1)
150
+ rdoc
151
+ reline (>= 0.4.2)
152
+ loofah (2.22.0)
153
+ crass (~> 1.0.2)
154
+ nokogiri (>= 1.12.0)
155
+ mail (2.8.1)
156
+ mini_mime (>= 0.1.1)
157
+ net-imap
158
+ net-pop
159
+ net-smtp
160
+ marcel (1.0.2)
161
+ matrix (0.4.2)
162
+ method_source (1.0.0)
163
+ mini_mime (1.1.5)
164
+ minitest (5.21.1)
165
+ mutex_m (0.2.0)
166
+ net-imap (0.4.9.1)
167
+ date
168
+ net-protocol
169
+ net-pop (0.1.2)
170
+ net-protocol
171
+ net-protocol (0.2.2)
172
+ timeout
173
+ net-smtp (0.4.0.1)
174
+ net-protocol
175
+ nio4r (2.7.0)
176
+ nokogiri (1.16.0-arm64-darwin)
177
+ racc (~> 1.4)
178
+ nokogiri (1.16.0-x86_64-linux)
179
+ racc (~> 1.4)
180
+ pagy (7.0.4)
181
+ pg (1.5.4)
182
+ pry (0.14.2)
183
+ coderay (~> 1.1)
184
+ method_source (~> 1.0)
185
+ psych (5.1.2)
186
+ stringio
187
+ public_suffix (5.0.4)
188
+ puma (6.4.2)
189
+ nio4r (~> 2.0)
190
+ racc (1.7.3)
191
+ rack (3.0.8)
192
+ rack-session (2.0.0)
193
+ rack (>= 3.0.0)
194
+ rack-test (2.1.0)
195
+ rack (>= 1.3)
196
+ rackup (2.1.0)
197
+ rack (>= 3)
198
+ webrick (~> 1.8)
199
+ rails (7.1.2)
200
+ actioncable (= 7.1.2)
201
+ actionmailbox (= 7.1.2)
202
+ actionmailer (= 7.1.2)
203
+ actionpack (= 7.1.2)
204
+ actiontext (= 7.1.2)
205
+ actionview (= 7.1.2)
206
+ activejob (= 7.1.2)
207
+ activemodel (= 7.1.2)
208
+ activerecord (= 7.1.2)
209
+ activestorage (= 7.1.2)
210
+ activesupport (= 7.1.2)
211
+ bundler (>= 1.15.0)
212
+ railties (= 7.1.2)
213
+ rails-dom-testing (2.2.0)
214
+ activesupport (>= 5.0.0)
215
+ minitest
216
+ nokogiri (>= 1.6)
217
+ rails-html-sanitizer (1.6.0)
218
+ loofah (~> 2.21)
219
+ nokogiri (~> 1.14)
220
+ railties (7.1.2)
221
+ actionpack (= 7.1.2)
222
+ activesupport (= 7.1.2)
223
+ irb
224
+ rackup (>= 1.0.0)
225
+ rake (>= 12.2)
226
+ thor (~> 1.0, >= 1.2.2)
227
+ zeitwerk (~> 2.6)
228
+ rake (13.1.0)
229
+ rdoc (6.6.2)
230
+ psych (>= 4.0.0)
231
+ regexp_parser (2.9.0)
232
+ reline (0.4.2)
233
+ io-console (~> 0.5)
234
+ rexml (3.2.6)
235
+ ruby2_keywords (0.0.5)
236
+ rubyzip (2.3.2)
237
+ selenium-webdriver (4.18.1)
238
+ base64 (~> 0.2)
239
+ rexml (~> 3.2, >= 3.2.5)
240
+ rubyzip (>= 1.2.2, < 3.0)
241
+ websocket (~> 1.0)
242
+ slim (5.2.1)
243
+ temple (~> 0.10.0)
244
+ tilt (>= 2.1.0)
245
+ sprockets (4.2.1)
246
+ concurrent-ruby (~> 1.0)
247
+ rack (>= 2.2.4, < 4)
248
+ sprockets-rails (3.4.2)
249
+ actionpack (>= 5.2)
250
+ activesupport (>= 5.2)
251
+ sprockets (>= 3.0.0)
252
+ stimulus-rails (1.3.3)
253
+ railties (>= 6.0.0)
254
+ stringio (3.1.0)
255
+ tailwindcss-rails (2.3.0-arm64-darwin)
256
+ railties (>= 6.0.0)
257
+ tailwindcss-rails (2.3.0-x86_64-linux)
258
+ railties (>= 6.0.0)
259
+ temple (0.10.3)
260
+ textacular (5.6.0)
261
+ activerecord (>= 5.0, < 7.2)
262
+ thor (1.3.0)
263
+ tilt (2.3.0)
264
+ timeout (0.4.1)
265
+ turbo-rails (2.0.4)
266
+ actionpack (>= 6.0.0)
267
+ activejob (>= 6.0.0)
268
+ railties (>= 6.0.0)
269
+ tzinfo (2.0.6)
270
+ concurrent-ruby (~> 1.0)
271
+ view_component (3.10.0)
272
+ activesupport (>= 5.2.0, < 8.0)
273
+ concurrent-ruby (~> 1.0)
274
+ method_source (~> 1.0)
275
+ webrick (1.8.1)
276
+ websocket (1.2.10)
277
+ websocket-driver (0.7.6)
278
+ websocket-extensions (>= 0.1.0)
279
+ websocket-extensions (0.1.5)
280
+ xpath (3.2.0)
281
+ nokogiri (~> 1.8)
282
+ zeitwerk (2.6.12)
283
+
284
+ PLATFORMS
285
+ arm64-darwin-22
286
+ x86_64-linux
287
+
288
+ DEPENDENCIES
289
+ capybara (~> 3.40)
290
+ mensa!
291
+ pry
292
+ puma
293
+ satis (~> 1)!
294
+ selenium-webdriver (~> 4.17)
295
+ slim (~> 5.2)
296
+ sprockets-rails
297
+
298
+ BUNDLED WITH
299
+ 2.3.21
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright Tom de Grunt
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Procfile ADDED
@@ -0,0 +1,2 @@
1
+ web: bin/rails server
2
+ css: bin/rails app:tailwind_watch
data/README.md CHANGED
@@ -1,37 +1,95 @@
1
1
  # Mensa
2
+ Fast and awesome tables, with pagination, sorting, filtering and custom views.
3
+
4
+ Wanted features:
5
+ * [X] very fast
6
+ * [X] row-links
7
+ * [X] sorting
8
+ * [X] tables without headers (and without most of the above)
9
+ * [ ] column sorting
10
+ * [ ] filtering (of multiple columns, single is done)
11
+ * [ ] view selection and exports per view
12
+ * [ ] group by
13
+ * [ ] sum/max/min
14
+ * [ ] tables backed by arrays (of ActiveModel)
2
15
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/mensa`. To experiment with that code, run `bin/console` for an interactive prompt.
16
+ ## Usage
4
17
 
5
- TODO: Delete this and the text above, and describe your gem
18
+ Add tables in your app/tables folder, inheriting from ApplicationTable.
19
+ This in turn should inherit from Mensa::Base.
6
20
 
7
- ## Installation
21
+ ```ruby
22
+ class UserTable < ApplicationTable
23
+ definition do
24
+ model User # implicit from name
8
25
 
9
- Install the gem and add to the application's Gemfile by executing:
26
+ order { name: :desc}
27
+
28
+ column(:name) do
29
+ attribute :name # Optional, we can deduct this from the column name
10
30
 
11
- $ bundle add mensa
31
+ filter do
32
+ collection -> { }
33
+ scope -> { where(name: ...) }
34
+ end
35
+ end
12
36
 
13
- If bundler is not being used to manage dependencies, install the gem by executing:
37
+ column(:nr_of_roles) do
38
+ attribute "roles_count" # We use a database column here
39
+ end
14
40
 
15
- $ gem install mensa
41
+ end
42
+ end
43
+ ```
16
44
 
17
- ## Usage
45
+ Currently mensa depends on satis, but that is something we might remove in a future version.
46
+ You can show your tables on the page using the following:
18
47
 
19
- TODO: Write usage instructions here
48
+ ```slim
49
+ = sts.table :users
50
+ ```
20
51
 
21
- ## Development
52
+ ### Fast
22
53
 
23
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
54
+ Mensa selects only the data it needs, based on the columns. Sometimes it needs additional columns to do it's work, but you don't want them displayed.
55
+ This can be done by adding `internal true` to the column definition.
24
56
 
25
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
57
+ ```ruby
58
+ column :born_on do
59
+ internal true # Needed for age below
60
+ end
61
+ column :age do
62
+ attribute "EXTRACT(YEAR FROM AGE(born_on))::int"
63
+ end
64
+ ```
26
65
 
27
- ## Contributing
66
+ ## Installation
67
+ Add this line to your application's Gemfile:
28
68
 
29
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/mensa. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/mensa/blob/main/CODE_OF_CONDUCT.md).
69
+ ```ruby
70
+ gem "mensa"
71
+ ```
30
72
 
31
- ## License
73
+ And then execute:
74
+ ```bash
75
+ $ bundle
76
+ ```
32
77
 
33
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
78
+ Or install it yourself as:
79
+ ```bash
80
+ $ gem install mensa
81
+ ```
34
82
 
35
- ## Code of Conduct
83
+ Always use `bundle` to install the gem. Next use the install generator to install migrations, add an initializer and do other setup:
84
+ ```bash
85
+ $ bin/rails g mensa:install
86
+ ```
36
87
 
37
- Everyone interacting in the Mensa project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/mensa/blob/main/CODE_OF_CONDUCT.md).
88
+ ## Contributing
89
+ ```
90
+ Contribution directions go here.
91
+
92
+
93
+
94
+ ## License
95
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile CHANGED
@@ -1,16 +1,8 @@
1
- # frozen_string_literal: true
1
+ require "bundler/setup"
2
2
 
3
- require "bundler/gem_tasks"
4
- require "rake/testtask"
5
-
6
- Rake::TestTask.new(:test) do |t|
7
- t.libs << "test"
8
- t.libs << "lib"
9
- t.test_files = FileList["test/**/test_*.rb"]
10
- end
3
+ APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
4
+ load "rails/tasks/engine.rake"
11
5
 
12
- require "rubocop/rake_task"
6
+ load "rails/tasks/statistics.rake"
13
7
 
14
- RuboCop::RakeTask.new
15
-
16
- task default: %i[test rubocop]
8
+ require "bundler/gem_tasks"
@@ -0,0 +1,5 @@
1
+ //= link_tree ../images
2
+ //= link_directory ../../javascript/mensa .js
3
+ //= link_directory ../../javascript/mensa/controllers .js
4
+ //= link_tree ../../components .js
5
+ //= link_tree ../../../vendor/javascript .js
File without changes
@@ -0,0 +1,11 @@
1
+ @import '../../../components/mensa/add_filter/component.css';
2
+ @import '../../../components/mensa/cell/component.css';
3
+ @import '../../../components/mensa/control_bar/component.css';
4
+ @import '../../../components/mensa/filters/component.css';
5
+ @import '../../../components/mensa/header/component.css';
6
+ @import '../../../components/mensa/row_action/component.css';
7
+ @import '../../../components/mensa/search/component.css';
8
+ @import '../../../components/mensa/table/component.css';
9
+ @import '../../../components/mensa/table_row/component.css';
10
+ @import '../../../components/mensa/view/component.css';
11
+ @import '../../../components/mensa/views/component.css';
@@ -0,0 +1,13 @@
1
+ .sts-table {
2
+ &__add_filter {
3
+ @apply relative;
4
+
5
+ &__popover_container {
6
+ @apply p-2 absolute z-10 mt-1 max-h-60 w-64 overflow-auto rounded-md bg-white dark:bg-gray-800 py-1 text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm;
7
+
8
+ &__clear {
9
+ @apply text-gray-600 dark:text-gray-400 no-underline;
10
+ }
11
+ }
12
+ }
13
+ }
@@ -0,0 +1,16 @@
1
+ .sts-table__add_filter data-controller="mensa-add-filter" data-mensa-add-filter-mensa-table-outlet=".mensa-table#table-#{table.table_id}"
2
+ button.relative.w-full.cursor-default.rounded-md.bg-white.dark:bg-gray-800.py-1.5.pl-3.pr-6.text-left.text-gray-900.dark:text-gray-400.shadow-sm.border.border-dashed.focus:outline-none.focus:ring-2.focus:ring-primary-600.sm:text-sm.sm:leading-6 type="button" data-action="mensa-add-filter#toggle"
3
+ span.block.truncate data-mensa-add-filter-target="description"
4
+ = t('.add_filter')
5
+ span.pointer-events-none.absolute.inset-y-0.right-0.flex.items-center.pr-2
6
+ .fal.fa-plus
7
+
8
+ ul.hidden.absolute.z-10.mt-1.max-h-60.w-64.overflow-auto.rounded-md.bg-white.dark:bg-gray-800.py-1.text-base.shadow-lg.ring-1.ring-black.ring-opacity-5.focus:outline-none.sm:text-sm data-mensa-add-filter-target="filterList"
9
+ - table.columns.select(&:filter?).each do |column|
10
+ li#listbox-option-0.text-gray-900.dark:text-gray-400.hover:bg-gray-100.relative.cursor-default.select-none.py-2.pl-8.pr-4 data-mensa-add-filter-target="filterListItem" data-action="click->mensa-add-filter#selectColumn" data-filter-column-name=column.name
11
+ .label.font-normal.block.truncate
12
+ = column.human_name
13
+ .check.hidden.text-primary-600.absolute.inset-y-0.left-0.flex.items-center.pl-3
14
+ .fal.fa-check
15
+
16
+ div.hidden.sts-table__add_filter__popover_container data-mensa-add-filter-target="valuePopover" id="mensa-filter-value-#{SecureRandom.base36}"
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mensa
4
+ module AddFilter
5
+ class Component < ::Mensa::ApplicationComponent
6
+ attr_reader :table
7
+
8
+ def initialize(table:)
9
+ @table = table
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,84 @@
1
+ import ApplicationController from 'mensa/controllers/application_controller'
2
+ // import { debounce } from '@entdec/satis'
3
+ import { get } from '@rails/request.js'
4
+
5
+ export default class AddFilterComponentController extends ApplicationController {
6
+ static outlets = [
7
+ "mensa-table"
8
+ ]
9
+ static targets = [
10
+ 'filterList', // all filters
11
+ 'filterListItem', // individual filters
12
+ 'description', // contains the filter description in the "tab"
13
+ 'valuePopover' // contains the filter-value
14
+ ]
15
+ static values = {
16
+ supportsViews: Boolean
17
+ }
18
+
19
+ connect () {
20
+ super.connect()
21
+
22
+ // this.filterValueEntered = debounce(this.filterValueEntered, 500).bind(this)
23
+ // this.filterValueEntered = this.filterValueEntered.bind(this)
24
+ this.selectedFilterColumn = null
25
+ }
26
+
27
+ // Called when you click add-filter
28
+ toggle (event) {
29
+ this.filterListTarget.classList.toggle('hidden')
30
+ }
31
+
32
+ // Called when you selected a column
33
+ openValuePopover (event) {
34
+ let url = this.ourUrl
35
+ url.pathname += `/filters/${this.selectedFilterColumn}`
36
+ url.searchParams.append('target', this.valuePopoverTarget.id)
37
+
38
+ get(url, {
39
+ responseKind: 'turbo-stream'
40
+ }).then(() => {
41
+ this.valuePopoverTarget.classList.remove('hidden')
42
+ })
43
+ }
44
+
45
+ // Called when you select a column from the "dropdown"
46
+ selectColumn (event) {
47
+ this.filterListItemTargets.forEach((lt) => {
48
+ let check = lt.querySelector('.check')
49
+ check.classList.add('hidden')
50
+ })
51
+ let check = event.target.closest('li').querySelector('.check')
52
+ check.classList.remove('hidden')
53
+ this.selectedFilterColumn = event.target.closest('li').getAttribute('data-filter-column-name')
54
+
55
+ let label = event.target.closest('li').querySelector('.label')
56
+ this.descriptionTarget.innerText = label.innerText + ': '
57
+
58
+ this.toggle()
59
+ this.openValuePopover()
60
+ }
61
+
62
+ // Called when you entered/selected a filter value
63
+ filterValueEntered (event) {
64
+ this.valuePopoverTarget.classList.add('hidden')
65
+
66
+ let url = this.ourUrl
67
+
68
+ let filters = url.searchParams.get('filters') || {}
69
+ // FIXME: Needs better way of getting value
70
+ url.searchParams.append(`filters[${this.selectedFilterColumn}]`, event.target.value)
71
+
72
+ get(url, {
73
+ responseKind: 'turbo-stream'
74
+ }).then(() => {
75
+ // 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)) ?
77
+ setTimeout(() => {
78
+ this.mensaTableOutlet.filtersTarget.classList.remove('hidden')
79
+ }, 50)
80
+ })
81
+ event.preventDefault()
82
+ return false
83
+ }
84
+ }