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
Move progress tracking fields in dedicated admin page
Christophe Bliardedc1d1843af5
diff --git a/app/controllers/admin/settings/progress_tracking_controller.rb b/app/controllers/admin/settings/progress_tracking_controller.rbnew file mode 100644index 00000000000..e6687d0afd6--- /dev/null+++ b/app/controllers/admin/settings/progress_tracking_controller.rb@@ -0,0 +1,35 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 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.+#++++module Admin::Settings+ class ProgressTrackingController < ::Admin::SettingsController+ current_menu_item :show do+ :progress_tracking+ end+ end+enddiff --git a/app/views/admin/settings/progress_tracking/show.html.erb b/app/views/admin/settings/progress_tracking/show.html.erbnew file mode 100644index 00000000000..45e7dcb48f0--- /dev/null+++ b/app/views/admin/settings/progress_tracking/show.html.erb@@ -0,0 +1,71 @@+<%#-- copyright+OpenProject is an open source project management software.+Copyright (C) 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.++++#%>++<% html_title t(:label_administration), t(:label_work_package_plural), t(:label_progress_tracking) -%>++<%=+ render Primer::OpenProject::PageHeader.new do |header|+ header.with_title { t(:label_progress_tracking) }+ header.with_breadcrumbs([{ href: admin_index_path, text: t("label_administration") },+ { href: admin_settings_work_packages_general_path, text: t(:label_work_package_plural) },+ t(:label_progress_tracking)])+ end+%>++<%= styled_form_tag({ action: :update }, method: :patch) do %>+ <section class="form--section"+ data-application-target="dynamic"+ data-controller="admin--progress-tracking"+ data-admin--progress-tracking-percent-complete-edition-active-value="<%= OpenProject::FeatureDecisions.percent_complete_edition_active? %>">+ <div class="form--field">+ <%= setting_select :work_package_done_ratio,+ WorkPackage::DONE_RATIO_OPTIONS.collect { |i| [t("setting_work_package_done_ratio_#{i}"), i] },+ container_class: "-middle",+ data: { admin__progress_tracking_target: "progressCalculationModeSelect",+ action: "admin--progress-tracking#displayWarning" } %>+ <div class="form--field-instructions"><%=+ if OpenProject::FeatureDecisions.percent_complete_edition_active?+ t("setting_work_package_done_ratio_explanation_html")+ else+ # This condition branch to be removed in 15.0 with :percent_complete_edition feature flag removal+ t("setting_work_package_done_ratio_explanation_pre_14_4_without_percent_complete_edition_html")+ end+ %></div>+ </div>+ <div class="op-toast -warning -with-bottom-spacing"+ hidden+ data-admin--progress-tracking-target="warningToast">+ <div class="op-toast--content">+ <p data-admin--progress-tracking-target="warningText"></p>+ </div>+ </div>+ </section>++ <%= styled_button_tag t(:button_save), class: "-primary -with-icon icon-checkmark" %>+<% end %>diff --git a/app/views/admin/settings/work_packages_general/show.html.erb b/app/views/admin/settings/work_packages_general/show.html.erbindex 06610ce1712..b0c7d3445a6 100644--- a/app/views/admin/settings/work_packages_general/show.html.erb+++ b/app/views/admin/settings/work_packages_general/show.html.erb@@ -39,28 +39,10 @@ See COPYRIGHT and LICENSE files for more details.%><%= styled_form_tag({ action: :update }, method: :patch) do %>- <section class="form--section"- data-application-target="dynamic"- data-controller="admin--work-packages-settings"- data-admin--work-packages-settings-percent-complete-edition-active-value="<%= OpenProject::FeatureDecisions.percent_complete_edition_active? %>">+ <section class="form--section"><div class="form--field"><%= setting_check_box :cross_project_work_package_relations %></div><div class="form--field"><%= setting_check_box :display_subprojects_work_packages %></div><div class="form--field"><%= setting_check_box :work_package_startdate_is_adddate %></div>- <div class="form--field">- <%= setting_select :work_package_done_ratio,- WorkPackage::DONE_RATIO_OPTIONS.collect { |i| [t("setting_work_package_done_ratio_#{i}"), i] },- container_class: "-middle",- data: { admin__work_packages_settings_target: "progressCalculationModeSelect",- action: "change->admin--work-packages-settings#displayWarning" } %>- <div class="form--field-instructions"><%=- if OpenProject::FeatureDecisions.percent_complete_edition_active?- t("setting_work_package_done_ratio_explanation_html")- else- # This condition branch to be removed in 15.0 with :percent_complete_edition feature flag removal- t("setting_work_package_done_ratio_explanation_pre_14_4_without_percent_complete_edition_html")- end- %></div>- </div><div class="op-toast -warning -with-bottom-spacing"hiddendata-admin--work-packages-settings-target="warningToast">diff --git a/config/initializers/menus.rb b/config/initializers/menus.rbindex 8fbdd3f96f7..b8488ff778c 100644--- a/config/initializers/menus.rb+++ b/config/initializers/menus.rb@@ -323,6 +323,12 @@ Redmine::MenuManager.map :admin_menu do |menu|caption: :label_status,parent: :admin_work_packages+ menu.push :progress_tracking,+ { controller: "/admin/settings/progress_tracking", action: :show },+ if: Proc.new { User.current.admin? },+ caption: :label_progress_tracking,+ parent: :admin_work_packages+menu.push :workflows,{ controller: "/workflows", action: "edit" },if: Proc.new { User.current.admin? },diff --git a/config/locales/en.yml b/config/locales/en.ymlindex a6fdc41e63b..b37a56f6a95 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -2415,6 +2415,7 @@ en:label_product_version: "Product version"label_profile: "Profile"label_percent_complete: "% Complete"+ label_progress_tracking: "Progress tracking"label_project: "Project"label_project_activity: "Project activity"label_project_attribute_plural: "Project attributes"diff --git a/config/routes.rb b/config/routes.rbindex 01071963778..cacfe5afe83 100644--- a/config/routes.rb+++ b/config/routes.rb@@ -491,6 +491,7 @@ Rails.application.routes.draw do# It is important to have this named something else than "work_packages".# Otherwise the angular ui-router will also recognize that as a WorkPackage page and apply according classes.resource :work_packages_general, controller: "/admin/settings/work_packages_general", only: %i[show update]+ resource :progress_tracking, controller: "/admin/settings/progress_tracking", only: %i[show update]resource :projects, controller: "/admin/settings/projects_settings", only: %i[show update]resource :new_project, controller: "/admin/settings/new_project_settings", only: %i[show update]resources :project_custom_fields, controller: "/admin/settings/project_custom_fields" dodiff --git a/frontend/src/stimulus/controllers/dynamic/admin/work-packages-settings.controller.ts b/frontend/src/stimulus/controllers/dynamic/admin/progress-tracking.controller.tssimilarity index 97%rename from frontend/src/stimulus/controllers/dynamic/admin/work-packages-settings.controller.tsrename to frontend/src/stimulus/controllers/dynamic/admin/progress-tracking.controller.tsindex 6dc3e76c235..fcba621f68d 100644--- a/frontend/src/stimulus/controllers/dynamic/admin/work-packages-settings.controller.ts+++ b/frontend/src/stimulus/controllers/dynamic/admin/progress-tracking.controller.ts@@ -30,7 +30,7 @@import { Controller } from '@hotwired/stimulus';-export default class WorkPackagesSettingsController extends Controller {+export default class ProgressTrackingController extends Controller {static values = {percentCompleteEditionActive: Boolean,};diff --git a/spec/controllers/admin/settings/progress_tracking_controller_spec.rb b/spec/controllers/admin/settings/progress_tracking_controller_spec.rbnew file mode 100644index 00000000000..20485f8328b--- /dev/null+++ b/spec/controllers/admin/settings/progress_tracking_controller_spec.rb@@ -0,0 +1,100 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) 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"++RSpec.describe Admin::Settings::ProgressTrackingController do+ shared_let(:user) { create(:admin) }++ current_user { user }++ include_examples "GET #show requires admin permission and renders template", path: "progress_tracking"++ context "when changing progress calculation from work-based to status-based" do+ shared_let(:status) { create(:status, default_done_ratio: 42) }+ shared_let(:work_package) { create(:work_package, status:, done_ratio: 10, estimated_hours: 100) }++ before do+ Setting.work_package_done_ratio = "field"+ end++ it "starts a job to update work packages % complete and remaining work values" do+ patch "update",+ params: {+ settings: {+ work_package_done_ratio: "status"+ }+ }+ expect(Setting.work_package_done_ratio).to eq("status")+ expect(WorkPackages::Progress::ApplyStatusesChangeJob)+ .to have_been_enqueued.with(cause_type: "progress_mode_changed_to_status_based")++ perform_enqueued_jobs++ expect(work_package.reload.read_attribute(:done_ratio)).to eq(status.default_done_ratio)+ expect(work_package.last_journal.details["cause"]).to eq([nil, { "type" => "progress_mode_changed_to_status_based" }])+ end+ end++ context "when sending path request to change progress calculation from status-based to status-based" do+ before do+ Setting.work_package_done_ratio = "status"+ end++ it "does not start a job" do+ patch "update",+ params: {+ settings: {+ work_package_done_ratio: "status"+ }+ }+ expect(WorkPackages::Progress::ApplyStatusesChangeJob)+ .not_to have_been_enqueued+ end+ end++ context "when changing progress calculation from status-based to work-based" do+ before do+ Setting.work_package_done_ratio = "status"+ end++ it "does not start a job" do+ patch "update",+ params: {+ settings: {+ work_package_done_ratio: "field"+ }+ }+ expect(WorkPackages::Progress::ApplyStatusesChangeJob)+ .not_to have_been_enqueued+ end+ end+enddiff --git a/spec/controllers/admin/settings/work_packages_general_controller_spec.rb b/spec/controllers/admin/settings/work_packages_general_controller_spec.rbindex fb2d97be5df..a15fd3d4f57 100644--- a/spec/controllers/admin/settings/work_packages_general_controller_spec.rb+++ b/spec/controllers/admin/settings/work_packages_general_controller_spec.rb@@ -37,64 +37,4 @@ RSpec.describe Admin::Settings::WorkPackagesGeneralController docurrent_user { user }include_examples "GET #show requires admin permission and renders template", path: "work_packages_general"-- context "when changing progress calculation from work-based to status-based" do- shared_let(:status) { create(:status, default_done_ratio: 42) }- shared_let(:work_package) { create(:work_package, status:, done_ratio: 10, estimated_hours: 100) }-- before do- Setting.work_package_done_ratio = "field"- end-- it "starts a job to update work packages % complete and remaining work values" do- patch "update",- params: {- settings: {- work_package_done_ratio: "status"- }- }- expect(Setting.work_package_done_ratio).to eq("status")- expect(WorkPackages::Progress::ApplyStatusesChangeJob)- .to have_been_enqueued.with(cause_type: "progress_mode_changed_to_status_based")-- perform_enqueued_jobs-- expect(work_package.reload.read_attribute(:done_ratio)).to eq(status.default_done_ratio)- expect(work_package.last_journal.details["cause"]).to eq([nil, { "type" => "progress_mode_changed_to_status_based" }])- end- end-- context "when sending path request to change progress calculation from status-based to status-based" do- before do- Setting.work_package_done_ratio = "status"- end-- it "does not start a job" do- patch "update",- params: {- settings: {- work_package_done_ratio: "status"- }- }- expect(WorkPackages::Progress::ApplyStatusesChangeJob)- .not_to have_been_enqueued- end- end-- context "when changing progress calculation from status-based to work-based" do- before do- Setting.work_package_done_ratio = "status"- end-- it "does not start a job" do- patch "update",- params: {- settings: {- work_package_done_ratio: "field"- }- }- expect(WorkPackages::Progress::ApplyStatusesChangeJob)- .not_to have_been_enqueued- end- endend