mirror of
https://github.com/TracksApp/tracks.git
synced 2026-03-03 03:20:15 +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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue