From d7e7e9346dedaaab18e3c321bd90c6ef3157a257 Mon Sep 17 00:00:00 2001 From: bsag Date: Sun, 13 Nov 2005 14:25:31 +0000 Subject: [PATCH] Added a button to the bottom the project/show/[name] fields which allows you to mark the project as completed (if it is currently uncompleted) or uncompleted (if it is currently completed). It redirects you to the projects page so that you can add another project to the list. For simplicity and flexibility, the button is visible all the time, so that you can complete a project at any time. Fixes #76. git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@163 a4c988fc-2ded-0310-b66e-134b36920a42 --- tracks/app/controllers/project_controller.rb | 15 ++++++- tracks/app/views/project/_empty.rhtml | 1 + .../app/views/project/_project_listing.rhtml | 2 +- tracks/app/views/project/show.rhtml | 42 ++++++++++++++----- tracks/public/stylesheets/standard.css | 16 ++++++- 5 files changed, 61 insertions(+), 15 deletions(-) create mode 100644 tracks/app/views/project/_empty.rhtml diff --git a/tracks/app/controllers/project_controller.rb b/tracks/app/controllers/project_controller.rb index e480125e..8faef22e 100644 --- a/tracks/app/controllers/project_controller.rb +++ b/tracks/app/controllers/project_controller.rb @@ -61,14 +61,25 @@ class ProjectController < ApplicationController # def toggle_check self.init - + item = check_user_return_item item.toggle!('done') item.completed = Time.now () # For some reason, the before_save in todo.rb stopped working - if item.save + if item.save render :partial => 'project/show_items', :object => item end end + + # Toggles the 'done' status of a project + # + def toggle_project_done + check_user_set_project + + @project.toggle!('done') + if @project.save + redirect_to(:action => "list") + end + end # Delete a project # diff --git a/tracks/app/views/project/_empty.rhtml b/tracks/app/views/project/_empty.rhtml new file mode 100644 index 00000000..f92ff187 --- /dev/null +++ b/tracks/app/views/project/_empty.rhtml @@ -0,0 +1 @@ +

<%= message %>

\ No newline at end of file diff --git a/tracks/app/views/project/_project_listing.rhtml b/tracks/app/views/project/_project_listing.rhtml index 9cc403cc..6f500d9d 100644 --- a/tracks/app/views/project/_project_listing.rhtml +++ b/tracks/app/views/project/_project_listing.rhtml @@ -9,7 +9,7 @@ <%= link_to( sanitize("#{project.name}"), :action => "show", :name => urlize(project.name) ) %><%= " (" + project.count_undone_todos("actions") + ")" %>
- <% if project.done == 1 -%> + <% if project.done? -%> COMPLETED <% else -%> ACTIVE diff --git a/tracks/app/views/project/show.rhtml b/tracks/app/views/project/show.rhtml index 32225085..0e1cf124 100644 --- a/tracks/app/views/project/show.rhtml +++ b/tracks/app/views/project/show.rhtml @@ -7,14 +7,21 @@ <% end -%>
- <% if @project.done == 1 -%> -

This project has been completed

- <%= render :partial => "show_items", :collection => @not_done %> - <% elsif @not_done.empty? -%> -

There are no next actions yet in this project

- <% else -%> - <%= render :partial => "show_items", :collection => @not_done %> + <% if @project.done? -%> +

Project has been marked as completed

<% end -%> + <% if !@project.done? and @not_done.empty? -%> +
+ <%= render :partial => "empty", + :locals => { :message => "There are currently no uncompleted actions in this project"} %> +
+ <% else -%> + + <% end -%> + <%= render :partial => "show_items", :collection => @not_done %>
@@ -23,10 +30,17 @@
<% if @done.empty? %> -

There are no completed next actions yet in this project

- <% else %> - <%= render :partial => "show_items", :collection => @done %> - <% end %> +
+ <%= render :partial => "empty", + :locals => {:message => "There are currently no completed next actions in this project"} %> +
+ <% else -%> + + <% end -%> + <%= render :partial => "show_items", :collection => @done %>
@@ -43,6 +57,12 @@ +<% if @project.done? -%> + <%= button_to "Mark project as uncompleted", {:action => "toggle_project_done", :id => @project.id} %>
+<% else -%> + <%= button_to "Mark project as completed", {:action => "toggle_project_done", :id => @project.id} %>
+<% end -%> + <%= link_to_function( "Add a note", "Element.toggle('new-note'); Form.focusFirstElement('form-new-note');") %>