diff --git a/app/views/projects/_project_listing.rhtml b/app/views/projects/_project_listing.rhtml
index 3cf72ae5..d185dc63 100644
--- a/app/views/projects/_project_listing.rhtml
+++ b/app/views/projects/_project_listing.rhtml
@@ -1,28 +1,27 @@
-<% project = project_listing
+<%
+project = project_listing
suppress_drag_handle ||= false
suppress_edit_button ||= false
-%>
" class="list">
-
+
+
<% unless suppress_drag_handle -%>
<%= t('common.drag_handle') %>
<% end -%>
+
<%= link_to_project( project ) %><%= " (" + count_undone_todos_and_notes_phrase(project,"actions") + ")" %>
+
<%= project.current_state.to_s.upcase %>
-
<%= link_to_delete_project(project, image_tag( "blank.png", :title => t('projects.delete_project'), :class=>"delete_item")) %>
-
- <% unless suppress_edit_button -%>
- <%= link_to_edit_project(project, image_tag( "blank.png", :title => t('projects.edit_project_title'), :class=>"edit_item")) %>
- <% end -%>
+ <%= suppress_edit_button ? "" : link_to_edit_project(project, image_tag( "blank.png", :title => t('projects.edit_project_title'), :class=>"edit_item")) %>
-
-
+
diff --git a/app/views/projects/edit.js.erb b/app/views/projects/edit.js.erb
index 6c4d3875..61f1886e 100644
--- a/app/views/projects/edit.js.erb
+++ b/app/views/projects/edit.js.erb
@@ -1,5 +1,9 @@
newHtml = "<%= escape_javascript(render(:partial => 'project_form', :locals => { :project_form => @project })) %>"
-$('div#<%=dom_id(@project, 'edit')%>').html(newHtml);
-$('div#<%=dom_id(@project)%>').hide();
-$('div#<%=dom_id(@project, 'edit')%>').show(500);
-$('input.project-name').focus();
+
+$('div#<%=dom_id(@project)%>').fadeOut(250, function() {
+ $('div#<%=dom_id(@project, 'edit')%>').html(newHtml);
+ $('div#<%=dom_id(@project, 'edit')%>').fadeIn(500);
+ $('input.project-name').focus();
+});
+
+
diff --git a/app/views/projects/update.js.erb b/app/views/projects/update.js.erb
index fb4c7aeb..647eb125 100644
--- a/app/views/projects/update.js.erb
+++ b/app/views/projects/update.js.erb
@@ -8,7 +8,7 @@
remove_project();
add_project();
<% else -%>
- replace_project();
+ replace_project_form_with_updated_project();
<% end -%>
update_sortable();
@@ -59,12 +59,12 @@ function update_sidebar() {
}
function update_sortable() {
- <%#* page.sortable "list-#{@project.state}-projects", get_listing_sortable_options("list-#{@project.state}-projects")%>
+ <%#* page.sortable "list-#{@project.state}-projects", get_listing_sortable_options("list-#{@project.state}-projects")-%>
console.log("Pending: update_sortable() on update project");
}
-function replace_project() {
- $('#<%=dom_id(@project, 'container')%>').fadeOut(500, function() {
+function replace_project_form_with_updated_project() {
+ $('#<%=dom_id(@project, 'container')%>').fadeOut(250, function() {
$('#<%=dom_id(@project, 'container')%>').html(html_for_project_listing());
$('#<%=dom_id(@project, 'container')%>').fadeIn(500);
});
diff --git a/features/edit_a_project.feature b/features/edit_a_project.feature
index 6d2710fe..f28a5254 100644
--- a/features/edit_a_project.feature
+++ b/features/edit_a_project.feature
@@ -8,8 +8,8 @@ Feature: Edit a project
Given the following user record
| login | password | is_admin |
| testuser | secret | false |
- And I have logged in as "testuser" with password "secret"
And there exists a project "manage me" for user "testuser"
+ And I have logged in as "testuser" with password "secret"
@selenium
Scenario: I can describe the project using markup
diff --git a/features/manage_list_of_projects.feature b/features/manage_list_of_projects.feature
index e39cb6b7..bdf4fdce 100644
--- a/features/manage_list_of_projects.feature
+++ b/features/manage_list_of_projects.feature
@@ -8,10 +8,10 @@ Feature: Manage the list of projects
Given the following user record
| login | password | is_admin |
| testuser | secret | false |
- And I have logged in as "testuser" with password "secret"
And there exists a project "manage me" for user "testuser"
And there exists a project "upgrade jquery" for user "testuser"
And there exists a project "a project name starting with a" for user "testuser"
+ And I have logged in as "testuser" with password "secret"
Scenario: The list of project contain all projects
When I go to the projects page
@@ -38,13 +38,16 @@ Feature: Manage the list of projects
And the badge should show 2
And the project list badge for "active" projects should show 2
- @selenium
+ @selenium, @wip
Scenario: Changing project state will move project to other state list
When I go to the projects page
Then the project "manage me" should be in state list "active"
+ And the project list badge for "active" projects should show 3
When I edit the project state of "manage me" to "hidden"
Then the project "manage me" should not be in state list "active"
And the project "manage me" should be in state list "hidden"
+ And the project list badge for "active" projects should show 2
+ And the project list badge for "hidden" projects should show 1
Scenario: Dragging a project to change list order of projects
Scenario: Adding a new project
diff --git a/features/step_definitions/project_list_steps.rb b/features/step_definitions/project_list_steps.rb
index 4390112f..7113e7c8 100644
--- a/features/step_definitions/project_list_steps.rb
+++ b/features/step_definitions/project_list_steps.rb
@@ -9,6 +9,20 @@ When /^I delete project "([^"]*)"$/ do |project_name|
end
end
+Then /^the project "([^"]*)" should not be in state list "([^"]*)"$/ do |project_name, state_name|
+ project = @current_user.projects.find_by_name(project_name)
+ project.should_not be_nil
+ xpath = "//div[@id='list-#{state_name}-projects-container']//div[@id='project_#{project.id}']"
+ response.should_not have_xpath(xpath)
+end
+
+Then /^the project "([^"]*)" should be in state list "([^"]*)"$/ do |project_name, state_name|
+ project = @current_user.projects.find_by_name(project_name)
+ project.should_not be_nil
+ xpath = "//div[@id='list-#{state_name}-projects-container']//div[@id='project_#{project.id}']"
+ response.should have_xpath(xpath)
+end
+
Then /^the project list badge for "([^"]*)" projects should show (\d+)$/ do |state_name, count|
selenium.get_text("css=span##{state_name}-projects-count").should == count
end
\ No newline at end of file
diff --git a/features/step_definitions/project_steps.rb b/features/step_definitions/project_steps.rb
index d380bc1a..a5ec220c 100644
--- a/features/step_definitions/project_steps.rb
+++ b/features/step_definitions/project_steps.rb
@@ -42,8 +42,8 @@ end
When /^I edit the project name to "([^\"]*)"$/ do |new_title|
click_link "link_edit_project_#{@project.id}"
-
- # no need to wait for the form because the AJAX loading should not be async!
+ selenium.wait_for_element("xpath=//div[@id='edit_project_#{@project.id}']/form//button[@id='submit_project_#{@project.id}']")
+
fill_in "project[name]", :with => new_title
# changed to make sure selenium waits until the saving has a result either
@@ -61,6 +61,28 @@ When /^I edit the project name of "([^"]*)" to "([^"]*)"$/ do |project_current_n
When "I edit the project name to \"#{project_new_name}\""
end
+
+When /^I edit the project state of "([^"]*)" to "([^"]*)"$/ do |project_name, state_name|
+ project = @current_user.projects.find_by_name(project_name)
+ project.should_not be_nil
+
+ click_link "link_edit_project_#{project.id}"
+ selenium.wait_for_element("xpath=//div[@id='edit_project_#{project.id}']/form//button[@id='submit_project_#{project.id}']")
+
+ choose "project_state_#{state_name}"
+
+ # changed to make sure selenium waits until the saving has a result either
+ # positive or negative. Was: :element=>"flash", :text=>"Project saved"
+ # we may need to change it back if you really need a positive outcome, i.e.
+ # this step needs to fail if the project was not saved successfully
+ selenium.click "submit_project_#{project.id}",
+ :wait_for => :text,
+ :text => /(Project saved|1 error prohibited this project from being saved)/
+
+ selenium.wait_for_element("list-#{state_name}-projects-container")
+
+end
+
Then /^I should see the bold text "([^\"]*)" in the project description$/ do |bold|
xpath="//div[@class='project_description']/p/strong"
diff --git a/public/javascripts/application.js b/public/javascripts/application.js
index 1ccf4919..8c402059 100644
--- a/public/javascripts/application.js
+++ b/public/javascripts/application.js
@@ -312,21 +312,6 @@ function enable_rich_interaction(){
field_touched = false;
$('h2#project_name').editable(save_project_name, {style: 'padding:0px', submit: "OK"});
-
- /* set behavior for edit project settings link */
- $("a.project_edit_settings").live('click', function (ev) {
- $.ajax({
- url: this.href,
- async: true,
- project_dom_id: 'project_'+this.id,
- dataType: 'script',
- beforeSend: function() {$(this.project_dom_id).block({message: null});},
- complete:function() {$(this.project_dom_id).unblock(); enable_rich_interaction();}
- });
- return false;
- });
-
- $("form.edit-project-form button.positive").live('click', function (ev) { $('form.edit-project-form').ajaxSubmit({type: 'POST', async: false}); return false; });
}
/* Auto-refresh */
@@ -475,11 +460,12 @@ $(document).ready(function() {
}
});
- $('.edit-form a.negative').live('click', function(){
- $(this).parents('.container').find('.item-show').show();
- $(this).parents('.container').find('.project').show();
- $(this).parents('.edit-form').hide();
- });
+ /* for edit project form and edit todo form */
+ $('.edit-form a.negative').live('click', function(){
+ $(this).parents('.edit-form').fadeOut(200, function () {
+ $(this).parents('.list').find('.project').fadeIn(500);
+ $(this).parents('.container').find('.item-show').fadeIn(500);
+ })});
/* add behavior to clear the date both buttons for show_from and due */
$(".date_clear").live('click', function() {
@@ -588,19 +574,36 @@ $(document).ready(function() {
}
});
+ /* set behavior for edit project settings link in projects list page and project page */
+ $("a.project_edit_settings").live('click', function (ev) {
+ $.ajax({
+ url: this.href,
+ async: true,
+ project_dom_elem: $(this).parent().parent(),
+ dataType: 'script',
+ beforeSend: function() {this.project_dom_elem.block({message: null});},
+ complete:function() {this.project_dom_elem.unblock(); enable_rich_interaction();}
+ });
+ return false;
+ });
+
+ $("form.edit-project-form button.positive").live('click', function (ev) {
+ $('form.edit-project-form').ajaxSubmit({
+ type: 'POST',
+ async: true,
+ buttons_dom_elem: $(this),
+ beforeSend: function() {
+ this.buttons_dom_elem.block({message: null});}
+ });
+ return false;
+ });
+
$('#toggle_project_new').click(function(evt){
TracksForm.toggle('toggle_project_new', 'project_new', 'project-form',
'« Hide form', 'Hide new project form',
'Create a new project »', 'Add a project');
});
- $(".project-list .edit-form a.negative").live('click', function(evt){
- evt.preventDefault();
- $(this).parents('.list').find('.project').show();
- $(this).parents('.edit-form').hide();
- $(this).parents('.edit-form').find('form').clearForm();
- });
-
$(".add_note_link a").live('click', function(){
$('#new-note').show();
$('#new-note form').clearForm();