Calendrier sur année entière
This commit is contained in:
parent
7031620e9d
commit
0572dea806
|
@ -5,3 +5,7 @@
|
||||||
$(document).ready ->
|
$(document).ready ->
|
||||||
$('form.region_selector select').change ->
|
$('form.region_selector select').change ->
|
||||||
this.form.submit()
|
this.form.submit()
|
||||||
|
|
||||||
|
selector = $('main form.region_selector + h2')
|
||||||
|
year = selector.html().substr selector.html().search(/\d{4}</), 4
|
||||||
|
selector.html selector.html().replace(/\d{4}</, '<a class="year_selector" href="?year='+year+'">'+year+'</a><')
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
form.region_selector
|
form.region_selector
|
||||||
width: 98.3%
|
width: 98.4%
|
||||||
position: absolute
|
position: absolute
|
||||||
margin-top: 2.6em
|
margin-top: 2.6em
|
||||||
label
|
label
|
||||||
|
@ -7,18 +7,28 @@ form.region_selector
|
||||||
|
|
||||||
main form.region_selector + h2
|
main form.region_selector + h2
|
||||||
margin-top: 1.1em
|
margin-top: 1.1em
|
||||||
|
margin-bottom: 2.5em
|
||||||
a
|
a
|
||||||
font-weight: normal
|
font-weight: normal
|
||||||
&.previous-month
|
&.previous-month
|
||||||
margin-right: 0.4em
|
margin-right: 0.35em
|
||||||
&.next-month
|
&.next-month
|
||||||
margin-left: 0.4em
|
margin-left: 0.35em
|
||||||
|
|
||||||
|
// For whole year calendar
|
||||||
|
main form.region_selector + h2 + h2
|
||||||
|
padding: 1px 0 0
|
||||||
|
font-size: 1.2em
|
||||||
|
margin-bottom: 19px
|
||||||
|
|
||||||
|
table.calendar + h2
|
||||||
|
margin: 1em
|
||||||
|
font-size: 1.2em
|
||||||
|
|
||||||
table.calendar
|
table.calendar
|
||||||
width: 90%
|
width: 90%
|
||||||
margin: 0 auto
|
margin: 0 auto
|
||||||
padding: 0
|
padding: 0
|
||||||
margin-top: 3.7em
|
|
||||||
border-spacing: 2px
|
border-spacing: 2px
|
||||||
th
|
th
|
||||||
padding: 0 0 5px 0
|
padding: 0 0 5px 0
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
class EventsController < InheritedResources::Base
|
class EventsController < InheritedResources::Base
|
||||||
def index
|
def index
|
||||||
params[:year] ||= Date.today.year
|
if (params[:year] and !params[:month])
|
||||||
params[:month] ||= Date.today.month
|
# Whole year calendar
|
||||||
|
@events = Event.year(params[:year] || Date.today.year)
|
||||||
@events = Event.month(params[:year], params[:month])
|
else
|
||||||
|
@events = Event.month(params[:year] || Date.today.year, params[:month] || Date.today.month)
|
||||||
|
end
|
||||||
if (params[:region] && params[:region].present?)
|
if (params[:region] && params[:region].present?)
|
||||||
@events = @events.region(params[:region])
|
@events = @events.region(params[:region])
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,7 +3,7 @@ class Event < ActiveRecord::Base
|
||||||
|
|
||||||
scope :year, -> year {
|
scope :year, -> year {
|
||||||
where "end_time >= ? and start_time < ?",
|
where "end_time >= ? and start_time < ?",
|
||||||
"#{year}-1-1", "#{year.to_is+1}-1-1"
|
"#{year}-1-1", "#{year.to_i+1}-1-1"
|
||||||
}
|
}
|
||||||
scope :month, -> year, month {
|
scope :month, -> year, month {
|
||||||
where "end_time >= ? and start_time < ?",
|
where "end_time >= ? and start_time < ?",
|
||||||
|
|
|
@ -8,6 +8,26 @@
|
||||||
options_from_collection_for_select(Region.all, 'id', 'name', params[:region]),
|
options_from_collection_for_select(Region.all, 'id', 'name', params[:region]),
|
||||||
prompt: t('region_selector')
|
prompt: t('region_selector')
|
||||||
|
|
||||||
|
- if (params[:year] and !params[:month])
|
||||||
|
-# Whole year calendar
|
||||||
|
%h2
|
||||||
|
- params[:year] ||= Date.today.year
|
||||||
|
= link_to '<<', "?year=#{params[:year].to_i-1}"
|
||||||
|
= params[:year]
|
||||||
|
= link_to '>>', "?year=#{params[:year].to_i+1}"
|
||||||
|
|
||||||
|
- (1..12).each do |i|
|
||||||
|
- params[:month] = i
|
||||||
|
|
||||||
|
= calendar @events, { prev_text: '', next_text: '', start_day: :monday,
|
||||||
|
params: { region: params[:region] } } do |event|
|
||||||
|
%ul.events
|
||||||
|
%li.event
|
||||||
|
= link_to event.url do
|
||||||
|
%strong= event.city
|
||||||
|
= event.title
|
||||||
|
|
||||||
|
- else
|
||||||
= calendar @events, { prev_text: '<<', next_text: '>>', start_day: :monday,
|
= calendar @events, { prev_text: '<<', next_text: '>>', start_day: :monday,
|
||||||
params: { region: params[:region] } } do |event|
|
params: { region: params[:region] } } do |event|
|
||||||
%ul.events
|
%ul.events
|
||||||
|
|
Loading…
Reference in New Issue