allow empty dates returned from date property (#4282)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
This commit is contained in:
parent
9cdae953b9
commit
97c2d91375
4 changed files with 21 additions and 10 deletions
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue