diff options
Diffstat (limited to 'app')
| -rw-r--r-- | app/controllers/menu_items_controller.rb | 10 | ||||
| -rw-r--r-- | app/views/menu_items/index.html.erb | 49 |
2 files changed, 53 insertions, 6 deletions
diff --git a/app/controllers/menu_items_controller.rb b/app/controllers/menu_items_controller.rb index 48018800..f169e0ca 100644 --- a/app/controllers/menu_items_controller.rb +++ b/app/controllers/menu_items_controller.rb | |||
| @@ -54,6 +54,16 @@ class MenuItemsController < ApplicationController | |||
| 54 | head :ok | 54 | head :ok |
| 55 | end | 55 | end |
| 56 | 56 | ||
| 57 | def move_up | ||
| 58 | MenuItem.find(params[:id]).move_higher | ||
| 59 | redirect_to menu_items_path | ||
| 60 | end | ||
| 61 | |||
| 62 | def move_down | ||
| 63 | MenuItem.find(params[:id]).move_lower | ||
| 64 | redirect_to menu_items_path | ||
| 65 | end | ||
| 66 | |||
| 57 | private | 67 | private |
| 58 | 68 | ||
| 59 | def menu_item_params | 69 | def menu_item_params |
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> |
