Replace tab content by own pages with own controllers

pull/7949/head
Henriette Dinger 5 years ago
parent b99b03bea5
commit 2be6ca186d
  1. 36
      app/controllers/project_settings/activities_controller.rb
  2. 36
      app/controllers/project_settings/categories_controller.rb
  3. 37
      app/controllers/project_settings/custom_fields_controller.rb
  4. 36
      app/controllers/project_settings/modules_controller.rb
  5. 52
      app/controllers/project_settings/repositories_controller.rb
  6. 37
      app/controllers/project_settings/types_controller.rb
  7. 36
      app/controllers/project_settings/versions_controller.rb
  8. 7
      app/controllers/project_settings_controller.rb
  9. 8
      app/helpers/projects_helper.rb
  10. 0
      app/views/project_settings/activities.html.erb
  11. 0
      app/views/project_settings/categories.html.erb
  12. 0
      app/views/project_settings/custom_fields.html.erb
  13. 29
      app/views/project_settings/information.html.erb
  14. 0
      app/views/project_settings/modules.html.erb
  15. 2
      app/views/project_settings/show.html.erb
  16. 0
      app/views/project_settings/types.html.erb
  17. 0
      app/views/project_settings/versions.html.erb
  18. 0
      app/views/repositories/project_settings.html.erb
  19. 14
      config/initializers/menus.rb
  20. 7
      config/initializers/permissions.rb
  21. 5
      config/routes.rb

@ -0,0 +1,36 @@
#-- encoding: UTF-8
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2018 the OpenProject Foundation (OPF)
#
# 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 ProjectSettings::ActivitiesController < ProjectSettingsController
menu_item :settings_activities
def show
render template: 'project_settings/activities'
end
end

@ -0,0 +1,36 @@
#-- encoding: UTF-8
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2018 the OpenProject Foundation (OPF)
#
# 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 ProjectSettings::CategoriesController < ProjectSettingsController
menu_item :settings_categories
def show
render template: 'project_settings/categories'
end
end

@ -0,0 +1,37 @@
#-- encoding: UTF-8
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2018 the OpenProject Foundation (OPF)
#
# 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 ProjectSettings::CustomFieldsController < ProjectSettingsController
menu_item :settings_custom_fields
def show
@wp_custom_fields = WorkPackageCustomField.order("#{CustomField.table_name}.position")
render template: 'project_settings/custom_fields'
end
end

@ -0,0 +1,36 @@
#-- encoding: UTF-8
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2018 the OpenProject Foundation (OPF)
#
# 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 ProjectSettings::ModulesController < ProjectSettingsController
menu_item :settings_modules
def show
render template: 'project_settings/modules'
end
end

@ -0,0 +1,52 @@
#-- encoding: UTF-8
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2018 the OpenProject Foundation (OPF)
#
# 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 ProjectSettings::RepositoriesController < ProjectSettingsController
menu_item :settings_repositories
def show
@repository = @project.repository || new_repository
render template: 'repositories/project_settings'
end
private
def new_repository
return unless params[:scm_vendor]
service = Scm::RepositoryFactoryService.new(@project, params)
if service.build_temporary
@repository = service.repository
else
logger.error("Cannot create repository for #{params[:scm_vendor]}")
flash[:error] = service.build_error
nil
end
end
end

@ -0,0 +1,37 @@
#-- encoding: UTF-8
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2018 the OpenProject Foundation (OPF)
#
# 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 ProjectSettings::TypesController < ProjectSettingsController
menu_item :settings_types
def show
@types = ::Type.all
render template: 'project_settings/types'
end
end

@ -0,0 +1,36 @@
#-- encoding: UTF-8
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2018 the OpenProject Foundation (OPF)
#
# 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 ProjectSettings::VersionsController < ProjectSettingsController
menu_item :settings_versions
def show
render template: 'project_settings/versions'
end
end

@ -28,14 +28,17 @@
#++
class ProjectSettingsController < ApplicationController
menu_item :settings
menu_item :settings_info
before_action :find_project
before_action :authorize
before_action :check_valid_tab
before_action :get_tab_settings
def show; end
def show
@altered_project = @project
render template: 'project_settings/information'
end
private

@ -95,6 +95,14 @@ module ProjectsHelper
tabs.select { |tab| User.current.allowed_to?(tab[:action], @project) }
end
def settings_project_path(project, opts = {})
if opts[:tab]
url_for controller: "project_settings/#{opts[:tab]}", action: 'show', only_path: true, id: project
else
url_for controller: "project_settings", action: 'show', only_path: true, id: project
end
end
# Returns a set of options for a select field, grouped by project.
def version_options_for_select(versions, selected = nil)
grouped = Hash.new { |h, k| h[k] = [] }

@ -0,0 +1,29 @@
<%#-- copyright
OpenProject is a project management system.
Copyright (C) 2012-2018 the OpenProject Foundation (OPF)
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.
++#%>
<%= render partial: 'projects/edit' %>

@ -27,5 +27,3 @@ See docs/COPYRIGHT.rdoc for more details.
++#%>
<% html_title(l(:label_project_settings)) -%>
<%= render_tabs project_settings_tabs %>

@ -372,37 +372,37 @@ Redmine::MenuManager.map :project_menu do |menu|
parent: :settings
menu.push :settings_modules,
{ controller: '/project_settings', action: 'show', tab: :modules },
{ controller: '/project_settings/modules', action: 'show' },
caption: :label_modules,
parent: :settings
menu.push :settings_custom_fields,
{ controller: '/project_settings', action: 'show', tab: :custom_fields },
{ controller: '/project_settings/custom_fields', action: 'show' },
caption: :label_custom_field_plural,
parent: :settings
menu.push :settings_versions,
{ controller: '/project_settings', action: 'show', tab: :versions },
{ controller: '/project_settings/versions', action: 'show' },
caption: :label_version_plural,
parent: :settings
menu.push :settings_categories,
{ controller: '/project_settings', action: 'show', tab: :categories },
{ controller: '/project_settings/categories', action: 'show' },
caption: :label_work_package_category_plural,
parent: :settings
menu.push :settings_repositories,
{ controller: '/project_settings', action: 'show', tab: :repository },
{ controller: '/project_settings/repositories', action: 'show' },
caption: :label_repository,
parent: :settings
menu.push :settings_activities,
{ controller: '/project_settings', action: 'show', tab: :activities },
{ controller: '/project_settings/activities', action: 'show'},
caption: :enumeration_activities,
parent: :settings
menu.push :settings_types,
{ controller: '/project_settings', action: 'show', tab: :types },
{ controller: '/project_settings/types', action: 'show' },
caption: :label_work_package_types,
parent: :settings

@ -49,6 +49,13 @@ OpenProject::AccessControl.map do |map|
{
projects: %i[edit update custom_fields],
project_settings: [:show],
'project_settings/modules': [:show],
'project_settings/custom_fields': [:show],
'project_settings/versions': [:show],
'project_settings/activities': [:show],
'project_settings/categories': [:show],
'project_settings/types': [:show],
'project_settings/repositories': [:show],
members: [:paginate_users]
},
require: :member

@ -171,7 +171,10 @@ OpenProject::Application.routes.draw do
# settings_project_path(@project, tab: 'members')
# => "/projects/1/settings/members"
#
get 'settings(/:tab)', controller: 'project_settings', action: 'show', as: :settings
%i(modules categories versions custom_fields types activities repositories).each do |tab|
get "settings/#{tab}", controller: "project_settings/#{tab}", action: 'show', as: "settings_#{tab}"
end
get 'settings', controller: 'project_settings', action: 'show', as: :settings
get 'identifier', action: 'identifier'
patch 'identifier', action: 'update_identifier'

Loading…
Cancel
Save