mirror of
https://github.com/TracksApp/tracks.git
synced 2026-01-31 05:05:18 +01:00
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
This commit is contained in:
parent
8a342036a1
commit
d7e7e9346d
5 changed files with 61 additions and 15 deletions
|
|
@ -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
|
||||
#
|
||||
|
|
|
|||
1
tracks/app/views/project/_empty.rhtml
Normal file
1
tracks/app/views/project/_empty.rhtml
Normal file
|
|
@ -0,0 +1 @@
|
|||
<p><%= message %></p>
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
<%= link_to( sanitize("#{project.name}"), :action => "show", :name => urlize(project.name) ) %><%= " (" + project.count_undone_todos("actions") + ")" %>
|
||||
</div>
|
||||
<div class="buttons">
|
||||
<% if project.done == 1 -%>
|
||||
<% if project.done? -%>
|
||||
<span class="grey">COMPLETED</span>
|
||||
<% else -%>
|
||||
<span class="grey">ACTIVE</span>
|
||||
|
|
|
|||
|
|
@ -7,14 +7,21 @@
|
|||
<% end -%>
|
||||
|
||||
<div id="next_actions">
|
||||
<% if @project.done == 1 -%>
|
||||
<p class="info">This project has been completed</p>
|
||||
<%= render :partial => "show_items", :collection => @not_done %>
|
||||
<% elsif @not_done.empty? -%>
|
||||
<p>There are no next actions yet in this project</p>
|
||||
<% else -%>
|
||||
<%= render :partial => "show_items", :collection => @not_done %>
|
||||
<% if @project.done? -%>
|
||||
<p class="completed">Project has been marked as completed</p>
|
||||
<% end -%>
|
||||
<% if !@project.done? and @not_done.empty? -%>
|
||||
<div id="empty-nd" style="display:block;">
|
||||
<%= render :partial => "empty",
|
||||
:locals => { :message => "There are currently no uncompleted actions in this project"} %>
|
||||
</div>
|
||||
<% else -%>
|
||||
<div id="empty-nd" style="display:none;">
|
||||
<%= render :partial => "empty",
|
||||
:locals => { :message => "There are currently no uncompleted actions in this project"} %>
|
||||
</div>
|
||||
<% end -%>
|
||||
<%= render :partial => "show_items", :collection => @not_done %>
|
||||
</div><!-- [end:next_actions] -->
|
||||
</div><!-- [end:contexts] -->
|
||||
|
||||
|
|
@ -23,10 +30,17 @@
|
|||
|
||||
<div id="completed">
|
||||
<% if @done.empty? %>
|
||||
<p>There are no completed next actions yet in this project</p>
|
||||
<% else %>
|
||||
<%= render :partial => "show_items", :collection => @done %>
|
||||
<% end %>
|
||||
<div id="empty-d">
|
||||
<%= render :partial => "empty",
|
||||
:locals => {:message => "There are currently no completed next actions in this project"} %>
|
||||
</div>
|
||||
<% else -%>
|
||||
<div id="empty-nd" style="display:none;">
|
||||
<%= render :partial => "empty",
|
||||
:locals => { :message => "There are currently no uncompleted actions in this project"} %>
|
||||
</div>
|
||||
<% end -%>
|
||||
<%= render :partial => "show_items", :collection => @done %>
|
||||
</div>
|
||||
</div><!-- [end:contexts] -->
|
||||
|
||||
|
|
@ -43,6 +57,12 @@
|
|||
</div>
|
||||
<!-- end div.contexts -->
|
||||
|
||||
<% if @project.done? -%>
|
||||
<%= button_to "Mark project as uncompleted", {:action => "toggle_project_done", :id => @project.id} %><br />
|
||||
<% else -%>
|
||||
<%= button_to "Mark project as completed", {:action => "toggle_project_done", :id => @project.id} %><br />
|
||||
<% end -%>
|
||||
|
||||
<%= link_to_function( "Add a note", "Element.toggle('new-note'); Form.focusFirstElement('form-new-note');") %>
|
||||
|
||||
<div id="new-note" style="display:none;">
|
||||
|
|
|
|||
|
|
@ -277,6 +277,14 @@ a.footer_link:hover {color: #fff; background-color: #cc3334 !important;}
|
|||
color: #ED2E38;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.completed {
|
||||
border: 1px solid #007E00;
|
||||
background-color: #c2ffc2;
|
||||
padding: 5px;
|
||||
color: #007E00;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* Draw attention to some text
|
||||
Same format as traffic lights */
|
||||
|
|
@ -454,7 +462,13 @@ form {
|
|||
border: none;
|
||||
padding: 3px;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
form.button-to {
|
||||
border: none;
|
||||
padding: 0px;
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
label {
|
||||
font-weight: bold;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue