main

mattermost/focalboard

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

property.tsx

TLDR

This file defines a class called NumberProperty that extends the PropertyType class. It also exports an object of type NumberProperty. The NumberProperty class has several properties and methods, including an Editor property, name, type, displayName, calculationOptions, and exportValue methods.

Classes

NumberProperty

The NumberProperty class extends the PropertyType class. It represents a number property type. The class has the following properties and methods:

  • Editor: An object of type NumberProp.
  • name: A string that represents the name of the property, which is set to "Number".
  • type: A string constant that represents the type of the property, which is set to "number" as a PropertyTypeEnum.
  • displayName: A function that takes an intl object of type IntlShape and returns the localized display name of the property.
  • calculationOptions: An array of calculation options available for this property.
  • exportValue: A method that takes a value of type string | string[] | undefined and returns the exported value as a string.
// 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 {PropertyType, PropertyTypeEnum} from '../types'

import NumberProp from './number'

export default class NumberProperty extends PropertyType {
    Editor = NumberProp
    name = 'Number'
    type = 'number' as PropertyTypeEnum
    displayName = (intl: IntlShape) => intl.formatMessage({id: 'PropertyType.Number', defaultMessage: 'Number'})
    calculationOptions = [Options.none, Options.count, Options.countEmpty,
        Options.countNotEmpty, Options.percentEmpty, Options.percentNotEmpty,
        Options.countValue, Options.countUniqueValue, Options.sum,
        Options.average, Options.median, Options.min, Options.max,
        Options.range]

    exportValue = (value: string | string[] | undefined): string => (value ? Number(value).toString() : '')
}