tap/app/views/users/show.html.erb
2015-09-01 16:51:21 +02:00

58 lines
2.1 KiB
Text

<%= render partial: 'flash' %>
<div class="row">
<div class="col-sm-3">
<div>
<h2>
<%= @user.nickname %>
<% if can? :edit, @user %>
<%= link_to content_tag(:small, content_tag(:span, "", class: "glyphicon glyphicon-cog")), edit_user_path(@user) %>
<% end %>
</h2>
</div>
<%= content_tag :div, image_tag(@user.avatar, class: "img-circle img-thumbnail center"), class: "user_avatar center" %>
<ul class="list-group">
<li class="list-group-item text-muted">Orders</li>
<li class="list-group-item"><strong>Orders placed</strong><span class="badge"><%= @user.orders_count %></span></li>
<li class="list-group-item"><strong>Products ordered</strong><span class="badge"><%= @products.map(&:count).sum %></span></li>
<% if can? :create, @user.orders.build %>
<li class="list-group-item"><%= link_to "Place new order", new_user_order_path(@user), class: "btn btn-default btn-block" %></li>
<% end %>
</ul>
<% if can? :edit, @user %>
<ul class="list-group">
<li class="list-group-item text-muted">
<% if @user.dagschotel %>
Huidige dagschotel
<%= image_tag @user.dagschotel.avatar %>
<%= link_to "Change dagschotel", user_edit_dagschotel_path(@user), class: "btn btn-default btn-block" %>
<% else %>
<%= link_to "Set dagschotel", user_edit_dagschotel_path(@user), class: "btn btn-default btn-block" %>
<% end %>
</li>
</ul>
<% end %>
</div>
<div id="user_info" class="col-sm-9">
<% if @orders.any? %>
<h4>Previously ordered</h4>
Total:
<ul>
<li>
<%= @categories.map{|c| pluralize(c.count, c.category)}.to_sentence %>
</li>
</ul>
Specifics:
<%= content_tag :ul do %>
<% @products.each do |p| %>
<%= content_tag :li, pluralize(p.count, p.name) %>
<% end %>
<% end %>
<h4>All orders (<%= @user.orders_count %>)</h4>
<table class="orders"><%= render @orders %></table>
<%= will_paginate @orders %>
</div>
<% end %>
</div>
</div>