Skip to content

Commit

Permalink
Merge pull request #15292 from opf/bug/54309-totals-with-0h-should-be…
Browse files Browse the repository at this point in the history
…-visible

[54309] Display total work even when set to 0h
  • Loading branch information
ulferts committed Apr 17, 2024
2 parents 2ece919 + 27ee3ca commit d15b7f9
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { DateDisplayField } from 'core-app/shared/components/fields/display/fiel
import { DateTimeDisplayField } from 'core-app/shared/components/fields/display/field-types/datetime-display-field.module';
import { DaysDurationDisplayField } from 'core-app/shared/components/fields/display/field-types/days-duration-display-field.module';
import { DisplayFieldService } from 'core-app/shared/components/fields/display/display-field.service';
import { EstimatedTimeDisplayField } from 'core-app/shared/components/fields/display/field-types/estimated-time-display-field.module';
import { WorkDisplayField } from 'core-app/shared/components/fields/display/field-types/work-display-field.module';
import { FloatDisplayField } from 'core-app/shared/components/fields/display/field-types/float-display-field.module';
import { FormattableDisplayField } from 'core-app/shared/components/fields/display/field-types/formattable-display-field.module';
import { HighlightedResourceDisplayField } from 'core-app/shared/components/fields/display/field-types/highlighted-resource-display-field.module';
Expand Down Expand Up @@ -75,8 +75,8 @@ export function initializeCoreDisplayFields(displayFieldService:DisplayFieldServ
.addFieldType(MultipleUserFieldModule, 'users', ['[]User'])
.addFieldType(FormattableDisplayField, 'formattable', ['Formattable'])
.addFieldType(DaysDurationDisplayField, 'duration', ['duration'])
.addFieldType(EstimatedTimeDisplayField, 'remainingTime', ['remainingTime'])
.addFieldType(EstimatedTimeDisplayField, 'estimatedTime', ['estimatedTime'])
.addFieldType(WorkDisplayField, 'remainingTime', ['remainingTime'])
.addFieldType(WorkDisplayField, 'estimatedTime', ['estimatedTime'])
.addFieldType(DateDisplayField, 'date', ['Date'])
.addFieldType(DateTimeDisplayField, 'datetime', ['DateTime'])
.addFieldType(BooleanDisplayField, 'boolean', ['Boolean'])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { PathHelperService } from 'core-app/core/path-helper/path-helper.service
import { uiStateLinkClass } from 'core-app/features/work-packages/components/wp-fast-table/builders/ui-state-link-builder';
import { HierarchyQueryLinkHelperService } from 'core-app/shared/components/fields/display/field-types/hierarchy-query-link-helper.service';

export class EstimatedTimeDisplayField extends DisplayField {
export class WorkDisplayField extends DisplayField {
@InjectField() timezoneService:TimezoneService;

@InjectField() PathHelper:PathHelperService;
Expand Down Expand Up @@ -80,7 +80,7 @@ export class EstimatedTimeDisplayField extends DisplayField {
this.renderActual(element, displayText);

const derived = this.derivedValue;
if (derived && this.timezoneService.toHours(derived) !== 0 && this.hasChildren()) {
if (derived && this.hasChildren()) {
this.renderSeparator(element);
this.renderDerived(element, this.derivedValueString);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ import * as URI from 'urijs';
import { TimeEntryCreateService } from 'core-app/shared/components/time_entries/create/create.service';
import { WorkPackageResource } from 'core-app/features/hal/resources/work-package-resource';
import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';
import { EstimatedTimeDisplayField } from 'core-app/shared/components/fields/display/field-types/estimated-time-display-field.module';
import { WorkDisplayField } from 'core-app/shared/components/fields/display/field-types/work-display-field.module';
import * as moment from 'moment-timezone';

export class WorkPackageSpentTimeDisplayField extends EstimatedTimeDisplayField {
export class WorkPackageSpentTimeDisplayField extends WorkDisplayField {
public text = {
linkTitle: this.I18n.t('js.work_packages.message_view_spent_time'),
logTime: this.I18n.t('js.button_log_time'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

require "spec_helper"

RSpec.describe "Estimated hours display", :js do
RSpec.describe "Work display", :js do
shared_let(:project) { create(:project) }
shared_let(:user) { create(:admin) }
shared_let(:wiki_page) { create(:wiki_page, wiki: project.wiki) }
Expand Down Expand Up @@ -58,7 +58,7 @@
login_as(user)
end

shared_examples "estimated time display" do |expected_text:|
shared_examples "work display" do |expected_text:|
it "work package index" do
wp_table.visit_query query
wp_table.expect_work_package_listed child
Expand All @@ -84,14 +84,14 @@
end
end

context "with both work and derived work" do
context "with both work and total work" do
let_work_packages(<<~TABLE)
hierarchy | work |
parent | 1h |
child | 3h |
TABLE

include_examples "estimated time display", expected_text: "1 h·Σ 4 h"
include_examples "work display", expected_text: "1 h·Σ 4 h"
end

context "with just work" do
Expand All @@ -101,47 +101,57 @@
child | 0h |
TABLE

include_examples "estimated time display", expected_text: "1 h"
include_examples "work display", expected_text: "1 h"
end

context "with just derived work with (parent work 0 h)" do
context "with just total work with (parent work 0 h)" do
let_work_packages(<<~TABLE)
hierarchy | work |
parent | 0h |
child | 3h |
TABLE

include_examples "estimated time display", expected_text: "0 h·Σ 3 h"
include_examples "work display", expected_text: "0 h·Σ 3 h"
end

context "with just derived work (parent work unset)" do
context "with just total work (parent work unset)" do
let_work_packages(<<~TABLE)
hierarchy | work |
parent | |
child | 3h |
TABLE

include_examples "estimated time display", expected_text: "-·Σ 3 h"
include_examples "work display", expected_text: "-·Σ 3 h"
end

context "with neither work nor derived work (both 0 h)" do
context "with neither work nor total work (both 0 h)" do
let_work_packages(<<~TABLE)
hierarchy | work |
parent | 0h |
child | 0h |
TABLE

include_examples "estimated time display", expected_text: "0 h"
include_examples "work display", expected_text: "0 h"
end

context "with neither work nor derived work (both unset)" do
context "with just total work being 0h" do
let_work_packages(<<~TABLE)
hierarchy | work |
parent | |
child | 0h |
TABLE

include_examples "work display", expected_text: "-·Σ 0 h"
end

context "with neither work nor total work (both unset)" do
let_work_packages(<<~TABLE)
hierarchy | work |
parent | |
child | |
TABLE

include_examples "estimated time display", expected_text: "-"
include_examples "work display", expected_text: "-"
end

describe "link to detailed view" do
Expand All @@ -155,7 +165,7 @@
other one | 2h |
TABLE

# Run UpdateAncestorsService on the grand child to update the whole hierarchy derived values
# Run UpdateAncestorsService on the grand child to update the whole hierarchy total values
let(:initiator_work_package) { grand_child21 }

it "displays a link to a detailed view explaining work calculation" do
Expand Down

0 comments on commit d15b7f9

Please sign in to comment.