diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-07-30 19:52:09 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-07-30 19:52:09 +0200 |
| commit | bc116a2acfe2450d85229379d54c3344e485db6a (patch) | |
| tree | bd49c465f45bcec6251325d406c7de3cd6733ddf /app/views/menu_items/index.html.erb | |
| parent | 6a1102e69230ed62138b8e6aec8a6348e8571b23 (diff) | |
Replaces the grey slab and filled-box handle with the house card idiom,
a tabler grip and icon-only edit and delete actions. Shows each item's
non-default translations muted below the title, read from the
translation rows rather than the accessor so the fallback chain cannot
disguise a missing label as a translated one.
Adds move up/down buttons via acts_as_list, the single-pointer
alternative WCAG 2.5.7 requires: the jQuery UI sortable binds mouse
events only, so dragging works neither on touch nor from the keyboard.
The grip is hidden below the desktop breakpoint for the same reason.
The sort handler dropped dataType: "json" against a head :ok response,
which sent every success down the error path, and now reloads so the
disabled chevron states match the stored order after a drag.
Diffstat (limited to 'app/views/menu_items/index.html.erb')
| -rw-r--r-- | app/views/menu_items/index.html.erb | 49 |
1 files changed, 43 insertions, 6 deletions
diff --git a/app/views/menu_items/index.html.erb b/app/views/menu_items/index.html.erb index cdc60c63..0eacc34a 100644 --- a/app/views/menu_items/index.html.erb +++ b/app/views/menu_items/index.html.erb | |||
| @@ -4,18 +4,55 @@ | |||
| 4 | <%= icon("plus", library: "tabler", "aria-hidden": true) %> <%= t(".create_item") %> | 4 | <%= icon("plus", library: "tabler", "aria-hidden": true) %> <%= t(".create_item") %> |
| 5 | <% end %> | 5 | <% end %> |
| 6 | 6 | ||
| 7 | <p class="field_hint"><%= t(".reorder_hint") %></p> | ||
| 8 | |||
| 7 | <table id="menu_item_list"> | 9 | <table id="menu_item_list"> |
| 8 | <% @menu_items.each do |menu_item| %> | 10 | <% @menu_items.each do |menu_item| %> |
| 9 | <tr id="menu_items-<%= menu_item.id %>"> | 11 | <tr id="menu_items-<%= menu_item.id %>"> |
| 10 | <td class="menu_sort_handle"> | 12 | <td class="menu_sort_handle"> |
| 11 | <div></div> | 13 | <span class="menu_grip"><%= icon("grip-vertical", library: "tabler", "aria-hidden": true) %></span> |
| 14 | |||
| 15 | <%= button_to move_up_menu_item_path(menu_item), method: :post, | ||
| 16 | disabled: menu_item.first?, | ||
| 17 | form: { class: "button_to menu_move" }, | ||
| 18 | "aria-label" => t(".move_up"), title: t(".move_up") do %> | ||
| 19 | <%= icon("chevron-up", library: "tabler", "aria-hidden": true) %> | ||
| 20 | <% end %> | ||
| 21 | |||
| 22 | <%= button_to move_down_menu_item_path(menu_item), method: :post, | ||
| 23 | disabled: menu_item.last?, | ||
| 24 | form: { class: "button_to menu_move" }, | ||
| 25 | "aria-label" => t(".move_down"), title: t(".move_down") do %> | ||
| 26 | <%= icon("chevron-down", library: "tabler", "aria-hidden": true) %> | ||
| 27 | <% end %> | ||
| 28 | </td> | ||
| 29 | <td class="menu_item_title"> | ||
| 30 | <%= menu_item.title %> | ||
| 31 | <% (I18n.available_locales - [:root, I18n.default_locale]).each do |locale| %> | ||
| 32 | <% translated = menu_item.translations.find_by(:locale => locale)&.title %> | ||
| 33 | <span class="menu_item_translation"> | ||
| 34 | <span class="menu_item_translation_locale"><%= locale.to_s.upcase %></span> | ||
| 35 | <% if translated.present? %> | ||
| 36 | <%= translated %> | ||
| 37 | <% else %> | ||
| 38 | <span class="menu_item_translation_absent"><%= t(".falls_back") %></span> | ||
| 39 | <% end %> | ||
| 40 | </span> | ||
| 41 | <% end %> | ||
| 42 | </td> | ||
| 43 | <td class="menu_item_action"> | ||
| 44 | <%= link_to edit_menu_item_path(menu_item), | ||
| 45 | "aria-label" => t("admin.common.edit"), | ||
| 46 | title: t("admin.common.edit") do %> | ||
| 47 | <%= icon("edit", library: "tabler", "aria-hidden": true) %> | ||
| 48 | <% end %> | ||
| 12 | </td> | 49 | </td> |
| 13 | <td class="menu_item_title"><%= menu_item.title %></td> | 50 | <td class="menu_item_action"> |
| 14 | <td><%= link_to t("admin.common.edit"), edit_menu_item_path(menu_item) %></td> | ||
| 15 | <td> | ||
| 16 | <%= button_to menu_item_path(menu_item), method: :delete, | 51 | <%= button_to menu_item_path(menu_item), method: :delete, |
| 17 | form: { data: { confirm: t(".confirm_destroy") }, class: 'button_to destructive' } do %> | 52 | form: { data: { confirm: t(".confirm_destroy") }, class: 'button_to destructive' }, |
| 18 | <%= icon("trash", library: "tabler", "aria-hidden": true) %> <%= t("admin.common.destroy") %> | 53 | "aria-label" => t("admin.common.destroy"), |
| 54 | title: t("admin.common.destroy") do %> | ||
| 55 | <%= icon("trash", library: "tabler", "aria-hidden": true) %> | ||
| 19 | <% end %> | 56 | <% end %> |
| 20 | </td> | 57 | </td> |
| 21 | </tr> | 58 | </tr> |
