mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-25 03:30:13 +01:00
102 lines
No EOL
3.8 KiB
Text
102 lines
No EOL
3.8 KiB
Text
<% if @saved -%>
|
|
TracksPages.page_notify('notice', '<%=t('projects.project_saved_status')%>', 5);
|
|
<% if source_view_is_one_of(:project_list, :review) -%>
|
|
update_project_list_page();
|
|
<% else # assume source_view :project
|
|
-%>
|
|
update_project_page();
|
|
<% end %>
|
|
<% else -%>
|
|
TracksPages.show_edit_errors(html_for_error_messages());
|
|
<% end %>
|
|
|
|
<% if @saved
|
|
# only add these js functions if the project is saved
|
|
-%>
|
|
|
|
function update_project_list_page() {
|
|
<% if @state_changed -%>
|
|
remove_and_re_add_project();
|
|
<% else -%>
|
|
replace_project_form_with_updated_project();
|
|
<% end -%>
|
|
|
|
ProjectListPage.update_all_states_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 %>);
|
|
TracksForm.set_project_name_and_default_project_name("<%= escape_javascript(@project.name)%>");
|
|
$('div.project-edit-current').removeClass('project-edit-current');
|
|
}
|
|
|
|
function update_project_page() {
|
|
remove_project_edit_form();
|
|
update_and_show_project_settings();
|
|
TracksForm.set_project_name("<%= escape_javascript(@project.name)%>");
|
|
$("h2 div#project_name").html("<%= escape_javascript(@project.name)%>");
|
|
<% if @project.default_context %>
|
|
TracksForm.set_context_name_and_default_context_name("<%= escape_javascript(@project.default_context.name)%>");
|
|
<% end %>
|
|
<% if @project.default_tags %>
|
|
TracksForm.set_tag_list("<%= escape_javascript(@project.default_tags)%>");
|
|
<% end %>
|
|
TracksPages.update_sidebar(html_for_sidebar());
|
|
}
|
|
|
|
function remove_project_edit_form() {
|
|
<%-
|
|
# do not remove() edit form as this will remove the DIV that is needed to replace with the new form, so only empty the DIV
|
|
-%>
|
|
$('#<%=dom_id(@project, 'edit')%>').hide(500, function() {
|
|
$('#<%=dom_id(@project, 'edit')%>').html("<!- empty ->");
|
|
});
|
|
}
|
|
|
|
function update_and_show_project_settings() {
|
|
$('#<%=dom_id(@project, 'container')%>').html(html_for_project_settings());
|
|
$('#<%=dom_id(@project)%>').show();
|
|
}
|
|
|
|
function replace_project_form_with_updated_project() {
|
|
$('div#<%=dom_id(@project, 'container')%>').each(function(index, elem) {
|
|
$(this).fadeOut(250, function() {
|
|
<%
|
|
# first add the updated project after the old one, then remove old one.
|
|
# Using html() does not work, because it will replace the _content_ of
|
|
# the container instead of the container itself, i.e. you will get
|
|
# a container within a container which will break drag-and-drop sorting
|
|
-%>
|
|
$(this).after(html_for_project_listing());
|
|
$(this).remove();
|
|
$('#<%=dom_id(@project, 'container')%>').fadeIn(500);
|
|
})});
|
|
}
|
|
|
|
function remove_and_re_add_project() {
|
|
$('#<%=dom_id(@project, 'container')%>').slideUp(500, function() {
|
|
$('#<%=dom_id(@project, 'container')%>').remove();
|
|
$('#list-<%=@project.state%>-projects').append(html_for_project_listing());
|
|
});
|
|
}
|
|
|
|
<%
|
|
# 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_one_of(:project_list, :review) ? escape_javascript(render(:partial => 'project_listing', :object => @project, :locals=>{:suppress_drag_handle => source_view_is(:review)} )) : "" %>";
|
|
}
|
|
|
|
function html_for_sidebar() {
|
|
return "<%= source_view_is(:project) ? escape_javascript(render(:file => 'sidebar/sidebar')) : "" %>";
|
|
}
|
|
|
|
function html_for_project_settings() {
|
|
return "<%= source_view_is(:project) ? escape_javascript(render(:partial => 'project_settings', :object => @project )) : "" %>";
|
|
}
|
|
|
|
<% end # if @saved
|
|
-%>
|
|
|
|
function html_for_error_messages() {
|
|
return "<%= escape_javascript(get_list_of_error_messages_for(@project)) %>";
|
|
} |