Add a bold state to emphasize the project status on the project detail page.

The bold state changes once the ajax operation is complete.
Project status changes now also show a flash notice when the ajax operation completes.
Add a selenium test to confirm this behavior.
Fixed a bug where hiding a project would make deferred items hidden. Now we leave them deferred.
Added a little breathing room between the project status options.



git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@395 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
lukemelia 2007-01-10 07:01:26 +00:00
parent f73401a850
commit ead9a4cfe9
7 changed files with 38 additions and 4 deletions

View file

@ -79,6 +79,8 @@ class ProjectController < ApplicationController
@project_not_done_counts[@project.id] = @project.reload().not_done_todo_count(:include_project_hidden_todos => true)
end
render
elsif params['update_status']
render :action => 'update_status'
else
render :text => success_text || 'Success'
end

View file

@ -47,7 +47,7 @@ class Project < ActiveRecord::Base
def hide_todos
todos.each do |t|
t.hide! unless t.completed?
t.hide! unless t.completed? || t.deferred?
t.save
end
end

View file

@ -13,7 +13,7 @@
<td width="150"><label for="project_done">Project status:</label></td>
<td width="300">
<% ['active', 'hidden', 'completed'].each do | state | %>
<%= radio_button(:project, 'state', state, {:class => 'project-done'}) %> <%= state.titlecase %>
<%= radio_button(:project, 'state', state) %> <%= state.titlecase %>
<% end %>
</td>
</tr>

View file

@ -35,8 +35,10 @@
<h2>Status</h2>
<div>
<% ['active', 'hidden', 'completed'].each do | state | %>
<% js = "new Ajax.Request('#{ url_for :controller => 'project', :action => 'update', :id => @project.id, :wants_render => false, 'project[state]' => state }', {asynchronous:true, evalScripts:true});" %>
<%= radio_button(:project, 'state', state, {:class => 'project-done', :onclick => js}) %> <%= state.titlecase %>
<% js = "new Ajax.Request('#{ url_for :controller => 'project', :action => 'update', :id => @project.id, :wants_render => false, :update_status => true, 'project[state]' => state }', {asynchronous:true, evalScripts:true});"
span_class = @project.current_state.to_s == state ? 'active_state' : 'inactive_state'
%>
<span class="<%= state %>"><%= radio_button(:project, 'state', state, {:onclick => js}) %> <span class="<%= span_class %>"><%= state.titlecase %></span></span>
<% end %>
</div>
</div>

View file

@ -0,0 +1,10 @@
page.select('#project_status .active span').each do |element|
element.className = @project.current_state == :active ? 'active_state' : 'inactive_state'
end
page.select('#project_status .hidden span').each do |element|
element.className = @project.current_state == :hidden ? 'active_state' : 'inactive_state'
end
page.select('#project_status .completed span').each do |element|
element.className = @project.current_state == :completed ? 'active_state' : 'inactive_state'
end
page.notify :notice, "Set project status to #{@project.current_state}", 5.0

View file

@ -308,6 +308,12 @@ div.add_note_link {
div#project_status > div {
padding: 10px;
}
#project_status span {
margin-right:5px;
}
#project_status .active_state {
font-weight:bold;
}
a.footer_link {color: #cc3334; font-style: normal;}
a.footer_link:hover {color: #fff; background-color: #cc3334 !important;}

View file

@ -0,0 +1,14 @@
setup :fixtures => :all
include_partial 'login/login', :username => 'admin', :password => 'abracadabra'
open '/project/Build_a_working_time_machine'
assert_checked 'project_state_active', 'ignored'
assert_attribute 'css=#project_status .active span', 'class', 'active_state'
assert_attribute 'css=#project_status .hidden span', 'class', 'inactive_state'
assert_text 'badge_count', '2'
click 'project_state_hidden'
wait_for_attribute 'css=#project_status .active span', 'class', 'inactive_state'
wait_for_attribute 'css=#project_status .hidden span', 'class', 'active_state'
assert_text 'badge_count', '2'
open '/project/Build_a_working_time_machine'
assert_text 'badge_count', '2'
assert_checked 'project_state_hidden', 'ignored'