Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VN locale and Sort Customers by ordered Date #75

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion app/controllers/customers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,22 @@ class CustomersController < ApplicationController
# GET /customers
# GET /customers.json
def index
sort_list = params[:sort]
if sort_list == "by_order" then sort_customers
else
@customers = Customer.all
end
end

# GET /customers/1
# GET /customers/1.json

def sort_customers
@customers = Customer.order("created_at DESC")
end

def show
@orders = @customer.orders
@orders = @customers.orders
@all_orders_total = @orders.map(&:total).inject(&:+)
end

Expand Down
23 changes: 17 additions & 6 deletions app/controllers/pumpkins_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,28 @@ class PumpkinsController < ApplicationController
# GET /pumpkins
# GET /pumpkins.json
def index
@pumpkins = Pumpkin.all
if params["pumpkinName"]
sorted = params[:sort]
if(sorted == "yes")
@pumpkins = Pumpkin.order(:species)
else
@pumpkins = Pumpkin.all
end


def Ordered
@pumpkinsOrdered = Pumpkin.order(:species)
end

if params["pumpkinName"]
Pumpkin.all.searchPumpkin(params["pumpkinName"])
end

@show = t '.show'
@edit = t '.edit'
@delete = t '.delete'
@new = t '.new'
@search_for = t'.search_for'

flash[:species] = t 'species'
flash[:carved] = t 'carved'
flash[:size] = t 'size'
Expand All @@ -26,8 +37,8 @@ def index
flash[:new] = t 'new'
flash[:search] = t 'search'
flash[:search_for] = t 'search_for'


end

# GET /pumpkins/1
Expand Down
1 change: 1 addition & 0 deletions app/views/customers/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<p id="notice"><%= notice %></p>

<h1>Customers</h1>
<%= link_to 'Sort by order date' , customers_path(:sort => "by_order") %>

<table>
<thead>
Expand Down
2 changes: 2 additions & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

<%= link_to '[EN]', locale: 'en' %>
<%= link_to '[DE]', locale: 'de' %>
<%= link_to '[VN]', locale: 'vn' %>

<%= yield %>
</body>
</html>
16 changes: 8 additions & 8 deletions app/views/pumpkins/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@ locale: <%= params[:locale] %>
<table>
<thead>
<tr>
<th><%=t '.species' %></th>
<th><%=t '.carved' %></th>
<th><%=t '.size' %></th>
<th><%=t '.weight' %></th>
<th><%=t '.price' %></th>
<th><%=t '.i_species' %></th>
<th><%=t '.i_carved' %></th>
<th><%=t '.i_size' %></th>
<th><%=t '.i_weight' %></th>
<th><%=t '.i_price' %></th>
<th colspan="3"></th>
</tr>
</thead>

<tbody>

<% @pumpkins.each do |pumpkin| %>
<tr>
<td><%= link_to pumpkin.species, pumpkin %></td>
<td><%= pumpkin.carved %></td>
<td><%= pumpkin.size %></td>
<td><%= pumpkin.weight %></td>
<td><%= pumpkin.price %></td>

<td><%= link_to @show, pumpkin %></td>
<td><%= link_to @edit, edit_pumpkin_path(pumpkin) %></td>
<td><%= link_to @delete, pumpkin, method: :delete, data: { confirm: 'Are you sure?' } %></td>
Expand All @@ -36,7 +36,7 @@ locale: <%= params[:locale] %>
<br>

<%= link_to @new, new_pumpkin_path %>

<%= link_to 'Ordered List', pumpkins_path(:sort => "yes") %>

<%= form_tag("/pumpkins", method: "get") do %>
<%= label_tag(:pumpkinName, @search_for) %>
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/locale.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
I18n.available_locales = [:en,:de]
I18n.available_locales = [:en,:de,:vn]
I18n.default_locale = :de
12 changes: 6 additions & 6 deletions config/locales/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ de:
pumpkins:
index:
pumpkins: Kürbisse
species: Spezies
carved: Verziert
size: Größe
weight: Gewicht
price: Preis
i_species: Spezies
i_carved: Verziert
i_size: Größe
i_weight: Gewicht
i_price: Preis
show: Anzeigen
edit: Bearbeiten
delete: Löschen
new: Neuer Kürbis
search: Suchen
search_for: Suche nach
search_for: Suche nach
11 changes: 5 additions & 6 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ en:
pumpkins:
index:
pumpkins: Pumpkins
species: Species
carved: Carved
size: Size
weight: Weight
price: Price
i_species: Species
i_carved: Carved
i_size: Size
i_weight: Weight
i_price: Price
show: Show
edit: Edit
delete: Delete
new: New Pumpkin
search: Search
search_for: Search for

19 changes: 19 additions & 0 deletions config/locales/vn.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
vn:
hello: "Xin Chao!"
layouts:
application:
app_name: Ung Dung HTW
pumpkins:
index:
pumpkins: Bi Ngo
i_species: Loai
i_size: Kich Thuoc
i_weight: Can Nang
i_price: Gia
i_carved: Trang Tri
show: Xem
edit: Chinh Sua
delete: Xoa
new: Them moi
search: Tim Kiem
search_for: Tim Kiem