From 988f8b79189b33ca76351c2fba41ceaa34e521f7 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 9 Apr 2015 10:33:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=9A=90=E8=97=8F=E9=9D=9E?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E4=BF=A1=E6=81=AF=E6=8C=89=E9=92=AE=E4=BB=A5?= =?UTF-8?q?=E5=8F=8A=E8=B7=AF=E7=94=B1=20=E5=AE=9E=E7=8E=B0=E7=82=B9?= =?UTF-8?q?=E5=87=BB=E6=8C=89=E9=92=AE=E4=BA=8B=E6=95=B0=E6=8D=AE=E7=9A=84?= =?UTF-8?q?=E5=AD=98=E5=82=A8=E4=B8=8E=E4=BF=AE=E6=94=B9=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/settings_controller.rb | 19 +++++++++++++++++++ app/views/settings/edit.html.erb | 4 +++- app/views/settings/hidden_non_project.js.erb | 5 +++++ config/locales/zh.yml | 2 ++ config/routes.rb | 1 + config/settings.yml | 2 ++ 6 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 app/views/settings/hidden_non_project.js.erb diff --git a/app/controllers/settings_controller.rb b/app/controllers/settings_controller.rb index c60d1bd8f..93e0e9c4b 100644 --- a/app/controllers/settings_controller.rb +++ b/app/controllers/settings_controller.rb @@ -29,6 +29,9 @@ class SettingsController < ApplicationController end def edit + hidden_non_project = Setting.find_by_name("hidden_non_project") + @text = (hidden_non_project && hidden_non_project.value == "0") ? l(:label_show_non_project) : l(:label_hidden_non_project) + @notifiables = Redmine::Notifiable.all if request.post? && params[:settings] && params[:settings].is_a?(Hash) settings = (params[:settings] || {}).dup.symbolize_keys @@ -70,4 +73,20 @@ class SettingsController < ApplicationController rescue Redmine::PluginNotFound render_404 end + + #隐藏/显示非项目信息 + def hidden_non_project + @notifiable = Setting.find_by_name("hidden_non_project") + if @notifiable + @notifiable.value == "1" ? @notifiable.value = 0 : @notifiable.value = 1 + @notifiable.save + else + @notifiable = Setting.new() + @notifiable.name = "hidden_non_project" + @notifiable.value = 0 + @notifiable.save + end + + redirect_to settings_url + end end diff --git a/app/views/settings/edit.html.erb b/app/views/settings/edit.html.erb index 8de53f55c..798db291b 100644 --- a/app/views/settings/edit.html.erb +++ b/app/views/settings/edit.html.erb @@ -1,4 +1,6 @@ -

<%= l(:label_settings) %>

+

<%=l(:label_settings)%>

+<%= link_to @text,settings_hidden_non_project_path,:id => "hidden_non_project",:style => "float: right;margin-right: 60px;margin-top: 9px;"%> +
<%= render_tabs administration_settings_tabs %> diff --git a/app/views/settings/hidden_non_project.js.erb b/app/views/settings/hidden_non_project.js.erb new file mode 100644 index 000000000..370fea33a --- /dev/null +++ b/app/views/settings/hidden_non_project.js.erb @@ -0,0 +1,5 @@ +<% if @notifiable.value == "0"%> + $("#hidden_non_project").replaceWith("<%= escape_javascript(link_to '显示非项目信息',settings_hidden_non_project_path,:id => 'hidden_non_project',:style => 'float: right;margin-right: 60px;margin-top: 9px;', :remote => true)%>"); +<% else%> + $("#hidden_non_project").replaceWith("<%= escape_javascript(link_to '隐藏非项目信息',settings_hidden_non_project_path,:id => 'hidden_non_project',:style => 'float: right;margin-right: 60px;margin-top: 9px;', :remote => true)%>"); +<% end%> \ No newline at end of file diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 17c445ae8..9cae8b25a 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -2031,4 +2031,6 @@ zh: modal_valid_unpassing: 该分班已经存在 mail_footer: 点击修改邮件发送设置 + label_show_non_project: 显示非项目信息 + label_hidden_non_project: 隐藏非项目信息 diff --git a/config/routes.rb b/config/routes.rb index c9220769c..03ed4d2ab 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -736,6 +736,7 @@ RedmineApp::Application.routes.draw do match 'settings', :controller => 'settings', :action => 'index', :via => :get match 'settings/edit', :via => [:get, :post] match 'settings/plugin/:id', :to => 'settings#plugin', :via => [:get, :post], :as => 'plugin_settings' + match 'settings/hidden_non_project', :via => [:get, :post] match 'sys/projects', :via => :get match 'sys/projects/:id/repository', :to => 'sys#create_project_repository', :via => :post diff --git a/config/settings.yml b/config/settings.yml index cd3f2974e..28d6c5dbc 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -266,6 +266,8 @@ repository_domain: default: repository.trustie.net please_chose: default: 请选择 +hidden_non_project: + default: 1 plugin_redmine_ckeditor: serialized: true default: --- !ruby/hash:ActiveSupport::HashWithIndifferentAccess