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
Handle null date values
Oliver Günther4feb60a558ea
diff --git a/config/locales/js-en.yml b/config/locales/js-en.ymlindex fe305779aa1..3c3c50b9776 100644--- a/config/locales/js-en.yml+++ b/config/locales/js-en.yml@@ -597,6 +597,7 @@ en:overdue_since: 'since %{difference_in_days}'property_is: 'is in %{difference_in_days}'property_was: 'was %{difference_in_days} ago'+ property_is_deleted: 'is deleted'facets:unread: 'Unread'unread_title: 'Show unread'diff --git a/frontend/src/app/core/state/in-app-notifications/in-app-notification.model.ts b/frontend/src/app/core/state/in-app-notifications/in-app-notification.model.tsindex 6a5adf47614..eeae2b406f0 100644--- a/frontend/src/app/core/state/in-app-notifications/in-app-notification.model.ts+++ b/frontend/src/app/core/state/in-app-notifications/in-app-notification.model.ts@@ -17,7 +17,7 @@ export type IInAppNotificationDetailsAttribute = 'startDate'|'dueDate'|'date';export interface IInAppNotificationDetailsResource {property:IInAppNotificationDetailsAttribute;- value:string;+ value:string|null;_links:{self:IHalResourceLink;diff --git a/frontend/src/app/features/in-app-notifications/entry/date-alert/in-app-notification-date-alert.component.ts b/frontend/src/app/features/in-app-notifications/entry/date-alert/in-app-notification-date-alert.component.tsindex 477870da0e1..acdde40d1ec 100644--- a/frontend/src/app/features/in-app-notifications/entry/date-alert/in-app-notification-date-alert.component.ts+++ b/frontend/src/app/features/in-app-notifications/entry/date-alert/in-app-notification-date-alert.component.ts@@ -46,6 +46,7 @@ export class InAppNotificationDateAlertComponent implements OnInit {this.I18n.t('js.notifications.date_alerts.property_is', { difference_in_days }),property_was: (difference_in_days:string):string =>this.I18n.t('js.notifications.date_alerts.property_was', { difference_in_days }),+ property_deleted: this.I18n.t('js.notifications.date_alerts.property_is_deleted'),startDate: this.I18n.t('js.work_packages.properties.startDate'),dueDate: this.I18n.t('js.work_packages.properties.dueDate'),date: this.I18n.t('js.notifications.date_alerts.milestone_date'),@@ -62,7 +63,17 @@ export class InAppNotificationDateAlertComponent implements OnInit {const detail = interestingAlert._embedded.details[0];const property = detail.property;- const dateValue = this.timezoneService.parseISODate(detail.value);++ if (!detail.value) {+ this.propertyText = this.text[property];+ this.alertText = this.text.property_deleted;+ } else {+ this.deriveDueDate(detail.value, property);+ }+ }++ private deriveDueDate(value:string, property:'startDate'|'dueDate'|'date') {+ const dateValue = this.timezoneService.parseISODate(value);this.dateIsPast = dateValue.isBefore();this.isOverdue = this.dateIsPast && ['date', 'dueDate'].includes(property);this.daysDiff = this.dateDiff(dateValue);diff --git a/spec/features/notifications/notification_center/notification_center_date_alerts_spec.rb b/spec/features/notifications/notification_center/notification_center_date_alerts_spec.rbindex ca720664d32..f42a73145a2 100644--- a/spec/features/notifications/notification_center/notification_center_date_alerts_spec.rb+++ b/spec/features/notifications/notification_center/notification_center_date_alerts_spec.rb@@ -23,6 +23,8 @@ describe "Notification center date alerts", js: true, with_settings: { journal_ashared_let(:wp_double_notification) { create(:work_package, subject: 'Alert + Mention', project:, due_date: 1.day.from_now) }+ shared_let(:wp_unset_date) { create(:work_package, subject: 'Unset date', project:, due_date: nil) }+shared_let(:wp_double_alert) docreate(:work_package, subject: 'Double alert', project:, start_date: 1.day.ago, due_date: 1.day.from_now)end@@ -107,6 +109,14 @@ describe "Notification center date alerts", js: true, with_settings: { journal_a[start, due]end+ shared_let(:notification_wp_unset_date) do+ create(:notification,+ reason: :date_alert_due_date,+ recipient: user,+ resource: wp_unset_date,+ project:)+ end+let(:center) { ::Pages::Notifications::Center.new }let(:side_menu) { ::Components::Notifications::Sidemenu.new }@@ -125,6 +135,8 @@ describe "Notification center date alerts", js: true, with_settings: { journal_acenter.expect_item(notification_milestone_past, 'Overdue since 2 days')center.expect_item(notification_milestone_future, 'Milestone date is in 1 day')+ center.expect_item(notification_wp_unset_date, 'Finish date is deleted')+# Doesn't show the date alert for the mention, not the alertcenter.expect_item(notification_wp_double_mention, /(seconds|minutes) ago by Anonymous/)center.expect_no_item(notification_wp_double_date_alert)