avrj/eventTicketing

View on GitHub
app/views/admin/ticket_types/index.html.erb

Summary

Maintainability
Test Coverage
<h1 class="page-header">
  <span>Ticket Types</span>
  <%= link_to new_admin_ticket_type_path, class: "btn btn-primary pull-right" do %>
      <span class="glyphicon glyphicon-plus"></span> Add
  <% end %>
</h1>

<% if !@ticket_types.any? %>
    <p>Looks like there are no ticket types yet.</p>
<% else %>
    <p>Total of <%= pluralize(@ticket_types.count, "ticket type") %>.</p>
    <%= form_tag admin_ticket_types_path, :method => :delete do %>
    <table class="table table-striped">
      <thead>
      <tr>
        <th></th>
        <th>Name</th>
        <th>Price</th>
        <th>Free</th>
        <th>Reserved</th>
        <th>Total</th>
        <th>Type</th>
        <th></th>
      </tr>
      </thead>

      <tbody>
      <% @ticket_types.each do |ticket_type| %>
          <tr>
            <td><%= check_box_tag 'ticket_type_ids[]', ticket_type.id %></td>
            <td><%= ticket_type.name %></td>
            <td><%= number_to_currency(ticket_type.price) %></td>
            <td><%= ticket_type.free.count %></td>
            <td><%= ticket_type.reserved.count %></td>
            <td><%= ticket_type.tickets.count %></td>
            <% if ticket_type.is_seat %>
                <td>Seat</td>
            <% else %>
                <td>Normal</td>
            <% end %>
            <td>
              <!-- Split button -->
              <div class="btn-group pull-right">
                <%= link_to 'Show', admin_ticket_type_path(ticket_type), class: "btn btn-primary" %>
                <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
                  <span class="caret"></span>
                  <span class="sr-only">Toggle Dropdown</span>
                </button>
                <ul class="dropdown-menu" role="menu">
                  <li>
                    <%= link_to edit_admin_ticket_type_path(ticket_type) do %>
                        <span class="glyphicon glyphicon-edit"></span> Edit
                    <% end %>
                  </li>
                  <li>
                    <%= link_to admin_ticket_type_path(ticket_type), method: :delete, data: {confirm: 'Are you sure?'} do %>
                        <span class="glyphicon glyphicon-remove"></span> Remove
                    <% end %>
                  </li>
                </ul>
              </div>
            </td>
          </tr>
      <% end %>
      </tbody>
    </table>
        <%= submit_tag "Delete selected", class: "btn btn-danger", data: { confirm: "Are you sure?" } %>
        <% end %>
<% end %>