mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-16 23:30:12 +01:00
Added first patch contributed by Jim Ray: adds a host of fixes and bits of cleaning up, including a position column for contexts and projects to allow custom sorting, and changes to the links for pages to make them more human-readable.
I also added a pop-up calendar to set the due date. This is entirely lifted from Michele's excellent tutorial on pxl8.com (<http://www.pxl8.com/calendar_date_picker.html>). It works well, but I need to make sure it doesn't break in postgresql or sqlite. git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@49 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
parent
f6eeb1d20d
commit
e0b9ba0182
20 changed files with 319 additions and 111 deletions
|
|
@ -11,9 +11,15 @@ class ContextController < ApplicationController
|
|||
# Main method for listing contexts
|
||||
# Set page title, and collect existing contexts in @contexts
|
||||
#
|
||||
|
||||
def index
|
||||
list
|
||||
render_action "list"
|
||||
end
|
||||
|
||||
def list
|
||||
@page_title = "List Contexts"
|
||||
@contexts = Context.find_all
|
||||
@contexts = Context.find_all( conditions = nil, "position ASC", limit = nil )
|
||||
end
|
||||
|
||||
|
||||
|
|
@ -33,7 +39,20 @@ class ContextController < ApplicationController
|
|||
redirect_to( :action => "list" )
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def new
|
||||
expire_action(:controller => "context", :action => "list")
|
||||
context = Context.new
|
||||
context.attributes = @params["new_context"]
|
||||
|
||||
if context.save
|
||||
flash["confirmation"] = "Succesfully created context \"#{context.name}\""
|
||||
redirect_to( :action => "list" )
|
||||
else
|
||||
flash["warning"] = "Couldn't add new context \"#{context.name}\""
|
||||
redirect_to( :action => "list" )
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
expire_action(:controller => "context", :action => "list")
|
||||
|
|
@ -56,10 +75,10 @@ class ContextController < ApplicationController
|
|||
|
||||
|
||||
# Filter the contexts to show just the one passed in the URL
|
||||
# e.g. <home>/context/show/<context_id> shows just <context_id>.
|
||||
# e.g. <home>/context/show/<context_name> shows just <context_name>.
|
||||
#
|
||||
def show
|
||||
@context = Context.find(@params["id"])
|
||||
@context = Context.find_by_name(@params["id"].humanize)
|
||||
@projects = Project.find_all
|
||||
@page_title = "Context: #{@context.name.capitalize}"
|
||||
@not_done = Todo.find_all( "context_id=#{@context.id} AND done=0", "created ASC" )
|
||||
|
|
@ -74,15 +93,16 @@ class ContextController < ApplicationController
|
|||
expire_action(:controller => "context", :action => "list")
|
||||
item = Todo.new
|
||||
item.attributes = @params["new_item"]
|
||||
where = Context.find_by_id(item.context_id)
|
||||
|
||||
back_to = item.context_id
|
||||
back_to = urlize(where.name)
|
||||
|
||||
if item.save
|
||||
flash["confirmation"] = "Succesfully added action \"#{item.description}\" to context"
|
||||
redirect_to( :controller => "context", :action => "show", :id => "#{back_to}" )
|
||||
redirect_to( :controller => "context", :action => "show", :name => "#{back_to}")
|
||||
else
|
||||
flash["warning"] = "Could not add action \"#{item.description}\" to context"
|
||||
redirect_to( :controller => "context", :action => "show", :id => "#{back_to}" )
|
||||
redirect_to( :controller => "context", :action => "show", :name => "#{back_to}" )
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,11 @@ class ProjectController < ApplicationController
|
|||
caches_action :list
|
||||
layout "standard"
|
||||
|
||||
def index
|
||||
list
|
||||
render_action "list"
|
||||
end
|
||||
|
||||
# Main method for listing projects
|
||||
# Set page title, and collect existing projects in @projects
|
||||
#
|
||||
|
|
@ -21,7 +26,7 @@ class ProjectController < ApplicationController
|
|||
# e.g. <home>/project/show/<project_id> shows just <project_id>.
|
||||
#
|
||||
def show
|
||||
@project = Project.find(@params["id"])
|
||||
@project = Project.find_by_name(@params["name"].humanize)
|
||||
@places = Context.find_all
|
||||
@page_title = "Project: #{@project.name}"
|
||||
@not_done = Todo.find_all( "project_id=#{@project.id} AND done=0", "created DESC" )
|
||||
|
|
@ -65,6 +70,20 @@ class ProjectController < ApplicationController
|
|||
redirect_to( :action => "list" )
|
||||
end
|
||||
end
|
||||
|
||||
def new
|
||||
expire_action(:controller => "project", :action => "list")
|
||||
project = Project.new
|
||||
project.name = @params["new_project"]["name"]
|
||||
|
||||
if project.save
|
||||
flash["confirmation"] = "Succesfully added project \"#{project.name}\""
|
||||
redirect_to( :action => "list" )
|
||||
else
|
||||
flash["warning"] = "Couldn't add project \"#{project.name}\""
|
||||
redirect_to( :action => "list" )
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# Called by a form button
|
||||
|
|
|
|||
|
|
@ -10,12 +10,18 @@ class TodoController < ApplicationController
|
|||
# Main method for listing tasks
|
||||
# Set page title, and fill variables with contexts and done and not-done tasks
|
||||
#
|
||||
|
||||
def index
|
||||
list
|
||||
render_action "list"
|
||||
end
|
||||
|
||||
def list
|
||||
@page_title = "List tasks"
|
||||
@projects = Project.find_all
|
||||
@places = Context.find_all
|
||||
@shown_places = Context.find_all_by_hide( 0, "name DESC")
|
||||
@hidden_places = Context.find_all_by_hide( 1 )
|
||||
@shown_places = Context.find_all_by_hide( 0, "position ASC")
|
||||
@hidden_places = Context.find_all_by_hide( 1, "position ASC" )
|
||||
@done = Todo.find_all_by_done( 1, "completed DESC", 5 )
|
||||
|
||||
# Set count badge to number of not-done, not hidden context items
|
||||
|
|
|
|||
|
|
@ -23,6 +23,10 @@ module ApplicationHelper
|
|||
def tag_object(object, tag)
|
||||
tagged = "<#{tag}>#{object}</#{tag}>"
|
||||
end
|
||||
|
||||
def urlize(name)
|
||||
name.to_s.gsub(/ /, "_").downcase
|
||||
end
|
||||
|
||||
|
||||
# Check due date in comparison to today's date
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
class Context < ActiveRecord::Base
|
||||
|
||||
acts_as_list
|
||||
has_many :todo, :dependent => true
|
||||
|
||||
# Context name must not be empty
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
class Project < ActiveRecord::Base
|
||||
|
||||
has_many :todo, :dependent => true
|
||||
acts_as_list
|
||||
|
||||
# Project name must not be empty
|
||||
# and must be less than 255 bytes
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
<div id="display_box">
|
||||
<h2>Edit context</h2>
|
||||
<%= error_messages_for 'context' %>
|
||||
<form action="/context/update" method="post">
|
||||
<%= start_form_tag :controller=>"context", :action=>"update", :id=>@context.id %>
|
||||
<%= render_partial "edit_context", "@context" %>
|
||||
<input type="submit" value="Update" />
|
||||
</form>
|
||||
<%= end_form_tag %>
|
||||
|
||||
<%= link_to 'Cancel', :action => 'list' %>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -8,8 +8,9 @@
|
|||
<% else %>
|
||||
<tr class="odd_row">
|
||||
<% end %>
|
||||
<td align="right" width="20"><%= @context.id.to_s %></td>
|
||||
<td width="390"><%= link_to( "#{@context.name.capitalize}", :action => "show", :id => @context.id ) %></td>
|
||||
<td align="right" width="20"><%= @context.position.to_s %></td>
|
||||
<!-- <td width="390"><%= link_to( "#{@context.name.capitalize}", :action => "show", :id => @context.id ) %></td> -->
|
||||
<td width="390"><%= link_to( "#{@context.name.capitalize}", :action => "show", :name => urlize(@context.name) ) %></td>
|
||||
<td>
|
||||
<% if @context.hide == 1 %>
|
||||
hidden
|
||||
|
|
@ -26,7 +27,7 @@
|
|||
</div><!- End of display_box -->
|
||||
|
||||
<div id="input_box">
|
||||
<form method="post" action="add_context">
|
||||
<%= start_form_tag :controller=>'context', :action=>'new' %>
|
||||
<label for="new_context_name">New context</label><br />
|
||||
<%= text_field("new_context", "name") %>
|
||||
<br />
|
||||
|
|
@ -35,8 +36,8 @@
|
|||
<br />
|
||||
<br />
|
||||
<input type="submit" value="Add context">
|
||||
</form>
|
||||
<%= end_form_tag %>
|
||||
</div>
|
||||
|
||||
<% if @flash["confirmation"] %><div class="confirmation"><%= @flash["confirmation"] %></div><% end %>
|
||||
<% if @flash["warning"] %><div class="warning"><%= @flash["warning"] %></div><% end %>
|
||||
<% if @flash["warning"] %><div class="warning"><%= @flash["warning"] %></div><% end %>
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
</div>
|
||||
<p>Other Contexts:
|
||||
<% for other_context in Context.find_all %>
|
||||
<%= link_to( other_context.name.capitalize, { :controller => "context", :action => "show", :id => other_context.id } ) + " | " %>
|
||||
<%= link_to( other_context.name.capitalize, { :controller => "context", :action => "show", :name => urlize(other_context.name) } ) + " | " %>
|
||||
<% end %>
|
||||
</p>
|
||||
</div><!- End of display_box -->
|
||||
|
|
@ -27,13 +27,24 @@
|
|||
<option value="" selected>None</option>
|
||||
<%= options_from_collection_for_select(@projects, "id", "name" ) %>
|
||||
</select><br />
|
||||
<label for="new_item_due">Due</label><br />
|
||||
<% now = Date.today %>
|
||||
<%= date_select( "new_item", "due", :include_blank => true, :start_year => now.year, "tabindex" => 5 ) %>
|
||||
<br />
|
||||
<label for="item_due" tab>Due</label><br />
|
||||
<%= text_field( "item", "due", "tabindex" => 5, "cols" => 10 ) %>
|
||||
<img src="/images/calendar.gif" onclick="showCal('','',document.forms[0].item_due,2,true,9)" style="cursor:pointer;cursor:hand" />
|
||||
<div id="calDiv" style="display:none">
|
||||
<div id="calTopBar">CLOSE <span onclick="document.getElementById('calDiv').style.display='none';" id="calClose">X</span></div>
|
||||
<table width="100%" id="calNav">
|
||||
<tr><td id="calNavPY"></td><td id="calNavPM"></td><td id="calNavMY" width="100"></td><td id="calNavNM"></td><td id="calNavNY"></td></tr>
|
||||
</table>
|
||||
<table id="calTbl" width="100%" cellspacing="0">
|
||||
<thead><tr style="background-color:#eaeaea"><td>Sun</td><td>Mon</td><td>Tue</td><td>Wed</td><td>Thu</td><td>Fri</td><td>Sat</td></tr></thead>
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
</div>
|
||||
<br />
|
||||
<br />
|
||||
<input type="submit" value="Add item">
|
||||
</form>
|
||||
</div><!-- End of input box -->
|
||||
|
||||
<% if @flash["confirmation"] %><div class="confirmation"><%= @flash["confirmation"] %></div><% end %>
|
||||
<% if @flash["warning"] %><div class="warning"><%= @flash["warning"] %></div><% end %>
|
||||
<% if @flash["warning"] %><div class="warning"><%= @flash["warning"] %></div><% end %>
|
||||
|
|
|
|||
|
|
@ -8,17 +8,15 @@
|
|||
|
||||
<title><%= @page_title %></title>
|
||||
|
||||
<style>
|
||||
#pyNav, #pmNav {border:1px #999 solid}
|
||||
#myNav {}
|
||||
#nmNav, #nyNav { border:1px #999 solid}
|
||||
#calNav td, #calNav td a { text-align:center;font-family:"Lucida Grande", Verdana, Geneva, Arial, sans-serif;font-size:12px;font-weight:bold;background-color:#eee;text-decoration:none }
|
||||
#calNav {margin-bottom:5px}
|
||||
#calNav tr td a {color:#cc3334}
|
||||
#calTbl {}
|
||||
#calTbl td {text-align:center;font-family:"Lucida Grande", Verdana, Geneva, Arial, sans-serif;font-size:11px;border:1px #ccc solid}
|
||||
#calTbl thead td {font-weight:bold}
|
||||
</style>
|
||||
<script>
|
||||
var date = new Date();
|
||||
var curr_dy = date.getDate();
|
||||
var curr_mn = date.getMonth();
|
||||
var curr_yr = date.getFullYear();
|
||||
var DOMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
||||
var lDOMonth = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
||||
var moty = ["January","February","March","April","May","June","July","August","September","October","November","December"];
|
||||
</script>
|
||||
|
||||
</head>
|
||||
<body onload="javascript:toggleAll('notes','none')">
|
||||
|
|
@ -31,12 +29,12 @@
|
|||
</div>
|
||||
<div id="navcontainer">
|
||||
<ul id="navlist">
|
||||
<li><%= link_to( "Home", :controller => "todo", :action => "list" ) %></li>
|
||||
<li><%= link_to( "Contexts", :controller => "context", :action => "list" ) %></li>
|
||||
<li><%= link_to( "Projects", :controller => "project", :action => "list" ) %></li>
|
||||
<li><%= link_to( "Completed", :controller => "todo", :action => "completed" ) %></li>
|
||||
<li><a href="javascript:toggleAll('notes','block')" title="Show all notes">Show</a></li>
|
||||
<li><a href="javascript:toggleAll('notes','none')" title="Show all notes">Hide</a></li>
|
||||
<li><%= link_to( "Home", {:controller => "todo", :action => "list"}, {:accesskey=>"t", :title=>"Home AccessKey: Alt+T"} ) %></li>
|
||||
<li><%= link_to( "Contexts", {:controller => "context", :action => "list"}, {:accesskey=>"c", :title=>"Contexts AccessKey: Alt+C"} ) %></li>
|
||||
<li><%= link_to( "Projects", {:controller => "project", :action => "list"}, {:accesskey=>"p", :title=>"Projects AccessKey: Alt+P"} ) %></li>
|
||||
<li><%= link_to( "Completed", {:controller => "todo", :action => "completed"}, {:accesskey=>"d", :title=>"Completed AccessKey: Alt+D"} ) %></li>
|
||||
<li><a href="javascript:toggleAll('notes','block')" accesskey="S" title="Show all notes AccessKey: Alt+S">Show</a></li>
|
||||
<li><a href="javascript:toggleAll('notes','none')" accesskey="H" title="Show all notes AccessKey: Alt+H">Hide</a></li>
|
||||
<li><%= link_to("<span style=\"font-family: verdana, sans-serif; font-size: 10px; font-weight:bold; text-decoration:none; color: white; background-color: #F60; border:1px solid;
|
||||
border-color: #FC9 #630 #330 #F96; padding:0px 3px 0px 3px; margin:0px;\">RSS</span>", {:controller => "feed", :action => "na_feed", :params => {"name", "#{@session['user']['login']}", "token", "#{@session['user']['word']}"}}, :title => "Subscribe to an RSS feed of your next actions" ) %></li>
|
||||
<li><%= link_to("<span style=\"font-family: verdana, sans-serif; font-size: 10px; font-weight:bold; text-decoration:none; color: white; background-color: #F60; border:1px solid;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
<tr class="odd_row">
|
||||
<% end %>
|
||||
<td align="right" width="20"><%= @project.id.to_s %></td>
|
||||
<td width="390"><%= link_to ( "#{@project.name}", :action => "show", :id => @project.id ) %></td>
|
||||
<td width="390"><%= link_to ( "#{@project.name}", :action => "show", :name => urlize(@project.name) ) %></td>
|
||||
<td width="40"><%= link_image_to( "edit", { :action => "edit", :id => @project.id }, :title => "Edit item", :size => "10x10", :border => "0" ) + " " + link_image_to( "delete", { :action => "destroy", :id => @project.id }, :title => "Delete item", :size => "10x10", :border => "0", :confirm => "Are you sure you want to delete the project \"#{@project.name}?\" Any todos in this project will be deleted." ) + " " %></td>
|
||||
</tr>
|
||||
<% row += 1 %>
|
||||
|
|
@ -19,14 +19,15 @@
|
|||
</div><!- End of display_box -->
|
||||
|
||||
<div id="input_box">
|
||||
<%= start_form_tag :controller => 'project', :action => 'new' %>
|
||||
<form method="post" action="add_project">
|
||||
<label for="new_project_name">New Project</label><br />
|
||||
<%= text_field( "new_project", "name" ) %>
|
||||
<br />
|
||||
<br />
|
||||
<input type="submit" value="Add project">
|
||||
</form>
|
||||
<%= end_form_tag %>
|
||||
</div>
|
||||
|
||||
<% if @flash["confirmation"] %><div class="confirmation"><%= @flash["confirmation"] %></div><% end %>
|
||||
<% if @flash["warning"] %><div class="warning"><%= @flash["warning"] %></div><% end %>
|
||||
<% if @flash["warning"] %><div class="warning"><%= @flash["warning"] %></div><% end %>
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
</div>
|
||||
<p>Other Projects:
|
||||
<% for other_project in Project.find_all %>
|
||||
<%= link_to( other_project.name.capitalize, { :controller => "project", :action => "show", :id => other_project.id } ) + " | " %>
|
||||
<%= link_to( other_project.name.capitalize, { :controller => "project", :action => "show", :name => urlize(other_project.name) } ) + " | " %>
|
||||
<% end %>
|
||||
</p>
|
||||
</div><!-- End of display box -->
|
||||
|
|
@ -33,13 +33,24 @@
|
|||
<%= options_from_collection_for_select(@places, "id", "name" ) %>
|
||||
</select>
|
||||
<br />
|
||||
<label for="new_item_due">Due</label><br />
|
||||
<% now = Date.today %>
|
||||
<%= date_select( "new_item", "due", :include_blank => true, :start_year => now.year, "tabindex" => 5 ) %>
|
||||
<br />
|
||||
<label for="item_due" tab>Due</label><br />
|
||||
<%= text_field( "item", "due", "tabindex" => 5, "cols" => 10 ) %>
|
||||
<img src="/images/calendar.gif" onclick="showCal('','',document.forms[0].item_due,2,true,9)" style="cursor:pointer;cursor:hand" />
|
||||
<div id="calDiv" style="display:none">
|
||||
<div id="calTopBar">CLOSE <span onclick="document.getElementById('calDiv').style.display='none';" id="calClose">X</span></div>
|
||||
<table width="100%" id="calNav">
|
||||
<tr><td id="calNavPY"></td><td id="calNavPM"></td><td id="calNavMY" width="100"></td><td id="calNavNM"></td><td id="calNavNY"></td></tr>
|
||||
</table>
|
||||
<table id="calTbl" width="100%" cellspacing="0">
|
||||
<thead><tr style="background-color:#eaeaea"><td>Sun</td><td>Mon</td><td>Tue</td><td>Wed</td><td>Thu</td><td>Fri</td><td>Sat</td></tr></thead>
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
</div>
|
||||
<br />
|
||||
<br />
|
||||
<input type="submit" value="Add item">
|
||||
</form>
|
||||
</div><!-- End of input box -->
|
||||
|
||||
<% if @flash["confirmation"] %><div class="confirmation"><%= @flash["confirmation"] %></div><% end %>
|
||||
<% if @flash["warning"] %><div class="warning"><%= @flash["warning"] %></div><% end %>
|
||||
<% if @flash["warning"] %><div class="warning"><%= @flash["warning"] %></div><% end %>
|
||||
|
|
|
|||
|
|
@ -35,8 +35,19 @@
|
|||
<% end %>
|
||||
</select>
|
||||
<br />
|
||||
|
||||
<label for="item_due" tab>Due</label><br />
|
||||
<% now = Date.today %>
|
||||
<%= date_select( "item", "due", :include_blank => true, :start_year => now.year, "tabindex" => 5 ) %>
|
||||
<%= text_field( "item", "due", "tabindex" => 5, "cols" => 10 ) %>
|
||||
<img src="/images/calendar.gif" onclick="showCal('','',document.forms[0].item_due,2,true,9)" style="cursor:pointer;cursor:hand" />
|
||||
<div id="calDiv" style="display:none">
|
||||
<div id="calTopBar">CLOSE <span onclick="document.getElementById('calDiv').style.display='none';" id="calClose">X</span></div>
|
||||
<table width="100%" id="calNav">
|
||||
<tr><td id="calNavPY"></td><td id="calNavPM"></td><td id="calNavMY" width="100"></td><td id="calNavNM"></td><td id="calNavNY"></td></tr>
|
||||
</table>
|
||||
<table id="calTbl" width="100%" cellspacing="0">
|
||||
<thead><tr style="background-color:#eaeaea"><td>Sun</td><td>Mon</td><td>Tue</td><td>Wed</td><td>Thu</td><td>Fri</td><td>Sat</td></tr></thead>
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
</div>
|
||||
<br />
|
||||
<br />
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
<td valign="top"><%= due_date( @notdone_item.due ) %>
|
||||
<%= @notdone_item.description %>
|
||||
<% if @notdone_item.project_id %>
|
||||
<%= link_to( "[P]", { :controller => "project", :action => "show", :id => @notdone_item.project_id }, :title => "View project: #{@notdone_item.project.name}" ) %>
|
||||
<%= link_to( "[P]", { :controller => "project", :action => "show", :name => urlize(@notdone_item.project.name) }, :title => "View project: #{@notdone_item.project.name}" ) %>
|
||||
<% end %>
|
||||
<% if @notdone_item.notes? %>
|
||||
<%= "<a href=\"javascript:toggle('" + @notdone_item.id.to_s + "')\" title=\"Show notes\">" + $notes_img + "</a>" %>
|
||||
|
|
@ -13,4 +13,4 @@
|
|||
<%= "<div class=\"notes\" id=\"" + @notdone_item.id.to_s + "\">" + m_notes + "</div>" %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
</tr>
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
<% @not_done = Todo.find_all("done=0 AND context_id=#{@shown_place.id}", "created ASC") %>
|
||||
<% if !@not_done.empty? %>
|
||||
<div class="contexts">
|
||||
<h2><%= link_to( "#{@shown_place.name.capitalize}", :controller => "context", :action => "show", :id => @shown_place.id ) %></h2>
|
||||
<h2><%= link_to( "#{@shown_place.name.capitalize}", :controller => "context", :action => "show", :name => urlize(@shown_place.name) ) %></h2>
|
||||
<table class="next_actions" id="incomplete" cellspacing="2" cellpadding="0" border="0">
|
||||
<%= render_collection_of_partials "not_done", @not_done %>
|
||||
</table>
|
||||
|
|
@ -29,43 +29,14 @@
|
|||
<p>Hidden contexts:
|
||||
<% for @hidden_place in @hidden_places %>
|
||||
<% num = count_items(@hidden_place) %>
|
||||
<a href="<%= url_for( :controller => "context", :action => "show", :id => "#{@hidden_place.id}" ) %>"><%= @hidden_place.name.capitalize %> (<%= num %>)</a> |
|
||||
<%= link_to @hidden_place.name.capitalize, :controller=>"context", :action=> "show", :name=> urlize(@hidden_place.name) %>
|
||||
<% end %>
|
||||
</p>
|
||||
|
||||
</div><!- End of display_box -->
|
||||
|
||||
<div id="input_box">
|
||||
|
||||
<div style="padding:0px;width:200px;background-color:#eee;margin-bottom:10px; margin-left: 60px;" id="calDiv">
|
||||
<table width="100%" id="calNav">
|
||||
<tr>
|
||||
<td id="pyNav"></td><td id="pmNav"></td><td id="myNav" width="100"></td><td id="nmNav"></td><td id="nyNav"></td>
|
||||
</tr>
|
||||
</table>
|
||||
<table id="calTbl" width="100%" cellspacing="0">
|
||||
<thead>
|
||||
<tr style="background-color:#eaeaea">
|
||||
<td>Sun</td>
|
||||
<td>Mon</td>
|
||||
<td>Tue</td>
|
||||
<td>Wed</td>
|
||||
<td>Thu</td>
|
||||
<td>Fri</td>
|
||||
<td>Sat</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<script language="Javascript" type="text/javascript">
|
||||
var date = new Date();
|
||||
var curr_dy = date.getDate();
|
||||
var curr_mn = date.getMonth();
|
||||
var curr_yr = date.getFullYear();
|
||||
buildCalendar(curr_mn,curr_yr);
|
||||
</script>
|
||||
<form method="post" action="add_item">
|
||||
<%= render_partial "todo/item", @item %>
|
||||
<input type="submit" value="Add item">
|
||||
|
|
|
|||
|
|
@ -9,9 +9,34 @@ ActionController::Routing::Routes.draw do |map|
|
|||
# Allow downloading Web Service WSDL as a file with an extension
|
||||
# instead of a file named 'wsdl'
|
||||
map.connect ':controller/service.wsdl', :action => 'wsdl'
|
||||
|
||||
|
||||
# Index Route
|
||||
map.connect '', :controller => 'todo', :action => 'list'
|
||||
|
||||
|
||||
# Login Routes
|
||||
map.connect 'login', :controller => 'login', :action => 'login'
|
||||
map.connect 'logout', :controller => 'login', :action => 'logout'
|
||||
map.connect 'signup', :controller => 'login', :action => 'signup'
|
||||
|
||||
# ToDo Routes
|
||||
map.connect 'completed', :controller => 'todo', :action => 'completed'
|
||||
map.connect 'delete/todo/:id', :controller =>'todo', :action => 'destroy'
|
||||
|
||||
# Context Routes
|
||||
map.connect 'contexts', :controller => 'context', :action => 'list'
|
||||
map.connect 'add/context', :controller => 'context', :action => 'new'
|
||||
map.connect 'context/:id', :controller=> 'context', :action => 'show'
|
||||
map.connect 'context/:name', :controller => 'context', :action => 'show'
|
||||
map.connect 'delete/context/:id', :controller => 'context', :action => 'destroy'
|
||||
|
||||
# Projects Routes
|
||||
map.connect 'projects', :controller => 'project', :action => 'list'
|
||||
map.connect 'add/project', :controller => 'project', :action => 'new'
|
||||
map.connect 'project/:name', :controller => 'project', :action => 'show'
|
||||
map.connect 'project/:id', :controller => 'project', :action => 'show'
|
||||
map.connect 'delete/project/:id', :controller => 'project', :action => 'destroy'
|
||||
|
||||
|
||||
map.connect 'add_item', :controller => 'todo', :action => 'add_item'
|
||||
|
||||
# Install the default route as the lowest priority.
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ CREATE TABLE `contexts` (
|
|||
`id` int(11) NOT NULL auto_increment,
|
||||
`name` varchar(255) NOT NULL default '',
|
||||
`hide` tinyint(4) NOT NULL default '0',
|
||||
`position` int(11) NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) TYPE=MyISAM;
|
||||
|
||||
|
|
@ -25,6 +26,7 @@ CREATE TABLE `contexts` (
|
|||
CREATE TABLE `projects` (
|
||||
`id` int(11) NOT NULL auto_increment,
|
||||
`name` varchar(255) NOT NULL default '',
|
||||
`position` int(11) NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) TYPE=MyISAM;
|
||||
|
||||
|
|
|
|||
BIN
tracks/public/images/calendar.gif
Normal file
BIN
tracks/public/images/calendar.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 103 B |
|
|
@ -1,7 +1,6 @@
|
|||
/* Today's date */
|
||||
var DOMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
||||
var lDOMonth = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
||||
var moty = ["January","February","March","April","May","June","July","August","September","October","November","December"];
|
||||
// Popup calendar date picker
|
||||
// Written by Michele Tranquilli of pxl8.com
|
||||
// <http://www.pxl8.com/calendar_date_picker.html>
|
||||
|
||||
function Calendar_get_daysofmonth(monthNo, p_year) {
|
||||
if ((p_year % 4) == 0) {
|
||||
|
|
@ -11,7 +10,9 @@ function Calendar_get_daysofmonth(monthNo, p_year) {
|
|||
} else
|
||||
return DOMonth[monthNo];
|
||||
}
|
||||
|
||||
// -- globals used with calendar and date functions
|
||||
var calField; var calSpan; var calFormat; var calWknd = false;
|
||||
/* ^^^^^^ end BASIC DATE STARTER-SET ^^^^^^ */
|
||||
function getNextMonth(m,y,incr){
|
||||
var ret_arr = new Array();
|
||||
ret_arr[0] = m + incr; ret_arr[1] = y;
|
||||
|
|
@ -20,16 +21,18 @@ function getNextMonth(m,y,incr){
|
|||
return ret_arr;
|
||||
}
|
||||
function figureDOTW(m,d,y){
|
||||
var tDate = new Date(); tDate.setDate(d); tDate.setMonth(m); tDate.setYear(y); return tDate.getDay();
|
||||
var tDate = new Date(); tDate.setDate(d); tDate.setMonth(m); tDate.setFullYear(y); return tDate.getDay();
|
||||
}
|
||||
function scramKids(n){ // this is a basic removeChild loop for removing all childNodes from node n
|
||||
var numKids = n.childNodes.length;
|
||||
for (i=0;i<numKids;i++) { n.removeChild(n.childNodes[0]); }
|
||||
}
|
||||
function buildCalendar(m,y,ff){
|
||||
function buildCalendar(m,y){
|
||||
// -- requires: Basic Date Starter-Set, getNextMonth(), figureDOTW(), scramKids()
|
||||
m = parseFloat(m); y = parseFloat(y);
|
||||
var dayNo = figureDOTW(m,1,y);
|
||||
var monthNo = Calendar_get_daysofmonth(m,y);
|
||||
|
||||
var rowNum = Math.ceil((monthNo+dayNo)/7);
|
||||
var dayCount = 1;
|
||||
var calTB = document.getElementById('calTbl').getElementsByTagName('tbody')[0];
|
||||
var calNav = document.getElementById('calNav');
|
||||
|
|
@ -37,33 +40,98 @@ function buildCalendar(m,y,ff){
|
|||
for (i=0;i<6;i++){ // row loop
|
||||
var calTR = document.createElement('tr');
|
||||
var calTDtext;
|
||||
|
||||
for (j=0; j < 7; j++){ // cells in row loop
|
||||
var cellContent;
|
||||
for (j=0; j < 7; j++){ // cells in row loop, days in the week
|
||||
var calTD = document.createElement('td');
|
||||
if (j == 0 || j == 6 )
|
||||
calTD.style.backgroundColor = '#fff';
|
||||
if ((i==0 && j < dayNo) || dayCount > monthNo) // if this is the first row....
|
||||
calTDtext = document.createElement('br');
|
||||
if (j == 0 || j == 6 ) // weekends
|
||||
calTD.style.backgroundColor = '#EDF0FF';
|
||||
if ((i==0 && j < dayNo) || dayCount > monthNo) // cells before the first of the month or after the last day
|
||||
cellContent = document.createElement('br');
|
||||
else {
|
||||
calTDtext = document.createTextNode(dayCount.toString());
|
||||
var dyA = document.createElement('a');
|
||||
dyA.setAttribute('href','javascript:placeDate('+m+','+dayCount+','+y+')');
|
||||
|
||||
calTDtext = document.createTextNode(dayCount.toString());
|
||||
cellContent = calTDtext;
|
||||
if (dayCount == curr_dy && m == curr_mn && y == curr_yr)
|
||||
calTD.style.color = '#ff6600';
|
||||
calTD.style.backgroundColor = '#FFFF99';
|
||||
if ((j!=0 && j!=6) || calWknd == true){ // if the day is a weekday or weekends allowed
|
||||
if (dayCount == curr_dy && m == curr_mn && y == curr_yr && calSpan != 3 && calSpan != 0 && calSpan != 4){
|
||||
dyA.appendChild(calTDtext); cellContent = dyA;
|
||||
}
|
||||
if (calSpan == 1 || calSpan == 4){
|
||||
if (y < curr_yr || (m < curr_mn && y == curr_yr) || (m == curr_mn && y == curr_yr && dayCount < curr_dy))
|
||||
{
|
||||
dyA.appendChild(calTDtext); cellContent = dyA;
|
||||
}
|
||||
}
|
||||
if (calSpan == 2 || calSpan == 3){
|
||||
if (y > curr_yr || (m > curr_mn && y == curr_yr) || (m == curr_mn && y == curr_yr && dayCount > curr_dy))
|
||||
{dyA.appendChild(calTDtext); cellContent = dyA;}
|
||||
}
|
||||
if (calSpan == 5){
|
||||
dyA.appendChild(calTDtext); cellContent = dyA;
|
||||
}
|
||||
}
|
||||
else { /* else if it's a weekend */ }
|
||||
dayCount++;
|
||||
}
|
||||
calTD.appendChild(calTDtext);
|
||||
calTD.appendChild(cellContent);
|
||||
calTD.setAttribute('width','14%');
|
||||
calTR.appendChild(calTD);
|
||||
}
|
||||
calTB.appendChild(calTR);
|
||||
}
|
||||
|
||||
var nMonth = getNextMonth(m,y,+1);
|
||||
var pMonth = getNextMonth(m,y,-1);
|
||||
|
||||
document.getElementById('pyNav').innerHTML = '<a href="javascript:void(0)" title="Previous Year" onclick="buildCalendar('+m+','+(y-1)+',\''+ff+'\')"><<</a>';
|
||||
document.getElementById('pmNav').innerHTML = '<a href="javascript:void(0)" title="Previous Month" onclick="buildCalendar('+pMonth[0]+','+pMonth[1]+')"><</a>';
|
||||
document.getElementById('myNav').innerHTML = moty[m] +' '+y;
|
||||
document.getElementById('nyNav').innerHTML = '<a href="javascript:void(0)" title="Next Year" onclick="buildCalendar('+m+','+(y+1)+')">>></a>';
|
||||
document.getElementById('nmNav').innerHTML = '<a href="javascript:void(0)" title="Next Month" onclick="buildCalendar('+nMonth[0]+','+nMonth[1]+')">></a>';
|
||||
document.getElementById('calNavPY').innerHTML = '<a href="javascript:void(0)" onclick="buildCalendar('+m+','+(y-1)+')"><<</a>';
|
||||
document.getElementById('calNavPM').innerHTML = '<a href="javascript:void(0)" onclick="buildCalendar('+pMonth[0]+','+pMonth[1]+')"><</a>';
|
||||
document.getElementById('calNavMY').innerHTML = moty[m] +' '+y;
|
||||
document.getElementById('calNavNY').innerHTML = '<a href="javascript:void(0)" onclick="buildCalendar('+m+','+(y+1)+')">>></a>';
|
||||
document.getElementById('calNavNM').innerHTML = '<a href="javascript:void(0)" onclick="buildCalendar('+nMonth[0]+','+nMonth[1]+')">></a>';
|
||||
}
|
||||
function showCal(m,y,f,dateSpan,wknd,format){
|
||||
/*
|
||||
dateSpan - date that should have links; does not include weekends
|
||||
0 = no dates
|
||||
1 = all past dates up to and including today
|
||||
2 = all future dates starting with today
|
||||
3 = all future dates NOT including today ( for GTC Dates )
|
||||
4 = all past dates NOT including today ( for start / from dates )
|
||||
5 = all dates
|
||||
*/
|
||||
calField = f; calSpan = dateSpan; calFormat = format; calWknd = wknd;
|
||||
if (m == '' && y == ''){m = curr_mn; y = curr_yr;}
|
||||
buildCalendar(m,y);
|
||||
document.getElementById('calDiv').style.display = '';
|
||||
}
|
||||
function placeDate(m,d,y){
|
||||
eval(calField).value = dateFormats(m,d,y,calFormat);
|
||||
document.getElementById('calDiv').style.display = 'none';
|
||||
}
|
||||
function dateFormats(m,d,y,calFormat){
|
||||
d = d.toString();
|
||||
m = m+1; m = m.toString();
|
||||
y = y.toString();
|
||||
var sy = y;
|
||||
// -- convert to 2 digit numbers
|
||||
if (m.length == 1){m = '0'+ m;}
|
||||
if (d.length == 1){d = '0'+ d;}
|
||||
if (y.length == 4)
|
||||
sy = y.substring(2,4);
|
||||
var format;
|
||||
switch (calFormat){
|
||||
case 0 : format = m + d + sy; break; // mmddyy
|
||||
case 1 : format = m + d + y; break; // mmddyyyy
|
||||
case 2 : format = m +'/'+ d +'/'+ y; break; // mm/dd/yyyy
|
||||
case 3 : format = m +'/'+ d +'/'+ sy; break; // mm/dd/yy
|
||||
case 4 : format = y + m; break; // yyyymm
|
||||
case 5 : format = d + m + sy; break; // ddmmyy
|
||||
case 6 : format = d +'/'+ m +'/'+ sy; break; // dd/mm/yy
|
||||
case 7 : format = d + m + y; break; // ddmmyyyy
|
||||
case 8 : format = d +'/'+ m +'/'+ y; break; // dd/mm/yyyy
|
||||
case 9 : format = y +'-'+ m +'-'+ d; break; // yyyy-mm-dd
|
||||
default: format = m + d + y; break; // mmddyyyy
|
||||
}
|
||||
return format;
|
||||
}
|
||||
|
|
@ -276,4 +276,60 @@ label {
|
|||
|
||||
input {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
}
|
||||
|
||||
/* Popup calendar styles */
|
||||
|
||||
#calNavPY, #calNavPM {border:1px #999 solid}
|
||||
#calNavNM, #calNavNY { border:1px #999 solid}
|
||||
|
||||
#calNav td, #calNav td a {
|
||||
text-align:center;
|
||||
font-family:"Lucida Grande", Verdana, Geneva, Arial, sans-serif;
|
||||
font-size:12px;
|
||||
font-weight:bold;
|
||||
background-color:#eaeaea;
|
||||
text-decoration:none
|
||||
}
|
||||
|
||||
#calNav td a,#calNav td a:visited,#calTbl td a,#calTbl td a:visited {color:#cc3334 }
|
||||
#calNav td a:hover,#calTbl td a:hover { color:#fff; background:#cc3334; }
|
||||
#calNav {margin-bottom:5px;width:100%}
|
||||
#calTbl {width:100%}
|
||||
#calTbl td {text-align:center;font-family:"Lucida Grande", Verdana, Geneva, Arial, sans-serif;font-size:11px;border:1px #ccc solid}
|
||||
|
||||
#calTbl thead td {
|
||||
font-weight:bold;
|
||||
background-color:#eaeaea;
|
||||
padding: 2px;
|
||||
border:1px #ccc solid
|
||||
height: auto;
|
||||
}
|
||||
|
||||
#calDiv {
|
||||
border:1px solid #ccc;
|
||||
padding:2px;
|
||||
width:200px;
|
||||
position:absolute;
|
||||
z-index:276;
|
||||
top:300px;
|
||||
left:300px;
|
||||
background-color:#fff
|
||||
}
|
||||
|
||||
#calTopBar {
|
||||
background-color:#ccc;
|
||||
color:#fff;
|
||||
padding:2px;
|
||||
text-align:right;
|
||||
font-family:"Lucida Grande", Verdana, Geneva, Arial, sans-serif;
|
||||
font-size:11px;
|
||||
font-weight:bold;
|
||||
width:100%
|
||||
}
|
||||
|
||||
#calClose {
|
||||
padding:0px 2px;border:1px #fff solid;cursor:pointer;cursor:hand
|
||||
}
|
||||
|
||||
#calPic {cursor:hand}
|
||||
Loading…
Add table
Add a link
Reference in a new issue