Yet more refactoring, particularly of the option drop downs.

git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@13 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
bsag 2005-01-23 19:15:17 +00:00
parent 177180ea6e
commit 9a649506a5
11 changed files with 41 additions and 64 deletions

View file

@ -41,7 +41,6 @@ class ContextController < ApplicationController
#
def show
@context = Context.find(@params["id"])
@places = Context.find_all
@projects = Project.find_all
@page_title = "Context: #{@context.name.capitalize}"
@not_done = Todo.find_all( "context_id=#{@context.id} AND done=0", "created ASC" )

View file

@ -88,22 +88,4 @@ class ProjectController < ApplicationController
end
# Toggles the 'done' status of the action
def toggle_check
item = Todo.find( @params['id'] )
case item.done
when 0: item.done = 1; item.completed = Time.now()
when 1: item.done = 0; item.completed = nil
end
if item.save
flash["confirmation"] = "Marked next action as completed"
redirect_to( :action => "list" )
else
flash["warning"] = "Couldn't mark next action as completed"
redirect_to( :action => "list" )
end
end
end

View file

@ -12,8 +12,8 @@ class TodoController < ApplicationController
#
def list
@page_title = "List tasks"
@places = Context.find_all
@projects = Project.find_all
@places = Context.find_all
@done = Todo.find_all( "done=1", "completed DESC", 5 )
@count = Todo.count( "done=0" )
end

View file

@ -49,5 +49,15 @@ module ApplicationHelper
end
end
def get_projects()
@projects = Project.find_all
return @@projects
end
def get_contexts()
@places = Context.find_all
return @@places
end
end

View file

@ -1,6 +1,6 @@
<div id="display_box">
<table cellpadding="5" width="450">
<table class="list" cellspacing="0" cellpadding="5" width="450" border="0">
<% row = 1 %>
<% for @context in @contexts %>
<% if row % 2 == 0 %>

View file

@ -21,9 +21,7 @@
<label for="new_item_project_id">Project</label><br />
<select name="new_item[project_id]" id="new_item_project_id">
<option value="" selected>None</option>
<% for @project in @projects %>
<option value="<%= @project.id %>"><%= @project.name %></option>
<% end %>
<%= options_from_collection_for_select(@projects, "id", "name" ) %>
</select><br />
<label for="new_item_due">Due</label><br />
<%= text_field( "new_item", "due", {"size" => 10, "maxlength" => 10} ) %>

View file

@ -0,0 +1,16 @@
<% @item = not_done %>
<tr>
<td valign="top"><%= check_box( "item", "done", "onclick" => "document.location.href='/todo/toggle_check/#{@item.id}'" ) %></td>
<td valign="top" width="30"><%= link_to( $edit_img, { :action => "edit", :id => @item.id }, :title => "Edit item" ) + " " + link_to($delete_img, { :controller => "todo", :action => "destroy", :id => @item.id }, :title => "Delete item", :confirm => "Are you sure you want to delete this entry: #{@item.description}" ) + " " %></td>
<td valign="top"><%= due_date( @item.due ) %>
<%= @item.description %>
<% if @item.project_id %>
<%= link_to( "[C]", { :controller => "context", :action => "show", :id => @item.context_id }, :title => "View context: #{@item.context['name'].capitalize}" ) %>
<% end %>
<% if @item.notes? %>
<%= "<a href=\"javascript:toggle('" + @item.id.to_s + "')\" title=\"Show notes\">" + $notes_img + "</a>" %>
<% m_notes = markdown( @item.notes ) %>
<%= "<div class=\"notes\" id=\"" + @item.id.to_s + "\">" + m_notes + "</div>" %>
<% end %>
</td>
</tr>

View file

@ -1,6 +1,6 @@
<div id="display_box">
<table cellpadding="5" width="450">
<table class="list" cellspacing="0" cellpadding="5" width="450" border="0">
<% row = 1 %>
<% for @project in @projects %>
<% if row % 2 == 0 %>

View file

@ -6,32 +6,10 @@
<% if @not_done == [] %>
<p>There are no next actions yet in this project</p>
<% else %>
<ul>
<% for @item in @not_done %>
<li>
<div class="box">
<%= check_box( "item", "done", "onclick" => "document.location.href='/todo/toggle_check/#{@item.id}'" ) %>
</div>
<div class="description">
<%= due_date( @item.due ) %>
<%= @item.description %>
<%= link_to( "[C]", { :controller => "context", :action => "show", :id => @item.context_id }, :title => "View context: #{@item.context['name'].capitalize}" ) %>
</div>
<div class="tools">
<%= link_to( $edit_img, { :controller => "todo", :action => "edit", :id => @item.id }, :title => "Edit item" ) + " " + link_to($delete_img, { :controller => "todo", :action => "destroy", :id => @item.id }, :title => "Delete item", :confirm => "Are you sure you want to delete this entry: #{@item.description}" ) + " " %>
<% if @item.notes? %>
<%= "<a href=\"javascript:toggle('" + @item.id.to_s + "')\" title=\"Show notes\">" + $notes_img + "</a>" %></div>
<% m_notes = markdown(@item.notes) %>
<%= "<div class=\"notes\" id=\"" + @item.id.to_s + "\">" + m_notes + "</div>" %>
<% else %>
</div>
<% end %>
</li>
<% end %>
</ul>
<table class="next_actions" cellspacing="2" cellpadding="0" border="0">
<%= render_collection_of_partials "not_done", @not_done %>
</table>
<% end %>
</div>
@ -49,9 +27,7 @@
<br />
<label for="new_item_context_id">Context</label><br />
<select name="new_item[context_id]" id="new_item_context_id">
<% for @place in @places %>
<option value="<%= @place.id %>"><%= @place.name.capitalize %></option>
<% end %>
<%= options_from_collection_for_select(@places, "id", "name" ) %>
</select>
<br />
<label for="new_item_due">Due</label><br />

View file

@ -38,17 +38,13 @@
<br />
<label for="new_item_context_id">Context</label><br />
<select name="new_item[context_id]" id="new_item_context_id">
<% for @place in @places %>
<option value="<%= @place.id %>"><%= @place.name.capitalize %></option>
<% end %>
<%= options_from_collection_for_select(@places, "id", "name" ) %>
</select>
<br />
<label for="new_item_project_id">Project</label><br />
<select name="new_item[project_id]" id="new_item_project_id">
<option value="" selected>None</option>
<% for @project in @projects %>
<option value="<%= @project.id %>"><%= @project.name %></option>
<% end %>
<%= options_from_collection_for_select(@projects, "id", "name" ) %>
</select>
<br />
<label for="new_item_due">Due</label><br />

View file

@ -240,10 +240,6 @@ li {
padding: 3px 0px;
}
td {
border: 1px solid #999;
}
.even_row {
background: #fff;
}
@ -252,6 +248,10 @@ td {
background: #EDF3FE;
}
table.list {
border: 1px solid #999;
}
.next_actions td {
border: none;
padding-top: 3px;