Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#56363] Add options for the mode in which totals are summed #16628

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
28 changes: 28 additions & 0 deletions app/forms/admin/settings/progress_tracking_settings_form.rb
Original file line number Diff line number Diff line change
@@ -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
4 changes: 3 additions & 1 deletion app/models/work_package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
43 changes: 43 additions & 0 deletions app/views/admin/settings/progress_tracking_settings/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<%#-- 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
%>
<%= primer_form_with(
url: admin_settings_progress_tracking_path,
method: :patch,
) do |f| %>
<%= render(Admin::Settings::ProgressTrackingSettingsForm.new(f)) %>
<% end %>
12 changes: 3 additions & 9 deletions app/views/admin/settings/work_packages_settings/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
<section class="form--section"
data-application-target="dynamic"
Expand Down Expand Up @@ -96,11 +93,9 @@ See COPYRIGHT and LICENSE files for more details.
</div>
<% end %>
</section>

<section class="form--section">
<fieldset class="form--fieldset">
<legend class="form--fieldset-legend"><%= t(:setting_column_options) %></legend>

<div class="form--field -full-width">
<div class="form--field-container">
<div class="form--text-field-container -xwide">
Expand All @@ -120,6 +115,5 @@ See COPYRIGHT and LICENSE files for more details.
</div>
</fieldset>
</section>

<%= styled_button_tag t(:button_save), class: "-primary -with-icon icon-checkmark" %>
<% end %>
10 changes: 8 additions & 2 deletions config/initializers/menus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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? },
Expand Down
10 changes: 10 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -2415,6 +2422,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"
Expand Down Expand Up @@ -2507,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}"
Expand Down Expand Up @@ -2592,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"
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
40 changes: 40 additions & 0 deletions spec/routing/admin/settings/progress_tracking_settings_spec.rb
Original file line number Diff line number Diff line change
@@ -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
Loading