summaryrefslogtreecommitdiff
path: root/app/views/gyms/_index.html.erb
blob: 47ac9d04952bb4d45dac61655c70a50eb5788380 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<nav class="level">
  <div class="level-left">
    <div class="level-item">
      <%= search_form %>
    </div>
    <div class="level-item">
      <p class="subtitle is-5">
        <strong><%= @gyms.total_count %></strong> gyms
      </p>
    </div>
  </div>
</nav>

<table class="table">
  <thead>
  <tr>
    <th>Name</th>
    <th>Address</th>
    <th></th>
  </tr>
  </thead>
  <tbody>
  <% @gyms.each do |gym| %>
    <tr>
      <td><%= gym.new_record? ? gym.name : link_to(gym.name, gym_path(gym)) %></td>
      <td>
        <%= gym.full_address %>
        <%= link_to gym.map_url do %>
          <i class="fa fa-map-marker" aria-hidden="true"></i>
        <% end %>
      </td>
      <td>
        <% if gym.new_record? && !gym.duplicate? %>
          <%= form_for(gym) do |form| %>
            <%= form.hidden_field :name %>
            <%= form.hidden_field :yelp_id %>
            <%= form.fields_for :location do |location_form| %>
              <%= location_form.hidden_field :address %>
              <%= location_form.hidden_field :city %>
              <%= location_form.hidden_field :region %>
              <%= location_form.hidden_field :country %>
              <%= location_form.hidden_field :postal_code %>
            <% end %>
            <%= form.submit t(:add), class: "button tiny" %>
          <% end %>
        <% end %>
      </td>
    </tr>
  <% end %>
  </tbody>
</table>
<%= paginate @gyms, remote: true %>