Browse Source

DRY the rendering of "an index with map" by moving listing to partial

tags/0.3.6^2
Bèr Kessels 1 month ago
parent
commit
fe98925812
3 changed files with 25 additions and 37 deletions
  1. 17
    0
      app/views/aside_places_partial.erb
  2. 4
    20
      app/views/region.erb
  3. 4
    17
      app/views/search.erb

+ 17
- 0
app/views/aside_places_partial.erb View File

@@ -0,0 +1,17 @@
<div class="col-3 list-group pl-3" id="map-listing">
<%- index.collection.each do |place| %>
<a href="/places/<%= place.id %>"
class="list-group-item list-group-item-action"
id="place-<%= place.id %>">
<div class="d-flex w-100 justify-content-between">
<h3 class="mb-1 small"><%= place.name %></h3>
</div>
<p class="mb-1 small"><%= place.address.street %>, <%= place.address.city %></p>
<p class="mb-1 small">
<%== erb :status_badge_partial, locals: { status: place.status } %>
<%= place.opening_hours %>
</p>
</a>
<% end %>
<%== pagy_bootstrap_nav(index.paginator) %>
</div>

+ 4
- 20
app/views/region.erb View File

@@ -14,25 +14,9 @@
<h2>Openingstijden in <%= @region.name %></h2>

<section class="row">
<div class="col-3 list-group pl-3" id="map-listing">
<%- @region.collection.each do |place| %>
<a href="/places/<%= place.id %>"
class="list-group-item list-group-item-action"
id="place-<%= place.id %>">
<div class="d-flex w-100 justify-content-between">
<h3 class="mb-1 small"><%= place.name %></h3>
</div>
<p class="mb-1 small"><%= place.address.street %>, <%= place.address.city %></p>
<p class="mb-1 small">
<%== erb :status_badge_partial, locals: { status: place.status } %>
<%= place.opening_hours %>
</p>
</a>
<% end %>
<%== pagy_bootstrap_nav(@region.paginator) %>
</div>
<div class="col">
<div id="map" class="full"></div>
</div>
<%== erb(:aside_places_partial, locals: { index: @region }) %>
<div class="col">
<div id="map" class="full"></div>
</div>
</section>
<% end %>

+ 4
- 17
app/views/search.erb View File

@@ -6,21 +6,8 @@
) %>

<section class="row">
<div class="col-3 list-group">
<%- @search_result.collection.each do |place| %>
<a href="/places/<%= place.id %>" class="list-group-item list-group-item-action">
<div class="d-flex w-100 justify-content-between">
<h3 class="mb-1 small"><%= place.name %></h3>
</div>
<p class="mb-1 small">
<%== erb :status_badge_partial, locals: { status: place.status } %>
<%= place.opening_hours %>
</p>
</a>
<% end %>
<%== pagy_bootstrap_nav(@search_result.paginator) %>
</div>
<div class="col">
<div id="map" class="full"></div>
</div>
<%== erb(:aside_places_partial, locals: { index: @search_result }) %>
<div class="col">
<div id="map" class="full"></div>
</div>
</section>

Loading…
Cancel
Save