mirror of
https://github.com/plankanban/planka.git
synced 2025-08-09 23:45:31 +02:00
feat: Added feature - open card once created with Ctrl+Enter
This commit is contained in:
parent
6021d67a00
commit
f5d83d0456
3 changed files with 28 additions and 20 deletions
|
@ -21,10 +21,12 @@ const CardAdd = React.memo(({ isOpened, onCreate, onClose }) => {
|
|||
|
||||
const nameField = useRef(null);
|
||||
|
||||
const submit = useCallback(() => {
|
||||
const submit = useCallback(
|
||||
(openCard) => {
|
||||
const cleanData = {
|
||||
...data,
|
||||
name: data.name.trim(),
|
||||
open: openCard,
|
||||
};
|
||||
|
||||
if (!cleanData.name) {
|
||||
|
@ -33,24 +35,28 @@ const CardAdd = React.memo(({ isOpened, onCreate, onClose }) => {
|
|||
}
|
||||
|
||||
onCreate(cleanData);
|
||||
|
||||
setData(DEFAULT_DATA);
|
||||
focusNameField();
|
||||
}, [onCreate, data, setData, focusNameField]);
|
||||
},
|
||||
[onCreate, data, setData, focusNameField],
|
||||
);
|
||||
|
||||
const handleFieldKeyDown = useCallback(
|
||||
(event) => {
|
||||
switch (event.key) {
|
||||
case 'Enter':
|
||||
case 'Enter': {
|
||||
event.preventDefault();
|
||||
|
||||
submit();
|
||||
const openCard = event.ctrlKey;
|
||||
submit(openCard);
|
||||
|
||||
break;
|
||||
case 'Escape':
|
||||
}
|
||||
case 'Escape': {
|
||||
onClose();
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
}
|
||||
},
|
||||
|
|
|
@ -84,7 +84,7 @@ export default {
|
|||
editUsername_title: 'Edit Username',
|
||||
email: 'E-mail',
|
||||
emailAlreadyInUse: 'E-mail already in use',
|
||||
enterCardTitle: 'Enter card title...',
|
||||
enterCardTitle: 'Enter card title... [Ctrl+Enter] to open',
|
||||
enterDescription: 'Enter description...',
|
||||
enterFilename: 'Enter filename',
|
||||
enterListTitle: 'Enter list title...',
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { call, put, select } from 'redux-saga/effects';
|
||||
|
||||
import { goToBoard } from './router';
|
||||
import { goToBoard, goToCard } from './router';
|
||||
import request from '../request';
|
||||
import selectors from '../../../selectors';
|
||||
import actions from '../../../actions';
|
||||
|
@ -33,8 +33,10 @@ export function* createCard(listId, data) {
|
|||
yield put(actions.createCard.failure(localId, error));
|
||||
return;
|
||||
}
|
||||
|
||||
yield put(actions.createCard.success(localId, card));
|
||||
if (data.open) {
|
||||
yield call(goToCard, card.id);
|
||||
}
|
||||
}
|
||||
|
||||
export function* handleCardCreate(card) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue