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
[50959] Display both self and derived value for duration time fields
Christophe Bliard9df1ef1250ae
diff --git a/frontend/src/app/shared/components/fields/display/field-types/estimated-time-display-field.module.ts b/frontend/src/app/shared/components/fields/display/field-types/estimated-time-display-field.module.tsindex 15a2f0716e4..8890c39a8cf 100644--- a/frontend/src/app/shared/components/fields/display/field-types/estimated-time-display-field.module.ts+++ b/frontend/src/app/shared/components/fields/display/field-types/estimated-time-display-field.module.ts@@ -36,7 +36,7 @@ export class EstimatedTimeDisplayField extends DisplayField {private derivedText = this.I18n.t('js.label_value_derived_from_children');public get valueString():string {- return this.timezoneService.formattedDuration(this.value);+ return this.timezoneService.formattedDuration(this.value as string);}/**@@ -67,38 +67,43 @@ export class EstimatedTimeDisplayField extends DisplayField {}element.classList.add('split-time-field');- if (this.value) {- this.renderActual(element, displayText);- }+ this.renderActual(element, displayText);const derived = this.derivedValue;if (derived && this.timezoneService.toHours(derived) !== 0) {- this.renderDerived(element, this.derivedValueString, !!this.value);+ this.renderSeparator(element);+ this.renderDerived(element, this.derivedValueString);}}public renderActual(element:HTMLElement, displayText:string):void {const span = document.createElement('span');- span.textContent = displayText;- span.title = this.valueString;+ if (this.value) {+ span.textContent = displayText;+ span.title = this.valueString;+ } else {+ span.textContent = this.texts.placeholder;+ span.title = this.texts.placeholder;+ }span.classList.add('-actual-value');element.appendChild(span);}- public renderDerived(element:HTMLElement, displayText:string, actualPresent:boolean):void {+ public renderSeparator(element:HTMLElement) {+ const span = document.createElement('span');+ span.classList.add('-separator');+ element.appendChild(span);+ }++ public renderDerived(element:HTMLElement, displayText:string):void {const span = document.createElement('span');- span.setAttribute('title', this.texts.empty);- span.textContent = `(${actualPresent ? '+' : ''}${displayText})`;+ span.textContent = `Σ ${displayText}`;span.title = `${this.derivedValueString} ${this.derivedText}`;span.classList.add('-derived-value');- if (actualPresent) {- span.classList.add('-with-actual-value');- }-element.appendChild(span);}diff --git a/frontend/src/global_styles/content/work_packages/inplace_editing/_display_fields.sass b/frontend/src/global_styles/content/work_packages/inplace_editing/_display_fields.sassindex 9bba47ace6e..c37330a3e60 100644--- a/frontend/src/global_styles/content/work_packages/inplace_editing/_display_fields.sass+++ b/frontend/src/global_styles/content/work_packages/inplace_editing/_display_fields.sass@@ -28,11 +28,11 @@@mixin wp-table--time-valuesdisplay: inline-block- width: 48%+ width: calc(50% - 0.5rem)@mixin wp-table--actual-time-valuestext-align: right- padding-right: 0.5rem+ padding-right: 0.25rem@mixin wp-table--placeholder-time-valuesdisplay: inline-block@@ -82,15 +82,17 @@.-derived-value@include wp-table--time-values- .-derived-value:not(.-with-actual-value)- margin-left: 48%-.-actual-value@include wp-table--actual-time-values+ .-separator+ padding-right: 0.25rem++ .-separator::before+ content: "·"+.-derived-valuecolor: var(--color-fg-muted)- font-style: italicfont-weight: var(--base-text-weight-bold)&.spentTime .time-logging--valuediff --git a/spec/features/work_packages/display_fields/estimated_hours_display_spec.rb b/spec/features/work_packages/display_fields/estimated_hours_display_spec.rbindex 14fb0f2a6e4..9e52145ee4d 100644--- a/spec/features/work_packages/display_fields/estimated_hours_display_spec.rb+++ b/spec/features/work_packages/display_fields/estimated_hours_display_spec.rb@@ -82,14 +82,14 @@ RSpec.describe 'Estimated hours display' dowp_table.expect_work_package_listed childwp_table.expect_work_package_with_attributes(- parent, estimatedTime: "1 h(+3 h)"+ parent, estimatedTime: "1 hΣ 3 h")endit 'work package details', :js dovisit work_package_path(parent.id)- expect(page).to have_content("Work\n1 h(+3 h)")+ expect(page).to have_content("Work\n1 hΣ 3 h")endend@@ -120,7 +120,7 @@ RSpec.describe 'Estimated hours display' doendend- context "with just derived work" do+ context "with just derived work with (parent work 0 h)" dolet(:hierarchy) do[{@@ -136,18 +136,45 @@ RSpec.describe 'Estimated hours display' dowp_table.expect_work_package_listed childwp_table.expect_work_package_with_attributes(- parent, subject: parent.subject, estimatedTime: "0 h(+3 h)"+ parent, subject: parent.subject, estimatedTime: "0 hΣ 3 h")endit 'work package details', :js dovisit work_package_path(parent.id)- expect(page).to have_content("Work\n0 h(+3 h)")+ expect(page).to have_content("Work\n0 hΣ 3 h")endend- context "with neither work nor derived work" do+ context "with just derived work (parent work unset)" do+ let(:hierarchy) do+ [+ {+ ["Parent", nil] => [+ ["Child", 3]+ ]+ }+ ]+ end++ it 'work package index', :js do+ wp_table.visit_query query+ wp_table.expect_work_package_listed child++ wp_table.expect_work_package_with_attributes(+ parent, subject: parent.subject, estimatedTime: "-Σ 3 h"+ )+ end++ it 'work package details', :js do+ visit work_package_path(parent.id)++ expect(page).to have_content("Work\n-Σ 3 h")+ end+ end++ context "with neither work nor derived work (both 0 h)" dolet(:hierarchy) do[{@@ -173,4 +200,31 @@ RSpec.describe 'Estimated hours display' doexpect(page).to have_content("Work\n0 h")endend++ context "with neither work nor derived work (both unset)" do+ let(:hierarchy) do+ [+ {+ ["Parent", nil] => [+ ["Child", nil]+ ]+ }+ ]+ end++ it 'work package index', :js do+ wp_table.visit_query query+ wp_table.expect_work_package_listed child++ wp_table.expect_work_package_with_attributes(+ parent, subject: parent.subject, estimatedTime: "-"+ )+ end++ it 'work package details', :js do+ visit work_package_path(parent.id)++ expect(page).to have_content("Work\n-")+ end+ endend