Skip to content

Commit

Permalink
Merge pull request #202 from Elastic-Suite/feat-1278904-ManageDateAtt…
Browse files Browse the repository at this point in the history
…ributeSourceField

feat(#1278904): [Source Field] Manage Date attributes
  • Loading branch information
matthias-goupil authored Jun 26, 2024
2 parents 7e8a6ee + 4149680 commit 69bf638
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/components/src/components/atoms/rules/Rule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { Close, CustomCombination, Root } from './Rule.styled'
import DropDownError from '../form/DropDownError'
import TreeSelectorError from '../form/TreeSelectorError'
import InputTextError from '../form/InputTextError'
import DatePickerError from '../form/DatePickerError'

function getInputType(valueType: RuleValueType): 'number' | 'text' {
if (ruleValueNumberTypes.includes(valueType)) {
Expand Down Expand Up @@ -188,6 +189,20 @@ function Rule(props: IProps): JSX.Element {
value={treeSelectorValue}
/>
)
} else if (attribute_type === RuleAttributeType.DATE) {
const datePickerValue =
(typeof value === 'string' && value) || value instanceof Date
? new Date(value)
: null

return (
<DatePickerError
showError={showError}
value={datePickerValue}
required
onChange={handleChange('value')}
/>
)
}

return (
Expand Down
1 change: 1 addition & 0 deletions packages/shared/src/types/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export enum RuleAttributeType {
REFERENCE = 'reference',
SELECT = 'select',
TEXT = 'text',
DATE = 'date',
}

export enum RuleValueType {
Expand Down

0 comments on commit 69bf638

Please sign in to comment.