Merge pull request #23 from ZeusWPI/profile_page_style

Styling on profile pages
This commit is contained in:
benji 2015-02-19 15:44:49 +01:00
commit 66a8dc4f68
5 changed files with 57 additions and 18 deletions

View file

@ -1,9 +1,46 @@
/* User profile */
.user_info h2 {
display: inline;
line-height: 45px;
text-align: center;
}
.user_info h5 {
display: inline;
padding-left: 10px;
.user_info h5 {
margin-right: 10px;
text-align: right;
}
.balance {
padding: 12px 0;
text-align: center;
font-family: monospace;
font-size: 16px;
width: 60%;
margin: auto;
background-color: #FF7F00;
color: white;
}
.stats{
width: 60%;
margin: auto;
}
.stats h4 {
text-transform: uppercase;
font-family: monospace;
background-color: #333;
color: white;
padding: 5px 10px;
margin-top: 15px;
}
.stats ul {
list-style-type: none;
padding: 0 0 0 15px;
margin: 0px;
}
.stats li {
}

View file

@ -4,7 +4,7 @@ class UsersController < ApplicationController
def show
@user = User.find_by_id(params[:id]) || current_user
@orders = @user.orders.includes(:products).order(:created_at).reverse_order.paginate(page: params[:page])
@products = @user.products.select("products.*", "sum(order_items.count) as count").group(:product_id)
@products = @user.products.select("products.*", "sum(order_items.count) as count").group(:product_id).order("count desc")
@categories = @user.products.select("products.category", "sum(order_items.count) as count").group(:category)
end

View file

@ -1 +0,0 @@
<%= simple_format(pluralize(category.count, category.category)) %>

View file

@ -1 +1,3 @@
<%= simple_format(pluralize(product.count, product.name)) %>
<ul>
<li><%=(pluralize(product.count, product.name)) %></li>
</ul>

View file

@ -1,23 +1,24 @@
<%= render partial: 'flash' %>
<div class="row">
<div class="user_info">
<h2><%= @user.nickname %> (<%= @user.full_name %>)</h2>
<h5><%= link_to "[Edit profile]" , edit_user_registration_path if current_user == @user%></h5>
<h4>Balance: <%= euro(@user.balance) %></h4>
<h2><%= @user.nickname %> (<%= @user.full_name %>)</h2>
<div class="balance">BALANCE: <%= euro(@user.balance) %></div>
</div>
<% if @user.orders.any? %>
<div class="col-md-6">
<h3>Orders (<%= @user.orders_count %>)</h3>
<div class="stats">
<h4>Total products</h4>
Total: <br/><ul><li><%=@categories.map{|c| pluralize(c.count, c.category)}.join(", ")%></li></ul>
<br/>
Specifics:<br/>
<%= render partial: "products/product_row", collection: @products, as: :product %>
<h4>All orders (<%= @user.orders_count %>)</h4>
<%= render @orders %>
<%= will_paginate @orders %>
</div>
<% end %>
<div class="col-md-6">
<h3>Products</h3>
<%= render partial: "products/product_row", collection: @products, as: :product %>
<h4>Categories</h4>
<%= render partial: "products/category", collection: @categories %>
</div>
</div>