Replace system settings tabs by submenu

pull/8520/head
Inga Mai 4 years ago
parent cab702b4a6
commit 1afc6782f7
  1. 36
      app/controllers/settings/display_controller.rb
  2. 36
      app/controllers/settings/general_controller.rb
  3. 36
      app/controllers/settings/projects_controller.rb
  4. 36
      app/controllers/settings/repositories_controller.rb
  5. 24
      app/helpers/settings_helper.rb
  6. 2
      app/views/settings/_display.html.erb
  7. 2
      app/views/settings/_general.html.erb
  8. 2
      app/views/settings/_projects.html.erb
  9. 1
      app/views/settings/_repositories.html.erb
  10. 2
      app/views/settings/show.html.erb
  11. 9
      config/initializers/menus.rb
  12. 9
      config/routes.rb

@ -0,0 +1,36 @@
#-- encoding: UTF-8
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2020 the OpenProject GmbH
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2017 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See docs/COPYRIGHT.rdoc for more details.
#++
class Settings::DisplayController < SettingsController
menu_item :settings_display
def show
render template: 'settings/_display'
end
end

@ -0,0 +1,36 @@
#-- encoding: UTF-8
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2020 the OpenProject GmbH
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2017 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See docs/COPYRIGHT.rdoc for more details.
#++
class Settings::GeneralController < SettingsController
menu_item :settings_general
def show
render template: 'settings/_general'
end
end

@ -0,0 +1,36 @@
#-- encoding: UTF-8
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2020 the OpenProject GmbH
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2017 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See docs/COPYRIGHT.rdoc for more details.
#++
class Settings::ProjectsController < SettingsController
menu_item :settings_projects
def show
render template: 'settings/_projects'
end
end

@ -0,0 +1,36 @@
#-- encoding: UTF-8
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2020 the OpenProject GmbH
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2017 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See docs/COPYRIGHT.rdoc for more details.
#++
class Settings::RepositoriesController < SettingsController
menu_item :settings_repositories
def show
render template: 'settings/_repositories'
end
end

@ -30,37 +30,43 @@
require 'securerandom'
module SettingsHelper
extend self
include OpenProject::FormTagHelper
def administration_settings_tabs
def system_settings_tabs
[
{
name: 'general',
partial: 'settings/general',
path: general_settings_path,
action: { controller: '/settings/general', action: 'show' },
label: :label_general
},
{
name: 'display',
partial: 'settings/display',
path: general_settings_path(tab: :display),
action: { controller: '/settings/display', action: 'show' },
label: :label_display
},
{
name: 'projects',
partial: 'settings/projects',
path: general_settings_path(tab: :projects),
action: { controller: '/settings/projects', action: 'show' },
label: :label_project_plural
},
{
name: 'repositories',
partial: 'settings/repositories',
path: general_settings_path(tab: :repositories),
action: { controller: '/settings/repositories', action: 'show' },
label: :label_repository_plural
}
]
end
def general_settings_path(opts = {})
if opts[:tab]
url_for controller: "settings/#{opts[:tab]}", action: 'show', only_path: true
else
url_for controller: "settings/general", action: 'show', only_path: true
end
end
def setting_select(setting, choices, options = {})
if blank_text = options.delete(:blank)
choices = [[blank_text.is_a?(Symbol) ? I18n.t(blank_text) : blank_text, '']] + choices

@ -31,6 +31,8 @@ See docs/COPYRIGHT.rdoc for more details.
<meta name="required_script" content="administration_settings" />
<% end %>
<%= toolbar title: t(:label_display) %>
<%= styled_form_tag(general_settings_path(tab: 'display'), method: :patch) do %>
<section class="form--section">

@ -26,6 +26,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
See docs/COPYRIGHT.rdoc for more details.
++#%>
<%= toolbar title: t(:label_general) %>
<%= styled_form_tag(general_settings_path, method: :patch) do %>
<section class="form--section">
<div class="form--field"><%= setting_text_field :app_title, size: 30, container_class: '-middle' %></div>

@ -26,6 +26,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
See docs/COPYRIGHT.rdoc for more details.
++#%>
<%= toolbar title: t(:label_project_plural) %>
<%= styled_form_tag(general_settings_path(tab: 'projects'), method: :patch) do %>
<section class="form--section">
<div class="form--field"><%= setting_check_box :default_projects_public %></div>

@ -26,6 +26,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
See docs/COPYRIGHT.rdoc for more details.
++#%>
<%= toolbar title: t(:label_repository_plural) %>
<%= styled_form_tag(general_settings_path(tab: 'repositories'), method: :patch) do %>
<section class="form--section">

@ -30,5 +30,3 @@ See docs/COPYRIGHT.rdoc for more details.
<% html_title t(:label_administration), t(:label_system_settings) -%>
<%= toolbar title: t(:label_system_settings) %>
<%= render_tabs administration_settings_tabs %>

@ -217,10 +217,17 @@ Redmine::MenuManager.map :admin_menu do |menu|
icon: 'icon2 icon-enumerations'
menu.push :settings,
{ controller: '/settings', action: 'show' },
{ controller: '/settings/general', action: 'show' },
caption: :label_system_settings,
icon: 'icon2 icon-settings2'
SettingsHelper.system_settings_tabs.each do |node|
menu.push :"settings_#{node[:name]}",
node[:action],
caption: node[:label],
parent: :settings
end
menu.push :email,
{ controller: '/admin/mail_notifications', action: 'show' },
caption: :'attributes.mail',

@ -394,7 +394,12 @@ OpenProject::Application.routes.draw do
resource :mail_notifications, only: %i[show update]
end
resource :settings, as: :general_settings, only: %i(update show) do
resource :settings, only: %i(update show) do
SettingsHelper.system_settings_tabs.each do |tab|
get "settings/#{tab[:name]}", controller: "settings/#{tab[:name]}", action: 'show', as: "settings_#{tab[:name]}"
end
get "settings", controller: "settings/general", action: 'show', as: "settings"
# We should fix this crappy routing (split up and rename controller methods)
collection do
match 'plugin/:id', action: 'plugin', via: %i[get post]
@ -403,7 +408,7 @@ OpenProject::Application.routes.draw do
resource :workflows, only: %i[edit update show] do
member do
# We should fix this crappy routing (split up and rename controller methods)
# We should fix this crappy routing (split upΩand rename controller methods)
match 'copy', action: 'copy', via: %i[get post]
end
end

Loading…
Cancel
Save