<div class="page-header">
 <ul class="breadcrumb">
  <li><a href="<%=  %>"><%= t("views.right_panel.button.home") %></a></li>
  <li><a href="<%= settings_menu_categories_path %>"><%= t("views.right_panel.header.menu_item_instances") %></a></li>

  <li><%= t("views.right_panel.header.menu_items") %></li>
  <span style="float: right">
    <%= link_to t("views.btn.new"),new_settings_menu_category_set_menu_item_path(@category),:class => 'btn btn-primary btn-sm' %>
  </span>
 </ul>
</div>
<div class="card">
  <div class="card-block">
    <h4 class="card-title"><%= t("views.right_panel.header.menu_category") %></h4>
    <table class="table">
      <thead>
        <tr>
          <th><%= t("views.right_panel.detail.menu") %></th>
          <th><%= t("views.right_panel.detail.name") %></th>
          <th><%= t("views.right_panel.detail.alt_name") %></th>
          <th><%= t("views.right_panel.detail.order_by") %></th>
          <th><%= t("views.right_panel.detail.parent") %></th>
          <th><%= t("views.right_panel.detail.actions") %></th>
        </tr>
      </thead>

      <tbody>
          <tr>
            <td><%= @category.menu.name %></td>
            <td><%= @category.name %></td>
            <td><%= @category.alt_name %></td>
            <td><%= @category.order_by %></td>
            <td><%= @category.parent.name rescue "-" %></td>
            <td><%= link_to t("views.btn.edit"), edit_settings_menu_category_path(@category) %>
              <button class="delete btn btn-danger btn-sm waves-effect" data-ref="<%= esettings_menu_category_path(@category)%>" data-method="delete">
                <%= t("views.btn.delete") %>
              </button>

              <span class="hidden" id="delete_text">
                  <h6>Are you sure you want to delete this row ?</h6>
                  <h6>This action can't be undo. </h6> 
              </span>
            </td>
          </tr>
      </tbody>
    </table>
  </div>
</div>
<br/>
<div class="card">
  <div class="card-block">
    <h4 class="card-title"><%= t("views.right_panel.header.menu_items") %>
      <span style="float: right">
        <%= link_to "New Simple Menu Item",new_settings_menu_category_simple_menu_item_path(@category),:class => 'btn btn-primary btn-sm' %>
        <%= link_to "New Set Menu Item",new_settings_menu_category_set_menu_item_path(@category),:class => 'btn btn-primary btn-sm' %>

      </span>
    </h4>
    <table class="table">
      <thead>
        <tr>
          <th><%= t("views.right_panel.detail.item_code") %></th>
          <th><%= t("views.right_panel.detail.name") %></th>
          <th><%= t("views.right_panel.detail.alt_name") %></th>
          <th><%= t("views.right_panel.detail.type") %></th>
          <th><%= t("views.right_panel.detail.parent_item") %></th>
          <th><%= t("views.right_panel.detail.created_by") %></th>
          <th><%= t("views.right_panel.detail.created_at") %></th>
          <th><%= t("views.right_panel.detail.actions") %></th>
        </tr>
      </thead>

      <tbody>
        <% @settings_menu_items.each do |settings_menu_item| %>
          <tr>
            <td><%= settings_menu_item.item_code %></td>
            <td><%= settings_menu_item.name %></td>
            <td><%= settings_menu_item.alt_name %></td>
            <td><%= settings_menu_item.type %></td>
            <td><%= settings_menu_item.parent.name rescue "-" %></td>
            <td><%= settings_menu_item.created_by %></td>
            <td><%=l settings_menu_item.created_at, :format => :short %></td>

            <% if settings_menu_item.type == "SimpleMenuItem" %>
            <td><%= link_to t("views.btn.show"), settings_menu_category_simple_menu_item_path(@category, settings_menu_item ),:class=>"btn btn-primary waves-effect btn-sm" %></td>
            <td><%= link_to t("views.btn.edit"), edit_settings_menu_category_simple_menu_item_path(@category, settings_menu_item),:class=>"btn btn-info waves-effect btn-sm" %></td>
            <td><%= link_to t("views.btn.delete"), settings_menu_category_simple_menu_item_path(@category, settings_menu_item ), method: :delete, data: { confirm: 'Are you sure?' },:class=>"btn btn-danger waves-effect btn-sm" %></td>
            <% else %>
            <td><%= link_to t("views.btn.show"), settings_menu_category_set_menu_item_path(@category, settings_menu_item ),,:class=>"btn btn-primary waves-effect btn-sm" %></td>
            <td><%= link_to t("views.btn.edit"), edit_settings_menu_category_set_menu_item_path(@category, settings_menu_item),,:class=>"btn btn-info waves-effect btn-sm" %></td>
            <td><%= link_to t("views.btn.delete"), settings_menu_category_set_menu_item_path(@category, settings_menu_item ), method: :delete, data: { confirm: 'Are you sure?' },:class=>"btn btn-danger waves-effect btn-sm" %></td>
            <% end %>
          </tr>
        <% end %>
      </tbody>
    </table>

  </div>

</div>
 <%= paginate @settings_menu_items, param_name: :page, :outer_window => 3 %> 
