mirror of
https://github.com/mattermost/focalboard.git
synced 2025-01-11 18:13:52 +02:00
Feature added: Pressing enter should create a category
This commit is contained in:
parent
d2c4a54d36
commit
d5c8f59878
@ -1,9 +1,9 @@
|
|||||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||||
// See LICENSE.txt for license information.
|
// See LICENSE.txt for license information.
|
||||||
|
|
||||||
import React, {useState} from 'react'
|
import React, { useState } from 'react'
|
||||||
|
|
||||||
import {useIntl} from 'react-intl'
|
import { useIntl } from 'react-intl'
|
||||||
|
|
||||||
import Dialog from '../dialog'
|
import Dialog from '../dialog'
|
||||||
import Button from '../../widgets/buttons/button'
|
import Button from '../../widgets/buttons/button'
|
||||||
@ -20,10 +20,10 @@ type Props = {
|
|||||||
const CreateCategory = (props: Props): JSX.Element => {
|
const CreateCategory = (props: Props): JSX.Element => {
|
||||||
const intl = useIntl()
|
const intl = useIntl()
|
||||||
|
|
||||||
const placeholder = intl.formatMessage({id: 'Categories.CreateCategoryDialog.Placeholder', defaultMessage: 'Name your category'})
|
const placeholder = intl.formatMessage({ id: 'Categories.CreateCategoryDialog.Placeholder', defaultMessage: 'Name your category' })
|
||||||
const cancelText = intl.formatMessage({id: 'Categories.CreateCategoryDialog.CancelText', defaultMessage: 'Cancel'})
|
const cancelText = intl.formatMessage({ id: 'Categories.CreateCategoryDialog.CancelText', defaultMessage: 'Cancel' })
|
||||||
const createText = intl.formatMessage({id: 'Categories.CreateCategoryDialog.CreateText', defaultMessage: 'Create'})
|
const createText = intl.formatMessage({ id: 'Categories.CreateCategoryDialog.CreateText', defaultMessage: 'Create' })
|
||||||
const updateText = intl.formatMessage({id: 'Categories.CreateCategoryDialog.UpdateText', defaultMessage: 'Update'})
|
const updateText = intl.formatMessage({ id: 'Categories.CreateCategoryDialog.UpdateText', defaultMessage: 'Update' })
|
||||||
|
|
||||||
const [name, setName] = useState(props.initialValue || '')
|
const [name, setName] = useState(props.initialValue || '')
|
||||||
|
|
||||||
@ -32,6 +32,7 @@ const CreateCategory = (props: Props): JSX.Element => {
|
|||||||
className='CreateCategoryModal'
|
className='CreateCategoryModal'
|
||||||
onClose={props.onClose}
|
onClose={props.onClose}
|
||||||
>
|
>
|
||||||
|
<form>
|
||||||
<div className='CreateCategory'>
|
<div className='CreateCategory'>
|
||||||
<h3>{props.title}</h3>
|
<h3>{props.title}</h3>
|
||||||
<input
|
<input
|
||||||
@ -56,11 +57,13 @@ const CreateCategory = (props: Props): JSX.Element => {
|
|||||||
filled={Boolean(name)}
|
filled={Boolean(name)}
|
||||||
onClick={() => props.onCreate(name)}
|
onClick={() => props.onCreate(name)}
|
||||||
disabled={!name}
|
disabled={!name}
|
||||||
|
submit={true}
|
||||||
>
|
>
|
||||||
{props.initialValue ? updateText : createText}
|
{props.initialValue ? updateText : createText}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</form>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user