二级域名的隐藏和显示

This commit is contained in:
huang 2016-05-05 15:16:14 +08:00
parent 79cd36f297
commit e0c011948c
5 changed files with 30 additions and 2 deletions

View File

@ -1,6 +1,6 @@
class SubDomainsController < ApplicationController
layout 'base_org'
before_filter :find_org_subfield_and_subdomain, :only => [:show, :index, :domain_update_priority, :destroy, :update]
before_filter :find_org_subfield_and_subdomain, :only => [:show, :index, :domain_update_priority, :destroy, :update, :hide_sub_domain, :show_sub_domain]
def new
@subdomain = SubDomain.new
@ -42,6 +42,15 @@ class SubDomainsController < ApplicationController
end
def hide_sub_domain
@subdomain.update_attribute(:hide, 1)
end
def show_sub_domain
@subdomain.update_attribute(:hide, 0)
end
private
def find_org_subfield_and_subdomain
@subfield = OrgSubfield.find(params[:org_subfield_id])

View File

@ -25,7 +25,7 @@
<li class="orgListCatalog hidden"> -- </li>
<%#= link_to "隐藏", hide_org_subsubdomain_organizations_path(subdomain), :method => 'post', :remote => true, :id => "hide_#{subdomain.id}", :class => "linkBlue fr mr5" %>
<li class="orgSubOperation">
<a href="javascript:void(0);" class="linkGrey fr ml5 mr10" onclick="hide($(this),'<%= subdomain.id %>');" id="hide_<%= subdomain.id %>"><%= subdomain.hide==0?"隐藏":"可见" %></a>
<a href="javascript:void(0);" class="linkGrey fr ml5 mr10" onclick="hide_domain($(this),'<%= subdomain.org_subfield.id %>','<%= subdomain.id %>');" id="hide_<%= subdomain.id %>"><%= subdomain.hide==0?"隐藏":"可见" %></a>
<span class="fr">|</span>
<%= link_to "删除", org_subfield_sub_domain_path(subdomain, :org_subfield_id => subdomain.org_subfield.id), :method => 'delete', :remote => true, :confirm => "您确定删除吗?", :class => "linkGrey fr ml5 mr5" %>
<span class="fr">|</span>
@ -68,4 +68,17 @@
$(show_id).show();
$(edit_id).hide();
}
function hide_domain(content, field_id, domain_id){
if (content.text() == '隐藏')
$.ajax({
url: "/org_subfields/" + field_id + "/sub_domains/" + domain_id + "/hide_sub_domain",
type: "post"
});
else
$.ajax({
url: "/org_subfields/" + field_id + "/sub_domains/" + domain_id + "/show_sub_domain",
type: "post"
});
}
</script>

View File

@ -0,0 +1,2 @@
$("#hide_<%= @subfield.id %>").text("可见");
$("#org_subfield_<%= @subfield.id %>").css("display", "none");

View File

@ -0,0 +1,2 @@
$("#hide_<%= @subfield.id %>").text("可见");
$("#org_subfield_<%= @subfield.id %>").css("display", "none");

View File

@ -138,6 +138,8 @@ RedmineApp::Application.routes.draw do
match 'domain_update_sub_dir', :via => [:put]
match 'domain_update_priority', :via => [:put]
match 'domain_update_status', :via => [:post]
post 'hide_sub_domain'
post 'show_sub_domain'
end
end