2010-10-06 17:50:49 +02:00
|
|
|
<% if @saved -%>
|
2010-10-07 23:24:50 +02:00
|
|
|
|
2010-10-06 17:50:49 +02:00
|
|
|
pageNotify('notice', '<%=t('projects.project_saved_status')%>', 5);
|
2010-10-07 23:24:50 +02:00
|
|
|
|
2010-10-06 17:50:49 +02:00
|
|
|
<% if source_view_is :project_list -%>
|
2010-10-07 23:24:50 +02:00
|
|
|
|
2010-10-06 17:50:49 +02:00
|
|
|
<% if @state_changed -%>
|
2010-10-15 11:49:34 +02:00
|
|
|
remove_and_re_add_project();
|
2010-10-07 23:24:50 +02:00
|
|
|
<% else -%>
|
2010-10-08 21:07:17 +02:00
|
|
|
replace_project_form_with_updated_project();
|
2010-10-06 17:50:49 +02:00
|
|
|
<% end -%>
|
2010-10-07 23:24:50 +02:00
|
|
|
|
|
|
|
|
update_sortable();
|
|
|
|
|
ProjectListPage.update_state_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 %>);
|
|
|
|
|
|
|
|
|
|
<% else # assume source_view :project %>
|
|
|
|
|
|
|
|
|
|
remove_project_edit_form();
|
|
|
|
|
update_and_show_project_settings();
|
|
|
|
|
|
|
|
|
|
TracksForm.set_project_name("<%= escape_javascript(@project.name)%>");
|
2010-10-06 17:50:49 +02:00
|
|
|
<% if @project.default_context %>
|
2010-10-07 23:24:50 +02:00
|
|
|
TracksForm.set_context_name_and_default_context_name("<%= escape_javascript(@project.default_context.name)%>");
|
2010-10-06 17:50:49 +02:00
|
|
|
<% end %>
|
|
|
|
|
<% if @project.default_tags %>
|
2010-10-07 23:24:50 +02:00
|
|
|
TracksForm.set_tag_list("<%= escape_javascript(@project.default_tags)%>");
|
2010-10-06 17:50:49 +02:00
|
|
|
<% end %>
|
2010-10-07 23:24:50 +02:00
|
|
|
|
|
|
|
|
update_sidebar();
|
|
|
|
|
|
2010-10-06 17:50:49 +02:00
|
|
|
<% end %>
|
2010-10-07 23:24:50 +02:00
|
|
|
|
|
|
|
|
TracksForm.set_project_name_and_default_project_name("<%= escape_javascript(@project.name)%>");
|
|
|
|
|
|
2010-10-06 17:50:49 +02:00
|
|
|
<% else -%>
|
2010-10-07 23:24:50 +02:00
|
|
|
show_errors();
|
2010-10-06 17:50:49 +02:00
|
|
|
<% end %>
|
2010-10-07 23:24:50 +02:00
|
|
|
|
2010-10-06 17:50:49 +02:00
|
|
|
enable_rich_interaction();
|
|
|
|
|
|
2010-10-07 23:24:50 +02:00
|
|
|
function show_errors() {
|
|
|
|
|
$('div#error_status').html(html_for_error_messages());
|
|
|
|
|
$('div#error_status').show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function remove_project_edit_form() {
|
2010-10-15 11:49:34 +02:00
|
|
|
$('#<%=dom_id(@project, 'edit')%>').hide(500, function() {$('#<%=dom_id(@project, 'edit')%>').remove();} );
|
2010-10-07 23:24:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function update_and_show_project_settings() {
|
|
|
|
|
$('#<%=dom_id(@project, 'container')%>').html(html_for_project_settings());
|
|
|
|
|
$('#<%=dom_id(@project)%>').show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function update_sidebar() {
|
|
|
|
|
$('#sidebar').html();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function update_sortable() {
|
2010-10-08 21:07:17 +02:00
|
|
|
<%#* page.sortable "list-#{@project.state}-projects", get_listing_sortable_options("list-#{@project.state}-projects")-%>
|
2010-10-15 11:49:34 +02:00
|
|
|
/*console.log("Pending: update_sortable() on update project");*/
|
2010-10-07 23:24:50 +02:00
|
|
|
}
|
|
|
|
|
|
2010-10-08 21:07:17 +02:00
|
|
|
function replace_project_form_with_updated_project() {
|
|
|
|
|
$('#<%=dom_id(@project, 'container')%>').fadeOut(250, function() {
|
2010-10-07 23:24:50 +02:00
|
|
|
$('#<%=dom_id(@project, 'container')%>').html(html_for_project_listing());
|
|
|
|
|
$('#<%=dom_id(@project, 'container')%>').fadeIn(500);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-15 11:49:34 +02:00
|
|
|
function remove_and_re_add_project() {
|
2010-10-07 23:24:50 +02:00
|
|
|
$('#<%=dom_id(@project, 'container')%>').slideUp(500, function() {
|
2010-10-15 11:49:34 +02:00
|
|
|
$('#<%=dom_id(@project, 'container')%>').remove();
|
|
|
|
|
$('#list-<%=@project.state%>-projects').append(html_for_project_listing);
|
|
|
|
|
});
|
2010-10-07 23:24:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
<%
|
|
|
|
|
# the following functions return empty string if rendering the partial is not
|
|
|
|
|
# necessary, for example the sidebar is not on the project list page, so do not
|
|
|
|
|
# render it into the function.
|
|
|
|
|
-%>
|
|
|
|
|
function html_for_project_listing() {
|
|
|
|
|
return "<%= source_view_is(:project_list) ? escape_javascript(render(:partial => 'project_listing', :locals => { :project_listing => @project })) : "" %>";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function html_for_sidebar() {
|
|
|
|
|
return "<%= source_view_is(:project) ? escape_javascript(render(:file => 'sidebar/sidebar.html.erb')) : "" %>";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function html_for_project_settings() {
|
|
|
|
|
return "<%= source_view_is(:project) ? escape_javascript(render(:partial => 'project_settings', :locals => { :project => @project })) : "" %>";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function html_for_error_messages() {
|
|
|
|
|
return "<%= escape_javascript(error_messages_for('project')) %>";
|
|
|
|
|
}
|