Skip to content

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

[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.ts
index 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.sass
index 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-values
display: inline-block
- width: 48%
+ width: calc(50% - 0.5rem)
@mixin wp-table--actual-time-values
text-align: right
- padding-right: 0.5rem
+ padding-right: 0.25rem
@mixin wp-table--placeholder-time-values
display: 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-value
color: var(--color-fg-muted)
- font-style: italic
font-weight: var(--base-text-weight-bold)
&.spentTime .time-logging--value
diff --git a/spec/features/work_packages/display_fields/estimated_hours_display_spec.rb b/spec/features/work_packages/display_fields/estimated_hours_display_spec.rb
index 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' do
wp_table.expect_work_package_listed child
wp_table.expect_work_package_with_attributes(
- parent, estimatedTime: "1 h(+3 h)"
+ parent, estimatedTime: "1 hΣ 3 h"
)
end
it 'work package details', :js do
visit 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")
end
end
@@ -120,7 +120,7 @@ RSpec.describe 'Estimated hours display' do
end
end
- context "with just derived work" do
+ context "with just derived work with (parent work 0 h)" do
let(:hierarchy) do
[
{
@@ -136,18 +136,45 @@ RSpec.describe 'Estimated hours display' do
wp_table.expect_work_package_listed child
wp_table.expect_work_package_with_attributes(
- parent, subject: parent.subject, estimatedTime: "0 h(+3 h)"
+ parent, subject: parent.subject, estimatedTime: "0 hΣ 3 h"
)
end
it 'work package details', :js do
visit 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")
end
end
- 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)" do
let(:hierarchy) do
[
{
@@ -173,4 +200,31 @@ RSpec.describe 'Estimated hours display' do
expect(page).to have_content("Work\n0 h")
end
end
+
+ 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
+ end
end