mensa 0.3.1 → 0.3.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 +4 -4
- data/Gemfile +1 -2
- data/Gemfile.lock +2 -34
- data/README.md +18 -44
- data/app/components/mensa/add_filter/component.html.erb +31 -0
- data/app/components/mensa/add_filter/component_controller.js +0 -1
- data/app/components/mensa/application_component.rb +0 -1
- data/app/components/mensa/cell/component.html.erb +1 -0
- data/app/components/mensa/column_customizer/component.html.erb +31 -0
- data/app/components/mensa/control_bar/component.html.erb +56 -0
- data/app/components/mensa/empty_state/component.html.erb +10 -0
- data/app/components/mensa/filter_pill/component.html.erb +20 -0
- data/app/components/mensa/filter_pill_list/component.html.erb +30 -0
- data/app/components/mensa/header/component.html.erb +12 -0
- data/app/components/mensa/row_action/component.html.erb +9 -0
- data/app/components/mensa/search/component.html.erb +26 -0
- data/app/components/mensa/selection/component_controller.js +1 -1
- data/app/components/mensa/table/component.html.erb +25 -0
- data/app/components/mensa/table_row/component.html.erb +18 -0
- data/app/components/mensa/view/component.html.erb +51 -0
- data/app/components/mensa/views/component.html.erb +74 -0
- data/app/helpers/mensa/application_helper.rb +15 -2
- data/app/javascript/mensa/controllers/index.js +2 -2
- data/app/javascript/mensa/controllers/link_controller.js +44 -0
- data/app/tables/mensa/base.rb +0 -6
- data/app/tables/mensa/column.rb +1 -10
- data/app/tables/mensa/row.rb +1 -1
- data/app/views/mensa/exports/_badge.html.erb +6 -0
- data/app/views/mensa/exports/_dialog.html.erb +52 -0
- data/app/views/mensa/exports/_list.html.erb +32 -0
- data/app/views/mensa/tables/filters/show.turbo_stream.erb +58 -0
- data/app/views/mensa/tables/show.html.erb +5 -0
- data/app/views/mensa/tables/show.turbo_stream.erb +7 -0
- data/app/views/mensa/tables/views/create.turbo_stream.erb +11 -0
- data/app/views/mensa/tables/views/destroy.turbo_stream.erb +11 -0
- data/app/views/mensa/tables/views/update.turbo_stream.erb +11 -0
- data/lib/generators/mensa/table_generator.rb +15 -0
- data/lib/generators/mensa/templates/config/initializers/mensa.rb +4 -5
- data/lib/generators/mensa/templates/table.rb.tt +18 -0
- data/lib/mensa/engine.rb +1 -2
- data/lib/mensa/version.rb +1 -1
- data/mensa.gemspec +3 -4
- metadata +43 -53
- data/app/components/mensa/add_filter/component.html.slim +0 -14
- data/app/components/mensa/cell/component.html.slim +0 -1
- data/app/components/mensa/column_customizer/component.html.slim +0 -14
- data/app/components/mensa/control_bar/component.html.slim +0 -43
- data/app/components/mensa/empty_state/component.html.slim +0 -7
- data/app/components/mensa/filter_pill/component.html.slim +0 -9
- data/app/components/mensa/filter_pill_list/component.html.slim +0 -11
- data/app/components/mensa/header/component.html.slim +0 -8
- data/app/components/mensa/row_action/component.html.slim +0 -6
- data/app/components/mensa/search/component.html.slim +0 -21
- data/app/components/mensa/table/component.html.slim +0 -10
- data/app/components/mensa/table_row/component.html.slim +0 -11
- data/app/components/mensa/view/component.html.slim +0 -30
- data/app/components/mensa/views/component.html.slim +0 -52
- data/app/views/mensa/exports/_badge.html.slim +0 -5
- data/app/views/mensa/exports/_dialog.html.slim +0 -42
- data/app/views/mensa/exports/_list.html.slim +0 -29
- data/app/views/mensa/tables/filters/show.turbo_stream.slim +0 -36
- data/app/views/mensa/tables/show.html.slim +0 -4
- data/app/views/mensa/tables/show.turbo_stream.slim +0 -5
- data/app/views/mensa/tables/views/create.turbo_stream.slim +0 -11
- data/app/views/mensa/tables/views/destroy.turbo_stream.slim +0 -11
- data/app/views/mensa/tables/views/update.turbo_stream.slim +0 -11
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
<% current_view = table.all_views.find { |v| v.id == table.table_view&.id } || table.all_views.first %>
|
|
2
|
+
<% current_view_name = current_view&.name || t(".all", default: "All") %>
|
|
3
|
+
<% current_view_id = current_view&.id || "" %>
|
|
4
|
+
|
|
5
|
+
<div class="mensa-table__views"
|
|
6
|
+
id="mensa-views-<%= table.table_id %>"
|
|
7
|
+
data-mensa-table-target="views"
|
|
8
|
+
data-controller="mensa-views"
|
|
9
|
+
data-mensa-views-mensa-filter-pill-list-outlet="#mensa-filter-pill-list-<%= table.table_id %>"
|
|
10
|
+
data-mensa-views-table-id-value="<%= table.table_id %>"
|
|
11
|
+
data-mensa-views-views-url-value="<%= helpers.mensa.table_views_path(table.name) %>">
|
|
12
|
+
<button class="mensa-table__views__trigger" type="button" data-action="mensa-views#toggleDropdown" data-mensa-views-target="trigger" aria-haspopup="listbox">
|
|
13
|
+
<span class="mensa-table__views__trigger-label" data-mensa-views-target="triggerLabel"><%= current_view_name %></span>
|
|
14
|
+
<i class="fa-solid fa-sort mensa-table__views__trigger-icon"></i>
|
|
15
|
+
</button>
|
|
16
|
+
|
|
17
|
+
<div class="mensa-table__views__dropdown hidden" data-mensa-views-target="dropdown">
|
|
18
|
+
<ul role="listbox">
|
|
19
|
+
<% table.all_views.each do |view| %>
|
|
20
|
+
<% is_selected = view.id == table.table_view&.id || (view.id == :default && table.table_view.blank?) %>
|
|
21
|
+
<% is_user_view = view.id.is_a?(String) && view.id.match?(/\A[0-9a-f-]{32,}\z/i) %>
|
|
22
|
+
<li class="mensa-table__views__option" role="option" data-view-id="<%= view.id %>" data-view-name="<%= view.name %>" data-mensa-views-target="view">
|
|
23
|
+
<button class="mensa-table__views__option-btn" type="button" data-action="mensa-views#select" data-view-id="<%= view.id %>">
|
|
24
|
+
<i class="mensa-table__views__option-check fa-solid fa-check<%= " invisible" unless is_selected %>"></i>
|
|
25
|
+
<span><%= view.name %></span>
|
|
26
|
+
</button>
|
|
27
|
+
<% if is_user_view %>
|
|
28
|
+
<button class="mensa-table__views__option-menu" type="button" data-action="mensa-views#toggleSubmenu" data-view-id="<%= view.id %>" title="View options">
|
|
29
|
+
<i class="fa-solid fa-ellipsis"></i>
|
|
30
|
+
</button>
|
|
31
|
+
<% else %>
|
|
32
|
+
<div class="mensa-table__views__option-system">
|
|
33
|
+
<i class="fa-solid fa-ban"></i>
|
|
34
|
+
</div>
|
|
35
|
+
<% end %>
|
|
36
|
+
</li>
|
|
37
|
+
<% end %>
|
|
38
|
+
</ul>
|
|
39
|
+
|
|
40
|
+
<div class="mensa-table__views__submenu hidden" data-mensa-views-target="submenu">
|
|
41
|
+
<button class="mensa-table__views__submenu-item" type="button" data-action="mensa-views#renameView">
|
|
42
|
+
<i class="fa-solid fa-pencil"></i>
|
|
43
|
+
<%= t(".rename_view", default: "Rename view") %>
|
|
44
|
+
</button>
|
|
45
|
+
<button class="mensa-table__views__submenu-item" type="button" data-action="mensa-views#duplicateView">
|
|
46
|
+
<i class="fa-solid fa-copy"></i>
|
|
47
|
+
<%= t(".duplicate_view", default: "Duplicate view") %>
|
|
48
|
+
</button>
|
|
49
|
+
<button class="mensa-table__views__submenu-item mensa-table__views__submenu-item--danger" type="button" data-action="mensa-views#deleteView">
|
|
50
|
+
<i class="fa-solid fa-trash"></i>
|
|
51
|
+
<%= t(".delete_view", default: "Delete view") %>
|
|
52
|
+
</button>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
|
|
56
|
+
<dialog class="mensa-table__views__rename-dialog" data-mensa-views-target="renameDialog" data-action="click->mensa-views#renameDialogBackdrop">
|
|
57
|
+
<form class="mensa-table__views__rename-form" data-action="submit->mensa-views#confirmRename">
|
|
58
|
+
<input type="hidden" data-mensa-views-target="renameViewId">
|
|
59
|
+
<h3 class="mensa-table__views__rename-title"><%= t(".rename_view", default: "Rename view") %></h3>
|
|
60
|
+
<label class="mensa-table__views__rename-label">
|
|
61
|
+
<%= t(".view_name", default: "Name") %>
|
|
62
|
+
<input class="mensa-table__views__rename-input" type="text" required placeholder="<%= t(".view_name_placeholder", default: "View name") %>" data-mensa-views-target="renameInput">
|
|
63
|
+
</label>
|
|
64
|
+
<div class="mensa-table__views__rename-actions">
|
|
65
|
+
<button class="mensa-table__views__rename-btn mensa-table__views__rename-btn--secondary" type="button" data-action="mensa-views#cancelRename">
|
|
66
|
+
<%= t(".cancel", default: "Cancel") %>
|
|
67
|
+
</button>
|
|
68
|
+
<button class="mensa-table__views__rename-btn mensa-table__views__rename-btn--primary" type="submit">
|
|
69
|
+
<%= t(".rename", default: "Rename") %>
|
|
70
|
+
</button>
|
|
71
|
+
</div>
|
|
72
|
+
</form>
|
|
73
|
+
</dialog>
|
|
74
|
+
</div>
|
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
module Mensa
|
|
2
2
|
module ApplicationHelper
|
|
3
3
|
def table(name, config = {}, **options)
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
component = ::Mensa::Table::Component.new(name, config, **options)
|
|
5
|
+
component.original_view_context = self
|
|
6
|
+
render(component)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def respond_to_missing?(method, include_private = false)
|
|
10
|
+
if method.to_s.ends_with?("_url") || method.to_s.ends_with?("_path") && main_app.respond_to?(method)
|
|
11
|
+
true
|
|
12
|
+
else
|
|
13
|
+
super
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def method_missing(method, *args, **kwargs, &block)
|
|
18
|
+
main_app.send(method, *args, **kwargs, &block)
|
|
6
19
|
end
|
|
7
20
|
end
|
|
8
21
|
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { application } from "mensa/controllers/application";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import LinkController from "mensa/controllers/link_controller";
|
|
4
|
+
application.register("mensa-link", LinkController);
|
|
5
5
|
|
|
6
6
|
import AddFilterComponentController from "mensa/components/add_filter/component_controller";
|
|
7
7
|
application.register("mensa-add-filter", AddFilterComponentController);
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import ApplicationController from "mensa/controllers/application_controller";
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Link controller
|
|
5
|
+
*
|
|
6
|
+
* div data-controller="mensa-link" href="" data-turbo="false" target="_blank" data-action='click->mensa-link#follow'
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
export default class LinkController extends ApplicationController {
|
|
10
|
+
connect() {
|
|
11
|
+
super.connect();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
follow(event) {
|
|
15
|
+
if (
|
|
16
|
+
event.target.tagName != this.element.tagName &&
|
|
17
|
+
event.target.closest(this.element.tagName.toLowerCase()) !=
|
|
18
|
+
this.element
|
|
19
|
+
) {
|
|
20
|
+
// Don't do this anymore when both tagNames are the same (the one you click and the element with the controller
|
|
21
|
+
// This is in to make sure row-links using mensa-link controller will not trigger when an A or an SVG in that A is triggered.
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (
|
|
26
|
+
event.target != this.element &&
|
|
27
|
+
event.target.closest("a") != undefined
|
|
28
|
+
) {
|
|
29
|
+
// There is an 'a' tag inside the 'mensa-link' tag, and we just clicked on it.
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (event.metaKey || event.ctrlKey) {
|
|
34
|
+
window.open(this.element.getAttribute("href"), "_blank");
|
|
35
|
+
} else if (this.element.getAttribute("data-turbo") == "false") {
|
|
36
|
+
window.open(
|
|
37
|
+
this.element.getAttribute("href"),
|
|
38
|
+
this.element.getAttribute("target"),
|
|
39
|
+
);
|
|
40
|
+
} else {
|
|
41
|
+
Turbo.visit(this.element.getAttribute("href"));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
data/app/tables/mensa/base.rb
CHANGED
|
@@ -129,12 +129,6 @@ module Mensa
|
|
|
129
129
|
)
|
|
130
130
|
end
|
|
131
131
|
|
|
132
|
-
def menu
|
|
133
|
-
Satis::Menus::Builder.build([:table, :view_menu]) do |m|
|
|
134
|
-
m.item :export, icon: "fal fa-file-export", link: nil
|
|
135
|
-
end
|
|
136
|
-
end
|
|
137
|
-
|
|
138
132
|
def all_views
|
|
139
133
|
views = system_views
|
|
140
134
|
views += TableView.where(table_name: name).where(user: [nil, current_user])
|
data/app/tables/mensa/column.rb
CHANGED
|
@@ -46,7 +46,7 @@ module Mensa
|
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
def active_record_column
|
|
49
|
-
@active_record_column ||= table.model&.columns&.find {
|
|
49
|
+
@active_record_column ||= table.model&.columns&.find { it.name == name.to_s }
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
def active_record_column_type
|
|
@@ -85,14 +85,5 @@ module Mensa
|
|
|
85
85
|
name.to_s.humanize
|
|
86
86
|
end
|
|
87
87
|
end
|
|
88
|
-
|
|
89
|
-
def menu
|
|
90
|
-
Satis::Menus::Builder.build(:filter_menu, event: "click") do |m|
|
|
91
|
-
if sortable?
|
|
92
|
-
m.item :sort_ascending, icon: "fa-solid fa-arrow-up-short-wide", link: table.path(order: {name => :asc}), link_attributes: {"data-turbo-frame": "_self"}
|
|
93
|
-
m.item :sort_descending, icon: "fa-solid fa-arrow-down-wide-short", link: table.path(order: {name => :desc}), link_attributes: {"data-turbo-frame": "_self"}
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
end
|
|
97
88
|
end
|
|
98
89
|
end
|
data/app/tables/mensa/row.rb
CHANGED
|
@@ -26,7 +26,7 @@ module Mensa
|
|
|
26
26
|
def link_attributes
|
|
27
27
|
return {} unless link
|
|
28
28
|
|
|
29
|
-
{href: link, data: {controller: "
|
|
29
|
+
{href: link, data: {controller: "mensa-link", action: "click->mensa-link#follow tap->mensa-link#follow"}}
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
def link
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<% count = Mensa::Export.completed_count(table_name, user) %>
|
|
2
|
+
<span id="<%= Mensa::Export.badge_dom_id(table_name, user) %>"
|
|
3
|
+
class="mensa-table__control_bar__badge <%= 'hidden' unless count.positive? %>"
|
|
4
|
+
aria-hidden="<%= count.positive? ? 'false' : 'true' %>">
|
|
5
|
+
<%= count %>
|
|
6
|
+
</span>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<% user = table.current_user %>
|
|
2
|
+
<% exports = Mensa::Export.for_table(table.name).for_user(user).recent %>
|
|
3
|
+
<dialog class="mensa-table__export-dialog" data-mensa-table-target="exportDialog" data-action="click->mensa-table#exportDialogBackdrop">
|
|
4
|
+
<div class="mensa-table__export-dialog__panel">
|
|
5
|
+
<header class="mensa-table__export-dialog__header">
|
|
6
|
+
<h2 class="mensa-table__export-dialog__title"><%= t("mensa.exports.title", default: "Export %{table}", table: table.name.to_s.humanize) %></h2>
|
|
7
|
+
<button class="mensa-table__export-dialog__close" type="button" data-action="mensa-table#cancelExport" aria-label="<%= t("mensa.exports.close", default: "Close") %>">
|
|
8
|
+
<i class="fa-solid fa-xmark"></i>
|
|
9
|
+
</button>
|
|
10
|
+
</header>
|
|
11
|
+
|
|
12
|
+
<div class="mensa-table__export-dialog__body">
|
|
13
|
+
<%= render partial: "mensa/exports/list", locals: {table_name: table.name, user: user, exports: exports} %>
|
|
14
|
+
|
|
15
|
+
<form class="mensa-table__export-dialog__form" data-action="submit->mensa-table#confirmExport">
|
|
16
|
+
<fieldset class="mensa-table__export-dialog__fieldset">
|
|
17
|
+
<legend class="mensa-table__export-dialog__section-title"><%= t("mensa.exports.new_export", default: "New export") %></legend>
|
|
18
|
+
<label class="mensa-table__export-dialog__option">
|
|
19
|
+
<input type="radio" name="scope" value="all" checked>
|
|
20
|
+
<span><%= t("mensa.exports.scope_all", default: "All records (matching current filters)") %></span>
|
|
21
|
+
</label>
|
|
22
|
+
<label class="mensa-table__export-dialog__option">
|
|
23
|
+
<input type="radio" name="scope" value="current_page">
|
|
24
|
+
<span><%= t("mensa.exports.scope_current_page", default: "Current page") %></span>
|
|
25
|
+
</label>
|
|
26
|
+
</fieldset>
|
|
27
|
+
|
|
28
|
+
<fieldset class="mensa-table__export-dialog__fieldset">
|
|
29
|
+
<legend class="mensa-table__export-dialog__section-title"><%= t("mensa.exports.export_as", default: "Export as") %></legend>
|
|
30
|
+
<label class="mensa-table__export-dialog__option">
|
|
31
|
+
<input type="radio" name="export_format" value="csv_excel" checked>
|
|
32
|
+
<span><%= t("mensa.exports.format_excel", default: "CSV for Excel, Numbers, or other spreadsheet programs") %></span>
|
|
33
|
+
</label>
|
|
34
|
+
<label class="mensa-table__export-dialog__option">
|
|
35
|
+
<input type="radio" name="export_format" value="plain_csv">
|
|
36
|
+
<span><%= t("mensa.exports.format_plain", default: "Plain CSV file") %></span>
|
|
37
|
+
</label>
|
|
38
|
+
</fieldset>
|
|
39
|
+
|
|
40
|
+
<div class="mensa-table__export-dialog__actions">
|
|
41
|
+
<button class="mensa-table__export-dialog__button mensa-table__export-dialog__button--secondary" type="button" data-action="mensa-table#cancelExport">
|
|
42
|
+
<%= t("mensa.exports.cancel", default: "Cancel") %>
|
|
43
|
+
</button>
|
|
44
|
+
<button class="mensa-table__export-dialog__button mensa-table__export-dialog__button--primary" type="submit">
|
|
45
|
+
<i class="fa-solid fa-file-export"></i>
|
|
46
|
+
<%= t("mensa.exports.submit", default: "Export") %>
|
|
47
|
+
</button>
|
|
48
|
+
</div>
|
|
49
|
+
</form>
|
|
50
|
+
</div>
|
|
51
|
+
</div>
|
|
52
|
+
</dialog>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<div id="<%= Mensa::Export.list_dom_id(table_name, user) %>" class="mensa-table__export-dialog__downloads">
|
|
2
|
+
<h3 class="mensa-table__export-dialog__section-title"><%= t("mensa.exports.available_downloads", default: "Available downloads") %></h3>
|
|
3
|
+
<% if exports.blank? %>
|
|
4
|
+
<p class="mensa-table__export-dialog__empty"><%= t("mensa.exports.empty", default: "You have no downloads yet. Create one below.") %></p>
|
|
5
|
+
<% else %>
|
|
6
|
+
<ul class="mensa-table__export-dialog__list">
|
|
7
|
+
<% exports.each do |export| %>
|
|
8
|
+
<li class="mensa-table__export-dialog__item">
|
|
9
|
+
<div class="mensa-table__export-dialog__item-info">
|
|
10
|
+
<span class="mensa-table__export-dialog__item-name"><%= export.filename.presence || t("mensa.exports.item_name", default: "%{table} export", table: export.table_name.to_s.humanize) %></span>
|
|
11
|
+
<span class="mensa-table__export-dialog__item-meta"><%= export.created_at.strftime("%Y-%m-%d %H:%M") %></span>
|
|
12
|
+
</div>
|
|
13
|
+
<div class="mensa-table__export-dialog__item-action">
|
|
14
|
+
<% if export.downloadable? %>
|
|
15
|
+
<%= link_to mensa.download_table_export_path(export.table_name, export), class: "mensa-table__export-dialog__download", data: {turbo: false} do %>
|
|
16
|
+
<i class="fa-solid fa-download"></i>
|
|
17
|
+
<%= t("mensa.exports.download", default: "Download") %>
|
|
18
|
+
<% end %>
|
|
19
|
+
<% elsif export.failed? %>
|
|
20
|
+
<span class="mensa-table__export-dialog__status mensa-table__export-dialog__status--failed"><%= t("mensa.exports.failed", default: "Failed") %></span>
|
|
21
|
+
<% else %>
|
|
22
|
+
<span class="mensa-table__export-dialog__status mensa-table__export-dialog__status--pending">
|
|
23
|
+
<i class="fa-solid fa-spinner fa-spin"></i>
|
|
24
|
+
<%= t("mensa.exports.processing", default: "Preparing…") %>
|
|
25
|
+
</span>
|
|
26
|
+
<% end %>
|
|
27
|
+
</div>
|
|
28
|
+
</li>
|
|
29
|
+
<% end %>
|
|
30
|
+
</ul>
|
|
31
|
+
<% end %>
|
|
32
|
+
</div>
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
<%= turbo_stream.update params[:target] do %>
|
|
2
|
+
<div class="mensa-table__add_filter__popover_container__heading"><%= @column.human_name %></div>
|
|
3
|
+
<% if @column.filter.operator_with_value? %>
|
|
4
|
+
<% collection = @column.filter.collection %>
|
|
5
|
+
<% if collection.present? %>
|
|
6
|
+
<% unless @multiple %>
|
|
7
|
+
<input type="hidden" data-mensa-add-filter-target="value" value="<%= @values.first %>">
|
|
8
|
+
<% end %>
|
|
9
|
+
<ul class="mensa-table__add_filter__popover_container__values" data-multiple="<%= 'true' if @multiple %>">
|
|
10
|
+
<% collection.each do |item| %>
|
|
11
|
+
<% opt_label = item.is_a?(Array) ? item.first.to_s : item.to_s %>
|
|
12
|
+
<% opt_value = item.is_a?(Array) ? item.last.to_s : item.to_s %>
|
|
13
|
+
<% is_selected = @values.include?(opt_value) %>
|
|
14
|
+
<li class="mensa-table__add_filter__popover_container__value"
|
|
15
|
+
data-mensa-add-filter-target="valueOption"
|
|
16
|
+
data-value="<%= opt_value %>"
|
|
17
|
+
data-label="<%= opt_label %>"
|
|
18
|
+
data-selected="<%= 'true' if is_selected %>"
|
|
19
|
+
data-action="click->mensa-add-filter#selectValue mouseenter->mensa-add-filter#highlightItem">
|
|
20
|
+
<% if @multiple %>
|
|
21
|
+
<span class="mensa-table__add_filter__checkbox<%= ' mensa-table__add_filter__checkbox--checked' if is_selected %>"></span>
|
|
22
|
+
<% else %>
|
|
23
|
+
<i class="mensa-table__add_filter__popover_container__value__check fa-solid fa-check<%= ' invisible' unless is_selected %>"></i>
|
|
24
|
+
<% end %>
|
|
25
|
+
<span class="flex-1"><%= opt_label %></span>
|
|
26
|
+
<span class="mensa-table__add_filter__enter-hint">↵ Enter</span>
|
|
27
|
+
</li>
|
|
28
|
+
<% end %>
|
|
29
|
+
</ul>
|
|
30
|
+
<% else %>
|
|
31
|
+
<input class="mensa-table__add_filter__popover_container__input"
|
|
32
|
+
type="<%= @column.filter.input_type %>"
|
|
33
|
+
value="<%= @values.first %>"
|
|
34
|
+
autocomplete="off"
|
|
35
|
+
inputmode="<%= @column.type == :integer ? 'numeric' : nil %>"
|
|
36
|
+
step="<%= @column.type == :integer ? 1 : (@column.type == :datetime ? 1 : nil) %>"
|
|
37
|
+
data-mensa-add-filter-target="value"
|
|
38
|
+
data-action="input->mensa-add-filter#manualValueChanged keydown.enter->mensa-add-filter#applyManualValue">
|
|
39
|
+
<% end %>
|
|
40
|
+
<hr class="mensa-table__add_filter__popover_container__separator">
|
|
41
|
+
<% end %>
|
|
42
|
+
<ul class="mensa-table__add_filter__popover_container__operators">
|
|
43
|
+
<% @column.filter.operators.each do |operator_name, label, requires_value| %>
|
|
44
|
+
<li class="mensa-table__add_filter__popover_container__operator"
|
|
45
|
+
data-mensa-add-filter-target="operatorOption"
|
|
46
|
+
data-operator="<%= operator_name %>"
|
|
47
|
+
data-requires-value="<%= requires_value ? 'true' : 'false' %>"
|
|
48
|
+
data-selected="<%= 'true' if @operator == operator_name.to_s %>"
|
|
49
|
+
data-action="click->mensa-add-filter#selectOperator mouseenter->mensa-add-filter#highlightItem">
|
|
50
|
+
<i class="mensa-table__add_filter__popover_container__operator__check fa-solid fa-check<%= ' invisible' unless @operator == operator_name.to_s %>"></i>
|
|
51
|
+
<span class="flex-1"><%= label %></span>
|
|
52
|
+
<span class="mensa-table__add_filter__enter-hint">↵ Enter</span>
|
|
53
|
+
</li>
|
|
54
|
+
<% end %>
|
|
55
|
+
</ul>
|
|
56
|
+
<hr class="mensa-table__add_filter__popover_container__separator">
|
|
57
|
+
<a class="mensa-table__add_filter__popover_container__clear" href="#" data-action="click->mensa-add-filter#reset">Clear</a>
|
|
58
|
+
<% end %>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<%= turbo_stream.replace "mensa-views-#{@table.table_id}" do %>
|
|
2
|
+
<%= render Mensa::Views::Component.new(table: @table) %>
|
|
3
|
+
<% end %>
|
|
4
|
+
|
|
5
|
+
<%= turbo_stream.update "filters-#{@table.table_id}" do %>
|
|
6
|
+
<%= render Mensa::FilterPillList::Component.new(table: @table) %>
|
|
7
|
+
<% end %>
|
|
8
|
+
|
|
9
|
+
<%= turbo_stream.update @table.table_id do %>
|
|
10
|
+
<%= render Mensa::View::Component.new(@table) %>
|
|
11
|
+
<% end %>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<%= turbo_stream.replace "mensa-views-#{@table.table_id}" do %>
|
|
2
|
+
<%= render Mensa::Views::Component.new(table: @table) %>
|
|
3
|
+
<% end %>
|
|
4
|
+
|
|
5
|
+
<%= turbo_stream.update "filters-#{@table.table_id}" do %>
|
|
6
|
+
<%= render Mensa::FilterPillList::Component.new(table: @table) %>
|
|
7
|
+
<% end %>
|
|
8
|
+
|
|
9
|
+
<%= turbo_stream.update @table.table_id do %>
|
|
10
|
+
<%= render Mensa::View::Component.new(@table) %>
|
|
11
|
+
<% end %>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<%= turbo_stream.replace "mensa-views-#{@table.table_id}" do %>
|
|
2
|
+
<%= render Mensa::Views::Component.new(table: @table) %>
|
|
3
|
+
<% end %>
|
|
4
|
+
|
|
5
|
+
<%= turbo_stream.update "filters-#{@table.table_id}" do %>
|
|
6
|
+
<%= render Mensa::FilterPillList::Component.new(table: @table) %>
|
|
7
|
+
<% end %>
|
|
8
|
+
|
|
9
|
+
<%= turbo_stream.update @table.table_id do %>
|
|
10
|
+
<%= render Mensa::View::Component.new(@table) %>
|
|
11
|
+
<% end %>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "rails/generators"
|
|
4
|
+
|
|
5
|
+
module Mensa
|
|
6
|
+
class TableGenerator < ::Rails::Generators::NamedBase
|
|
7
|
+
desc "Generates a table"
|
|
8
|
+
|
|
9
|
+
source_root File.expand_path("templates", __dir__)
|
|
10
|
+
|
|
11
|
+
def copy_table_file
|
|
12
|
+
template "table.rb", "app/tables/#{name}_table.rb"
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
Mensa.setup do |config|
|
|
2
2
|
# Callbacks for exporting of tables
|
|
3
3
|
config.callbacks = {
|
|
4
|
-
export_started: lambda do |
|
|
4
|
+
export_started: lambda do |export|
|
|
5
5
|
end,
|
|
6
|
-
export_completed: lambda do |
|
|
6
|
+
export_completed: lambda do |export|
|
|
7
7
|
end
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
# Override icons in use
|
|
11
11
|
config.icons = {
|
|
12
|
-
order_indicator_asc: "fa-solid fa-
|
|
13
|
-
order_indicator_desc: "fa-solid fa-
|
|
14
|
-
order_indicator: "fa-solid fa-sort",
|
|
12
|
+
order_indicator_asc: "fa-solid fa-arrow-up",
|
|
13
|
+
order_indicator_desc: "fa-solid fa-arrow-down",
|
|
15
14
|
control_bar_search: "fa-solid fa-magnifying-glass",
|
|
16
15
|
control_bar_filter: "fa-solid fa-filter",
|
|
17
16
|
control_bar_edit: "fa-solid fa-table-columns",
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class <%= name.camelize %>Table < Mensa::Base
|
|
4
|
+
model <%= name.camelize %>
|
|
5
|
+
|
|
6
|
+
<%-
|
|
7
|
+
klass = class_name&.safe_constantize
|
|
8
|
+
if klass.present?
|
|
9
|
+
-%>
|
|
10
|
+
<%- klass.columns.each do |column| -%>
|
|
11
|
+
column(:<%= column.name %>)
|
|
12
|
+
<%- end -%>
|
|
13
|
+
<%- end -%>
|
|
14
|
+
|
|
15
|
+
scope do
|
|
16
|
+
<%= class_name %>.all
|
|
17
|
+
end
|
|
18
|
+
end
|
data/lib/mensa/engine.rb
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
require "pagy"
|
|
2
|
-
require "satis"
|
|
3
2
|
require "textacular"
|
|
4
|
-
require "slim"
|
|
5
3
|
require "tailwindcss-rails"
|
|
6
4
|
require "importmap-rails"
|
|
7
5
|
require "turbo-rails"
|
|
8
6
|
require "stimulus-rails"
|
|
7
|
+
require "view_component"
|
|
9
8
|
|
|
10
9
|
module Mensa
|
|
11
10
|
class Engine < ::Rails::Engine
|
data/lib/mensa/version.rb
CHANGED
data/mensa.gemspec
CHANGED
|
@@ -18,7 +18,8 @@ Gem::Specification.new do |spec|
|
|
|
18
18
|
Mensa requires additional setup. Please run the following
|
|
19
19
|
command to install the necessary files:
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
rails g mensa:install
|
|
22
|
+
rails mensa:install:migrations
|
|
22
23
|
MESSAGE
|
|
23
24
|
|
|
24
25
|
spec.metadata["homepage_uri"] = spec.homepage
|
|
@@ -33,14 +34,12 @@ Gem::Specification.new do |spec|
|
|
|
33
34
|
spec.add_dependency "csv"
|
|
34
35
|
spec.add_dependency "rubyzip", ">= 1.2.2"
|
|
35
36
|
spec.add_dependency "pagy", ">=43"
|
|
37
|
+
spec.add_dependency "pg", ">= 1.6"
|
|
36
38
|
spec.add_dependency "textacular", ">=5"
|
|
37
39
|
spec.add_dependency "view_component", "~> 3.11"
|
|
38
40
|
|
|
39
|
-
spec.add_dependency "slim"
|
|
40
41
|
spec.add_dependency "tailwindcss-rails", "~> 3.3"
|
|
41
42
|
spec.add_dependency "importmap-rails"
|
|
42
43
|
spec.add_dependency "turbo-rails"
|
|
43
44
|
spec.add_dependency "stimulus-rails"
|
|
44
|
-
|
|
45
|
-
spec.add_development_dependency "sqlite3", "~> 2.8"
|
|
46
45
|
end
|