main

mattermost/focalboard

Last updated at: 29/12/2023 09:42

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: The Editor property is set to the UpdatedTime component, which is used as the editor for the property in the UI.
  • name property: The name property is set to "Last Modified At".
  • type property: The type property is set to "updatedTime".
  • isReadOnly property: The isReadOnly property is set to true, indicating that the property is read-only.
  • displayName method: The displayName method returns the display name of the property, which is obtained from the intl instance passed as a parameter.
  • calculationOptions property: The calculationOptions 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: The displayValue method formats and returns the display value of the property based on the input values and the provided card and intl instances.
  • getDateFrom method: The getDateFrom method returns the date value to be used as the start date for calculations based on the input values and the provided card instance.
  • getDateTo method: The getDateTo method returns the date value to be used as the end date for calculations based on the input values and the provided card 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)
}