Skip to content

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

move time entry activities to nested settings

ulferts81e45a2a9dc4
diff --git a/app/controllers/project_settings/activities_controller.rb b/app/controllers/project_settings/activities_controller.rb
deleted file mode 100644
index 7efce9b8cf4..00000000000
--- a/app/controllers/project_settings/activities_controller.rb
+++ /dev/null
@@ -1,37 +0,0 @@
-#-- encoding: UTF-8
-
-#-- 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.
-#++
-
-class ProjectSettings::ActivitiesController < ProjectSettingsController
- menu_item :settings_activities
-
- def show
- render template: 'project_settings/activities'
- end
-end
diff --git a/app/helpers/project_settings_helper.rb b/app/helpers/project_settings_helper.rb
index 88a9ccbe1cc..178b3ec1880 100644
--- a/app/helpers/project_settings_helper.rb
+++ b/app/helpers/project_settings_helper.rb
@@ -69,8 +69,8 @@ module ProjectSettingsHelper
label: :label_repository
},
{
- name: 'activities',
- action: { controller: '/project_settings/activities', action: 'show' },
+ name: 'time_entry_activities',
+ action: { controller: '/projects/settings/time_entry_activities', action: 'show' },
label: :enumeration_activities
},
{
diff --git a/app/views/projects/form/_project_attributes.html.erb b/app/views/projects/form/_project_attributes.html.erb
deleted file mode 100644
index 085655b19df..00000000000
--- a/app/views/projects/form/_project_attributes.html.erb
+++ /dev/null
@@ -1,70 +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.
-
-++#%>
-<% all_fields = (render_advanced) ? false : true %>
-
-<%= render partial: "projects/form/attributes/name",
- locals: { form: form } %>
-
-<% if project.new_record? && !is_copy %>
- <%= render partial: "projects/form/select_template",
- locals: { project: project, form: form } %>
-<% end %>
-
-<%= render partial: "customizable/form",
- locals: { form: form, help_text: { 'attribute-scope': :Project }, all_fields: all_fields, only_required: render_advanced } %>
-<% if render_advanced %>
-<fieldset id="advanced-project-settings" class="form--fieldset -collapsible collapsed">
- <legend class="form--fieldset-legend" title="<%=t(:label_show_hide)%>" >
- <a href="#"><%= t(:label_advanced_settings) %></a>
- </legend>
-
- <div style="display:none;" class="advanced-settings-inner">
-<% end %>
- <%= render partial: "projects/form/attributes/parent_id",
- locals: { form: form } %>
- <%= render partial: "projects/form/attributes/description",
- locals: { form: form } %>
- <%= render partial: "projects/form/attributes/public",
- locals: { form: form } %>
- <%= render partial: "projects/form/attributes/status",
- locals: { form: form } %>
- <% unless all_fields %>
- <%= render partial: "customizable/form",
- locals: { form: form, help_text: { 'attribute-scope': :Project }, all_fields: false, only_required: false } %>
- <% end %>
-<% if render_advanced %>
- </div>
-</fieldset>
-<% end %>
-
-<% unless form.object.errors[:identifier].blank? %>
- <%= nonced_javascript_tag do %>
- jQuery('#advanced-project-settings > .advanced-settings-inner').show();
- <% end %>
-<% end %>
diff --git a/app/views/projects/form/_select_template.html.erb b/app/views/projects/form/_select_template.html.erb
deleted file mode 100644
index ada2d0d9d8a..00000000000
--- a/app/views/projects/form/_select_template.html.erb
+++ /dev/null
@@ -1,39 +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.
-
-++#%>
-
-<div class="form--field">
- <%= styled_label_tag 'from_template', t('project.template.use_template') %>
- <div class="form--field-container">
- <%= styled_select_tag :from_template,
- options_for_select(project_options_for_templated, @template_project&.id),
- id: 'project-select-template',
- prompt: "(#{t(:label_none)})",
- container_class: '-wide' %>
- </div>
-</div>
diff --git a/config/routes.rb b/config/routes.rb
index fb7392a7b26..26e634cc847 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -184,7 +184,7 @@ OpenProject::Application.routes.draw do
namespace 'settings' do
ProjectSettingsHelper
.project_settings_tabs
- .select { |s| %w[modules general types custom_fields versions categories repository].include?(s[:name]) }
+ .select { |s| %w[modules general types custom_fields versions categories repository time_entry_activities].include?(s[:name]) }
.each do |tab|
get tab[:name],
controller: tab[:name],
@@ -198,7 +198,7 @@ OpenProject::Application.routes.draw do
ProjectSettingsHelper
.project_settings_tabs
- .reject { |s| %w[modules general types custom_fields versions categories repository].include?(s[:name]) }
+ .reject { |s| %w[modules general types custom_fields versions categories repository time_entry_activities].include?(s[:name]) }
.each do |tab|
get "settings/#{tab[:name]}",
controller: "project_settings/#{tab[:name]}",
@@ -228,8 +228,6 @@ OpenProject::Application.routes.draw do
get :level_list
end
- resource :time_entry_activities, controller: 'projects/time_entry_activities', only: %i[update]
-
resources :versions, only: %i[new create] do
collection do
put :close_completed
diff --git a/modules/costs/app/controllers/projects/time_entry_activities_controller.rb b/modules/costs/app/controllers/projects/settings/time_entry_activities_controller.rb
similarity index 89%
rename from modules/costs/app/controllers/projects/time_entry_activities_controller.rb
rename to modules/costs/app/controllers/projects/settings/time_entry_activities_controller.rb
index 0829fc80c25..e9c536e15cc 100644
--- a/modules/costs/app/controllers/projects/time_entry_activities_controller.rb
+++ b/modules/costs/app/controllers/projects/settings/time_entry_activities_controller.rb
@@ -28,15 +28,14 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-class Projects::TimeEntryActivitiesController < ApplicationController
- before_action :find_project_by_project_id
- before_action :authorize
+class Projects::Settings::TimeEntryActivitiesController < ProjectSettingsController
+ menu_item :settings_time_entry_activities
def update
TimeEntryActivitiesProject.upsert_all(update_params, unique_by: %i[project_id activity_id])
flash[:notice] = t(:notice_successful_update)
- redirect_to settings_activities_project_path(@project)
+ redirect_to time_entry_activities_settings_project_path(@project)
end
private
diff --git a/app/views/projects/form/_activities.html.erb b/modules/costs/app/views/projects/settings/time_entry_activities/_activities.html.erb
similarity index 90%
rename from app/views/projects/form/_activities.html.erb
rename to modules/costs/app/views/projects/settings/time_entry_activities/_activities.html.erb
index c2a4dac662f..e78b5b392f0 100644
--- a/app/views/projects/form/_activities.html.erb
+++ b/modules/costs/app/views/projects/settings/time_entry_activities/_activities.html.erb
@@ -44,8 +44,6 @@ See COPYRIGHT and LICENSE files for more details.
</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 %>
+<div class="generic-table--action-buttons">
+ <%= styled_button_tag t(:button_save), class: '-highlight -with-icon icon-checkmark' %>
+</div>
diff --git a/app/views/project_settings/activities.html.erb b/modules/costs/app/views/projects/settings/time_entry_activities/show.html.erb
similarity index 86%
rename from app/views/project_settings/activities.html.erb
rename to modules/costs/app/views/projects/settings/time_entry_activities/show.html.erb
index a040a4d9399..49b169e4804 100644
--- a/app/views/project_settings/activities.html.erb
+++ b/modules/costs/app/views/projects/settings/time_entry_activities/show.html.erb
@@ -32,10 +32,10 @@ See COPYRIGHT and LICENSE files for more details.
<% if TimeEntryActivity.any? %>
<%= labelled_tabular_form_for @project,
- url: project_time_entry_activities_path(@project),
- method: :put do %>
+ url: time_entry_activities_settings_project_path(@project) do %>
- <%= render partial: 'projects/form/activities', locals: { project: @project, withControlls: true } %>
+ <%= render partial: '/projects/settings/time_entry_activities/activities',
+ locals: { project: @project } %>
<% end %>
<br/>
diff --git a/modules/costs/lib/costs/engine.rb b/modules/costs/lib/costs/engine.rb
index 8bec7e61bf4..e4d62577e09 100644
--- a/modules/costs/lib/costs/engine.rb
+++ b/modules/costs/lib/costs/engine.rb
@@ -60,7 +60,7 @@ module Costs
require: :loggedin
permission :manage_project_activities,
- { 'projects/time_entry_activities': %i[update] },
+ { 'projects/settings/time_entry_activities': %i[show update] },
require: :member
permission :view_own_hourly_rate, {}
permission :view_hourly_rates, {}
diff --git a/modules/costs/spec/features/time_entry/activity_spec.rb b/modules/costs/spec/features/time_entry/activity_spec.rb
index 94c33afd797..1734376a5cb 100644
--- a/modules/costs/spec/features/time_entry/activity_spec.rb
+++ b/modules/costs/spec/features/time_entry/activity_spec.rb
@@ -30,6 +30,7 @@ require 'spec_helper'
describe 'Time entry activity', type: :feature do
shared_let(:admin) { FactoryBot.create :admin }
+ let(:project) { FactoryBot.create(:project) }
before do
login_as(admin)
@@ -48,5 +49,22 @@ describe 'Time entry activity', type: :feature do
expect(page)
.to have_content('A new activity')
+
+ visit general_settings_project_path(project)
+
+ click_on "Time tracking activities"
+
+ expect(page)
+ .to have_field('A new activity', checked: true)
+
+ uncheck 'A new activity'
+
+ click_on 'Save'
+
+ expect(page)
+ .to have_content "Successful update."
+
+ expect(page)
+ .to have_field('A new activity', checked: false)
end
end
diff --git a/spec/routing/project_settings_routing_spec.rb b/spec/routing/project_settings_routing_spec.rb
index a3c8a412e8c..09925901bf9 100644
--- a/spec/routing/project_settings_routing_spec.rb
+++ b/spec/routing/project_settings_routing_spec.rb
@@ -87,9 +87,9 @@ describe ProjectSettingsController, type: :routing do
end
it do
- expect(get('/projects/123/settings/activities'))
+ expect(get('/projects/123/settings/time_entry_activities'))
.to route_to(
- controller: 'project_settings/activities', action: 'show', id: '123'
+ controller: 'projects/settings/time_entry_activities', action: 'show', id: '123'
)
end
diff --git a/spec/routing/projects/time_entry_activities_spec.rb b/spec/routing/projects/time_entry_activities_spec.rb
deleted file mode 100644
index 263e864c09c..00000000000
--- a/spec/routing/projects/time_entry_activities_spec.rb
+++ /dev/null
@@ -1,38 +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.
-#++
-
-require 'spec_helper'
-
-describe 'project/time_entry_activities routes', type: :routing do
- describe 'update' do
- it 'links PUT /projects/:project_id/time_entry_activities' do
- expect(put('/projects/64/time_entry_activities'))
- .to route_to('projects/time_entry_activities#update', project_id: '64')
- end
- end
-end