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 remote-tracking branch 'origin/dev' into feature/replace-settings-tab-by-sub-menu-entries
Henriette Dinger962c50e21214
diff --cc app/controllers/projects/time_entry_activities_controller.rbindex 21eec403446,7741a584ab1..5bc58744817--- a/app/controllers/projects/time_entry_activities_controller.rb+++ b/app/controllers/projects/time_entry_activities_controller.rb@@@ -33,23 -33,17 +33,17 @@@ class Projects::TimeEntryActivitiesContbefore_action :authorizedef update- if permitted_params.enumerations.present?- Project.transaction do- permitted_params.enumerations.each do |id, activity|- @project.update_or_create_time_entry_activity(id, activity)- end- end- flash[:notice] = l(:notice_successful_update)- end+ TimeEntryActivitiesProject.upsert_all(update_params, unique_by: %i[project_id activity_id])+ flash[:notice] = t(:notice_successful_update)- redirect_to settings_project_path(id: @project, tab: 'activities')+ redirect_to settings_activities_project_path(@project)end- def destroy- TimeEntryActivity.bulk_destroy(@project.time_entry_activities)-- flash[:notice] = l(:notice_successful_update)+ private- redirect_to settings_activities_project_path(@project)+ def update_params+ permitted_params.time_entry_activities_project.map do |attributes|+ { project_id: @project.id, active: false }.with_indifferent_access.merge(attributes.to_h)+ endendenddiff --cc app/controllers/versions_controller.rbindex a218f290c6a,84f0bf20f91..bdd7c721804--- a/app/controllers/versions_controller.rb+++ b/app/controllers/versions_controller.rb@@@ -116,7 -116,7 +116,7 @@@ class VersionsController < ApplicationCflash[:error] = call.errors.full_messagesend- redirect_to settings_versions_project_path(@projectsettings_versions_project_path)- redirect_to settings_project_path(tab: 'versions', id: @project)++ redirect_to settings_versions_project_path(@project)endprivatediff --cc app/views/project_settings/activities.html.erbindex bc554423f8a,45c6c155f46..f7db64cf65e--- a/app/views/project_settings/activities.html.erb+++ b/app/views/project_settings/activities.html.erb@@@ -26,10 -26,8 +26,10 @@@ Foundation, Inc., 51 Franklin Street, FSee docs/COPYRIGHT.rdoc for more details.++#%>+<%= toolbar title: l(:enumeration_activities) %>+- <% if @project.activities(true).any? %>- <%= form_tag project_enumerations_path(@project),+ <% if TimeEntryActivity.any? %>+ <%= form_tag project_time_entry_activities_path(@project),method: :put,class: "tabular" do %>diff --cc app/views/projects/form/_activities.html.erbindex 7bf077115d4,349aaa267b0..4eaa01508fd--- a/app/views/projects/form/_activities.html.erb+++ b/app/views/projects/form/_activities.html.erb@@@ -27,69 -27,29 +27,25 @@@ See docs/COPYRIGHT.rdoc for more detail++#%>- <div class="generic-table--container">- <div class="generic-table--results-container">- <table class="generic-table">- <colgroup>- <col highlight-col>- <col highlight-col>- <col highlight-col>- <% TimeEntryActivity.new.available_custom_fields.each do |value| %>- <col highlight-col>- <% end %>- </colgroup>- <thead>- <tr>- <th>- <div class="generic-table--sort-header-outer">- <div class="generic-table--sort-header">- <span>- <%= Enumeration.human_attribute_name(:active) %>- </span>- </div>- </div>- </th>- <th>- <div class="generic-table--sort-header-outer">- <div class="generic-table--sort-header">- <span>- <%= Enumeration.human_attribute_name(:name) %>- </span>- </div>- </div>- </th>- <th>- <div class="generic-table--sort-header-outer">- <div class="generic-table--sort-header">- <span>- <%= l(:enumeration_system_activity) %>- </span>- </div>- </div>- </th>- </tr>- </thead>- <% @project.activities(true).each do |enumeration| %>- <%= fields_for "enumerations[#{enumeration.id}]", enumeration do |ff| %>- <tr>- <td>- <%= label_tag "enumerations_#{enumeration.id}_active", "#{h(enumeration.name)} #{l(:description_active)}", class: "hidden-for-sighted" %>- <%= ff.check_box :active %>- </td>- <td>- <%= ff.hidden_field :parent_id, value: enumeration.id unless enumeration.project %>- <%= h(enumeration) %>- </td>- <td><%= checked_image !enumeration.project %></td>- </tr>- <% end %>- <% end %>- </table>-<fieldset class="form--fieldset">- <legend class="form--fieldset-legend"><%=t(:label_enabled_project_activities)%></legend>--- <% TimeEntryActivity- .includes(:time_entry_activities_projects)- .order(:name)- .each do |activity| %>- <div class="form--field">- <%= styled_label_tag "time_entry_activities_project_#{activity.id}_active", activity.name %>- <div class="form--field-container" >- <%= hidden_field_tag "time_entry_activities_project[][activity_id]",- activity.id %>- <%= styled_check_box_tag "time_entry_activities_project[][active]",- 1,- activity.active_in_project?(@project),- id: "time_entry_activities_project_#{activity.id}_active" %>- </div>++<% TimeEntryActivity++ .includes(:time_entry_activities_projects)++ .order(:name)++ .each do |activity| %>++ <div class="form--field">++ <%= styled_label_tag "time_entry_activities_project_#{activity.id}_active", activity.name %>++ <div class="form--field-container" >++ <%= hidden_field_tag "time_entry_activities_project[][activity_id]",++ activity.id %>++ <%= styled_check_box_tag "time_entry_activities_project[][active]",++ 1,++ activity.active_in_project?(@project),++ id: "time_entry_activities_project_#{activity.id}_active" %>+ </div>- <% end %>-- <% if withControlls == true %>- <div class="generic-table--action-buttons">- <%= styled_button_tag t(:button_save), class: '-highlight -with-icon icon-checkmark' %>- </div>- <% end %>-</fieldset>+ </div>- </div>++<% end %>+++<% if withControlls == true %>+ <div class="generic-table--action-buttons">- <%= styled_button_tag l(:button_save), class: '-highlight -with-icon icon-checkmark' %>++ <%= styled_button_tag t(:button_save), class: '-highlight -with-icon icon-checkmark' %>+ </div>+<% end %>diff --cc spec/features/menu_items/menu_permissions_spec.rbindex c9c1d7b6737,00000000000..3cfe7cf0b72mode 100644,000000..100644--- a/spec/features/menu_items/menu_permissions_spec.rb+++ b/spec/features/menu_items/menu_permissions_spec.rb@@@ -1,88 -1,0 +1,88 @@@+#-- 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.+#++++require 'spec_helper'++describe 'menu permissions', type: :feature, js: true do+ let(:user) do+ FactoryBot.create(:user,+ member_in_project: project,+ member_with_permissions: %i[manage_versions view_work_packages])+ end+ let(:admin) { FactoryBot.create(:admin) }++ let(:project) { FactoryBot.create(:project) }++ context 'as an admin' do+ before do+ login_as(admin)++ # Allowed to see the settings version page+ visit settings_versions_project_path(project)+ end++ it 'I can see all menu entries' do+ expect(page).to have_selector('#menu-sidebar .menu-item--title', text: 'Versions')+ expect(page).to have_selector('#menu-sidebar .menu-item--title', text: 'Information')- expect(page).to have_selector('#menu-sidebar .menu-item--title', text: 'Modules')++ expect(page).to have_selector('#menu-sidebar .menu-item--title', text: 'Enabled modules')+ end++ it 'the parent node directs to the generic settings page' do+ # The settings menu item exists+ expect(page).to have_selector('#menu-sidebar .main-item-wrapper', text: 'Project settings', visible: false)++ # Clicking the menu parent item leads to the version page+ find('.main-menu--parent-node', text: 'Project settings').click+ expect(page).to have_current_path(settings_generic_project_path(project))+ end+ end++ context 'as an user who can only manage_versions' do+ before do+ login_as(user)++ # Allowed to see the settings version page+ visit settings_versions_project_path(project)+ end++ it 'I can only see the version settings page' do+ expect(page).to have_selector('#menu-sidebar .menu-item--title', text: 'Versions')+ expect(page).not_to have_selector('#menu-sidebar .menu-item--title', text: 'Information')+ expect(page).not_to have_selector('#menu-sidebar .menu-item--title', text: 'Modules')+ end++ it 'the parent node directs to the only visible children page' do+ # The settings menu item exists+ expect(page).to have_selector('#menu-sidebar .main-item-wrapper', text: 'Project settings', visible: false)++ # Clicking the menu parent item leads to the version page+ find('.main-menu--parent-node', text: 'Project settings').click+ expect(page).to have_current_path(settings_versions_project_path(project))+ end+ end+end