二级域名编辑功能自动刷新

This commit is contained in:
huang 2016-05-05 11:28:28 +08:00
parent 5f696fe123
commit 2920f21c95
4 changed files with 31 additions and 2 deletions

View File

@ -20,6 +20,14 @@ class SubDomainsController < ApplicationController
end
end
def update
@subdomain = SubDomain.find(params[:id])
@subfield = OrgSubfield.find(params[:org_subfield_id])
@organization = @subfield.organization
@subdomain.update_column(:name, params[:name])
end
def show
render_404
# @subfield_content = @organization.org_subfields.order("priority")

View File

@ -14,7 +14,7 @@
<li class="orgSubColumn">
<div id="subsubdomain_show_<%= subdomain.id %>" class="subColumnControl"><%= subdomain.name %></div>
<div id="subsubdomain_edit_<%= subdomain.id %>" style="display:none;">
<input type="text" name="name" onblur="update_subfield('#subsubdomain_show_<%= subdomain.id %>','#subsubdomain_edit_<%= subdomain.id %>','<%= subdomain.id %>',$(this).val());" value="<%= subdomain.name %>" style="width:70px;"/>
<input type="text" name="name" onblur="update_subfield_subdomain('#subsubdomain_show_<%= subdomain.id %>','#subsubdomain_edit_<%= subdomain.id %>','<%= subdomain.org_subfield.id %>','<%= subdomain.id %>',$(this).val());" value="<%= subdomain.name %>" style="width:70px;"/>
</div>
</li>
<li class="orgSubStatus">新增</li>
@ -35,3 +35,21 @@
</ul>
<% end %>
<% end %>
<script>
function update_subfield_subdomain(show_id, edit_id, field_id, domain_id, input_value) {
if ($(show_id).html().trim() != input_value.trim()) {
if (confirm('确定修改为' + input_value + "?"))
$.ajax({
url: "/org_subfields/" + field_id + "/sub_domains/" + domain_id + "?name=" + input_value,
type: 'put'
});
else{
$(edit_id).children("input").val($(show_id).html().trim());
}
}
$(show_id).show();
$(edit_id).hide();
// $(edit_id).focus();
}
</script>

View File

@ -0,0 +1,3 @@
$("#subsubdomain_show_<%= @subdomain.id %>").html("<%= @subdomain.name %>");
$("#sub_field_left_lists").html("");
$("#sub_field_left_lists").html("<%= escape_javascript(render :partial => 'organizations/org_left_subfield_list', :locals => {:organization => @organization}) %>");

View File

@ -118,7 +118,7 @@ RedmineApp::Application.routes.draw do
end
end
resources :sub_domains, :only => [:index, :new, :create, :show] do
resources :sub_domains, :only => [:index, :new, :create, :show, :update] do
resources :sub_document_comments, :only => [:index, :new, :create, :show] do
member do
post 'add_reply'