Skip to content

Commit

Permalink
Improve venues#show
Browse files Browse the repository at this point in the history
  • Loading branch information
raghubetina committed Nov 28, 2016
1 parent bed2a56 commit 9170a53
Showing 1 changed file with 87 additions and 154 deletions.
241 changes: 87 additions & 154 deletions app/views/venues/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,174 +1,107 @@
<div class="page-header">
<h3>Venue #<%= @venue.id %></h3>
</div>

<div class="row">
<div class="col-md-12 mb-2">
<dl class="dl-horizontal">
<dt>Name</dt>
<dd><%= @venue.name %></dd>

<dt>Address</dt>
<dd>
<div>
<div id="location_map" style="height: 480px;"></div>
</div>
</dd>

<dt>Neighborhood</dt>
<dd>
<% if @venue.neighborhood.present? %>
<a href="/neighborhoods/<%= @venue.neighborhood_id %>">
<%= @venue.neighborhood.name %>
</a>
<% end %>
</dd>

</dl>

<div class="btn-group btn-group-justified">
<a href="/venues" class="btn btn-primary">
Back
</a>
<a href="/venues/<%= @venue.id %>/edit" class="btn btn-warning">
Edit
</a>
<a href="/delete_venue/<%= @venue.id %>" class="btn btn-danger" rel="nofollow">
Delete
</a>
</div>
</div>
</div>

<!-- A Venue has many bookmarks -->
<div class="row mt-2">
<div class="col-md-6 col-md-offset-3">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<%= @venue.name %>

<% if @venue.neighborhood.present? %>
<small class="text-muted">
<%= @venue.neighborhood.name %>,
<%= @venue.neighborhood.city %>,
<%= @venue.neighborhood.state %>
</small>
<% end %>
</h4>
</div>

<div class="row">
<div class="col-md-12">
<ul class="list-group">
<li class="list-group-item list-group-item-info">
Bookmarks
</li>
<div class="panel-body">
<div id="location_map" style="height: 360px;"></div>
</div>

<% @venue.bookmarks.each do |bookmark| %>
<li class="list-group-item">
<a href="/bookmarks/<%= bookmark.id %>">
<%= bookmark.notes %>
</a>
<div class="btn-group btn-group-xs pull-right">
<a href="/bookmarks/<%= bookmark.id %>" class="btn btn-primary">
<i class="fa fa-search-plus"></i>
</a>
<a href="/bookmarks/<%= bookmark.id %>/edit" class="btn btn-warning">
<i class="fa fa-edit"></i>
</a>
<a href="/delete_bookmark/<%= bookmark.id %>" class="btn btn-danger" rel="nofollow">
<i class="fa fa-trash-o"></i>
</a>
</div>
<ul class="list-group">
<li class="list-group-item list-group-item-success">
Dishes you loved here
</li>
<% end %>

<li class="list-group-item">
<form action="/create_bookmark" method="post">
<!-- Hidden input for authenticity token to protect from forgery -->
<input name="authenticity_token" type="hidden" value="<%= form_authenticity_token %>">

<!-- Label and input for dish_id -->
<div class="form-group">
<label for="dish_id" class="control-label">
Dish
</label>
<% @venue.bookmarks.where(:user_id => current_user.id).order(:created_at => :desc).each do |bookmark| %>
<li class="list-group-item">
<p>
<a href="/venues/<%= bookmark.venue_id %>">
<%= bookmark.dish.name %>
</a>

<small class="pull-right text-muted">
<%= time_ago_in_words(bookmark.created_at) %> ago

<a href="/bookmarks/<%= bookmark.id %>/edit">
<i class="fa fa-fw fa-edit"></i>
</a>

<a href="/delete_bookmark/<%= bookmark.id %>">
<i class="fa fa-fw fa-trash-o"></i>
</a>
</small>
</p>

<% if bookmark.notes.present? %>
<p>
<%= bookmark.notes %>
</p>
<% end %>
</li>
<% end %>

<%= select_tag(:dish_id, options_from_collection_for_select(Dish.all, :id, :name), :class => "form-control") %>
</div>
<li class="list-group-item">
<form action="/create_bookmark" class="form-inline" method="post">
<!-- Hidden input for authenticity token to protect from forgery -->
<input name="authenticity_token" type="hidden" value="<%= form_authenticity_token %>">

<!-- Label and input for venue_id -->
<input type="hidden" name="venue_id" value="<%= @venue.id %>">

<!-- Label and input for user_id -->
<input type="hidden" name="user_id" value="<%= current_user.id %>">
<input type="hidden" name="venue_id" value="<%= @venue.id %>">
<input type="hidden" name="user_id" value="<%= current_user.id %>">

<!-- Label and input for notes -->
<div class="form-group">
<label for="notes" class="control-label">
Notes
</label>
<!-- Label and input for dish_id -->
<div class="form-group">
<label for="dish_id" class="control-label sr-only">
Dish
</label>

<textarea id="notes" name="notes" placeholder="Notes" class="form-control" rows="3"></textarea>
</div>
<%= select_tag(:dish_id, options_from_collection_for_select(Dish.all, :id, :name), :class => "form-control") %>
</div>

<button class="btn btn-block btn-success">
Create Bookmark
</button>
</form>
</li>
</ul>
</div>
</div>
<button class="btn btn-primary btn">
<i class="fa fa-heart"></i>
</button>

<!-- A Venue has many fans -->

<div class="row">
<div class="col-md-12">
<ul class="list-group">
<li class="list-group-item list-group-item-info">
Fans
</li>

<% @venue.fans.each do |user| %>
<li class="list-group-item">
<a href="/users/<%= user.id %>">
<%= user.username %>
</a>
<div class="btn-group btn-group-xs pull-right">
<a href="/users/<%= user.id %>" class="btn btn-primary">
<i class="fa fa-search-plus"></i>
</a>
<a href="/users/<%= user.id %>/edit" class="btn btn-warning">
<i class="fa fa-edit"></i>
</a>
<a href="/delete_user/<%= user.id %>" class="btn btn-danger" rel="nofollow">
<i class="fa fa-trash-o"></i>
</a>
</div>
<small class="pull-right text-muted">
right now
</small>
</form>
</li>
<% end %>
</ul>
</div>
</div>

<!-- A Venue has many specialties -->

<div class="row">
<div class="col-md-12">
<ul class="list-group">
<li class="list-group-item list-group-item-info">
Specialties
</li>
<li class="list-group-item list-group-item-success">
Popular dishes here
</li>

<% @venue.specialties.each do |dish| %>
<li class="list-group-item">
<a href="/dishes/<%= dish.id %>">
<%= dish.name %>
</a>
<div class="btn-group btn-group-xs pull-right">
<a href="/dishes/<%= dish.id %>" class="btn btn-primary">
<i class="fa fa-search-plus"></i>
</a>
<a href="/dishes/<%= dish.id %>/edit" class="btn btn-warning">
<i class="fa fa-edit"></i>
</a>
<a href="/delete_dish/<%= dish.id %>" class="btn btn-danger" rel="nofollow">
<i class="fa fa-trash-o"></i>
<% @venue.specialties.order(:name).each do |dish| %>
<li class="list-group-item">
<a href="/dishes/<%= dish.id %>">
<%= dish.name %>
</a>
</div>
</li>
<% end %>
</ul>
</li>
<% end %>
</ul>

<div class="panel-footer text-center">
<a href="/venues" class="btn btn-block btn-default">
<i class="fa fa-chevron-left"></i>
</a>
</div>
</div>
</div>
</div>


<script src="//maps.google.com/maps/api/js?v=3.24&key=AIzaSyCOTPWiuvyyo6sKoIBzKA4-1ol-vTOIOlM"></script>
<script src="//cdn.rawgit.com/mahnunchik/markerclustererplus/master/dist/markerclusterer.min.js"></script>
<script>
Expand All @@ -184,4 +117,4 @@
handler.bounds.extendWith(markers);
handler.fitMapToBounds();
});
</script>
</script>

0 comments on commit 9170a53

Please sign in to comment.