2010-10-16 16:45:08 +02:00
|
|
|
<% if @saved -%>
|
2010-10-16 17:22:55 +02:00
|
|
|
<% if @go_to_project -%>
|
|
|
|
|
redirect_to ("<%= project_path(@project) -%>")
|
|
|
|
|
<% else -%>
|
2010-11-25 23:29:32 +01:00
|
|
|
TracksPages.hide_errors();
|
2010-10-22 20:46:06 +02:00
|
|
|
hide_empty_message();
|
2010-12-03 17:52:24 +01:00
|
|
|
TracksPages.set_page_badge(<%= @down_count %>);
|
2010-10-16 16:45:08 +02:00
|
|
|
update_active_projects_container();
|
|
|
|
|
add_project();
|
|
|
|
|
clear_form();
|
2010-12-25 16:28:53 +01:00
|
|
|
TracksPages.page_notify('notice', "Created new project '<%= @project.name%>'", 5);
|
2010-10-16 17:22:55 +02:00
|
|
|
<% end -%>
|
2010-10-16 16:45:08 +02:00
|
|
|
<% else -%>
|
2010-11-25 23:29:32 +01:00
|
|
|
TracksPages.show_errors(html_for_error_messages());
|
2010-10-16 16:45:08 +02:00
|
|
|
<% end -%>
|
|
|
|
|
|
2010-12-03 17:52:24 +01:00
|
|
|
/* TODO: make this generic for all pages with lists */
|
2010-10-22 20:46:06 +02:00
|
|
|
function hide_empty_message() {
|
2010-10-16 16:45:08 +02:00
|
|
|
$('projects-empty-nd').hide();
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-03 17:52:24 +01:00
|
|
|
/* TODO: refactor and move this to application.js */
|
2010-10-16 16:45:08 +02:00
|
|
|
function add_project() {
|
2010-10-22 20:46:06 +02:00
|
|
|
$('#list-active-projects').append(html_for_project_listing());
|
2010-10-16 16:45:08 +02:00
|
|
|
}
|
|
|
|
|
|
2010-12-03 17:52:24 +01:00
|
|
|
/* TODO: refactor and move this to application.js */
|
2010-10-16 16:45:08 +02:00
|
|
|
function clear_form() {
|
|
|
|
|
$('#project_form').clearForm();
|
|
|
|
|
$('#project_form input:text:first').focus();
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-03 17:52:24 +01:00
|
|
|
/* TODO: refactor and move this to application.js */
|
2010-10-16 16:45:08 +02:00
|
|
|
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 })) : "" %>";
|
|
|
|
|
}
|