migrate editing a context and refactor project with it

This commit is contained in:
Reinier Balt 2010-10-24 22:31:57 +02:00
parent 4e9777dc88
commit fb39d841a7
13 changed files with 163 additions and 43 deletions

View file

@ -7,7 +7,7 @@ project = project_form
:class => "inline-form edit-project-form",
:method => :put }) do
-%>
<div id="error_status"><%= error_messages_for("project") %></div>
<div id="edit_error_status"><%= error_messages_for("project") %></div>
<%= source_view_tag( @source_view ) -%>
<label for="project_name">Name:</label><br/>

View file

@ -1,9 +1,21 @@
newHtml = "<%= escape_javascript(render(:partial => 'project_form', :locals => { :project_form => @project })) %>"
replace_project_with_edit_form();
$('div#<%=dom_id(@project)%>').fadeOut(250, function() {
$('div#<%=dom_id(@project, 'edit')%>').html(newHtml);
function replace_project_with_edit_form() {
$('div#<%=dom_id(@project)%>').fadeOut(250, function() {
show_edit_form();
set_focus();
});
}
function show_edit_form() {
$('div#<%=dom_id(@project, 'edit')%>').html(html_for_edit_form());
$('div#<%=dom_id(@project, 'edit')%>').fadeIn(500);
}
function set_focus() {
$('input.project-name').focus();
});
}
function html_for_edit_form() {
return "<%= escape_javascript(render(:partial => 'project_form', :locals => { :project_form => @project })) %>"
}

View file

@ -39,8 +39,8 @@
enable_rich_interaction();
function show_errors() {
$('div#error_status').html(html_for_error_messages());
$('div#error_status').show();
$('div#edit_error_status').html(html_for_error_messages());
$('div#edit_error_status').show();
}
function remove_project_edit_form() {
@ -73,7 +73,7 @@ function replace_project_form_with_updated_project() {
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);
$('#list-<%=@project.state%>-projects').append(html_for_project_listing());
});
}