OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
merge common global roles view files from users and groups
Christophe Bliard447f10cabf7c
diff --git a/app/helpers/groups_helper.rb b/app/helpers/groups_helper.rbindex 498a247620d..2a7ede9422e 100644--- a/app/helpers/groups_helper.rb+++ b/app/helpers/groups_helper.rb@@ -51,7 +51,7 @@ module GroupsHelper},{name: 'global_roles',- partial: 'groups/global_roles',+ partial: 'principals/global_roles',path: edit_group_path(group, tab: :global_roles),label: :label_global_roles}diff --git a/app/views/groups/_global_roles.html.erb b/app/views/principals/_global_roles.html.erbsimilarity index 91%rename from app/views/groups/_global_roles.html.erbrename to app/views/principals/_global_roles.html.erbindex 30ae5a20549..7ad96be8ba5 100644--- a/app/views/groups/_global_roles.html.erb+++ b/app/views/principals/_global_roles.html.erb@@ -27,9 +27,12 @@ See COPYRIGHT and LICENSE files for more details.++#%>-<%= render partial: 'global_roles_header' %>+<%= render partial: 'principals/global_roles_header' %>-<% global_member = Member.global.where(principal: @group).includes(:roles).first %>+<%+ principal = @group || @user+ global_member = Member.global.where(principal: principal).includes(:roles).first+%><div class="grid-block" id="principal_global_roles_content"><div id="assigned_principal_roles" class="grid-content">@@ -69,5 +72,5 @@ See COPYRIGHT and LICENSE files for more details.<% end %></div>- <%= render partial: 'principals/available_global_roles', locals: { principal: @group, global_member: global_member } %>+ <%= render partial: 'principals/available_global_roles', locals: { principal: principal, global_member: global_member } %></div>diff --git a/app/views/groups/_global_roles_header.html.erb b/app/views/principals/_global_roles_header.html.erbsimilarity index 100%rename from app/views/groups/_global_roles_header.html.erbrename to app/views/principals/_global_roles_header.html.erbdiff --git a/app/views/roles/_form.html.erb b/app/views/roles/_form.html.erbindex 54654a2d33f..3de7a4c3c59 100644--- a/app/views/roles/_form.html.erb+++ b/app/views/roles/_form.html.erb@@ -27,7 +27,7 @@ See COPYRIGHT and LICENSE files for more details.++#%>-<%= render :partial => 'users/global_roles_header' %>+<%= render partial: 'principals/global_roles_header' %><% roles ||= nil %>@@ -66,4 +66,3 @@ See COPYRIGHT and LICENSE files for more details.<%= render partial: "permissions", locals: {permissions: grouped_setable_permissions(role), role: role, showGlobalRole: false }%></div><% end %>-diff --git a/app/views/users/_global_roles.html.erb b/app/views/users/_global_roles.html.erbdeleted file mode 100644index c14250959a3..00000000000--- a/app/views/users/_global_roles.html.erb+++ /dev/null@@ -1,73 +0,0 @@-<%#-- copyright-OpenProject is an open source project management software.-Copyright (C) 2012-2021 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-2013 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 COPYRIGHT and LICENSE files for more details.--++#%>--<%= render partial: 'global_roles_header' %>--<% global_member = Member.global.where(principal: @user).includes(:roles).first %>--<div class="grid-block" id="principal_global_roles_content">- <div id="assigned_principal_roles" class="grid-content">- <% unless global_member&.roles&.any? %>- <%= no_results_box %>- <% else %>- <div class="generic-table--container">- <div class="generic-table--results-container">- <table class="generic-table principal_roles" id="table_principal_roles">- <colgroup>- <col opHighlightCol>- <col>- </colgroup>- <thead>- <tr>- <th>- <div class="generic-table--sort-header-outer">- <div class="generic-table--sort-header">- <span>- <%= Role.model_name.human %>- </span>- </div>- </div>- </th>- <th><div class="generic-table--empty-header"></div></th>- </tr>- </thead>- <tbody id="table_principal_roles_body">- <% global_member.roles.each do |role| %>- <%= render partial: 'principals/assigned_global_role', locals: { role: role, member: global_member } %>- <% end %>- </tbody>- </table>-- </div>- </div>- <% end %>- </div>-- <%= render partial: 'principals/available_global_roles', locals: { principal: @user, global_member: global_member } %>-</div>diff --git a/app/views/users/_global_roles_header.html.erb b/app/views/users/_global_roles_header.html.erbdeleted file mode 100644index 2ead7011daa..00000000000--- a/app/views/users/_global_roles_header.html.erb+++ /dev/null@@ -1,32 +0,0 @@-<%#-- copyright-OpenProject is an open source project management software.-Copyright (C) 2012-2021 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-2013 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 COPYRIGHT and LICENSE files for more details.--++#%>--<% content_for :header_tags do %>- <meta name="required_script" content="global_roles" />-<% end %>diff --git a/lib/open_project/ui/extensible_tabs.rb b/lib/open_project/ui/extensible_tabs.rbindex 38d58509edd..3eb142f334f 100644--- a/lib/open_project/ui/extensible_tabs.rb+++ b/lib/open_project/ui/extensible_tabs.rb@@ -79,7 +79,7 @@ module OpenProject},{name: 'global_roles',- partial: 'users/global_roles',+ partial: 'principals/global_roles',path: ->(params) { edit_user_path(params[:user], tab: :global_roles) },label: :label_global_roles,only_if: ->(*) { User.current.admin? }