summaryrefslogtreecommitdiff
path: root/app/views/menu_items/index.html.erb
blob: b1c235da8fba33ba7364aa4efacf657dd5652e01 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<%= render "shared/page_actions",
      :title => t(".title"),
      :icon_name => "list-details",
      :label => t(".create_item"),
      :options => [[t(".create_item"), new_menu_item_path]] %>

<p class="field_hint"><%= t(".reorder_hint") %></p>

<table id="menu_item_list">
  <% @menu_items.each do |menu_item| %>
  <tr id="menu_items-<%= menu_item.id %>">
    <td class="menu_sort_handle">
      <span class="menu_grip"><%= icon("grip-vertical", library: "tabler", "aria-hidden": true) %></span>

      <%= button_to move_up_menu_item_path(menu_item), method: :post,
            disabled: menu_item.first?,
            form: { class: "button_to menu_move" },
            "aria-label" => t(".move_up"), title: t(".move_up") do %>
        <%= icon("chevron-up", library: "tabler", "aria-hidden": true) %>
      <% end %>

      <%= button_to move_down_menu_item_path(menu_item), method: :post,
            disabled: menu_item.last?,
            form: { class: "button_to menu_move" },
            "aria-label" => t(".move_down"), title: t(".move_down") do %>
        <%= icon("chevron-down", library: "tabler", "aria-hidden": true) %>
      <% end %>
    </td>
    <td class="menu_item_title">
      <%= menu_item.title %>
      <% (I18n.available_locales - [:root, I18n.default_locale]).each do |locale| %>
        <% translated = menu_item.translations.find_by(:locale => locale)&.title %>
        <span class="menu_item_translation">
          <span class="menu_item_translation_locale"><%= locale.to_s.upcase %></span>
          <% if translated.present? %>
            <%= translated %>
          <% else %>
            <span class="menu_item_translation_absent"><%= t(".falls_back") %></span>
          <% end %>
        </span>
      <% end %>
    </td>
    <td class="menu_item_action">
      <%= link_to edit_menu_item_path(menu_item),
            "aria-label" => t("admin.common.edit"),
            title: t("admin.common.edit") do %>
        <%= icon("edit", library: "tabler", "aria-hidden": true) %>
      <% end %>
    </td>
    <td class="menu_item_action">
      <%= button_to menu_item_path(menu_item), method: :delete,
            form: { data: { confirm: t(".confirm_destroy") }, class: 'button_to destructive' },
            "aria-label" => t("admin.common.destroy"),
            title: t("admin.common.destroy") do %>
        <%= icon("trash", library: "tabler", "aria-hidden": true) %>
      <% end %>
    </td>
  </tr>
  <% end %>
</table>