Skip to content

Commit

Permalink
add translation and calendar navigation to calendar view and controller
Browse files Browse the repository at this point in the history
  • Loading branch information
Francisco de Juan committed Jun 9, 2013
1 parent 834fb58 commit c5b475c
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 19 deletions.
7 changes: 7 additions & 0 deletions app/controllers/calendars_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,12 @@ class CalendarsController < ApplicationController
def show
@users_by_availability = User.by_availability
@weekdays = %w(monday tuesday wednesday thursday friday saturday sunday)

@date = params[:date] && Date.parse(params[:date]) || Date.today

@beginning_of_week = @date.beginning_of_week
@end_of_week = @date.end_of_week

@weekdays = (@beginning_of_week..@end_of_week)
end
end
21 changes: 16 additions & 5 deletions app/views/calendars/show.html.haml
Original file line number Diff line number Diff line change
@@ -1,28 +1,39 @@
.page-header
%h1 Calendar
%h1= t('calendar')

.well
%row
.span2
= link_to t('previous_week'), calendar_path(date: @beginning_of_week - 1.day)
.span2.offset3
= link_to t('this_week'), calendar_path
.span2.offset3
= link_to t('next_week'), calendar_path(date: @end_of_week + 1.day)

%p= t('calendar_help')

%table.table.table-striped
%thead
%tr
%td &nbsp;
- @weekdays.each do |day|
%th= day
%th= I18n.localize(day, :format => :short)
%tbody
- (10..22).each do |hour|
%tr
%th= hour
- @weekdays.each do |day|
%td
- @users_by_availability["#{day}_#{hour}"].each do |user|
- @users_by_availability["#{I18n.localize(day, :format => :weekday, :locale => :en).downcase}_#{hour}"].each do |user|
%i{:class => "icon-user", :title => user.name}

- if @users_by_availability["#{day}_#{hour}"].count > 0
- if @users_by_availability["#{I18n.localize(day, :format => :weekday, :locale => :en).downcase}_#{hour}"].count > 0
.modal.hide.fade.in{:style => "display: none; ", :id => "#{day}_#{hour}"}
.modal-header
%a.close{"data-dismiss" => "modal"} ×
%h3= "#{day} at #{hour}"
.modal-body
%p= @users_by_availability["#{day}_#{hour}"].collect(&:name).to_sentence
%p= @users_by_availability["#{I18n.localize(day, :format => :weekday, :locale => :en).downcase}_#{hour}"].collect(&:name).to_sentence
.modal-footer
%a.btn.btn-success{:href => "#"} Let's play
%a.btn{"data-dismiss" => "modal", :href => "#"} Close
Expand Down
6 changes: 6 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@

en:
hello: "Hello world"
date:
formats:
default: ! '%e/%m/%Y'
long: ! '%e de %B de %Y'
short: ! '%e de %b'
weekday: ! '%A'
6 changes: 6 additions & 0 deletions config/locales/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ es:
not_available: "No estoy disponible"
available: "Avísame cuando se creen partidos"

previous_week: "Semana anterior"
this_week: "Esta semana"
next_week: "Próxima semana"

calendar_help: "Pulsa sobre el símbolo + para crear un partido y notificar a los demás usuarios"

# Scaffold
helpers:
links:
Expand Down
28 changes: 14 additions & 14 deletions config/locales/rails.es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ es:
- sáb
abbr_month_names:
-
- Ene
- Feb
- Mar
- Abr
- May
- Jun
- Jul
- Ago
- Sep
- Oct
- Nov
- Dic
- ene
- feb
- mar
- abr
- may
- jun
- jul
- ago
- sep
- oct
- nov
- dic
day_names:
- domingo
- lunes
Expand All @@ -34,8 +34,8 @@ es:
formats:
default: ! '%e/%m/%Y'
long: ! '%e de %B de %Y'
short: ! '%e de %b'
month_year: ! '%b %y'
short: ! '%a %e de %b'
weekday: ! '%A'
month_names:
-
- enero
Expand Down

0 comments on commit c5b475c

Please sign in to comment.