Merge branch 'master' of github.com:ZeusWPI/Tab
This commit is contained in:
commit
cb17fdc1a7
9 changed files with 70 additions and 19 deletions
|
@ -5,14 +5,14 @@ class OrdersController < ApplicationController
|
||||||
|
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@user = User.find(params[:id])
|
@user = User.find(params[:user_id])
|
||||||
@order = @user.orders.build
|
@order = @user.orders.build
|
||||||
@products = Product.all
|
@products = Product.all
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@user = User.find(params[:id])
|
@user = User.find(params[:user_id])
|
||||||
@order = @user.orders.build(order_params)
|
@order = @user.orders.build(order_params)
|
||||||
if @order.save
|
if @order.save
|
||||||
#flash[:success] = "order created!"
|
#flash[:success] = "order created!"
|
||||||
|
|
|
@ -33,7 +33,9 @@ class ProductsController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete
|
def destroy
|
||||||
|
Product.find(params[:id]).destroy
|
||||||
|
redirect_to products_path
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -17,10 +17,29 @@ class UsersController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def edit
|
||||||
|
@user = User.find(params[:id])
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
@user = User.find(params[:id])
|
||||||
|
if @user.update_attributes(user_params)
|
||||||
|
redirect_to @user
|
||||||
|
else
|
||||||
|
render 'edit'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@users = User.all
|
@users = User.all
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
User.find(params[:id]).destroy
|
||||||
|
redirect_to users_path
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def user_params
|
def user_params
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
<!-- Collect the nav links, forms, and other content for toggling -->
|
<!-- Collect the nav links, forms, and other content for toggling -->
|
||||||
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
|
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
|
||||||
<ul class="nav navbar-nav">
|
<ul class="nav navbar-nav">
|
||||||
<li><%= link_to "Index" , users_path %> </li>
|
|
||||||
<li><%= link_to "Overview" , overview_path %> </li> <!-- tijdelijk voor iedereen -->
|
<li><%= link_to "Overview" , overview_path %> </li> <!-- tijdelijk voor iedereen -->
|
||||||
<li class="dropdown">
|
<li class="dropdown">
|
||||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Products <span class="caret"></span></a>
|
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Products <span class="caret"></span></a>
|
||||||
|
@ -20,15 +19,20 @@
|
||||||
<li class="dropdown">
|
<li class="dropdown">
|
||||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Users <span class="caret"></span></a>
|
<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">
|
<ul class="dropdown-menu" role="menu">
|
||||||
<li><a href="#">new</a></li>
|
<li><%= link_to "New User", new_user_path %></li>
|
||||||
<li><a href="#">index</a></li>
|
<li><%= link_to "index" , users_path %></li>
|
||||||
<li><a href="#">edit</a></li>
|
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
<ul class="nav navbar-nav navbar-center">
|
||||||
|
<li class="navbar-text">
|
||||||
|
ADMIN NAVBAR
|
||||||
|
</li>
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
|
||||||
<ul class="nav navbar-nav navbar-right">
|
<ul class="nav navbar-nav navbar-right">
|
||||||
<li><%= link_to "Index" , users_path %> </li>
|
|
||||||
<li class="dropdown">
|
<li class="dropdown">
|
||||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Account <span class="caret"></span></a>
|
<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">
|
<ul class="dropdown-menu" role="menu">
|
||||||
|
|
|
@ -1,15 +1,7 @@
|
||||||
<%= @user.name %>
|
<%= @user.name %>
|
||||||
|
|
||||||
<% @products.each do |p| %>
|
<% @products.each do |p| %>
|
||||||
<%#= render "orders/order_button" %>
|
<%= render "orders/order_button" , p: p %>
|
||||||
|
|
||||||
<!-- dit moet in een andere file -->
|
|
||||||
<button class="btn btn-default product-btn"
|
|
||||||
data-name= '<%= p.name %>'
|
|
||||||
date-price= '<%= p.sale_price %>'>
|
|
||||||
<%= p.name %>
|
|
||||||
</button>
|
|
||||||
<!-- tot hier -->
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= form_for( @order, url: user_orders_path(@user)) do |f| %>
|
<%= form_for( @order, url: user_orders_path(@user)) do |f| %>
|
||||||
|
|
|
@ -3,7 +3,9 @@
|
||||||
<ul class="products">
|
<ul class="products">
|
||||||
<% @products.each do |product| %>
|
<% @products.each do |product| %>
|
||||||
<li>
|
<li>
|
||||||
<%= link_to product.name, product %>
|
<%= link_to product.name, product %> |
|
||||||
|
<%= link_to "delete", product, method: :delete,
|
||||||
|
data: { confirm: "You sure?" } %>
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
27
app/views/users/edit.html.erb
Normal file
27
app/views/users/edit.html.erb
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
<h1>Update user</h1>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6 col-md-offset-3">
|
||||||
|
<%= form_for(@user) do |f| %>
|
||||||
|
<%= render partial: 'errors', locals: { model: @user } %>
|
||||||
|
|
||||||
|
<%= f.label :nickname %>
|
||||||
|
<%= f.text_field :nickname %>
|
||||||
|
|
||||||
|
<%= f.label :name %>
|
||||||
|
<%= f.text_field :name %>
|
||||||
|
|
||||||
|
<%= f.label :last_name %>
|
||||||
|
<%= f.text_field :last_name %>
|
||||||
|
|
||||||
|
<%= f.label :password %>
|
||||||
|
<%= f.password_field :password %>
|
||||||
|
|
||||||
|
<%= f.label :password_confirmation, "Confirmation" %>
|
||||||
|
<%= f.password_field :password_confirmation %>
|
||||||
|
|
||||||
|
<%= f.submit "Save changes", class: "btn btn-primary" %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -3,7 +3,9 @@
|
||||||
<ul class="users">
|
<ul class="users">
|
||||||
<% @users.each do |user| %>
|
<% @users.each do |user| %>
|
||||||
<li>
|
<li>
|
||||||
<%= link_to user.name, user %>
|
<%= link_to user.name, user %> |
|
||||||
|
<%= link_to "delete", user, method: :delete,
|
||||||
|
data: { confirm: "You sure?" } %>
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -6,6 +6,9 @@
|
||||||
<h1>Nickname: <%= @user.nickname %></h1>
|
<h1>Nickname: <%= @user.nickname %></h1>
|
||||||
<h1>Balance: <%= @user.balance %></h1>
|
<h1>Balance: <%= @user.balance %></h1>
|
||||||
<h1>User id: <%= @user.id %></h1>
|
<h1>User id: <%= @user.id %></h1>
|
||||||
|
<p>
|
||||||
|
<%= link_to "edit" , edit_user_path %>
|
||||||
|
</p>
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
</aside>
|
</aside>
|
||||||
|
|
Loading…
Reference in a new issue