From e0c011948c9eb65a946e5bed4c9b3d820c64fdba Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 5 May 2016 15:16:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=8C=E7=BA=A7=E5=9F=9F=E5=90=8D=E7=9A=84?= =?UTF-8?q?=E9=9A=90=E8=97=8F=E5=92=8C=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/sub_domains_controller.rb | 11 ++++++++++- .../_subfield_sub_domains_list.html.erb | 15 ++++++++++++++- app/views/sub_domains/hide_sub_domain.js.erb | 2 ++ app/views/sub_domains/show_sub_domain.js.erb | 2 ++ config/routes.rb | 2 ++ 5 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 app/views/sub_domains/hide_sub_domain.js.erb create mode 100644 app/views/sub_domains/show_sub_domain.js.erb diff --git a/app/controllers/sub_domains_controller.rb b/app/controllers/sub_domains_controller.rb index fd6b9e166..e32935789 100644 --- a/app/controllers/sub_domains_controller.rb +++ b/app/controllers/sub_domains_controller.rb @@ -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]) diff --git a/app/views/organizations/_subfield_sub_domains_list.html.erb b/app/views/organizations/_subfield_sub_domains_list.html.erb index 891b0aede..10ee47e72 100644 --- a/app/views/organizations/_subfield_sub_domains_list.html.erb +++ b/app/views/organizations/_subfield_sub_domains_list.html.erb @@ -25,7 +25,7 @@ <%#= link_to "隐藏", hide_org_subsubdomain_organizations_path(subdomain), :method => 'post', :remote => true, :id => "hide_#{subdomain.id}", :class => "linkBlue fr mr5" %>
  • - <%= subdomain.hide==0?"隐藏":"可见" %> + <%= subdomain.hide==0?"隐藏":"可见" %> | <%= 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" %> | @@ -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" + }); + } diff --git a/app/views/sub_domains/hide_sub_domain.js.erb b/app/views/sub_domains/hide_sub_domain.js.erb new file mode 100644 index 000000000..e09629dcf --- /dev/null +++ b/app/views/sub_domains/hide_sub_domain.js.erb @@ -0,0 +1,2 @@ +$("#hide_<%= @subfield.id %>").text("可见"); +$("#org_subfield_<%= @subfield.id %>").css("display", "none"); \ No newline at end of file diff --git a/app/views/sub_domains/show_sub_domain.js.erb b/app/views/sub_domains/show_sub_domain.js.erb new file mode 100644 index 000000000..e09629dcf --- /dev/null +++ b/app/views/sub_domains/show_sub_domain.js.erb @@ -0,0 +1,2 @@ +$("#hide_<%= @subfield.id %>").text("可见"); +$("#org_subfield_<%= @subfield.id %>").css("display", "none"); \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 556d8b233..0816dadc7 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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