From 2996daef71c14d64ba6c72d840cace07ed56bfb1 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 4 May 2016 17:06:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=8C=E7=BA=A7=E5=9F=9F=E5=90=8D=E5=B1=80?= =?UTF-8?q?=E9=83=A8=E5=88=B7=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/sub_domains_controller.rb | 10 +--------- app/views/sub_domains/create.js.erb | 8 ++++++++ 2 files changed, 9 insertions(+), 9 deletions(-) create mode 100644 app/views/sub_domains/create.js.erb diff --git a/app/controllers/sub_domains_controller.rb b/app/controllers/sub_domains_controller.rb index c45dff1d7..d289c7e39 100644 --- a/app/controllers/sub_domains_controller.rb +++ b/app/controllers/sub_domains_controller.rb @@ -11,17 +11,9 @@ class SubDomainsController < ApplicationController def create if SubDomain.where("org_subfield_id=#{params[:org_subfield_id]} and name=?",params[:name]).count == 0 @res = true - # @organization = Organization.find(params[:organization_id]) @subfield = OrgSubfield.find(params[:org_subfield_id]) - # @subfield = OrgSubfield.create(:name => params[:name], :organization_id => params[:organization_id],:priority => @organization.org_subfields.order("priority").last.priority + 1) + @organization = @subfield.organization @subdomain = SubDomain.create(:name => params[:name], :org_subfield_id => params[:org_subfield_id],:priority => @subfield.sub_domains.blank? ? 1.1 : @subfield.sub_domains.order("priority").last.priority + 0.1) - # if !params[:sub_dir].blank? - # sql = "select subfield_subdomain_dirs.* from subfield_subdomain_dirs, org_subfields where subfield_subdomain_dirs.org_subfield_id = org_subfields.id "+ - # "and org_subfields.organization_id=#{@organization.id} and subfield_subdomain_dirs.name='#{params[:sub_dir]}'" - # if SubfieldSubdomainDir.find_by_sql(sql).count == 0 - # SubfieldSubdomainDir.create(:org_subfield_id => @subfield.id, :name => params[:sub_dir].downcase) - # end - # end @subdomain.update_column(:field_type, params[:field_type]) else @res = false diff --git a/app/views/sub_domains/create.js.erb b/app/views/sub_domains/create.js.erb new file mode 100644 index 000000000..0990e35de --- /dev/null +++ b/app/views/sub_domains/create.js.erb @@ -0,0 +1,8 @@ +<% if @res %> +$("#org_subfield_list").html(""); +$("#org_subfield_list").html("<%= escape_javascript(render :partial => 'organizations/subfield_list', :locals => {:subfields => @organization.org_subfields.order("priority") }) %>"); +$("#sub_field_left_lists").html(""); +$("#sub_field_left_lists").html("<%= escape_javascript(render :partial => 'organizations/org_left_subfield_list', :locals => {:organization => @organization}) %>"); +<% end %> +$("#subfield_name").val(""); +$("#sub_dir").val(""); \ No newline at end of file