mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-19 16:50:12 +01:00
migrate project creation
This commit is contained in:
parent
36e63a4ad9
commit
4413cabbba
12 changed files with 152 additions and 94 deletions
|
|
@ -10,6 +10,7 @@ class ProjectsController < ApplicationController
|
||||||
def index
|
def index
|
||||||
@source_view = params['_source_view'] || 'project_list'
|
@source_view = params['_source_view'] || 'project_list'
|
||||||
@projects = current_user.projects
|
@projects = current_user.projects
|
||||||
|
@new_project = current_user.projects.build
|
||||||
if params[:projects_and_actions]
|
if params[:projects_and_actions]
|
||||||
projects_and_actions
|
projects_and_actions
|
||||||
else
|
else
|
||||||
|
|
@ -73,6 +74,7 @@ class ProjectsController < ApplicationController
|
||||||
render_failure "Expected post format is valid xml like so: <request><project><name>project name</name></project></request>."
|
render_failure "Expected post format is valid xml like so: <request><project><name>project name</name></project></request>."
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@project = current_user.projects.build
|
@project = current_user.projects.build
|
||||||
params_are_invalid = true
|
params_are_invalid = true
|
||||||
if (params['project'] || (params['request'] && params['request']['project']))
|
if (params['project'] || (params['request'] && params['request']['project']))
|
||||||
|
|
@ -81,9 +83,11 @@ class ProjectsController < ApplicationController
|
||||||
end
|
end
|
||||||
@go_to_project = params['go_to_project']
|
@go_to_project = params['go_to_project']
|
||||||
@saved = @project.save
|
@saved = @project.save
|
||||||
|
|
||||||
@project_not_done_counts = { @project.id => 0 }
|
@project_not_done_counts = { @project.id => 0 }
|
||||||
@active_projects_count = current_user.projects.active.count
|
@active_projects_count = current_user.projects.active.count
|
||||||
@contexts = current_user.contexts
|
@contexts = current_user.contexts
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js { @down_count = current_user.projects.size }
|
format.js { @down_count = current_user.projects.size }
|
||||||
format.xml do
|
format.xml do
|
||||||
|
|
@ -95,6 +99,7 @@ class ProjectsController < ApplicationController
|
||||||
head :created, :location => project_url(@project), :text => @project.id
|
head :created, :location => project_url(@project), :text => @project.id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
format.html {redirect_to :action => 'index'}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
40
app/views/projects/_new_project_form.rhtml
Normal file
40
app/views/projects/_new_project_form.rhtml
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
<div id="project_new_project_container">
|
||||||
|
|
||||||
|
<div id="toggle_project_link" class="hide_form">
|
||||||
|
<a id="toggle_project_new" href="#" title="<%= t('projects.hide_new_project_form') %>" accesskey="n">« <%= t('projects.hide_form') %></a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="project_new" class="project_new" style="display:block">
|
||||||
|
<% form_for(@new_project, :html => {:id => 'project_form',:name=>'project',:class => "inline-form", :method => :post }) do -%>
|
||||||
|
<div id="error_status"><%= error_messages_for("project") %></div>
|
||||||
|
|
||||||
|
<label for="project_name"><%= Project.human_attribute_name(:name) %>:</label><br />
|
||||||
|
<%= text_field 'project', 'name', "tabindex" => 1 %><br />
|
||||||
|
|
||||||
|
<label for="project_description"><%= Project.human_attribute_name(:description) %> (<%= t('common.optional') %>):</label><br />
|
||||||
|
<%= text_area 'project', 'description', "cols" => 30, "rows" => 4, "tabindex" => 2 %><br />
|
||||||
|
|
||||||
|
<% unless @contexts.empty? -%>
|
||||||
|
<label for="default_context_name"><%= Project.human_attribute_name(:default_context_name) %> (<%= t('common.optional') %>):</label><br />
|
||||||
|
<%= text_field_tag("project[default_context_name]", @new_project.default_context.name, :tabindex => 3) %>
|
||||||
|
<br />
|
||||||
|
<% end -%>
|
||||||
|
|
||||||
|
<label for="default_tags"><%= Project.human_attribute_name(:default_tags) %> (<%= t('common.optional') %>):</label><br />
|
||||||
|
<%= text_field_tag("project[default_tags]", @new_project.default_tags, :tabindex => 4) %>
|
||||||
|
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
<div class="submit_box">
|
||||||
|
<div class="widgets">
|
||||||
|
<button type="submit" class="positive" id="project_new_project_submit">
|
||||||
|
<%= image_tag("accept.png", :alt => "") + t('projects.add_project') %>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<input id="go_to_project" type="checkbox" tabindex="5" name="go_to_project"/><label for="go_to_project"><%= t('projects.to_new_project_page') %></label><br />
|
||||||
|
|
||||||
|
<% end -%>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
48
app/views/projects/create.js.erb
Normal file
48
app/views/projects/create.js.erb
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
<% if @saved -%>
|
||||||
|
<% if @go_to_project %>
|
||||||
|
redirect_to ("<%= project_path(@project) %>")
|
||||||
|
<% end %>
|
||||||
|
hide_errors();
|
||||||
|
hide_empty_msg();
|
||||||
|
set_page_badge(<%= @down_count %>);
|
||||||
|
update_active_projects_container();
|
||||||
|
add_project();
|
||||||
|
clear_form();
|
||||||
|
<% else -%>
|
||||||
|
show_errors();
|
||||||
|
<% end -%>
|
||||||
|
|
||||||
|
function show_errors() {
|
||||||
|
$('div#error_status').html(html_for_error_messages());
|
||||||
|
$('div#error_status').show();
|
||||||
|
}
|
||||||
|
|
||||||
|
function hide_errors() {
|
||||||
|
$('div#error_status').hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
function hide_empty_msg() {
|
||||||
|
$('projects-empty-nd').hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
function add_project() {
|
||||||
|
$('#list-active-projects').append(html_for_project_listing);
|
||||||
|
}
|
||||||
|
|
||||||
|
function clear_form() {
|
||||||
|
$('#project_form').clearForm();
|
||||||
|
$('#project_form input:text:first').focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
function update_active_projects_container() {
|
||||||
|
ProjectListPage.set_state_container_visibility('active', true);
|
||||||
|
ProjectListPage.update_state_count('active', <%=@active_projects_count%>);
|
||||||
|
}
|
||||||
|
|
||||||
|
function html_for_error_messages() {
|
||||||
|
return "<%= escape_javascript(error_messages_for('project')) %>";
|
||||||
|
}
|
||||||
|
|
||||||
|
function html_for_project_listing() {
|
||||||
|
return "<%= @saved ? escape_javascript(render(:partial => 'project_listing', :locals => { :project_listing => @project })) : "" %>";
|
||||||
|
}
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
if @saved and @go_to_project
|
|
||||||
page.redirect_to project_path(@project)
|
|
||||||
elsif @saved
|
|
||||||
page.hide 'status'
|
|
||||||
page['badge_count'].replace_html @down_count
|
|
||||||
page.hide 'projects-empty-nd'
|
|
||||||
page.show 'list-active-projects-container'
|
|
||||||
page.replace_html "active-projects-count", @active_projects_count
|
|
||||||
page.insert_html :bottom, "list-active-projects", :partial => 'project_listing', :locals => { :project_listing => @project }
|
|
||||||
page.sortable "list-active-projects", get_listing_sortable_options('list-active-projects')
|
|
||||||
page << "$('#project-form').clearForm();"
|
|
||||||
page << "$('#project-form input:text:first').focus();"
|
|
||||||
else
|
|
||||||
page.show 'status'
|
|
||||||
page.replace_html 'status', "#{error_messages_for('project')}"
|
|
||||||
end
|
|
||||||
page.hide "busy"
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
remove_deleted_project();
|
remove_deleted_project();
|
||||||
ProjectListPage.update_state_count(<%=@active_projects_count%>, <%=@hidden_projects_count%>, <%=@completed_projects_count%>)
|
ProjectListPage.update_all_states_count(<%=@active_projects_count%>, <%=@hidden_projects_count%>, <%=@completed_projects_count%>)
|
||||||
ProjectListPage.show_or_hide_state_container(<%= @show_active_projects %>, <%= @show_hidden_projects %>, <%= @show_completed_projects %>);
|
ProjectListPage.show_or_hide_all_state_containers(<%= @show_active_projects %>, <%= @show_hidden_projects %>, <%= @show_completed_projects %>);
|
||||||
page_notify('notice', "Deleted project '#{@project.name}'", 5);
|
page_notify('notice', "Deleted project '<%= @project.name%>'", 5);
|
||||||
set_page_badge(<%=@down_count%>);
|
set_page_badge(<%=@down_count%>);
|
||||||
|
|
||||||
function remove_deleted_project() {
|
function remove_deleted_project() {
|
||||||
|
|
|
||||||
|
|
@ -7,60 +7,8 @@
|
||||||
<%= render :partial => 'project_state_group', :object => @completed_projects, :locals => { :state => 'completed'} %>
|
<%= render :partial => 'project_state_group', :object => @completed_projects, :locals => { :state => 'completed'} %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% @project = @new_project -%>
|
|
||||||
<div id="input_box">
|
<div id="input_box">
|
||||||
<div id="project_new_project_filler">
|
<div id="project_new_project_filler">
|
||||||
<div id="project_new_project_container">
|
<%= render :partial => 'new_project_form' %>
|
||||||
|
|
||||||
<div id="toggle_project_link" class="hide_form">
|
|
||||||
<a id="toggle_project_new" href="#" title="<%= t('projects.hide_new_project_form') %>" accesskey="n">« <%= t('projects.hide_form') %></a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="project_new" class="project_new" style="display:block">
|
|
||||||
<% form_remote_tag(:url => projects_path, :method => :post,
|
|
||||||
:html=> { :id=>'project-form', :name=>'project', :class => 'inline-form'},
|
|
||||||
:before => "$('#project_new_project_submit').block({message:null})",
|
|
||||||
:complete => "$('#project_new_project_submit').unblock()") do -%>
|
|
||||||
|
|
||||||
<div id="status"><%= error_messages_for('project') %></div>
|
|
||||||
|
|
||||||
<label for="project_name"><%= Project.human_attribute_name(:name) %>:</label><br />
|
|
||||||
<%= text_field 'project', 'name', "tabindex" => 1 %><br />
|
|
||||||
|
|
||||||
<label for="project_description"><%= Project.human_attribute_name(:description) %> (<%= t('common.optional') %>):</label><br />
|
|
||||||
<%= text_area 'project', 'description', "cols" => 30, "rows" => 4, "tabindex" => 2 %><br />
|
|
||||||
|
|
||||||
<% unless @contexts.empty? -%>
|
|
||||||
<label for="default_context_name"><%= Project.human_attribute_name(:default_context_name) %> (<%= t('common.optional') %>):</label><br />
|
|
||||||
<%= text_field_tag("project[default_context_name]", @project.default_context.name, :tabindex => 3) %>
|
|
||||||
<br />
|
|
||||||
<% end -%>
|
|
||||||
|
|
||||||
<label for="default_tags"><%= Project.human_attribute_name(:default_tags) %> (<%= t('common.optional') %>):</label><br />
|
|
||||||
<%= text_field_tag("project[default_tags]", @project.default_tags, :tabindex => 4) %>
|
|
||||||
<br />
|
|
||||||
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
<div class="submit_box">
|
|
||||||
<div class="widgets">
|
|
||||||
<button type="submit" class="positive" id="project_new_project_submit">
|
|
||||||
<%= image_tag("accept.png", :alt => "") + t('projects.add_project') %>
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<br/><br/>
|
|
||||||
<input id="go_to_project" type="checkbox" tabindex="5" name="go_to_project"/><label for="go_to_project"><%= t('projects.to_new_project_page') %></label><br />
|
|
||||||
|
|
||||||
<% end -%>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
window.onload=function(){
|
|
||||||
Nifty("div#project_new_project_container","normal");
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,8 @@
|
||||||
replace_project_form_with_updated_project();
|
replace_project_form_with_updated_project();
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
||||||
update_sortable();
|
ProjectListPage.update_all_states_count(<%=@active_projects_count%>, <%=@hidden_projects_count%>, <%=@completed_projects_count%>)
|
||||||
ProjectListPage.update_state_count(<%=@active_projects_count%>, <%=@hidden_projects_count%>, <%=@completed_projects_count%>)
|
ProjectListPage.show_or_hide_all_state_containers(<%= @show_active_projects %>, <%= @show_hidden_projects %>, <%= @show_completed_projects %>);
|
||||||
ProjectListPage.show_or_hide_state_container(<%= @show_active_projects %>, <%= @show_hidden_projects %>, <%= @show_completed_projects %>);
|
|
||||||
|
|
||||||
<% else # assume source_view :project %>
|
<% else # assume source_view :project %>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ Feature: Manage the list of projects
|
||||||
When I drag the project "manage me" below "upgrade jquery"
|
When I drag the project "manage me" below "upgrade jquery"
|
||||||
Then the project "upgrade jquery" should be above the project "manage me"
|
Then the project "upgrade jquery" should be above the project "manage me"
|
||||||
|
|
||||||
@selenium, @wip
|
@selenium
|
||||||
Scenario: Hiding and unhiding the new project form
|
Scenario: Hiding and unhiding the new project form
|
||||||
When I go to the projects page
|
When I go to the projects page
|
||||||
Then the new project form should be visible
|
Then the new project form should be visible
|
||||||
|
|
@ -65,7 +65,14 @@ Feature: Manage the list of projects
|
||||||
When I follow "Create a new project »"
|
When I follow "Create a new project »"
|
||||||
Then the new project form should be visible
|
Then the new project form should be visible
|
||||||
|
|
||||||
|
@selenium, @wip
|
||||||
Scenario: Adding a new project
|
Scenario: Adding a new project
|
||||||
|
When I go to the projects page
|
||||||
|
And I submit a new project with name "finish cucumber tests for project"
|
||||||
|
Then I should see "finish cucumber tests for project"
|
||||||
|
And the badge should show 4
|
||||||
|
And the project list badge for "active" projects should show 4
|
||||||
|
|
||||||
Scenario: Adding a new project and take me to the project page
|
Scenario: Adding a new project and take me to the project page
|
||||||
Scenario: Sorting the project alphabetically
|
Scenario: Sorting the project alphabetically
|
||||||
Scenario: Sorting the project by number of task
|
Scenario: Sorting the project by number of task
|
||||||
|
|
@ -26,6 +26,11 @@ When /^I drag the project "([^"]*)" below "([^"]*)"$/ do |project_drag, project_
|
||||||
selenium.mouse_up_at(drop_project_container_xpath,coord_string)
|
selenium.mouse_up_at(drop_project_container_xpath,coord_string)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
When /^I submit a new project with name "([^"]*)"$/ do |project_name|
|
||||||
|
fill_in "project[name]", :with => project_name
|
||||||
|
submit_new_project_form
|
||||||
|
end
|
||||||
|
|
||||||
Then /^the project "([^"]*)" should be above the project "([^"]*)"$/ do |project_high, project_low|
|
Then /^the project "([^"]*)" should be above the project "([^"]*)"$/ do |project_high, project_low|
|
||||||
high_id = @current_user.projects.find_by_name(project_high).id
|
high_id = @current_user.projects.find_by_name(project_high).id
|
||||||
low_id = @current_user.projects.find_by_name(project_low).id
|
low_id = @current_user.projects.find_by_name(project_low).id
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,18 @@ if ENV["RAILS_ENV"] == "selenium"
|
||||||
puts "Configuring to use Selenium with Webrat for Cucumber stories"
|
puts "Configuring to use Selenium with Webrat for Cucumber stories"
|
||||||
Webrat.configure do |config|
|
Webrat.configure do |config|
|
||||||
config.mode = :selenium
|
config.mode = :selenium
|
||||||
|
|
||||||
config.application_environment = :selenium
|
config.application_environment = :selenium
|
||||||
|
# use only if you run a separate rails test server instance and do not
|
||||||
|
# want webrat to start one for you
|
||||||
|
# config.application_port = 3001
|
||||||
|
|
||||||
config.selenium_browser_startup_timeout = 30
|
config.selenium_browser_startup_timeout = 30
|
||||||
# use only if you run a separate selenium server instance and do not
|
# use only if you run a separate selenium server instance and do not
|
||||||
# want webrat to start one for you
|
# want webrat to start one for you
|
||||||
# config.selenium_server_address = "localhost"
|
# config.selenium_server_address = "localhost"
|
||||||
|
# config.selenium_server_port = "4444"
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Cucumber::Rails::World.use_transactional_fixtures = false
|
Cucumber::Rails::World.use_transactional_fixtures = false
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,9 @@ module TracksStepHelper
|
||||||
selenium.click("xpath=//form[@id='context-form']//button[@id='context_new_submit']", :wait_for => :ajax, :javascript_framework => :jquery)
|
selenium.click("xpath=//form[@id='context-form']//button[@id='context_new_submit']", :wait_for => :ajax, :javascript_framework => :jquery)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def submit_new_project_form
|
||||||
|
selenium.click("xpath=//form[@id='project_form']//button[@id='project_new_project_submit']", :wait_for => :ajax, :javascript_framework => :jquery)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
World(TracksStepHelper)
|
World(TracksStepHelper)
|
||||||
|
|
@ -45,23 +45,20 @@ var TracksForm = {
|
||||||
}
|
}
|
||||||
|
|
||||||
var ProjectListPage = {
|
var ProjectListPage = {
|
||||||
update_state_count: function (active, hidden, completed) {
|
update_state_count: function(state, count) {
|
||||||
$('#active-projects-count').html(active);
|
$('#'+state+'-projects-count').html(count);
|
||||||
$('#hidden-projects-count').html(hidden);
|
|
||||||
$('#completed-projects-count').html(completed);
|
|
||||||
},
|
},
|
||||||
show_or_hide_state_container: function (show_active, show_hidden, show_completed) {
|
update_all_states_count: function (active_count, hidden_count, completed_count) {
|
||||||
$(["active", "hidden", "completed"]).each(function() {
|
$(["active", "hidden", "completed"]).each(function() { ProjectListPage.update_state_count(this, eval(this+'_count')); });
|
||||||
container = $('#list-'+this+'-projects-container');
|
},
|
||||||
set_state_container_visibility(container, eval('show_'+this));
|
show_or_hide_all_state_containers: function (show_active, show_hidden, show_completed) {
|
||||||
});
|
$(["active", "hidden", "completed"]).each(function() { ProjectListPage.set_state_container_visibility(this, eval('show_'+this)); });
|
||||||
|
},
|
||||||
function set_state_container_visibility (container, set_visible) {
|
set_state_container_visibility: function (state, set_visible) {
|
||||||
if (set_visible) {
|
if (set_visible) {
|
||||||
container.slideDown("fast");
|
$('#list-'+state+'-projects-container').slideDown("fast");
|
||||||
} else {
|
} else {
|
||||||
container.slideUp("fast");
|
$('#list-'+state+'-projects-container').slideUp("fast");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -147,6 +144,10 @@ todoItems = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function redirect_to(path) {
|
||||||
|
$(window.location).attr('href', path);
|
||||||
|
}
|
||||||
|
|
||||||
function setup_container_toggles(){
|
function setup_container_toggles(){
|
||||||
// bind handlers
|
// bind handlers
|
||||||
$('.container_toggle').click(function(evt){
|
$('.container_toggle').click(function(evt){
|
||||||
|
|
@ -373,6 +374,7 @@ $(document).ready(function() {
|
||||||
Nifty("div#feedicons-project","normal");
|
Nifty("div#feedicons-project","normal");
|
||||||
Nifty("div#feedicons-context","normal");
|
Nifty("div#feedicons-context","normal");
|
||||||
Nifty("div#todo_new_action_container","normal");
|
Nifty("div#todo_new_action_container","normal");
|
||||||
|
Nifty("div#project_new_project_container","normal");
|
||||||
|
|
||||||
/* Moved from standard.html.erb layout */
|
/* Moved from standard.html.erb layout */
|
||||||
$('ul.sf-menu').superfish({
|
$('ul.sf-menu').superfish({
|
||||||
|
|
@ -604,6 +606,17 @@ $(document).ready(function() {
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$("form#project_form button.positive").live('click', function (ev) {
|
||||||
|
$('form.#project_form').ajaxSubmit({
|
||||||
|
type: 'POST',
|
||||||
|
async: true,
|
||||||
|
buttons_dom_elem: $(this),
|
||||||
|
beforeSend: function() {this.buttons_dom_elem.block({message: null});},
|
||||||
|
complete: function() {this.buttons_dom_elem.unblock();}
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
$('#toggle_project_new').click(function(evt){
|
$('#toggle_project_new').click(function(evt){
|
||||||
TracksForm.toggle('toggle_project_new', 'project_new', 'project-form',
|
TracksForm.toggle('toggle_project_new', 'project_new', 'project-form',
|
||||||
'« Hide form', 'Hide new project form',
|
'« Hide form', 'Hide new project form',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue