admin interface

This commit is contained in:
ohsab 2014-11-25 13:09:55 +01:00
parent 73e24e2b55
commit 69dc9ce05a
9 changed files with 155 additions and 13 deletions

View file

@ -53,3 +53,35 @@ input, textarea, select, .uneditable-input {
input {
height: auto !important;
}
/* footer */
footer {
margin-top: 45px;
padding-top: 5px;
border-top: 1px solid #eaeaea;
color: #777;
}
footer a {
color: #555;
}
footer a:hover {
color: #222;
}
footer small {
float: left;
}
footer ul {
float: right;
list-style: none;
}
footer ul li {
float: left;
margin-left: 15px;
}

View file

@ -16,7 +16,12 @@ class ProductsController < ApplicationController
@product = Product.find(params[:id])
end
def index
@products = Product.all
end
def edit
@product = Product.find(params[:id])
end
def delete

View file

@ -0,0 +1,13 @@
<footer class="footer">
<small>
<a href="#">Tab</a>
by <a href="#">Zeus WPI</a>
</small>
<nav>
<ul>
<li><%= link_to "About", '#' %></li>
<li><%= link_to "Contact", '#' %></li>
<li><a href="http://zeus.ugent.be">News</a></li>
</ul>
</nav>
</footer>

View file

@ -0,0 +1,43 @@
<nav class="navbar navbar-default" role="navigation">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<a class="navbar-brand" href="#">Tab</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li><%= link_to "Index" , users_path %> </li>
<li><%= link_to "Overview" , overview_path %> </li> <!-- tijdelijk voor iedereen -->
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Products <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><%= link_to "New product" , "/products/new" %></li>
<li><%= link_to "Index", "/products" %></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Users <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><a href="#">new</a></li>
<li><a href="#">index</a></li>
<li><a href="#">edit</a></li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><%= link_to "Index" , users_path %> </li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Account <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><a href="#">Profile</a></li>
<li><a href="#">Update</a></li>
<li><a href="#">Logout</a></li>
</ul>
</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>

View file

@ -8,9 +8,17 @@
</head>
<body>
<%= yield %>
<%= render "layouts/header" %>
<div class="container">
<%= yield %>
<%= render "layouts/footer" %>
</div>
<%= debug(params) if Rails.env.development? %>
</body>
</html>

View file

@ -3,15 +3,24 @@
<span class="products"><%= order.products %></span>
<span class="products"></span>
<span class="timestamp">
Posted <%= time_ago_in_words(order.created_at) %> ago.
Ordered <%= time_ago_in_words(order.created_at) %> ago.
</span>
</li>
<script charset="utf-8">
var products = JSON.stringify(<%=order.products%> );
jQuery.each(products, function(i, product) {
$(".products").append("<p> - "+ i +": "+ product.number_of +"</p>");
$(document).ready(function() {
//$(".products").empty()
var op = '<%=order.products%>'.replace(/&quot;/g , "\"" );
console.log(op);
var products = JSON.parse(op);
console.log(products)
$.each(products, function(i, product) {
$(".products").append("<p> - "+ i +": "+ product.number_of +"</p>");
});
});
</script>

View file

@ -1,2 +1,23 @@
<h1>Products#edit</h1>
<p>Find me in app/views/products/edit.html.erb</p>
<h1>Update product</h1>
<div class="row">
<div class="col-md-6 col-md-offset-3">
<%= form_for(@product) do |f| %>
<%= f.label :name %>
<%= f.text_field :name %>
<%= f.label :purchase_price %>
<%= f.number_field :purchase_price %>
<%= f.label :sale_price %>
<%= f.number_field :sale_price %>
<%= f.label :img_path %>
<%= f.text_field :img_path %>
<%= f.submit "Save changes", class: "btn btn-primary" %>
<% end %>
</div>
</div>

View file

@ -0,0 +1,9 @@
<h1>All products</h1>
<ul class="products">
<% @products.each do |product| %>
<li>
<%= link_to product.name, product %>
</li>
<% end %>
</ul>

View file

@ -1,9 +1,11 @@
<aside>
<h1>Products#show</h1>
<h1>Name: <%= @product.name %></h1>
<h1>Purchase price: <%= @product.purchase_price %> </h1>
<h1>Sale price: <%= @product.sale_price %> </h1>
<h1>Img path: <%= @product.img_path %> </h1>
<p>Products#show</p>
<p>Name: <%= @product.name %></p>
<p>Purchase price: <%= @product.purchase_price %> </p>
<p>Sale price: <%= @product.sale_price %> </p>
<p>Img path: <%= @product.img_path %></p>
<%= link_to "edit", edit_product_path(@product) %>
</aside>