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

[33457] Date fields of closed work packages are highlighted red (#8446)

Behrokh Satarnejad5256e8c5252b
diff --git a/frontend/src/app/modules/fields/display/field-types/date-display-field.module.ts b/frontend/src/app/modules/fields/display/field-types/date-display-field.module.ts
index 00411bfcf93..0052d34e1f4 100644
--- a/frontend/src/app/modules/fields/display/field-types/date-display-field.module.ts
+++ b/frontend/src/app/modules/fields/display/field-types/date-display-field.module.ts
@@ -30,9 +30,11 @@ import {TimezoneService} from 'core-components/datetime/timezone.service';
import {Highlighting} from "core-components/wp-fast-table/builders/highlighting/highlighting.functions";
import {HighlightableDisplayField} from "core-app/modules/fields/display/field-types/highlightable-display-field.module";
import {InjectField} from "core-app/helpers/angular/inject-field.decorator";
+import {StatusCacheService} from "core-components/statuses/status-cache.service";
export class DateDisplayField extends HighlightableDisplayField {
@InjectField() timezoneService:TimezoneService;
+ @InjectField() statusCache:StatusCacheService;
public render(element:HTMLElement, displayText:string):void {
super.render(element, displayText);
@@ -49,7 +51,12 @@ export class DateDisplayField extends HighlightableDisplayField {
// Highlight overdue tasks
if (this.shouldHighlight && this.canOverdue) {
const diff = this.timezoneService.daysFromToday(this.value);
- element.classList.add(Highlighting.overdueDate(diff));
+
+ this.statusCache.require(this.resource.status.id).then((status) => {
+ if (!status.isClosed) {
+ element.classList.add(Highlighting.overdueDate(diff));
+ }
+ });
}
}
diff --git a/frontend/src/app/modules/work_packages/routing/wp-view-base/view-services/wp-view-highlighting.service.ts b/frontend/src/app/modules/work_packages/routing/wp-view-base/view-services/wp-view-highlighting.service.ts
index b3cef274037..089c8b31976 100644
--- a/frontend/src/app/modules/work_packages/routing/wp-view-base/view-services/wp-view-highlighting.service.ts
+++ b/frontend/src/app/modules/work_packages/routing/wp-view-base/view-services/wp-view-highlighting.service.ts
@@ -10,7 +10,7 @@ import {QuerySchemaResource} from "core-app/modules/hal/resources/query-schema-r
import {WorkPackageViewHighlight} from "core-app/modules/work_packages/routing/wp-view-base/view-services/wp-table-highlight";
@Injectable()
-export class WorkPackageViewHighlightingService extends WorkPackageQueryStateService<WorkPackageViewHighlight>{
+export class WorkPackageViewHighlightingService extends WorkPackageQueryStateService<WorkPackageViewHighlight> {
public constructor(readonly states:States,
readonly Banners:BannersService,
readonly querySpace:IsolatedQuerySpace) {
diff --git a/spec/features/work_packages/display_fields/date_field_display_spec.rb b/spec/features/work_packages/display_fields/date_field_display_spec.rb
new file mode 100644
index 00000000000..5055080ef9e
--- /dev/null
+++ b/spec/features/work_packages/display_fields/date_field_display_spec.rb
@@ -0,0 +1,73 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2020 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-2017 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 docs/COPYRIGHT.rdoc for more details.
+#++
+
+require 'spec_helper'
+
+describe 'Show the date of a Work Package', type: :feature, js: true do
+ let(:project) { FactoryBot.create :project }
+ let(:admin) { FactoryBot.create :admin}
+ let(:work_package) do
+ FactoryBot.create :work_package,
+ project: project,
+ due_date: Date.yesterday,
+ type: type,
+ status: open_status
+ end
+
+ let(:open_status) { FactoryBot.create :default_status }
+ let(:closed_status) { FactoryBot.create :closed_status }
+
+ let(:wp_page) { Pages::FullWorkPackage.new(work_package, project) }
+
+ let(:type) { FactoryBot.create :type }
+ let!(:workflow) do
+ FactoryBot.create :workflow,
+ type_id: type.id,
+ old_status: open_status,
+ new_status: closed_status
+ end
+
+ context 'with an overdue date' do
+ before do
+ login_as(admin)
+ wp_page.visit!
+ end
+
+ it 'should be highlighted only if the WP status is open (#33457)' do
+ # Highlighted with an open status
+ expect(page).to have_selector('.inline-edit--display-field.startDate .__hl_date_overdue')
+
+ # Change status to closed
+ status_field = WorkPackageStatusField.new(page)
+ status_field.update(closed_status.name)
+
+ # Not highlighted with a closed status
+ expect(page).not_to have_selector('.inline-edit--display-field.startDate .__hl_date_overdue')
+ end
+ end
+end
diff --git a/spec/features/work_packages/estimated_hours_display_spec.rb b/spec/features/work_packages/display_fields/estimated_hours_display_spec.rb
similarity index 100%
rename from spec/features/work_packages/estimated_hours_display_spec.rb
rename to spec/features/work_packages/display_fields/estimated_hours_display_spec.rb
diff --git a/spec/features/work_packages/spent_time_display_spec.rb b/spec/features/work_packages/display_fields/spent_time_display_spec.rb
similarity index 100%
rename from spec/features/work_packages/spent_time_display_spec.rb
rename to spec/features/work_packages/display_fields/spent_time_display_spec.rb