property.tsx
TLDR
This file contains the implementation of the UpdatedTimeProperty
class, which is a subclass of DatePropertyType
. It provides properties and methods to handle the "Last Modified At" property type, including an editor component, display name, calculation options, and methods to get and display the date from a card.
Classes
UpdatedTimeProperty
The UpdatedTimeProperty
class is a subclass of DatePropertyType
and represents the "Last Modified At" property type. It provides the following functionality:
-
Editor
property: TheEditor
property is set to theUpdatedTime
component, which is used as the editor for the property in the UI. -
name
property: Thename
property is set to "Last Modified At". -
type
property: Thetype
property is set to "updatedTime". -
isReadOnly
property: TheisReadOnly
property is set totrue
, indicating that the property is read-only. -
displayName
method: ThedisplayName
method returns the display name of the property, which is obtained from theintl
instance passed as a parameter. -
calculationOptions
property: ThecalculationOptions
property is an array of calculation options available for the property. The options include none, count, countEmpty, countNotEmpty, percentEmpty, percentNotEmpty, countValue, countUniqueValue, earliest, latest, and dateRange. -
displayValue
method: ThedisplayValue
method formats and returns the display value of the property based on the input values and the providedcard
andintl
instances. -
getDateFrom
method: ThegetDateFrom
method returns the date value to be used as the start date for calculations based on the input values and the providedcard
instance. -
getDateTo
method: ThegetDateTo
method returns the date value to be used as the end date for calculations based on the input values and the providedcard
instance.
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {IntlShape} from 'react-intl'
import {Options} from '../../components/calculations/options'
import {IPropertyTemplate} from '../../blocks/board'
import {Card} from '../../blocks/card'
import {Utils} from '../../utils'
import {DatePropertyType, PropertyTypeEnum} from '../types'
import UpdatedTime from './updatedTime'
export default class UpdatedTimeProperty extends DatePropertyType {
Editor = UpdatedTime
name = 'Last Modified At'
type = 'updatedTime' as PropertyTypeEnum
isReadOnly = true
displayName = (intl: IntlShape) => intl.formatMessage({id: 'PropertyType.UpdatedTime', defaultMessage: 'Last updated time'})
calculationOptions = [Options.none, Options.count, Options.countEmpty,
Options.countNotEmpty, Options.percentEmpty, Options.percentNotEmpty,
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.updateAt), intl)
getDateFrom = (_: string | string[] | undefined, card: Card) => new Date(card.updateAt || 0)
getDateTo = (_: string | string[] | undefined, card: Card) => new Date(card.updateAt || 0)
}