osunyorg/admin

View on GitHub
app/views/server/blocks/show.html.erb

Summary

Maintainability
Test Coverage
<% content_for :title, t("enums.communication.block.template_kind.#{@template}") %>

<div class="table-responsive">
  <table class="<%= table_classes %>">
    <thead>
      <tr>
        <th><%= t('server_admin.blocks.title') %></th>
        <th><%= t('server_admin.blocks.about') %></th>
        <th><%= t('server_admin.blocks.data') %></th>
        <th><%= University.model_name.human %></th>
        <th><%= t('server_admin.blocks.url') %></th>
      </tr>
    </thead>
    <tbody>
      <%
      @blocks.each do |block|
        about = block.about
        %>
        <tr>
          <td>
            <%= truncate "#{block}" %><br>
            <small><%= block.id %></small>
          </td>
          <td>
            <% if about.present?
              begin
                name = about.about.to_s_in(block.language)
              rescue
                name = about.to_s
              end
              %>
              <p class="mb-0"><%= name %></p>
              <span class="badge bg-dark">
                <%= block.about_type %>
              </span>
            <% end %>
          </td>
          <td class="pe-3" width="600">
            <%= link_to t('server_admin.blocks.see'),
                        "#collpase-#{block.id}",
                        class: 'btn btn-xs btn-light',
                        role: 'button',
                        'data-bs-toggle': 'collapse',
                        'aria-expanded': 'false',
                        'aria-controls': "collpase-#{block.id}" %>
            <div class="collapse" id="collpase-<%= block.id %>">
              <textarea rows="10" class="form-control"><%= block.data %></textarea>
            </div>
          </td>
          <td>
            <%= link_to block.university, [:server, block.university] %>
          </td>
          <td>
            <% url = "#{block.university.url }#{edit_admin_communication_block_path(block)}" %>
            <%= link_to t('server_admin.blocks.open'),
                        url,
                        target: :_blank %>
          </td>
        </tr>
      <% end %>
    </tbody>
  </table>
</div>

<%= paginate @blocks %>


<% content_for :action_bar_right do %>
  <%= link_to t('server_admin.blocks.resave'),
              resave_server_block_path(@template),
              method: :post,
              class: button_classes %>
<% end %>