noesya/osuny

View on GitHub
app/views/admin/communication/websites/pages/_treebranch.html.erb

Summary

Maintainability
Test Coverage
<% pages.each do |page| %>
  <li class=" treeview__element
              js-treeview-element
              mb-2
              <%= 'treeview__element--draft' unless page.published_in?(current_language) %>
              <%= 'treeview__element--empty' unless page.has_children? %>"
      data-id="<%= page.id %>"
      data-parent="<%= page.parent_id %>">
    <div class="<%= osuny_card_classes(horizontal: true) %> treeview__label">
      <%= link_to children_admin_communication_website_page_path(website_id: page.website.id, id: page.id),
                  class: 'js-treeview-openzone d-inline-block', remote: true do %>
        <%= osuny_thumbnail_localized page %>
      <% end %>
      <div class="card-body">
        <span class="leaf-title">
          <%= osuny_published_localized page %>
          <%= osuny_link_localized page, admin_communication_website_page_path(page) %>
          <% if page.children.any? %>
            <span class="text-muted">(<%= page.children.count %>)</span>
          <% end %>
        </span>
        <span class="show-on-hover">
          <%= render 'admin/application/tree/sort' unless page.is_home? %>
          <%= link_to children_admin_communication_website_page_path(website_id: page.website.id, id: page.id),
                      class: 'js-treeview-openzone small ps-2', remote: true do %>
            <span class="open_text"><%= t 'folder.open' %></span>
            <span class="close_text"><%= t 'folder.close' %></span>
          <% end %>
        </span>
      </div>
      <div class="card-footer">
        <% if page.is_special_page? %>
          <span class="show-on-hover"><%= t("communication.website.pages.defaults.#{page.type_key}.title") %></span>
        <% end %>
      </div>
    </div>
    <ul class=" list-unstyled
                treeview__children
                js-treeview-children
                mt-2
                <%= 'js-treeview-sortable-container' if can?(:reorder, page) %>"
        data-id="<%= page.id %>">
      <li class="treeview__empty">
        <div class="d-flex align-items-center treeview__label py-1">
          <span class="p-2 ps-0"><%= t('folder.empty') %></span>
        </div>
      </li>
      <li class="treeview__loading p-1"><%= t('loading') %></li>
    </ul>
  </li>
<% end %>