mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-29 13:28:49 +01:00
add calendar to menu and implement ical
tested ical with outlook 2007
This commit is contained in:
parent
fcaea3ce20
commit
541d6f5b69
7 changed files with 89 additions and 14 deletions
|
|
@ -2,8 +2,8 @@ class TodosController < ApplicationController
|
|||
|
||||
helper :todos
|
||||
|
||||
skip_before_filter :login_required, :only => [:index]
|
||||
prepend_before_filter :login_or_feed_token_required, :only => [:index]
|
||||
skip_before_filter :login_required, :only => [:index, :calendar]
|
||||
prepend_before_filter :login_or_feed_token_required, :only => [:index, :calendar]
|
||||
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 ]
|
||||
|
||||
|
|
@ -172,6 +172,7 @@ class TodosController < ApplicationController
|
|||
@original_item_context_id = @todo.context_id
|
||||
@original_item_project_id = @todo.project_id
|
||||
@original_item_was_deferred = @todo.deferred?
|
||||
@original_item_due = @todo.due
|
||||
if params['todo']['project_id'].blank? && !params['project_name'].nil?
|
||||
if params['project_name'] == 'None'
|
||||
project = Project.null_object
|
||||
|
|
@ -222,6 +223,25 @@ class TodosController < ApplicationController
|
|||
@context_changed = @original_item_context_id != @todo.context_id
|
||||
@todo_was_activated_from_deferred_state = @original_item_was_deferred && @todo.active?
|
||||
|
||||
@due_date_changed = @original_item_due != @todo.due
|
||||
if @due_date_changed
|
||||
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
|
||||
if @todo.due <= due_today_date
|
||||
@new_due_id = "due_today"
|
||||
elsif @todo.due <= due_this_week_date
|
||||
@new_due_id = "due_this_week"
|
||||
elsif @todo.due <= due_next_week_date
|
||||
@new_due_id = "due_next_week"
|
||||
elsif @todo.due <= due_this_month_date
|
||||
@new_due_id = "due_this_month_week"
|
||||
else
|
||||
@new_due_id = "due_after_this_month"
|
||||
end
|
||||
end
|
||||
|
||||
if @context_changed
|
||||
determine_remaining_in_context_count(@original_item_context_id)
|
||||
else
|
||||
|
|
@ -432,7 +452,12 @@ class TodosController < ApplicationController
|
|||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.ics { render :text => 'Not implemented yet', :status => 200 }
|
||||
format.ics {
|
||||
@due_all = current_user.todos.find(:all,
|
||||
:conditions => ['(todos.state = ? OR todos.state = ?) AND NOT todos.due IS NULL', 'active', 'deferred'],
|
||||
:order => "due")
|
||||
render :action => 'calendar', :layout => false, :content_type => Mime::ICS
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ window.onload=function(){
|
|||
<% if current_user.is_admin? -%>
|
||||
<li><%= navigation_link("Admin", users_path, {:accesskey => "a", :title => "Add or delete users"} ) %></li>
|
||||
<% end -%>
|
||||
<li><%= navigation_link(image_tag("x-office-calendar.png", :size => "16X16", :border => 0), calendar_path, :title => "Calendar of due actions" ) %></li>
|
||||
<li><%= navigation_link(image_tag("recurring_menu16x16.png", :size => "16X16", :border => 0), {:controller => "recurring_todos", :action => "index"}, :title => "Manage recurring actions" ) %></li>
|
||||
<li><%= navigation_link(image_tag("feed-icon.png", :size => "16X16", :border => 0), {:controller => "feedlist", :action => "index"}, :title => "See a list of available feeds" ) %></li>
|
||||
<li><%= navigation_link(image_tag("menustar.gif", :size => "16X16", :border => 0), tag_path("starred"), :title => "See your starred actions" ) %></li>
|
||||
|
|
|
|||
|
|
@ -2,33 +2,50 @@
|
|||
|
||||
<div class="container">
|
||||
<h2>Due today</h2>
|
||||
<%= render :partial => "todos/todo", :collection => @due_today %>
|
||||
<div id="due_today">
|
||||
<%= render :partial => "todos/todo", :collection => @due_today %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
<h2>Due this week</h2>
|
||||
<%= render :partial => "todos/todo", :collection => @due_this_week %>
|
||||
<h2>Due in rest of this week</h2>
|
||||
<div id="due_this_week">
|
||||
<%= render :partial => "todos/todo", :collection => @due_this_week %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
<h2>Due next week</h2>
|
||||
<%= render :partial => "todos/todo", :collection => @due_next_week %>
|
||||
<div id="due_next_week">
|
||||
<%= render :partial => "todos/todo", :collection => @due_next_week %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
<h2>Due rest of this month</h2>
|
||||
<%= render :partial => "todos/todo", :collection => @due_this_month %>
|
||||
<h2>Due in rest of this month</h2>
|
||||
<div id="due_this_month">
|
||||
<%= render :partial => "todos/todo", :collection => @due_this_month %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
<h2>Due next month and later</h2>
|
||||
<%= render :partial => "todos/todo", :collection => @due_after_this_month %>
|
||||
<div id="due_after_this_month">
|
||||
<%= render :partial => "todos/todo", :collection => @due_after_this_month %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div><!-- End of display_box -->
|
||||
<div id="input_box">
|
||||
<input id="hide_tickler" type="checkbox" tabindex="5" name="hide_tickler" checked="true"/>
|
||||
<div class="input_box" id="input_box">
|
||||
<input class="hide_tickler" 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>
|
||||
<p><%= link_to('<span class="feed">iCal</span>', {:format => 'ics', :token => current_user.token}, :title => "iCal feed" ) %>
|
||||
- Get this calendar in iCal format</p>
|
||||
</div>
|
||||
|
||||
<%
|
||||
apply_behavior 'input.hide_tickler:click', :prevent_default => true do |page|
|
||||
page << "alert('hiding action in tickler from calendar is not yet implemented');"
|
||||
end
|
||||
%>
|
||||
25
app/views/todos/calendar.ics.erb
Normal file
25
app/views/todos/calendar.ics.erb
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
BEGIN:VCALENDAR
|
||||
PRODID:-//TRACKS//<%= TRACKS_VERSION %>//EN
|
||||
VERSION:2.0
|
||||
CALSCALE:GREGORIAN
|
||||
METHOD:PUBLISH
|
||||
X-WR-CALNAME:Tracks
|
||||
<% for todo in @due_all -%>
|
||||
BEGIN:VEVENT
|
||||
DTSTART;VALUE=DATE:<%= todo.due.strftime("%Y%m%d") %>
|
||||
DTEND;VALUE=DATE:<%= (todo.due+1.day).strftime("%Y%m%d") %>
|
||||
DTSTAMP:<%= todo.due.strftime("%Y%m%dT%H%M%SZ") %>
|
||||
UID:<%= todo_url(todo) %>
|
||||
CLASS:PUBLIC
|
||||
CATEGORIES:Tracks
|
||||
CREATED:<%= todo.created_at.strftime("%Y%m%dT%H%M%SZ") %>
|
||||
DESCRIPTION:<%= format_ical_notes(todo.notes) %>
|
||||
LAST-MODIFIED:<%= todo.due.strftime("%Y%m%dT%H%M%SZ") %>
|
||||
LOCATION:
|
||||
SEQUENCE:0
|
||||
STATUS:CONFIRMED
|
||||
SUMMARY:<%= todo.description %>
|
||||
TRANSP:TRANSPARENT
|
||||
END:VEVENT
|
||||
<% end -%>
|
||||
END:VCALENDAR
|
||||
|
|
@ -101,6 +101,12 @@ if @saved
|
|||
elsif source_view_is :stats
|
||||
page.replace dom_id(@todo), :partial => 'todos/todo', :locals => { :parent_container_type => parent_container_type }
|
||||
page.visual_effect :highlight, dom_id(@todo), :duration => 3
|
||||
elsif source_view_is :calendar
|
||||
if @due_date_changed
|
||||
page[@todo].remove
|
||||
page.insert_html :bottom, @new_due_id, :partial => 'todos/todo'
|
||||
page.visual_effect :highlight, dom_id(@todo), :duration => 3
|
||||
end
|
||||
else
|
||||
logger.error "unexpected source_view '#{params[:_source_view]}'"
|
||||
end
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ 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.ics', :action => "calendar", :format => 'ics'
|
||||
todos.calendar 'calendar', :action => "calendar"
|
||||
|
||||
todos.mobile 'mobile', :action => "index", :format => 'm'
|
||||
|
|
|
|||
BIN
public/images/x-office-calendar.png
Normal file
BIN
public/images/x-office-calendar.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 515 B |
Loading…
Add table
Add a link
Reference in a new issue