From e2f7ce39a9b6b3f1da7253f4c0e4dfbf91f917e4 Mon Sep 17 00:00:00 2001 From: Aaron Contreras Date: Wed, 4 Sep 2024 07:07:53 -0500 Subject: [PATCH 1/5] Change menu entry name from "Work packages settings" to "General" --- .../admin/settings/work_packages_settings_controller.rb | 2 +- config/initializers/menus.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/admin/settings/work_packages_settings_controller.rb b/app/controllers/admin/settings/work_packages_settings_controller.rb index d2f1f369f00f..6d14aa4cd8c1 100644 --- a/app/controllers/admin/settings/work_packages_settings_controller.rb +++ b/app/controllers/admin/settings/work_packages_settings_controller.rb @@ -29,7 +29,7 @@ module Admin::Settings class WorkPackagesSettingsController < ::Admin::SettingsController current_menu_item :show do - :work_packages_setting + :admin_work_packages_general end end end diff --git a/config/initializers/menus.rb b/config/initializers/menus.rb index 8800c3d6a770..7dc8c1e27823 100644 --- a/config/initializers/menus.rb +++ b/config/initializers/menus.rb @@ -305,10 +305,10 @@ caption: :label_work_package_plural, icon: "op-view-list" - menu.push :work_packages_setting, + menu.push :admin_work_packages_general, { controller: "/admin/settings/work_packages_settings", action: :show }, if: Proc.new { User.current.admin? }, - caption: :label_work_packages_settings, + caption: :label_general, parent: :admin_work_packages menu.push :types, From a004bc7dbb6cf3d8c03e93b6d2ddfba34a8326d8 Mon Sep 17 00:00:00 2001 From: Aaron Contreras Date: Wed, 4 Sep 2024 07:10:12 -0500 Subject: [PATCH 2/5] Rename headings and breadcrumbs from "Work packages settings" to "General" --- .../settings/work_packages_settings/show.html.erb | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/app/views/admin/settings/work_packages_settings/show.html.erb b/app/views/admin/settings/work_packages_settings/show.html.erb index 24865fffc3c2..7c04646bfc9f 100644 --- a/app/views/admin/settings/work_packages_settings/show.html.erb +++ b/app/views/admin/settings/work_packages_settings/show.html.erb @@ -26,18 +26,15 @@ 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_packages_settings) -%> - +<% html_title t(:label_administration), t(:label_general) -%> <%= render Primer::OpenProject::PageHeader.new do |header| - header.with_title { t(:label_work_packages_settings) } + header.with_title { t(:label_general) } header.with_breadcrumbs([{ href: admin_index_path, text: t("label_administration") }, { href: admin_settings_work_package_tracking_path, text: t(:label_work_package_plural) }, - t(:label_work_packages_settings)]) + t(:label_general)]) end %> - <%= styled_form_tag({ action: :update }, method: :patch) do %>
<% end %>
-
<%= t(:setting_column_options) %> -
@@ -120,6 +115,5 @@ See COPYRIGHT and LICENSE files for more details.
- <%= styled_button_tag t(:button_save), class: "-primary -with-icon icon-checkmark" %> <% end %> From f290f6fe7391da06d6f5d11bef8b621b26404745 Mon Sep 17 00:00:00 2001 From: Aaron Contreras Date: Wed, 4 Sep 2024 08:49:17 -0500 Subject: [PATCH 3/5] Add new menu entry for "Progress tracking" settings --- .../progress_tracking_settings_controller.rb | 35 ++++++++++++++++ .../progress_tracking_settings/show.html.erb | 1 + config/initializers/menus.rb | 6 +++ config/locales/en.yml | 1 + config/routes.rb | 1 + .../progress_tracking_settings_spec.rb | 40 +++++++++++++++++++ 6 files changed, 84 insertions(+) create mode 100644 app/controllers/admin/settings/progress_tracking_settings_controller.rb create mode 100644 app/views/admin/settings/progress_tracking_settings/show.html.erb create mode 100644 spec/routing/admin/settings/progress_tracking_settings_spec.rb diff --git a/app/controllers/admin/settings/progress_tracking_settings_controller.rb b/app/controllers/admin/settings/progress_tracking_settings_controller.rb new file mode 100644 index 000000000000..8f6bc5234692 --- /dev/null +++ b/app/controllers/admin/settings/progress_tracking_settings_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 ProgressTrackingSettingsController < ::Admin::SettingsController + current_menu_item :show do + :progress_tracking + end + end +end diff --git a/app/views/admin/settings/progress_tracking_settings/show.html.erb b/app/views/admin/settings/progress_tracking_settings/show.html.erb new file mode 100644 index 000000000000..077a427a43bf --- /dev/null +++ b/app/views/admin/settings/progress_tracking_settings/show.html.erb @@ -0,0 +1 @@ +

Hello

\ No newline at end of file diff --git a/config/initializers/menus.rb b/config/initializers/menus.rb index 7dc8c1e27823..c42fdfa6ad18 100644 --- a/config/initializers/menus.rb +++ b/config/initializers/menus.rb @@ -324,6 +324,12 @@ parent: :admin_work_packages, html: { class: "statuses" } + menu.push :progress_tracking, + { controller: "/admin/settings/progress_tracking_settings", action: :show }, + if: Proc.new { OpenProject::FeatureDecisions.percent_complete_edition_active? && 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.yml index b44c77f5cdcf..9ebd02e63a14 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.rb index 599deee6f166..b1a48744c9fa 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -491,6 +491,7 @@ # 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_package_tracking, controller: "/admin/settings/work_packages_settings", only: %i[show update] + resource :progress_tracking, controller: "/admin/settings/progress_tracking_settings", 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" do diff --git a/spec/routing/admin/settings/progress_tracking_settings_spec.rb b/spec/routing/admin/settings/progress_tracking_settings_spec.rb new file mode 100644 index 000000000000..98fd52bbf741 --- /dev/null +++ b/spec/routing/admin/settings/progress_tracking_settings_spec.rb @@ -0,0 +1,40 @@ +#-- 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 "progress_tracking_settings routing" do + it do + expect(get: "/admin/settings/progress_tracking") + .to route_to(controller: "admin/settings/progress_tracking_settings", action: "show") + end + + it do + expect(patch: "/admin/settings/progress_tracking") + .to route_to(controller: "admin/settings/progress_tracking_settings", action: "update") + end +end From 029934057fcf4c987ee5f0d7315ea1ce3d9bc76e Mon Sep 17 00:00:00 2001 From: Aaron Contreras Date: Thu, 5 Sep 2024 06:54:48 -0500 Subject: [PATCH 4/5] Add PageHeader + Breadcrumb --- .../progress_tracking_settings/show.html.erb | 38 ++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/app/views/admin/settings/progress_tracking_settings/show.html.erb b/app/views/admin/settings/progress_tracking_settings/show.html.erb index 077a427a43bf..9e8e4d32cfd6 100644 --- a/app/views/admin/settings/progress_tracking_settings/show.html.erb +++ b/app/views/admin/settings/progress_tracking_settings/show.html.erb @@ -1 +1,37 @@ -

Hello

\ No newline at end of file +<%#-- 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_progress_tracking) -%> +<%= + render(Primer::OpenProject::PageHeader.new) do |header| + header.with_title(test_selector: "op-progress-tracking-admin-settings--title") { t(:label_progress_tracking) } + header.with_breadcrumbs([{ href: admin_index_path, text: t("label_administration") }, + { href: admin_settings_work_package_tracking_path, text: t(:label_work_package_plural) }, + t(:label_progress_tracking)]) + end +%> From f4aabd13fe70de3ed44ed79e82934a0de35af9c9 Mon Sep 17 00:00:00 2001 From: Aaron Contreras Date: Thu, 5 Sep 2024 09:16:09 -0500 Subject: [PATCH 5/5] Add "Progress calculation mode" section to Progress Tracking settings --- .../progress_tracking_settings_form.rb | 28 +++++++++++++++++++ app/models/work_package.rb | 4 ++- .../progress_tracking_settings/show.html.erb | 6 ++++ config/locales/en.yml | 9 ++++++ 4 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 app/forms/admin/settings/progress_tracking_settings_form.rb diff --git a/app/forms/admin/settings/progress_tracking_settings_form.rb b/app/forms/admin/settings/progress_tracking_settings_form.rb new file mode 100644 index 000000000000..10d8e42c6b7d --- /dev/null +++ b/app/forms/admin/settings/progress_tracking_settings_form.rb @@ -0,0 +1,28 @@ +class Admin::Settings::ProgressTrackingSettingsForm < ApplicationForm + attr_reader :i18n_scope + + def initialize + super + @i18n_scope = "admin.settings.progress_tracking_settings_form" + end + + form do |form_element| + form_element.radio_button_group( + name: "settings[work_package_done_ratio]", + label: I18n.t("#{i18n_scope}.progress_calculation_section.group_label") + ) do |group| + group.radio_button(label: I18n.t(:label_work_based), + value: WorkPackage::DONE_RATIO_FIELD_OPTION, + checked: WorkPackage.use_field_for_done_ratio?, + caption: I18n.t("#{i18n_scope}.progress_calculation_section.work_based_caption")) + group.radio_button(label: I18n.t(:label_status_based), + value: WorkPackage::DONE_RATIO_STATUS_OPTION, + checked: WorkPackage.use_status_for_done_ratio?, + caption: I18n.t("#{i18n_scope}.progress_calculation_section.status_based_caption")) + end + + form_element.submit(scheme: :primary, + name: :submit, + label: I18n.t(:button_save)) + end +end diff --git a/app/models/work_package.rb b/app/models/work_package.rb index f7aef89f0ea3..68ff318698a4 100644 --- a/app/models/work_package.rb +++ b/app/models/work_package.rb @@ -44,7 +44,9 @@ class WorkPackage < ApplicationRecord include OpenProject::Journal::AttachmentHelper - DONE_RATIO_OPTIONS = %w[field status].freeze + DONE_RATIO_FIELD_OPTION = "field".freeze + DONE_RATIO_STATUS_OPTION = "status".freeze + DONE_RATIO_OPTIONS = [DONE_RATIO_FIELD_OPTION, DONE_RATIO_STATUS_OPTION].freeze belongs_to :project belongs_to :type diff --git a/app/views/admin/settings/progress_tracking_settings/show.html.erb b/app/views/admin/settings/progress_tracking_settings/show.html.erb index 9e8e4d32cfd6..52d22d4a8f8f 100644 --- a/app/views/admin/settings/progress_tracking_settings/show.html.erb +++ b/app/views/admin/settings/progress_tracking_settings/show.html.erb @@ -35,3 +35,9 @@ See COPYRIGHT and LICENSE files for more details. t(:label_progress_tracking)]) end %> +<%= primer_form_with( + url: admin_settings_progress_tracking_path, + method: :patch, +) do |f| %> + <%= render(Admin::Settings::ProgressTrackingSettingsForm.new(f)) %> +<% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 9ebd02e63a14..bd554dd9aefb 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1300,6 +1300,13 @@ en: wiki_edit: "Wiki" work_package: "Work packages" + admin: + settings: + progress_tracking_settings_form: + progress_calculation_section: + group_label: "Progress calculation mode" + work_based_caption: "% Complete can be freely set to any value. If you optionally enter a value for Work, Remaining work will automatically be derived." + status_based_caption: "Each status has a % Complete value associated with it. Changing status will change % Complete." # common attributes of all models attributes: active: "Active" @@ -2508,6 +2515,7 @@ en: label_start_to_start: "start to start" label_statistics: "Statistics" label_status: "Status" + label_status_based: "Status-based" label_storage_free_space: "Remaining disk space" label_storage_used_space: "Used disk space" label_storage_group: "Storage filesystem %{identifier}" @@ -2593,6 +2601,7 @@ en: label_wiki_show_submenu_item: "Show as submenu item of " label_wiki_start: "Start page" label_work: "Work" + label_work_based: "Work-based" label_work_package: "Work package" label_work_package_attachments: "Work package attachments" label_work_package_category_new: "New category"