first pass at adding calendar view

This commit is contained in:
Reinier Balt 2008-10-02 17:28:49 +02:00
parent 01c7fd1296
commit fcaea3ce20
3 changed files with 68 additions and 2 deletions

View file

@ -4,7 +4,7 @@ class TodosController < ApplicationController
skip_before_filter :login_required, :only => [:index]
prepend_before_filter :login_or_feed_token_required, :only => [:index]
append_before_filter :init, :except => [ :destroy, :completed, :completed_archive, :check_deferred, :toggle_check, :toggle_star, :edit, :update, :create ]
append_before_filter :init, :except => [ :destroy, :completed, :completed_archive, :check_deferred, :toggle_check, :toggle_star, :edit, :update, :create, :calendar ]
append_before_filter :get_todo_from_params, :only => [ :edit, :toggle_check, :toggle_star, :show, :update, :destroy ]
session :off, :only => :index, :if => Proc.new { |req| is_feed_request(req) }
@ -404,7 +404,37 @@ class TodosController < ApplicationController
format.js {render :action => 'update'}
end
end
def calendar
@source_view = params['_source_view'] || 'calendar'
@page_title = "TRACKS::Calendar"
due_today_date = Time.zone.now
due_this_week_date = Time.zone.now.end_of_week
due_next_week_date = due_this_week_date + 7.days
due_this_month_date = Time.zone.now.end_of_month
@due_today = current_user.todos.find(:all,
:conditions => ['(todos.state = ? OR todos.state = ?) AND todos.due <= ?', 'active', 'deferred', due_today_date],
:order => "due")
@due_this_week = current_user.todos.find(:all,
:conditions => ['(todos.state = ? OR todos.state = ?) AND todos.due > ? AND todos.due <= ?', 'active', 'deferred', due_today_date, due_this_week_date],
:order => "due")
@due_next_week = current_user.todos.find(:all,
:conditions => ['(todos.state = ? OR todos.state = ?) AND todos.due > ? AND todos.due <= ?', 'active', 'deferred', due_this_week_date, due_next_week_date],
:order => "due")
@due_this_month = current_user.todos.find(:all,
:conditions => ['(todos.state = ? OR todos.state = ?) AND todos.due > ? AND todos.due <= ?', 'active', 'deferred', due_next_week_date, due_this_month_date],
:order => "due")
@due_after_this_month = current_user.todos.find(:all,
:conditions => ['(todos.state = ? OR todos.state = ?) AND todos.due > ?', 'active', 'deferred', due_this_month_date],
:order => "due")
respond_to do |format|
format.html
format.ics { render :text => 'Not implemented yet', :status => 200 }
end
end
private

View file

@ -0,0 +1,34 @@
<div id="display_box">
<div class="container">
<h2>Due today</h2>
<%= render :partial => "todos/todo", :collection => @due_today %>
</div>
<div class="container">
<h2>Due this week</h2>
<%= render :partial => "todos/todo", :collection => @due_this_week %>
</div>
<div class="container">
<h2>Due next week</h2>
<%= render :partial => "todos/todo", :collection => @due_next_week %>
</div>
<div class="container">
<h2>Due rest of this month</h2>
<%= render :partial => "todos/todo", :collection => @due_this_month %>
</div>
<div class="container">
<h2>Due next month and later</h2>
<%= render :partial => "todos/todo", :collection => @due_after_this_month %>
</div>
</div><!-- End of display_box -->
<div id="input_box">
<input id="hide_tickler" type="checkbox" tabindex="5" name="hide_tickler" checked="true"/>
<label for="hide_tickler"> Show actions in tickler</label>
<br/><br/>
<p><span class="feed">iCal</span> - Get this calendar in iCal-format to add to your own calendar</p>
</div>

View file

@ -46,6 +46,8 @@ ActionController::Routing::Routes.draw do |map|
todos.tag 'todos/tag/:name.m', :action => "tag", :format => 'm'
todos.tag 'todos/tag/:name', :action => "tag", :name => /.*/
todos.calendar 'calendar', :action => "calendar"
todos.mobile 'mobile', :action => "index", :format => 'm'
todos.mobile_abbrev 'm', :action => "index", :format => 'm'
todos.mobile_abbrev_new 'm/new', :action => "new", :format => 'm'