gitcoinco/code_fund_ads

View on GitHub
app/views/user_campaigns/_table.html.erb

Summary

Maintainability
Test Coverage
<%= table_wrapper do %>
  <%= paginated_table do %>
    <%= table_head do %>
      <%= table_row header: true do %>
        <%= table_column "Name", add_style: "min-width: 260px" %>
        <%= table_column "Organization" %>
        <%= table_column "Expires" %>
        <%= table_column "Status" %>
        <%= table_column "" %>
      <% end %>
    <% end %>
    <%= table_body do %>
      <% if campaigns.exists? %>
        <% campaigns.each do |campaign| %>
          <%= table_row do %>
            <%= table_data link_to(campaign.name, campaign), add_class: "text-truncate" %>
            <%= table_data link_to(campaign.organization&.name, campaign.organization) %>
            <%= table_data campaign.end_date.to_s("bdy") %>
            <%= table_data do %>
              <span class="badge badge-<%= status_color(campaign.status) %>">
              <%= campaign.status.humanize %>
            <% end %>
            <%= table_data do %>
              <%= edit_button(link: edit_campaign_path(campaign), title: "Edit Campaign") %>
              <%= delete_button(link: campaign_path(campaign, redir: user_campaigns_path(@user)), title: "Archive Campaign") unless campaign.archived? %>
            <% end %>
          <% end %>
        <% end %>
      <% else %>
        <%= render "/shared/no_data_alert" %>
      <% end %>
    <% end %>
  <% end %>
  <%= pagination_wrapper do %>
    <span><%== pagy_bootstrap_nav(pagy) %></span>
    <%= pagy_entries(pagy) %>
  <% end if pagy.pages > 1 %>
<% end %>