mensa 0.1.3 → 0.1.6
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 +4 -4
- data/README.md +24 -2
- data/app/components/mensa/view/component.css +30 -34
- data/app/components/mensa/view/component.html.slim +1 -1
- data/app/tables/mensa/scope.rb +1 -7
- data/lib/mensa/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7226e3b108be29225302a8b24456936f438c6895682677270ee8480f1a299a4c
|
4
|
+
data.tar.gz: 49e9c236c89e0228a1a9013ad93eebfc6434a5dac8eca3c2592051c68264f79a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d715885899d340b13b603e9b115df16616a45573d33e370439532922ec485a0bf779cf37aa55f782a585094ac62d91d4c165ea586529600d6acfceed5abc91fc
|
7
|
+
data.tar.gz: 58bf68467dd23a698362a946b784b2dc5a5152f60bd8cb397a8665794c51b96c8eb1c6a0b930ac6c29ff2f442634ba4a96202ce488aa8ae221f5e32078b756aa
|
data/README.md
CHANGED
@@ -13,6 +13,10 @@ Wanted features:
|
|
13
13
|
* [ ] sum/max/min
|
14
14
|
* [ ] tables backed by arrays (of ActiveModel)
|
15
15
|
|
16
|
+
Todo:
|
17
|
+
* [ ] Hide filter icon in case there are no filters
|
18
|
+
* [ ] Search only works on table columns
|
19
|
+
|
16
20
|
## Usage
|
17
21
|
|
18
22
|
Add tables in your app/tables folder, inheriting from ApplicationTable.
|
@@ -23,11 +27,15 @@ class UserTable < ApplicationTable
|
|
23
27
|
definition do
|
24
28
|
model User # implicit from name
|
25
29
|
|
26
|
-
order
|
30
|
+
order name: :desc
|
27
31
|
|
28
32
|
column(:name) do
|
29
33
|
attribute :name # Optional, we can deduct this from the column name
|
30
|
-
|
34
|
+
sortable true
|
35
|
+
sanitize true
|
36
|
+
internal false
|
37
|
+
method nil
|
38
|
+
visible true
|
31
39
|
filter do
|
32
40
|
collection -> { }
|
33
41
|
scope -> { where(name: ...) }
|
@@ -38,6 +46,20 @@ class UserTable < ApplicationTable
|
|
38
46
|
attribute "roles_count" # We use a database column here
|
39
47
|
end
|
40
48
|
|
49
|
+
# You can add one or more actions to a row
|
50
|
+
action :delete do
|
51
|
+
link { |user| user_path(user) }
|
52
|
+
icon "fa fa-trash"
|
53
|
+
link_attributes data: {"turbo-confirm": "Are you sure you want to delete the user?", "turbo-method": :delete}
|
54
|
+
show ->(user) { true }
|
55
|
+
end
|
56
|
+
|
57
|
+
link { |user| edit_user_path(user) }
|
58
|
+
supports_views true # This table supports custom views
|
59
|
+
show_header true
|
60
|
+
view_columns_sorting false # Disabled for now
|
61
|
+
view_condensed false # Default false
|
62
|
+
view_condensed_toggle true # Whether to show the toggle, default true
|
41
63
|
end
|
42
64
|
end
|
43
65
|
```
|
@@ -4,6 +4,7 @@
|
|
4
4
|
.badge {
|
5
5
|
@apply bg-primary-100 text-primary-600 hidden ml-3 rounded-full text-xs font-medium md:inline-block py-0.5 px-2.5;
|
6
6
|
}
|
7
|
+
|
7
8
|
table {
|
8
9
|
@apply min-w-full divide-y divide-gray-50 dark:divide-gray-800 border-0;
|
9
10
|
|
@@ -12,6 +13,7 @@
|
|
12
13
|
|
13
14
|
/* tr and th moved to header */
|
14
15
|
}
|
16
|
+
|
15
17
|
tbody {
|
16
18
|
|
17
19
|
@apply divide-y divide-gray-200 dark:divide-gray-600;
|
@@ -33,50 +35,44 @@
|
|
33
35
|
.paging {
|
34
36
|
@apply flex items-center justify-between border-t border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-800 px-4 py-3 sm:px-6;
|
35
37
|
|
36
|
-
.pagy-info {
|
37
|
-
@apply text-sm text-gray-700;
|
38
|
-
b {
|
39
|
-
@apply font-medium;
|
40
|
-
}
|
41
|
-
}
|
42
38
|
|
43
|
-
.pagy
|
44
|
-
@apply
|
45
|
-
}
|
39
|
+
.pagy {
|
40
|
+
@apply flex space-x-1 text-sm text-gray-500;
|
46
41
|
|
47
|
-
|
48
|
-
|
49
|
-
}
|
42
|
+
a:not(.gap) {
|
43
|
+
@apply block rounded-lg px-3 py-1 bg-gray-200 no-underline;
|
50
44
|
|
51
|
-
|
52
|
-
|
53
|
-
|
45
|
+
&:hover {
|
46
|
+
@apply bg-gray-300;
|
47
|
+
}
|
54
48
|
|
55
|
-
|
56
|
-
|
57
|
-
|
49
|
+
&:not([href]) {
|
50
|
+
/* disabled links */
|
51
|
+
@apply text-gray-300 bg-gray-100 cursor-default;
|
52
|
+
}
|
58
53
|
|
59
|
-
|
60
|
-
|
61
|
-
|
54
|
+
&.current {
|
55
|
+
@apply text-white bg-primary-600;
|
56
|
+
}
|
57
|
+
}
|
62
58
|
|
63
|
-
|
64
|
-
|
65
|
-
}
|
59
|
+
label {
|
60
|
+
@apply inline-block whitespace-nowrap bg-gray-200 rounded-lg px-3 py-0.5;
|
66
61
|
|
67
|
-
|
68
|
-
|
62
|
+
input {
|
63
|
+
@apply bg-gray-100 border-none rounded-md;
|
64
|
+
}
|
65
|
+
}
|
69
66
|
}
|
70
|
-
}
|
71
67
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
68
|
+
&__condensed {
|
69
|
+
table {
|
70
|
+
tbody {
|
71
|
+
td {
|
72
|
+
@apply pl-4 py-2;
|
73
|
+
}
|
77
74
|
}
|
78
75
|
}
|
79
76
|
}
|
80
77
|
}
|
81
|
-
|
82
|
-
}
|
78
|
+
}
|
data/app/tables/mensa/scope.rb
CHANGED
@@ -54,12 +54,6 @@ module Mensa
|
|
54
54
|
@selected_scope = ordered_scope
|
55
55
|
@selected_scope = @selected_scope.select([:id] + columns.map(&:attribute).compact)
|
56
56
|
|
57
|
-
Rails.logger.debug("*" * 80)
|
58
|
-
Rails.logger.debug("Selected scope")
|
59
|
-
Rails.logger.debug(@selected_scope.to_sql)
|
60
|
-
Rails.logger.debug("*" * 80)
|
61
|
-
|
62
|
-
|
63
57
|
@selected_scope
|
64
58
|
end
|
65
59
|
|
@@ -78,7 +72,7 @@ module Mensa
|
|
78
72
|
def pagy_object
|
79
73
|
return if @pagy_details && @records
|
80
74
|
|
81
|
-
@pagy_details, @records = selected_scope.is_a?(Array) ? pagy_array(ordered_scope) : pagy(selected_scope)
|
75
|
+
@pagy_details, @records = selected_scope.is_a?(Array) ? pagy_array(ordered_scope, anchor_string: 'data-turbo-frame="_self"') : pagy(selected_scope, anchor_string: 'data-turbo-frame="_self"')
|
82
76
|
end
|
83
77
|
|
84
78
|
# Though this works, perhaps moving this in column(s) is nicer
|
data/lib/mensa/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mensa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom de Grunt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-04-
|
11
|
+
date: 2024-04-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: caxlsx_rails
|