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');") %>