mensa 0.3.2 → 0.3.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.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +5 -21
- data/README.md +25 -42
- data/app/components/mensa/add_filter/component.html.erb +31 -0
- 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 +10 -0
- data/app/components/mensa/search/component.html.erb +26 -0
- 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/tables/mensa/action.rb +8 -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 +0 -1
- data/lib/mensa/version.rb +1 -1
- data/mensa.gemspec +2 -4
- metadata +29 -54
- 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>
|
data/app/tables/mensa/action.rb
CHANGED
|
@@ -21,10 +21,17 @@ module Mensa
|
|
|
21
21
|
@config = config
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
+
def icon(record)
|
|
25
|
+
if @config[:icon].is_a?(Proc)
|
|
26
|
+
@config[:icon].call(record)
|
|
27
|
+
else
|
|
28
|
+
@config[:icon]
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
24
32
|
config_reader :title
|
|
25
33
|
config_reader :link, call: false
|
|
26
34
|
config_reader :link_attributes
|
|
27
|
-
config_reader :icon
|
|
28
35
|
config_reader :show, call: false
|
|
29
36
|
end
|
|
30
37
|
end
|
|
@@ -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.downcase}_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
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
|
|
@@ -37,11 +38,8 @@ Gem::Specification.new do |spec|
|
|
|
37
38
|
spec.add_dependency "textacular", ">=5"
|
|
38
39
|
spec.add_dependency "view_component", "~> 3.11"
|
|
39
40
|
|
|
40
|
-
spec.add_dependency "slim"
|
|
41
41
|
spec.add_dependency "tailwindcss-rails", "~> 3.3"
|
|
42
42
|
spec.add_dependency "importmap-rails"
|
|
43
43
|
spec.add_dependency "turbo-rails"
|
|
44
44
|
spec.add_dependency "stimulus-rails"
|
|
45
|
-
|
|
46
|
-
spec.add_development_dependency "sqlite3", "~> 2.8"
|
|
47
45
|
end
|
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.3.
|
|
4
|
+
version: 0.3.4
|
|
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: 2026-06-
|
|
11
|
+
date: 2026-06-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|
|
@@ -108,20 +108,6 @@ dependencies:
|
|
|
108
108
|
- - "~>"
|
|
109
109
|
- !ruby/object:Gem::Version
|
|
110
110
|
version: '3.11'
|
|
111
|
-
- !ruby/object:Gem::Dependency
|
|
112
|
-
name: slim
|
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
|
114
|
-
requirements:
|
|
115
|
-
- - ">="
|
|
116
|
-
- !ruby/object:Gem::Version
|
|
117
|
-
version: '0'
|
|
118
|
-
type: :runtime
|
|
119
|
-
prerelease: false
|
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
-
requirements:
|
|
122
|
-
- - ">="
|
|
123
|
-
- !ruby/object:Gem::Version
|
|
124
|
-
version: '0'
|
|
125
111
|
- !ruby/object:Gem::Dependency
|
|
126
112
|
name: tailwindcss-rails
|
|
127
113
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -178,20 +164,6 @@ dependencies:
|
|
|
178
164
|
- - ">="
|
|
179
165
|
- !ruby/object:Gem::Version
|
|
180
166
|
version: '0'
|
|
181
|
-
- !ruby/object:Gem::Dependency
|
|
182
|
-
name: sqlite3
|
|
183
|
-
requirement: !ruby/object:Gem::Requirement
|
|
184
|
-
requirements:
|
|
185
|
-
- - "~>"
|
|
186
|
-
- !ruby/object:Gem::Version
|
|
187
|
-
version: '2.8'
|
|
188
|
-
type: :development
|
|
189
|
-
prerelease: false
|
|
190
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
191
|
-
requirements:
|
|
192
|
-
- - "~>"
|
|
193
|
-
- !ruby/object:Gem::Version
|
|
194
|
-
version: '2.8'
|
|
195
167
|
description: Fast and awesome tables, with pagination, sorting, filtering and custom
|
|
196
168
|
views.
|
|
197
169
|
email:
|
|
@@ -221,55 +193,55 @@ files:
|
|
|
221
193
|
- app/assets/images/mensa/.keep
|
|
222
194
|
- app/assets/stylesheets/mensa/application.css
|
|
223
195
|
- app/components/mensa/add_filter/component.css
|
|
224
|
-
- app/components/mensa/add_filter/component.html.
|
|
196
|
+
- app/components/mensa/add_filter/component.html.erb
|
|
225
197
|
- app/components/mensa/add_filter/component.rb
|
|
226
198
|
- app/components/mensa/add_filter/component_controller.js
|
|
227
199
|
- app/components/mensa/application_component.rb
|
|
228
200
|
- app/components/mensa/cell/component.css
|
|
229
|
-
- app/components/mensa/cell/component.html.
|
|
201
|
+
- app/components/mensa/cell/component.html.erb
|
|
230
202
|
- app/components/mensa/cell/component.rb
|
|
231
203
|
- app/components/mensa/column_customizer/component.css
|
|
232
|
-
- app/components/mensa/column_customizer/component.html.
|
|
204
|
+
- app/components/mensa/column_customizer/component.html.erb
|
|
233
205
|
- app/components/mensa/column_customizer/component.rb
|
|
234
206
|
- app/components/mensa/column_customizer/component_controller.js
|
|
235
207
|
- app/components/mensa/control_bar/component.css
|
|
236
|
-
- app/components/mensa/control_bar/component.html.
|
|
208
|
+
- app/components/mensa/control_bar/component.html.erb
|
|
237
209
|
- app/components/mensa/control_bar/component.rb
|
|
238
210
|
- app/components/mensa/empty_state/component.css
|
|
239
|
-
- app/components/mensa/empty_state/component.html.
|
|
211
|
+
- app/components/mensa/empty_state/component.html.erb
|
|
240
212
|
- app/components/mensa/empty_state/component.rb
|
|
241
213
|
- app/components/mensa/filter_pill/component.css
|
|
242
|
-
- app/components/mensa/filter_pill/component.html.
|
|
214
|
+
- app/components/mensa/filter_pill/component.html.erb
|
|
243
215
|
- app/components/mensa/filter_pill/component.rb
|
|
244
216
|
- app/components/mensa/filter_pill/component_controller.js
|
|
245
217
|
- app/components/mensa/filter_pill_list/component.css
|
|
246
|
-
- app/components/mensa/filter_pill_list/component.html.
|
|
218
|
+
- app/components/mensa/filter_pill_list/component.html.erb
|
|
247
219
|
- app/components/mensa/filter_pill_list/component.rb
|
|
248
220
|
- app/components/mensa/filter_pill_list/component_controller.js
|
|
249
221
|
- app/components/mensa/header/component.css
|
|
250
|
-
- app/components/mensa/header/component.html.
|
|
222
|
+
- app/components/mensa/header/component.html.erb
|
|
251
223
|
- app/components/mensa/header/component.rb
|
|
252
224
|
- app/components/mensa/row_action/component.css
|
|
253
|
-
- app/components/mensa/row_action/component.html.
|
|
225
|
+
- app/components/mensa/row_action/component.html.erb
|
|
254
226
|
- app/components/mensa/row_action/component.rb
|
|
255
227
|
- app/components/mensa/search/component.css
|
|
256
|
-
- app/components/mensa/search/component.html.
|
|
228
|
+
- app/components/mensa/search/component.html.erb
|
|
257
229
|
- app/components/mensa/search/component.rb
|
|
258
230
|
- app/components/mensa/search/component_controller.js
|
|
259
231
|
- app/components/mensa/selection/component_controller.js
|
|
260
232
|
- app/components/mensa/table/component.css
|
|
261
|
-
- app/components/mensa/table/component.html.
|
|
233
|
+
- app/components/mensa/table/component.html.erb
|
|
262
234
|
- app/components/mensa/table/component.rb
|
|
263
235
|
- app/components/mensa/table/component_controller.js
|
|
264
236
|
- app/components/mensa/table_row/component.css
|
|
265
|
-
- app/components/mensa/table_row/component.html.
|
|
237
|
+
- app/components/mensa/table_row/component.html.erb
|
|
266
238
|
- app/components/mensa/table_row/component.rb
|
|
267
239
|
- app/components/mensa/view/component.css
|
|
268
|
-
- app/components/mensa/view/component.html.
|
|
240
|
+
- app/components/mensa/view/component.html.erb
|
|
269
241
|
- app/components/mensa/view/component.rb
|
|
270
242
|
- app/components/mensa/view/paging.css
|
|
271
243
|
- app/components/mensa/views/component.css
|
|
272
|
-
- app/components/mensa/views/component.html.
|
|
244
|
+
- app/components/mensa/views/component.html.erb
|
|
273
245
|
- app/components/mensa/views/component.rb
|
|
274
246
|
- app/components/mensa/views/component_controller.js
|
|
275
247
|
- app/controllers/concerns/.keep
|
|
@@ -311,15 +283,15 @@ files:
|
|
|
311
283
|
- app/tables/mensa/row.rb
|
|
312
284
|
- app/tables/mensa/scope.rb
|
|
313
285
|
- app/tables/mensa/system_view.rb
|
|
314
|
-
- app/views/mensa/exports/_badge.html.
|
|
315
|
-
- app/views/mensa/exports/_dialog.html.
|
|
316
|
-
- app/views/mensa/exports/_list.html.
|
|
317
|
-
- app/views/mensa/tables/filters/show.turbo_stream.
|
|
318
|
-
- app/views/mensa/tables/show.html.
|
|
319
|
-
- app/views/mensa/tables/show.turbo_stream.
|
|
320
|
-
- app/views/mensa/tables/views/create.turbo_stream.
|
|
321
|
-
- app/views/mensa/tables/views/destroy.turbo_stream.
|
|
322
|
-
- app/views/mensa/tables/views/update.turbo_stream.
|
|
286
|
+
- app/views/mensa/exports/_badge.html.erb
|
|
287
|
+
- app/views/mensa/exports/_dialog.html.erb
|
|
288
|
+
- app/views/mensa/exports/_list.html.erb
|
|
289
|
+
- app/views/mensa/tables/filters/show.turbo_stream.erb
|
|
290
|
+
- app/views/mensa/tables/show.html.erb
|
|
291
|
+
- app/views/mensa/tables/show.turbo_stream.erb
|
|
292
|
+
- app/views/mensa/tables/views/create.turbo_stream.erb
|
|
293
|
+
- app/views/mensa/tables/views/destroy.turbo_stream.erb
|
|
294
|
+
- app/views/mensa/tables/views/update.turbo_stream.erb
|
|
323
295
|
- bin/importmap
|
|
324
296
|
- bin/overmind
|
|
325
297
|
- bin/rails
|
|
@@ -336,8 +308,10 @@ files:
|
|
|
336
308
|
- docs/filters.png
|
|
337
309
|
- docs/table.png
|
|
338
310
|
- lib/generators/mensa/install_generator.rb
|
|
311
|
+
- lib/generators/mensa/table_generator.rb
|
|
339
312
|
- lib/generators/mensa/tailwind_config_generator.rb
|
|
340
313
|
- lib/generators/mensa/templates/config/initializers/mensa.rb
|
|
314
|
+
- lib/generators/mensa/templates/table.rb.tt
|
|
341
315
|
- lib/mensa.rb
|
|
342
316
|
- lib/mensa/configuration.rb
|
|
343
317
|
- lib/mensa/engine.rb
|
|
@@ -359,7 +333,8 @@ post_install_message: |
|
|
|
359
333
|
Mensa requires additional setup. Please run the following
|
|
360
334
|
command to install the necessary files:
|
|
361
335
|
|
|
362
|
-
|
|
336
|
+
rails g mensa:install
|
|
337
|
+
rails mensa:install:migrations
|
|
363
338
|
rdoc_options: []
|
|
364
339
|
require_paths:
|
|
365
340
|
- lib
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
.mensa-table__add_filter data-controller="mensa-add-filter" data-mensa-add-filter-mensa-filter-pill-list-outlet="#mensa-filter-pill-list-#{table.table_id}" data-mensa-add-filter-operator-labels-value=operator_labels.to_json
|
|
2
|
-
button.mensa-table__add_filter__trigger[type="button" title=t("mensa.add_filter.add", default: "Add filter") data-action="mensa-add-filter#openAllColumns"]
|
|
3
|
-
i.fa-solid.fa-circle-plus
|
|
4
|
-
ul.hidden.fixed.z-50.max-h-96.overflow-auto.rounded-lg.bg-white.dark:bg-gray-800.p-2.text-base.shadow-lg.ring-1.ring-black.ring-opacity-5.focus:outline-none.sm:text-sm data-mensa-add-filter-target="filterList"
|
|
5
|
-
- table.columns.select(&:filter?).each do |column|
|
|
6
|
-
li.text-gray-900.dark:text-gray-300.hover:bg-gray-100.dark:hover:bg-gray-700.relative.cursor-default.select-none.rounded-md.py-2.px-3.flex.items-center.gap-2 data-mensa-add-filter-target="filterListItem" data-action="click->mensa-add-filter#selectColumn mouseenter->mensa-add-filter#columnItemHovered" data-filter-column-name=column.name
|
|
7
|
-
.label.font-normal.block.truncate.flex-1
|
|
8
|
-
= column.human_name
|
|
9
|
-
.check.hidden.text-primary-600.flex.items-center
|
|
10
|
-
.fal.fa-check
|
|
11
|
-
span.mensa-table__add_filter__enter-hint
|
|
12
|
-
| ↵ Enter
|
|
13
|
-
|
|
14
|
-
div.hidden.mensa-table__add_filter__popover_container data-mensa-add-filter-target="valuePopover" id="mensa-filter-pill-value-#{SecureRandom.base36}"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
td = cell.render(:html)
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
.relative data-controller="mensa-column-customizer" data-mensa-column-customizer-table-name-value=table.name data-mensa-column-customizer-turbo-frame-id-value=table.table_id data-mensa-column-customizer-mensa-table-outlet="#table-#{table.table_id}"
|
|
2
|
-
button.mensa-table__control_bar__button type="button" data-action="click->mensa-column-customizer#toggle"
|
|
3
|
-
i class=Mensa.config.icons[:control_bar_edit]
|
|
4
|
-
.mensa-table__column_customizer__popover.hidden data-mensa-column-customizer-target="popover"
|
|
5
|
-
p.mensa-table__column_customizer__heading Columns
|
|
6
|
-
ul
|
|
7
|
-
- table.columns.reject(&:internal?).each do |column|
|
|
8
|
-
li.mensa-table__column_customizer__row[data-mensa-column-customizer-target="columnRow" data-column-name=column.name.to_s data-visible=column.visible?.to_s draggable="true" data-action="dragstart->mensa-column-customizer#dragStart dragover->mensa-column-customizer#dragOver drop->mensa-column-customizer#drop dragend->mensa-column-customizer#dragEnd"]
|
|
9
|
-
i.mensa-table__column_customizer__handle.fa-solid.fa-grip-vertical
|
|
10
|
-
span.mensa-table__column_customizer__name[class=(!column.visible? ? "mensa-table__column_customizer__name--hidden" : "")]
|
|
11
|
-
= column.human_name
|
|
12
|
-
button.mensa-table__column_customizer__visibility type="button" data-action="click->mensa-column-customizer#toggleVisibility"
|
|
13
|
-
i.fa-solid.fa-eye
|
|
14
|
-
i.fa-solid.fa-eye-slash
|