diff --git a/webapp/src/components/calendar/fullCalendar.tsx b/webapp/src/components/calendar/fullCalendar.tsx index dc2495516..32dda87e1 100644 --- a/webapp/src/components/calendar/fullCalendar.tsx +++ b/webapp/src/components/calendar/fullCalendar.tsx @@ -99,8 +99,17 @@ const CalendarFullView = (props: Props): JSX.Element|null => { let dateFrom = new Date(card.createAt || 0) let dateTo = new Date(card.createAt || 0) if (property.isDate && property.getDateFrom && property.getDateTo) { - dateFrom = property.getDateFrom(card.fields.properties[dateDisplayProperty?.id || ''], card) - dateTo = property.getDateTo(card.fields.properties[dateDisplayProperty?.id || ''], card) + const dateFromValue = property.getDateFrom(card.fields.properties[dateDisplayProperty?.id || ''], card) + if (!dateFromValue) { + return [] + } + dateFrom = dateFromValue + + const dateToValue = property.getDateTo(card.fields.properties[dateDisplayProperty?.id || ''], card) + if (!dateToValue) { + return [] + } + dateTo = dateToValue } return [{ id: card.id, diff --git a/webapp/src/properties/createdTime/property.tsx b/webapp/src/properties/createdTime/property.tsx index 11d847d56..a03bf4b00 100644 --- a/webapp/src/properties/createdTime/property.tsx +++ b/webapp/src/properties/createdTime/property.tsx @@ -23,4 +23,6 @@ export default class CreatedAtProperty extends PropertyType { Options.countValue, Options.countUniqueValue, Options.earliest, Options.latest, Options.dateRange] displayValue = (_1: string | string[] | undefined, card: Card, _2: IPropertyTemplate, intl: IntlShape) => Utils.displayDateTime(new Date(card.createAt), intl) + getDateFrom = (_: string | string[] | undefined, card: Card) => new Date(card.createAt || 0) + getDateTo = (_: string | string[] | undefined, card: Card) => new Date(card.createAt || 0) } diff --git a/webapp/src/properties/date/property.tsx b/webapp/src/properties/date/property.tsx index cb2a0ad6f..158527df3 100644 --- a/webapp/src/properties/date/property.tsx +++ b/webapp/src/properties/date/property.tsx @@ -51,10 +51,10 @@ export default class DateProperty extends PropertyType { return displayValue } - getDateFrom = (value: string | string[] | undefined, card: Card) => { + getDateFrom = (value: string | string[] | undefined) => { const dateProperty = createDatePropertyFromString(value as string) if (!dateProperty.from) { - return new Date(card.createAt || 0) + return undefined } // date properties are stored as 12 pm UTC, convert to 12 am (00) UTC for calendar @@ -63,10 +63,10 @@ export default class DateProperty extends PropertyType { return dateFrom } - getDateTo = (value: string | string[] | undefined, card: Card) => { + getDateTo = (value: string | string[] | undefined) => { const dateProperty = createDatePropertyFromString(value as string) if (!dateProperty.from) { - return new Date(card.createAt || 0) + return undefined } const dateFrom = dateProperty.from ? new Date(dateProperty.from + (dateProperty.includeTime ? 0 : timeZoneOffset(dateProperty.from))) : new Date() dateFrom.setHours(0, 0, 0, 0) diff --git a/webapp/src/properties/types.tsx b/webapp/src/properties/types.tsx index d3f1e3fb5..3199e5c53 100644 --- a/webapp/src/properties/types.tsx +++ b/webapp/src/properties/types.tsx @@ -42,14 +42,14 @@ export abstract class PropertyType { Options.countNotEmpty, Options.percentEmpty, Options.percentNotEmpty, Options.countValue, Options.countUniqueValue] displayValue: (value: string | string[] | undefined, card: Card, template: IPropertyTemplate, intl: IntlShape) => string | string[] | undefined - getDateFrom: (value: string | string[] | undefined, card: Card) => Date - getDateTo: (value: string | string[] | undefined, card: Card) => Date + getDateFrom: (value: string | string[] | undefined, card: Card) => Date | undefined + getDateTo: (value: string | string[] | undefined, card: Card) => Date | undefined valueLength: (value: string | string[] | undefined, card: Card, template: IPropertyTemplate, intl: IntlShape, fontDescriptor: string, perItemPadding?: number) => number constructor() { this.displayValue = (value: string | string[] | undefined) => value - this.getDateFrom = (_: string | string[] | undefined, card: Card) => new Date(card.createAt || 0) - this.getDateTo = (_: string | string[] | undefined, card: Card) => new Date(card.createAt || 0) + this.getDateFrom = () => undefined + this.getDateTo = () => undefined this.valueLength = (value: string | string[] | undefined, card: Card, template: IPropertyTemplate, intl: IntlShape, fontDescriptor: string): number => { const displayValue = this.displayValue(value, card, template, intl) || '' return Utils.getTextWidth(displayValue.toString(), fontDescriptor)