Changed the instances of :project (referring to flagging whether we are on a project page) for an @on_page = "project" variable. In forms, I send a request parameter @param["on_project_page"] to set @on_page to "project" before rendering the partial.

It works fine except in the following circumstances, which I can't seem to figure out:

* If you edit an action on a project page, it will render with '[P]' link until you refresh
* If you mark an action completed on a project page, it will also render with a '[P]' link until you refresh.

However, adding a new action on a project page renders properly immediately.



git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@167 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
bsag 2005-12-07 19:06:24 +00:00
parent 1424b12834
commit 7d33019265
11 changed files with 23 additions and 14 deletions

View file

@ -24,6 +24,7 @@ class ContextController < ApplicationController
def show
init
init_todos
@on_page = "context"
@page_title = "TRACKS::Context: #{@context.name}"
end

View file

@ -27,6 +27,7 @@ class ProjectController < ApplicationController
init
init_todos
@notes = @project.notes
@on_page = "project"
@page_title = "TRACKS::Project: #{@project.name}"
if @not_done.empty?

View file

@ -21,6 +21,7 @@ class TodoController < ApplicationController
#
def list
self.init
@on_page = "home"
@page_title = "TRACKS::List tasks"
@done = @done[0..(NO_OF_ACTIONS-1)]
@ -36,6 +37,9 @@ class TodoController < ApplicationController
# in the selected context.
def add_item
self.init
if @params["on_project_page"]
@on_page = "project"
end
item = @user.todos.build
item.attributes = @params["new_item"]
@ -46,7 +50,7 @@ class TodoController < ApplicationController
end
if item.save
render :partial => 'item', :object => item, :project => @params["project"]
render :partial => 'item', :object => item
else
flash["warning"] = "Couldn't add next action \"#{item.description}\""
render_text ""
@ -77,7 +81,9 @@ class TodoController < ApplicationController
#
def update_action
self.init
if @params["on_project_page"] == true
@on_page = "project"
end
item = check_user_return_item
item.attributes = @params["item"]
@ -88,7 +94,7 @@ class TodoController < ApplicationController
end
if item.save
render :partial => 'item', :object => item, :project => @params["project"]
render :partial => 'item', :object => item
else
flash["warning"] = "Couldn't update the action"
render_text ""

View file

@ -11,6 +11,6 @@
<%= render :partial => "shared/empty",
:locals => { :message => "Currently there are no uncompleted actions in this context"} %>
</div>
<%= render :partial => "todo/item", :collection => @not_done, :locals => { :project => false } %>
<%= render :partial => "todo/item", :collection => @not_done %>
</div><!-- [end:items] -->
</div><!-- [end:c<%= context.id %>] -->

View file

@ -14,11 +14,11 @@
<p class="project_completed">Project has been marked as completed</p>
<% end -%>
<div class="items toggle_target">
<div id="empty-nd" style="display:<%= @not_done.empty? ? 'block' : 'none'%>;">
<%= render :partial => "shared/empty",
:locals => { :message => "Currently there are no uncompleted actions in this project"} %>
</div>
<%= render :partial => "todo/item", :collection => @not_done, :locals => { :project => true } %>
<%= render :partial => "todo/item", :collection => @not_done %>
</div><!-- [end:items] -->
</div><!-- [end:p<%= project.id %>] -->

View file

@ -50,7 +50,7 @@
<% if controller.controller_name == "project" -%>
<%= hidden_field( "new_item", "project_id", "value" => "#{@project.id}") %>
<input type="hidden" name="project" value="true" />
<input type="hidden" name="on_project_page" value="true" />
<% elsif controller.controller_name == "context" -%>
<%= hidden_field( "new_item", "context_id", "value" => "#{@context.id}") %>
<% end -%>

View file

@ -49,7 +49,7 @@
</tr>
<tr>
<% if controller.controller_name == "project" -%>
<input type="hidden" name="project" value="true" />
<input type="hidden" name="on_project_page" value="true" />
<% end -%>
<td><input type="submit" value="Update" tabindex="6" />
<a href="javascript:void(0);" onclick="Element.toggle('item-<%= @item.id %>','action-<%= @item.id %>-edit-form');Form.reset('form-action-<%= @item.id %>');">Cancel</a></td>

View file

@ -1,4 +1,4 @@
<% suffix = append_descriptor ? append_descriptor : '' %>
<% suffix = append_descriptor ? append_descriptor : '' -%>
<div class="container completed">
<h2>
<% if collapsible %>

View file

@ -1,4 +1,5 @@
<div id="item-<%= item.id %>-container" class="item-container">
<div id="item-<%= item.id %>">
<%= form_remote_tag_toggle_todo( item ) %>
<%= form_tag( { :controller => "todo", :action => "toggle_check", :id => item.id },
@ -12,7 +13,7 @@
<%= due_date( item.due ) -%>
<% end -%>
<%= sanitize(item.description) %>
<% if project -%>
<% if @on_page == "project" -%>
<%= link_to( "[C]", { :controller => "context", :action => "show", :name => urlize(item.context.name) }, :title => "View context: #{item.context.name}" ) %>
<% elsif item.project_id -%>
<%= link_to( "[P]", { :controller => "project", :action => "show", :name => urlize(item.project.name) }, :title => "View project: #{item.project.name}" ) %>

View file

@ -2,7 +2,7 @@
* Homepage: http://www.rousette.org.uk/projects/
* Author: bsag (http://www.rousette.org.uk/)
* Contributors: Nicholas Lee, Lolindrath, Jim Ray, Arnaud Limbourg, Timothy Martens, Luke, John Leonard (for great installation tutorials on Windows XP)
* Contributors: Nicholas Lee, Lolindrath, Jim Ray, Arnaud Limbourg, Timothy Martens, Luke Melia, John Leonard (for great installation tutorials on Windows XP)
* Version: 1.03
* Copyright: (cc) 2004-2005 rousette.org.uk
* License: GNU GPL

View file

@ -2,7 +2,7 @@
* Homepage: http://www.rousette.org.uk/projects/
* Author: bsag (http://www.rousette.org.uk/)
* Contributors: Nicholas Lee, Lolindrath, Jim Ray, Arnaud Limbourg, Timothy Martens, Luke, John Leonard (for great installation tutorials on Windows XP)
* Contributors: Nicholas Lee, Lolindrath, Jim Ray, Arnaud Limbourg, Timothy Martens, Luke Melia, John Leonard (for great installation tutorials on Windows XP)
* Version: 1.031
* Copyright: (cc) 2004-2005 rousette.org.uk
* License: GNU GPL
@ -15,9 +15,9 @@ While fully usable for everyday use, Tracks is still a work in progress. Make su
<b>IF THIS CRASHES YOUR MACHINE AND LOSES YOUR DATA, IT'S NOT MY FAULT!</b>
== Installation
== Installation (for trunk version <b>only</b>)
Before you start, you need to make sure that you have Ruby 1.8.2, Rails 0.13.1 (it <i>may</i> work with versions down to 0.12.0, but it's much better to get the latest version), and Redcloth 3.0.3. By far the easiest way to get these installed is using gems (see instructions on getting gems here http://wiki.rubyonrails.com/rails/show/GemRails). You also need some kind of database. MySQL is probably the most popular, but it's also easy to use PostgreSQL or SQLite. If you have Mac OS X Tiger, you already have Ruby 1.8.2 and SQLite3 installed, so all you need to do after installing Rails and Redcloth is to install the sqlite3-ruby gem (1.1.0). See http://dev.rousette.org.uk/wiki/Tracks/Install for more details on installing all the necessary components on all the supported platforms.
Before you start, you need to make sure that you have Ruby 1.8.2, Rails 0.14.3, and Redcloth 3.0.3. By far the easiest way to get these installed is using gems (see instructions on getting gems here http://wiki.rubyonrails.com/rails/show/GemRails). You also need some kind of database. MySQL is probably the most popular, but it's also easy to use PostgreSQL or SQLite. If you have Mac OS X Tiger, you already have Ruby 1.8.2 and SQLite3 installed, so all you need to do after installing Rails and Redcloth is to install the sqlite3-ruby gem (1.1.0). See http://dev.rousette.org.uk/wiki/Tracks/Install for more details on installing all the necessary components on all the supported platforms.
=== New users