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
[55467] Warn about potential data loss when changing progress modes
Christophe Bliard7356ddfcf380
diff --git a/app/views/admin/settings/work_packages_settings/show.html.erb b/app/views/admin/settings/work_packages_settings/show.html.erbindex 0151e41e51f..dd76fbf955a 100644--- a/app/views/admin/settings/work_packages_settings/show.html.erb+++ b/app/views/admin/settings/work_packages_settings/show.html.erb@@ -32,16 +32,29 @@ See COPYRIGHT and LICENSE files for more details.<%= toolbar title: t(:label_work_package_tracking) %><%= styled_form_tag({ action: :update }, method: :patch) do %>- <section class="form--section">+ <section class="form--section"+ data-application-target="dynamic"+ data-controller="admin--work-packages-settings"><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" %>+ container_class: "-middle",+ data: { admin__work_packages_settings_target: "progressCalculationModeSelect",+ action: "change->admin--work-packages-settings#displayWarning" } %><div class="form--field-instructions"><%= t("setting_work_package_done_ratio_explanation_html") %></div></div>+ <div class="op-toast -warning -with-bottom-spacing"+ hidden+ data-admin--work-packages-settings-target="warningToast">+ <div class="op-toast--content">+ <p data-admin--work-packages-settings-target="warningText">+ Changing progress calculation mode from work-based is dangerous! Take this!+ </p>+ </div>+ </div><div class="form--field settings--highlighting-mode"><%= setting_select(:work_package_list_default_highlighting_mode,Query::Highlighting::QUERY_HIGHLIGHTING_MODES.map do |mode|diff --git a/app/views/admin/settings/working_days_and_hours_settings/show.html.erb b/app/views/admin/settings/working_days_and_hours_settings/show.html.erbindex 29bf4690feb..26e2c8552c9 100644--- a/app/views/admin/settings/working_days_and_hours_settings/show.html.erb+++ b/app/views/admin/settings/working_days_and_hours_settings/show.html.erb@@ -70,14 +70,13 @@ See COPYRIGHT and LICENSE files for more details.<section class="form--section"><fieldset class="form--fieldset"><legend class="form--fieldset-legend"><%= t('settings.working_days.section_work_week') %></legend>- <div class="op-toast -warning">+ <div class="op-toast -warning -with-bottom-spacing"><div class="op-toast--content"><p><%= t("working_days.warning") %></p></div></div>- <p><p><%= t("working_days.info") %></p>diff --git a/config/locales/js-en.yml b/config/locales/js-en.ymlindex a5cd566e1bd..bc65a24cc3a 100644--- a/config/locales/js-en.yml+++ b/config/locales/js-en.yml@@ -303,6 +303,19 @@ en:Are you sure you want to continue?++ work_packages_settings:+ warning_progress_calculation_mode_change_from_status_to_field_html: >-+ Changing progress calculation mode from status-based to work-based will make+ <i>% Complete</i> a non-editable field whose value is derived from <i>Work</i>+ and <i>Remaining work</i>. Existing values for <i>% Complete</i> are preserved.+ If values for <i>Work</i> and <i>Remaining work</i> were not present, they+ will be required in order to change <i>% Complete</i>.+ warning_progress_calculation_mode_change_from_field_to_status_html: >-+ Changing progress calculation mode from work-based to status-based will result+ in all existing <i>% Complete</i> values to be lost and replaced with values+ associated with each status. Existing values for <i>Remaining work</i> may+ also be recalculated to reflect this change. This action is not reversible.custom_actions:date:specific: "on"diff --git a/frontend/src/stimulus/controllers/dynamic/admin/work-packages-settings.controller.ts b/frontend/src/stimulus/controllers/dynamic/admin/work-packages-settings.controller.tsnew file mode 100644index 00000000000..f805ff85473--- /dev/null+++ b/frontend/src/stimulus/controllers/dynamic/admin/work-packages-settings.controller.ts@@ -0,0 +1,69 @@+/*+ * -- copyright+ * OpenProject is an open source project management software.+ * Copyright (C) 2023 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.+ * +++ */++import { Controller } from '@hotwired/stimulus';++/*+ * Helps keep daysPerWeek and daysPerMonth in-line with each other+ */+export default class WorkPackagesSettingsController extends Controller {+ static targets = [+ 'progressCalculationModeSelect',+ 'warningText',+ 'warningToast',+ ];++ declare readonly progressCalculationModeSelectTarget:HTMLSelectElement;+ declare readonly warningTextTarget:HTMLElement;+ declare readonly warningToastTarget:HTMLElement;+ private initialMode:string;++ connect() {+ this.initialMode = this.progressCalculationModeSelectTarget.value;+ }++ displayWarning() {+ const warningMessageHtml = this.getWarningMessageHtml();+ if (warningMessageHtml) {+ this.warningTextTarget.innerHTML = warningMessageHtml;+ this.warningToastTarget.hidden = false;+ } else {+ this.warningToastTarget.hidden = true;+ }+ }++ getWarningMessageHtml():string {+ const newMode = this.progressCalculationModeSelectTarget.value;+ return I18n.t(+ `js.admin.work_packages_settings.warning_progress_calculation_mode_change_from_${this.initialMode}_to_${newMode}_html`,+ { defaultValue: '' },+ );+ }+}diff --git a/frontend/src/stimulus/controllers/op-application.controller.ts b/frontend/src/stimulus/controllers/op-application.controller.tsindex 375065e3e90..e1234cc820e 100644--- a/frontend/src/stimulus/controllers/op-application.controller.ts+++ b/frontend/src/stimulus/controllers/op-application.controller.ts@@ -26,7 +26,7 @@ export class OpApplicationController extends ApplicationController {/*** Derive dynamic path from controller name.*- * Stimlus conventions allow subdirectories to be used by double dashes.+ * Stimulus conventions allow subdirectories to be used by double dashes.* We convert these to slashes for the dynamic import.** https://stimulus.hotwired.dev/handbook/installing#controller-filenames-map-to-identifiers