From 479cb7c3d57ffd16486141c696c8077051cdbcb3 Mon Sep 17 00:00:00 2001 From: Christophe Bliard Date: Wed, 17 Apr 2024 15:35:03 +0200 Subject: [PATCH] [54308] Make rounding consistent with 2 decimals in progress modal See https://community.openproject.org/wp/54308 2 decimals is what is used by default everywhere else. --- .../field-types/progress-popover-edit-field.component.ts | 3 +-- spec/features/work_packages/progress_modal_spec.rb | 8 ++++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/frontend/src/app/shared/components/fields/edit/field-types/progress-popover-edit-field.component.ts b/frontend/src/app/shared/components/fields/edit/field-types/progress-popover-edit-field.component.ts index 38f71e1808a1..5c320d54c051 100644 --- a/frontend/src/app/shared/components/fields/edit/field-types/progress-popover-edit-field.component.ts +++ b/frontend/src/app/shared/components/fields/edit/field-types/progress-popover-edit-field.component.ts @@ -58,7 +58,6 @@ import { HalEventsService } from 'core-app/features/hal/services/hal-events.serv import { WorkPackageResource } from 'core-app/features/hal/resources/work-package-resource'; import { ToastService } from 'core-app/shared/components/toaster/toast.service'; import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service'; -import * as moment from 'moment/moment'; import { TimezoneService } from 'core-app/core/datetime/timezone.service'; @Component({ @@ -137,7 +136,7 @@ export class ProgressPopoverEditFieldComponent extends ProgressEditFieldComponen if (value === null) { return ''; } - return moment.duration(value).asHours().toFixed(1); + return `${this.timezoneService.toHours(value)}`; } public statusFormatter(value:null|string):string { diff --git a/spec/features/work_packages/progress_modal_spec.rb b/spec/features/work_packages/progress_modal_spec.rb index a8e198cbff9d..a46fbc63b6bf 100644 --- a/spec/features/work_packages/progress_modal_spec.rb +++ b/spec/features/work_packages/progress_modal_spec.rb @@ -315,10 +315,10 @@ def update_work_package_with(work_package, attributes) describe "field value format" do context "with all values set" do - before { update_work_package_with(work_package, estimated_hours: 10.0, remaining_hours: 2.5) } + before { update_work_package_with(work_package, estimated_hours: 10.0, remaining_hours: 2.543) } it "populates fields with correctly values formatted " \ - "with the minimum fractional part if present" do + "with the minimum fractional part if present, and 2 decimals max" do work_package_table.visit_query(progress_query) work_package_table.expect_work_package_listed(work_package) @@ -329,8 +329,8 @@ def update_work_package_with(work_package, attributes) work_edit_field.activate! work_edit_field.expect_modal_field_value("10") - remaining_work_edit_field.expect_modal_field_value("2.5") - percent_complete_edit_field.expect_modal_field_value("75", readonly: true) + remaining_work_edit_field.expect_modal_field_value("2.54") + percent_complete_edit_field.expect_modal_field_value("74", readonly: true) end end