mirror of
https://github.com/plankanban/planka.git
synced 2025-07-18 20:59:44 +02:00
Move cards between boards and projects
This commit is contained in:
parent
ba2017705b
commit
b1d187476d
24 changed files with 474 additions and 16 deletions
|
@ -7,6 +7,13 @@ export const createBoardInCurrentProject = (data) => ({
|
|||
},
|
||||
});
|
||||
|
||||
export const fetchBoard = (id) => ({
|
||||
type: EntryActionTypes.BOARD_FETCH,
|
||||
payload: {
|
||||
id,
|
||||
},
|
||||
});
|
||||
|
||||
export const updateBoard = (id, data) => ({
|
||||
type: EntryActionTypes.BOARD_UPDATE,
|
||||
payload: {
|
||||
|
|
|
@ -23,7 +23,7 @@ export const updateCurrentCard = (data) => ({
|
|||
},
|
||||
});
|
||||
|
||||
export const moveCard = (id, listId, index) => ({
|
||||
export const moveCard = (id, listId, index = 0) => ({
|
||||
type: EntryActionTypes.CARD_MOVE,
|
||||
payload: {
|
||||
id,
|
||||
|
@ -32,6 +32,33 @@ export const moveCard = (id, listId, index) => ({
|
|||
},
|
||||
});
|
||||
|
||||
export const moveCurrentCard = (listId, index = 0) => ({
|
||||
type: EntryActionTypes.CURRENT_CARD_MOVE,
|
||||
payload: {
|
||||
listId,
|
||||
index,
|
||||
},
|
||||
});
|
||||
|
||||
export const transferCard = (id, boardId, listId, index = 0) => ({
|
||||
type: EntryActionTypes.CARD_TRANSFER,
|
||||
payload: {
|
||||
id,
|
||||
boardId,
|
||||
listId,
|
||||
index,
|
||||
},
|
||||
});
|
||||
|
||||
export const transferCurrentCard = (boardId, listId, index = 0) => ({
|
||||
type: EntryActionTypes.CURRENT_CARD_TRANSFER,
|
||||
payload: {
|
||||
boardId,
|
||||
listId,
|
||||
index,
|
||||
},
|
||||
});
|
||||
|
||||
export const deleteCard = (id) => ({
|
||||
type: EntryActionTypes.CARD_DELETE,
|
||||
payload: {
|
||||
|
|
|
@ -4,7 +4,7 @@ import Config from '../constants/Config';
|
|||
|
||||
const http = {};
|
||||
|
||||
// TODO: all methods
|
||||
// TODO: add all methods
|
||||
['POST'].forEach((method) => {
|
||||
http[method.toLowerCase()] = (url, data, headers) => {
|
||||
const formData = Object.keys(data).reduce((result, key) => {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import pick from 'lodash/pick';
|
||||
import React, { useCallback } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
@ -10,6 +11,7 @@ import ProjectMembershipsStep from '../ProjectMembershipsStep';
|
|||
import LabelsStep from '../LabelsStep';
|
||||
import EditDueDateStep from '../EditDueDateStep';
|
||||
import EditTimerStep from '../EditTimerStep';
|
||||
import MoveCardStep from '../MoveCardStep';
|
||||
import DeleteStep from '../DeleteStep';
|
||||
|
||||
import styles from './ActionsPopup.module.css';
|
||||
|
@ -19,21 +21,26 @@ const StepTypes = {
|
|||
LABELS: 'LABELS',
|
||||
EDIT_DUE_DATE: 'EDIT_DUE_DATE',
|
||||
EDIT_TIMER: 'EDIT_TIMER',
|
||||
MOVE: 'MOVE',
|
||||
DELETE: 'DELETE',
|
||||
};
|
||||
|
||||
const ActionsStep = React.memo(
|
||||
({
|
||||
card,
|
||||
projectsToLists,
|
||||
projectMemberships,
|
||||
currentUserIds,
|
||||
labels,
|
||||
currentLabelIds,
|
||||
onNameEdit,
|
||||
onUpdate,
|
||||
onMove,
|
||||
onTransfer,
|
||||
onDelete,
|
||||
onUserAdd,
|
||||
onUserRemove,
|
||||
onBoardFetch,
|
||||
onLabelAdd,
|
||||
onLabelRemove,
|
||||
onLabelCreate,
|
||||
|
@ -65,6 +72,10 @@ const ActionsStep = React.memo(
|
|||
openStep(StepTypes.EDIT_TIMER);
|
||||
}, [openStep]);
|
||||
|
||||
const handleMoveClick = useCallback(() => {
|
||||
openStep(StepTypes.MOVE);
|
||||
}, [openStep]);
|
||||
|
||||
const handleDeleteClick = useCallback(() => {
|
||||
openStep(StepTypes.DELETE);
|
||||
}, [openStep]);
|
||||
|
@ -130,6 +141,18 @@ const ActionsStep = React.memo(
|
|||
onClose={onClose}
|
||||
/>
|
||||
);
|
||||
case StepTypes.MOVE:
|
||||
return (
|
||||
<MoveCardStep
|
||||
projectsToLists={projectsToLists}
|
||||
defaultPath={pick(card, ['projectId', 'boardId', 'listId'])}
|
||||
onMove={onMove}
|
||||
onTransfer={onTransfer}
|
||||
onBoardFetch={onBoardFetch}
|
||||
onBack={handleBack}
|
||||
onClose={onClose}
|
||||
/>
|
||||
);
|
||||
case StepTypes.DELETE:
|
||||
return (
|
||||
<DeleteStep
|
||||
|
@ -180,6 +203,11 @@ const ActionsStep = React.memo(
|
|||
context: 'title',
|
||||
})}
|
||||
</Menu.Item>
|
||||
<Menu.Item className={styles.menuItem} onClick={handleMoveClick}>
|
||||
{t('action.moveCard', {
|
||||
context: 'title',
|
||||
})}
|
||||
</Menu.Item>
|
||||
<Menu.Item className={styles.menuItem} onClick={handleDeleteClick}>
|
||||
{t('action.deleteCard', {
|
||||
context: 'title',
|
||||
|
@ -195,6 +223,7 @@ const ActionsStep = React.memo(
|
|||
ActionsStep.propTypes = {
|
||||
/* eslint-disable react/forbid-prop-types */
|
||||
card: PropTypes.object.isRequired,
|
||||
projectsToLists: PropTypes.array.isRequired,
|
||||
projectMemberships: PropTypes.array.isRequired,
|
||||
currentUserIds: PropTypes.array.isRequired,
|
||||
labels: PropTypes.array.isRequired,
|
||||
|
@ -202,9 +231,12 @@ ActionsStep.propTypes = {
|
|||
/* eslint-enable react/forbid-prop-types */
|
||||
onNameEdit: PropTypes.func.isRequired,
|
||||
onUpdate: PropTypes.func.isRequired,
|
||||
onMove: PropTypes.func.isRequired,
|
||||
onTransfer: PropTypes.func.isRequired,
|
||||
onDelete: PropTypes.func.isRequired,
|
||||
onUserAdd: PropTypes.func.isRequired,
|
||||
onUserRemove: PropTypes.func.isRequired,
|
||||
onBoardFetch: PropTypes.func.isRequired,
|
||||
onLabelAdd: PropTypes.func.isRequired,
|
||||
onLabelRemove: PropTypes.func.isRequired,
|
||||
onLabelCreate: PropTypes.func.isRequired,
|
||||
|
|
|
@ -24,17 +24,24 @@ const Card = React.memo(
|
|||
dueDate,
|
||||
timer,
|
||||
coverUrl,
|
||||
listId,
|
||||
boardId,
|
||||
projectId,
|
||||
isPersisted,
|
||||
notificationsTotal,
|
||||
users,
|
||||
labels,
|
||||
tasks,
|
||||
allProjectsToLists,
|
||||
allProjectMemberships,
|
||||
allLabels,
|
||||
onUpdate,
|
||||
onMove,
|
||||
onTransfer,
|
||||
onDelete,
|
||||
onUserAdd,
|
||||
onUserRemove,
|
||||
onBoardFetch,
|
||||
onLabelAdd,
|
||||
onLabelRemove,
|
||||
onLabelCreate,
|
||||
|
@ -143,17 +150,24 @@ const Card = React.memo(
|
|||
name,
|
||||
dueDate,
|
||||
timer,
|
||||
listId,
|
||||
boardId,
|
||||
projectId,
|
||||
isPersisted,
|
||||
}}
|
||||
projectsToLists={allProjectsToLists}
|
||||
projectMemberships={allProjectMemberships}
|
||||
currentUserIds={users.map((user) => user.id)}
|
||||
labels={allLabels}
|
||||
currentLabelIds={labels.map((label) => label.id)}
|
||||
onNameEdit={handleNameEdit}
|
||||
onUpdate={onUpdate}
|
||||
onMove={onMove}
|
||||
onTransfer={onTransfer}
|
||||
onDelete={onDelete}
|
||||
onUserAdd={onUserAdd}
|
||||
onUserRemove={onUserRemove}
|
||||
onBoardFetch={onBoardFetch}
|
||||
onLabelAdd={onLabelAdd}
|
||||
onLabelRemove={onLabelRemove}
|
||||
onLabelCreate={onLabelCreate}
|
||||
|
@ -184,19 +198,26 @@ Card.propTypes = {
|
|||
dueDate: PropTypes.instanceOf(Date),
|
||||
timer: PropTypes.object, // eslint-disable-line react/forbid-prop-types
|
||||
coverUrl: PropTypes.string,
|
||||
listId: PropTypes.string.isRequired,
|
||||
boardId: PropTypes.string.isRequired,
|
||||
projectId: PropTypes.string.isRequired,
|
||||
isPersisted: PropTypes.bool.isRequired,
|
||||
notificationsTotal: PropTypes.number.isRequired,
|
||||
/* eslint-disable react/forbid-prop-types */
|
||||
users: PropTypes.array.isRequired,
|
||||
labels: PropTypes.array.isRequired,
|
||||
tasks: PropTypes.array.isRequired,
|
||||
allProjectsToLists: PropTypes.array.isRequired,
|
||||
allProjectMemberships: PropTypes.array.isRequired,
|
||||
allLabels: PropTypes.array.isRequired,
|
||||
/* eslint-enable react/forbid-prop-types */
|
||||
onUpdate: PropTypes.func.isRequired,
|
||||
onMove: PropTypes.func.isRequired,
|
||||
onTransfer: PropTypes.func.isRequired,
|
||||
onDelete: PropTypes.func.isRequired,
|
||||
onUserAdd: PropTypes.func.isRequired,
|
||||
onUserRemove: PropTypes.func.isRequired,
|
||||
onBoardFetch: PropTypes.func.isRequired,
|
||||
onLabelAdd: PropTypes.func.isRequired,
|
||||
onLabelRemove: PropTypes.func.isRequired,
|
||||
onLabelCreate: PropTypes.func.isRequired,
|
||||
|
|
|
@ -20,6 +20,7 @@ import ProjectMembershipsPopup from '../ProjectMembershipsPopup';
|
|||
import LabelsPopup from '../LabelsPopup';
|
||||
import EditDueDatePopup from '../EditDueDatePopup';
|
||||
import EditTimerPopup from '../EditTimerPopup';
|
||||
import MoveCardPopup from '../MoveCardPopup';
|
||||
import DeletePopup from '../DeletePopup';
|
||||
|
||||
import styles from './CardModal.module.css';
|
||||
|
@ -33,18 +34,25 @@ const CardModal = React.memo(
|
|||
isSubscribed,
|
||||
isActionsFetching,
|
||||
isAllActionsFetched,
|
||||
listId,
|
||||
boardId,
|
||||
projectId,
|
||||
users,
|
||||
labels,
|
||||
tasks,
|
||||
attachments,
|
||||
actions,
|
||||
allProjectsToLists,
|
||||
allProjectMemberships,
|
||||
allLabels,
|
||||
isEditable,
|
||||
onUpdate,
|
||||
onMove,
|
||||
onTransfer,
|
||||
onDelete,
|
||||
onUserAdd,
|
||||
onUserRemove,
|
||||
onBoardFetch,
|
||||
onLabelAdd,
|
||||
onLabelRemove,
|
||||
onLabelCreate,
|
||||
|
@ -328,7 +336,9 @@ const CardModal = React.memo(
|
|||
<EditDueDatePopup defaultValue={dueDate} onUpdate={handleDueDateUpdate}>
|
||||
<Button fluid className={styles.actionButton}>
|
||||
<Icon name="calendar check outline" className={styles.actionIcon} />
|
||||
{t('common.dueDate')}
|
||||
{t('common.dueDate', {
|
||||
context: 'title',
|
||||
})}
|
||||
</Button>
|
||||
</EditDueDatePopup>
|
||||
<EditTimerPopup defaultValue={timer} onUpdate={handleTimerUpdate}>
|
||||
|
@ -354,6 +364,26 @@ const CardModal = React.memo(
|
|||
<Icon name="paper plane outline" className={styles.actionIcon} />
|
||||
{isSubscribed ? t('action.unsubscribe') : t('action.subscribe')}
|
||||
</Button>
|
||||
<MoveCardPopup
|
||||
projectsToLists={allProjectsToLists}
|
||||
defaultPath={{
|
||||
projectId,
|
||||
boardId,
|
||||
listId,
|
||||
}}
|
||||
onMove={onMove}
|
||||
onTransfer={onTransfer}
|
||||
onBoardFetch={onBoardFetch}
|
||||
>
|
||||
<Button
|
||||
fluid
|
||||
className={styles.actionButton}
|
||||
onClick={handleToggleSubscribeClick}
|
||||
>
|
||||
<Icon name="share square outline" className={styles.actionIcon} />
|
||||
{t('action.move')}
|
||||
</Button>
|
||||
</MoveCardPopup>
|
||||
<DeletePopup
|
||||
title={t('common.deleteCard', {
|
||||
context: 'title',
|
||||
|
@ -385,20 +415,27 @@ CardModal.propTypes = {
|
|||
isSubscribed: PropTypes.bool.isRequired,
|
||||
isActionsFetching: PropTypes.bool.isRequired,
|
||||
isAllActionsFetched: PropTypes.bool.isRequired,
|
||||
listId: PropTypes.string.isRequired,
|
||||
boardId: PropTypes.string.isRequired,
|
||||
projectId: PropTypes.string.isRequired,
|
||||
/* eslint-disable react/forbid-prop-types */
|
||||
users: PropTypes.array.isRequired,
|
||||
labels: PropTypes.array.isRequired,
|
||||
tasks: PropTypes.array.isRequired,
|
||||
attachments: PropTypes.array.isRequired,
|
||||
actions: PropTypes.array.isRequired,
|
||||
allProjectsToLists: PropTypes.array.isRequired,
|
||||
allProjectMemberships: PropTypes.array.isRequired,
|
||||
allLabels: PropTypes.array.isRequired,
|
||||
/* eslint-enable react/forbid-prop-types */
|
||||
isEditable: PropTypes.bool.isRequired,
|
||||
onUpdate: PropTypes.func.isRequired,
|
||||
onMove: PropTypes.func.isRequired,
|
||||
onTransfer: PropTypes.func.isRequired,
|
||||
onDelete: PropTypes.func.isRequired,
|
||||
onUserAdd: PropTypes.func.isRequired,
|
||||
onUserRemove: PropTypes.func.isRequired,
|
||||
onBoardFetch: PropTypes.func.isRequired,
|
||||
onLabelAdd: PropTypes.func.isRequired,
|
||||
onLabelRemove: PropTypes.func.isRequired,
|
||||
onLabelCreate: PropTypes.func.isRequired,
|
||||
|
|
5
client/src/components/MoveCardPopup.jsx
Normal file
5
client/src/components/MoveCardPopup.jsx
Normal file
|
@ -0,0 +1,5 @@
|
|||
import { withPopup } from '../lib/popup';
|
||||
|
||||
import MoveCardStep from './MoveCardStep';
|
||||
|
||||
export default withPopup(MoveCardStep);
|
161
client/src/components/MoveCardStep/MoveCardStep.jsx
Normal file
161
client/src/components/MoveCardStep/MoveCardStep.jsx
Normal file
|
@ -0,0 +1,161 @@
|
|||
import React, { useMemo, useCallback } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Button, Dropdown, Form } from 'semantic-ui-react';
|
||||
import { Popup } from '../../lib/custom-ui';
|
||||
|
||||
import { useForm } from '../../hooks';
|
||||
|
||||
import styles from './MoveCardStep.module.css';
|
||||
|
||||
const MoveCardStep = React.memo(
|
||||
({ projectsToLists, defaultPath, onMove, onTransfer, onBoardFetch, onBack, onClose }) => {
|
||||
const [t] = useTranslation();
|
||||
|
||||
const [path, handleFieldChange] = useForm(() => ({
|
||||
projectId: null,
|
||||
boardId: null,
|
||||
listId: null,
|
||||
...defaultPath,
|
||||
}));
|
||||
|
||||
const selectedProject = useMemo(
|
||||
() => projectsToLists.find((project) => project.id === path.projectId) || null,
|
||||
[projectsToLists, path.projectId],
|
||||
);
|
||||
|
||||
const selectedBoard = useMemo(
|
||||
() =>
|
||||
(selectedProject && selectedProject.boards.find((board) => board.id === path.boardId)) ||
|
||||
null,
|
||||
[selectedProject, path.boardId],
|
||||
);
|
||||
|
||||
const selectedList = useMemo(
|
||||
() => (selectedBoard && selectedBoard.lists.find((list) => list.id === path.listId)) || null,
|
||||
[selectedBoard, path.listId],
|
||||
);
|
||||
|
||||
const handleBoardIdFieldChange = useCallback(
|
||||
(event, data) => {
|
||||
if (selectedProject.boards.find((board) => board.id === data.value).isFetching === null) {
|
||||
onBoardFetch(data.value);
|
||||
}
|
||||
|
||||
handleFieldChange(event, data);
|
||||
},
|
||||
[onBoardFetch, handleFieldChange, selectedProject],
|
||||
);
|
||||
|
||||
const handleSubmit = useCallback(() => {
|
||||
if (selectedBoard.id !== defaultPath.boardId) {
|
||||
onTransfer(selectedBoard.id, selectedList.id);
|
||||
} else if (selectedList.id !== defaultPath.listId) {
|
||||
onMove(selectedList.id);
|
||||
}
|
||||
|
||||
onClose();
|
||||
}, [defaultPath, onMove, onTransfer, onClose, selectedBoard, selectedList]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Popup.Header onBack={onBack}>
|
||||
{t('common.moveCard', {
|
||||
context: 'title',
|
||||
})}
|
||||
</Popup.Header>
|
||||
<Popup.Content>
|
||||
<Form onSubmit={handleSubmit}>
|
||||
<div className={styles.text}>{t('common.project')}</div>
|
||||
<Dropdown
|
||||
fluid
|
||||
selection
|
||||
name="projectId"
|
||||
options={projectsToLists.map((project) => ({
|
||||
text: project.name,
|
||||
value: project.id,
|
||||
}))}
|
||||
value={selectedProject && selectedProject.id}
|
||||
placeholder={
|
||||
projectsToLists.length === 0 ? t('common.noProjects') : t('common.selectProject')
|
||||
}
|
||||
disabled={projectsToLists.length === 0}
|
||||
className={styles.field}
|
||||
onChange={handleFieldChange}
|
||||
/>
|
||||
{selectedProject && (
|
||||
<>
|
||||
<div className={styles.text}>{t('common.board')}</div>
|
||||
<Dropdown
|
||||
fluid
|
||||
selection
|
||||
name="boardId"
|
||||
options={selectedProject.boards.map((board) => ({
|
||||
text: board.name,
|
||||
value: board.id,
|
||||
}))}
|
||||
value={selectedBoard && selectedBoard.id}
|
||||
placeholder={
|
||||
selectedProject.boards.length === 0
|
||||
? t('common.noBoards')
|
||||
: t('common.selectBoard')
|
||||
}
|
||||
disabled={selectedProject.boards.length === 0}
|
||||
className={styles.field}
|
||||
onChange={handleBoardIdFieldChange}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
{selectedBoard && (
|
||||
<>
|
||||
<div className={styles.text}>{t('common.list')}</div>
|
||||
<Dropdown
|
||||
fluid
|
||||
selection
|
||||
name="listId"
|
||||
options={selectedBoard.lists.map((list) => ({
|
||||
text: list.name,
|
||||
value: list.id,
|
||||
}))}
|
||||
value={selectedList && selectedList.id}
|
||||
placeholder={
|
||||
selectedBoard.isFetching === false && selectedBoard.lists.length === 0
|
||||
? t('common.noLists')
|
||||
: t('common.selectList')
|
||||
}
|
||||
loading={selectedBoard.isFetching !== false}
|
||||
disabled={selectedBoard.isFetching !== false || selectedBoard.lists.length === 0}
|
||||
className={styles.field}
|
||||
onChange={handleFieldChange}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
<Button
|
||||
positive
|
||||
content={t('action.move')}
|
||||
disabled={(selectedBoard && selectedBoard.isFetching !== false) || !selectedList}
|
||||
/>
|
||||
</Form>
|
||||
</Popup.Content>
|
||||
</>
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
MoveCardStep.propTypes = {
|
||||
/* eslint-disable react/forbid-prop-types */
|
||||
projectsToLists: PropTypes.array.isRequired,
|
||||
defaultPath: PropTypes.object.isRequired,
|
||||
/* eslint-enable react/forbid-prop-types */
|
||||
onMove: PropTypes.func.isRequired,
|
||||
onTransfer: PropTypes.func.isRequired,
|
||||
onBoardFetch: PropTypes.func.isRequired,
|
||||
onBack: PropTypes.func,
|
||||
onClose: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
MoveCardStep.defaultProps = {
|
||||
onBack: undefined,
|
||||
};
|
||||
|
||||
export default MoveCardStep;
|
10
client/src/components/MoveCardStep/MoveCardStep.module.css
Normal file
10
client/src/components/MoveCardStep/MoveCardStep.module.css
Normal file
|
@ -0,0 +1,10 @@
|
|||
.field {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.text {
|
||||
color: #444444;
|
||||
font-size: 12px;
|
||||
font-weight: bold;
|
||||
padding-bottom: 6px;
|
||||
}
|
3
client/src/components/MoveCardStep/index.js
Normal file
3
client/src/components/MoveCardStep/index.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
import MoveCardStep from './MoveCardStep';
|
||||
|
||||
export default MoveCardStep;
|
|
@ -49,6 +49,7 @@ export default {
|
|||
/* Board */
|
||||
|
||||
BOARD_IN_CURRENT_PROJECT_CREATE: `${PREFIX}/BOARD_IN_CURRENT_PROJECT_CREATE`,
|
||||
BOARD_FETCH: `${PREFIX}/BOARD_FETCH`,
|
||||
BOARD_UPDATE: `${PREFIX}/BOARD_UPDATE`,
|
||||
BOARD_MOVE: `${PREFIX}/BOARD_MOVE`,
|
||||
BOARD_DELETE: `${PREFIX}/BOARD_DELETE`,
|
||||
|
@ -78,6 +79,9 @@ export default {
|
|||
CARD_UPDATE: `${PREFIX}/CARD_UPDATE`,
|
||||
CURRENT_CARD_UPDATE: `${PREFIX}/CURRENT_CARD_UPDATE`,
|
||||
CARD_MOVE: `${PREFIX}/CARD_MOVE`,
|
||||
CURRENT_CARD_MOVE: `${PREFIX}/CURRENT_CARD_MOVE`,
|
||||
CARD_TRANSFER: `${PREFIX}/CARD_TRANSFER`,
|
||||
CURRENT_CARD_TRANSFER: `${PREFIX}/CURRENT_CARD_TRANSFER`,
|
||||
CARD_DELETE: `${PREFIX}/CARD_DELETE`,
|
||||
CURRENT_CARD_DELETE: `${PREFIX}/CURRENT_CARD_DELETE`,
|
||||
|
||||
|
|
|
@ -9,6 +9,8 @@ import {
|
|||
makeTasksByCardIdSelector,
|
||||
makeUsersByCardIdSelector,
|
||||
membershipsForCurrentProjectSelector,
|
||||
pathSelector,
|
||||
projectsToListsForCurrentUserSelector,
|
||||
} from '../selectors';
|
||||
import {
|
||||
addLabelToCard,
|
||||
|
@ -16,8 +18,11 @@ import {
|
|||
createLabelInCurrentBoard,
|
||||
deleteCard,
|
||||
deleteLabel,
|
||||
fetchBoard,
|
||||
moveCard,
|
||||
removeLabelFromCard,
|
||||
removeUserFromCard,
|
||||
transferCard,
|
||||
updateLabel,
|
||||
updateCard,
|
||||
} from '../actions/entry';
|
||||
|
@ -31,10 +36,15 @@ const makeMapStateToProps = () => {
|
|||
const notificationsTotalByCardIdSelector = makeNotificationsTotalByCardIdSelector();
|
||||
|
||||
return (state, { id, index }) => {
|
||||
const { projectId } = pathSelector(state);
|
||||
const allProjectsToLists = projectsToListsForCurrentUserSelector(state);
|
||||
const allProjectMemberships = membershipsForCurrentProjectSelector(state);
|
||||
const allLabels = labelsForCurrentBoardSelector(state);
|
||||
|
||||
const { name, dueDate, timer, coverUrl, isPersisted } = cardByIdSelector(state, id);
|
||||
const { name, dueDate, timer, coverUrl, listId, boardId, isPersisted } = cardByIdSelector(
|
||||
state,
|
||||
id,
|
||||
);
|
||||
|
||||
const users = usersByCardIdSelector(state, id);
|
||||
const labels = labelsByCardIdSelector(state, id);
|
||||
|
@ -48,11 +58,15 @@ const makeMapStateToProps = () => {
|
|||
dueDate,
|
||||
timer,
|
||||
coverUrl,
|
||||
listId,
|
||||
boardId,
|
||||
projectId,
|
||||
isPersisted,
|
||||
notificationsTotal,
|
||||
users,
|
||||
labels,
|
||||
tasks,
|
||||
allProjectsToLists,
|
||||
allProjectMemberships,
|
||||
allLabels,
|
||||
};
|
||||
|
@ -63,9 +77,12 @@ const mapDispatchToProps = (dispatch, { id }) =>
|
|||
bindActionCreators(
|
||||
{
|
||||
onUpdate: (data) => updateCard(id, data),
|
||||
onMove: (listId, index) => moveCard(id, listId, index),
|
||||
onTransfer: (boardId, listId) => transferCard(id, boardId, listId),
|
||||
onDelete: () => deleteCard(id),
|
||||
onUserAdd: (userId) => addUserToCard(userId, id),
|
||||
onUserRemove: (userId) => removeUserFromCard(userId, id),
|
||||
onBoardFetch: fetchBoard,
|
||||
onLabelAdd: (labelId) => addLabelToCard(labelId, id),
|
||||
onLabelRemove: (labelId) => removeLabelFromCard(labelId, id),
|
||||
onLabelCreate: (data) => createLabelInCurrentBoard(data),
|
||||
|
|
|
@ -11,6 +11,8 @@ import {
|
|||
labelsForCurrentBoardSelector,
|
||||
labelsForCurrentCardSelector,
|
||||
membershipsForCurrentProjectSelector,
|
||||
pathSelector,
|
||||
projectsToListsForCurrentUserSelector,
|
||||
tasksForCurrentCardSelector,
|
||||
usersForCurrentCardSelector,
|
||||
} from '../selectors';
|
||||
|
@ -27,8 +29,11 @@ import {
|
|||
deleteLabel,
|
||||
deleteTask,
|
||||
fetchActionsInCurrentCard,
|
||||
fetchBoard,
|
||||
moveCurrentCard,
|
||||
removeLabelFromCurrentCard,
|
||||
removeUserFromCurrentCard,
|
||||
transferCurrentCard,
|
||||
updateAttachment,
|
||||
updateCommentAction,
|
||||
updateCurrentCard,
|
||||
|
@ -39,7 +44,9 @@ import Paths from '../constants/Paths';
|
|||
import CardModal from '../components/CardModal';
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
const { projectId } = pathSelector(state);
|
||||
const { isAdmin } = currentUserSelector(state);
|
||||
const allProjectsToLists = projectsToListsForCurrentUserSelector(state);
|
||||
const allProjectMemberships = membershipsForCurrentProjectSelector(state);
|
||||
const allLabels = labelsForCurrentBoardSelector(state);
|
||||
|
||||
|
@ -51,6 +58,7 @@ const mapStateToProps = (state) => {
|
|||
isSubscribed,
|
||||
isActionsFetching,
|
||||
isAllActionsFetched,
|
||||
listId,
|
||||
boardId,
|
||||
} = currentCardSelector(state);
|
||||
|
||||
|
@ -68,14 +76,17 @@ const mapStateToProps = (state) => {
|
|||
isSubscribed,
|
||||
isActionsFetching,
|
||||
isAllActionsFetched,
|
||||
listId,
|
||||
boardId,
|
||||
projectId,
|
||||
users,
|
||||
labels,
|
||||
tasks,
|
||||
attachments,
|
||||
actions,
|
||||
allProjectsToLists,
|
||||
allProjectMemberships,
|
||||
allLabels,
|
||||
boardId,
|
||||
isEditable: isAdmin,
|
||||
};
|
||||
};
|
||||
|
@ -84,9 +95,12 @@ const mapDispatchToProps = (dispatch) =>
|
|||
bindActionCreators(
|
||||
{
|
||||
onUpdate: updateCurrentCard,
|
||||
onMove: moveCurrentCard,
|
||||
onTransfer: transferCurrentCard,
|
||||
onDelete: deleteCurrentCard,
|
||||
onUserAdd: addUserToCurrentCard,
|
||||
onUserRemove: removeUserFromCurrentCard,
|
||||
onBoardFetch: fetchBoard,
|
||||
onLabelAdd: addLabelToCurrentCard,
|
||||
onLabelRemove: removeLabelFromCurrentCard,
|
||||
onLabelCreate: createLabelInCurrentBoard,
|
||||
|
@ -108,7 +122,7 @@ const mapDispatchToProps = (dispatch) =>
|
|||
);
|
||||
|
||||
const mergeProps = (stateProps, dispatchProps) => ({
|
||||
...omit(stateProps, 'boardId'),
|
||||
...stateProps,
|
||||
...omit(dispatchProps, 'push'),
|
||||
onClose: () => dispatchProps.push(Paths.BOARDS.replace(':id', stateProps.boardId)),
|
||||
});
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
0 0 0 1px rgba(9, 45, 66, 0.08) !important;
|
||||
margin-top: 6px !important;
|
||||
max-height: calc(100% - 70px);
|
||||
overflow: hidden;
|
||||
overflow-y: auto;
|
||||
padding: 0 12px 12px !important;
|
||||
width: 304px;
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ export default {
|
|||
attachment: 'Attachment',
|
||||
attachments: 'Attachments',
|
||||
authentication: 'Authentication',
|
||||
board: 'Board',
|
||||
boardNotFound_title: 'Board Not Found',
|
||||
cardActions_title: 'Card Actions',
|
||||
cardNotFound_title: 'Card Not Found',
|
||||
|
@ -46,7 +47,7 @@ export default {
|
|||
createTextFile_title: 'Create Text File',
|
||||
currentPassword: 'Current password',
|
||||
date: 'Date',
|
||||
dueDate: 'Due date',
|
||||
dueDate_title: 'Due Date',
|
||||
deleteAttachment_title: 'Delete Attachment',
|
||||
deleteBoard_title: 'Delete Board',
|
||||
deleteCard_title: 'Delete Card',
|
||||
|
@ -82,14 +83,19 @@ export default {
|
|||
hours: 'Hours',
|
||||
invalidCurrentPassword: 'Invalid current password',
|
||||
labels: 'Labels',
|
||||
list: 'List',
|
||||
listActions_title: 'List Actions',
|
||||
members: 'Members',
|
||||
minutes: 'Minutes',
|
||||
moveCard_title: 'Move Card',
|
||||
name: 'Name',
|
||||
newEmail: 'New e-mail',
|
||||
newPassword: 'New password',
|
||||
newUsername: 'New username',
|
||||
noConnectionToServer: 'No connection to server',
|
||||
noBoards: 'No boards',
|
||||
noLists: 'No lists',
|
||||
noProjects: 'No projects',
|
||||
notifications: 'Notifications',
|
||||
noUnreadNotifications: 'No unread notifications',
|
||||
openBoard_title: 'Open Board',
|
||||
|
@ -99,11 +105,15 @@ export default {
|
|||
preferences: 'Preferences',
|
||||
pressPasteShortcutToAddAttachmentFromClipboard:
|
||||
'Tip: press Ctrl-V (Cmd-V on Mac) to add an attachment from the clipboard.',
|
||||
project: 'Project',
|
||||
projectNotFound_title: 'Project Not Found',
|
||||
refreshPageToLoadLastDataAndReceiveUpdates:
|
||||
'<0>Refresh the page</0> to load last data<br />and receive updates',
|
||||
removeMember_title: 'Remove Member',
|
||||
seconds: 'Seconds',
|
||||
selectBoard: 'Select board',
|
||||
selectList: 'Select list',
|
||||
selectProject: 'Select project',
|
||||
settings: 'Settings',
|
||||
subscribeToMyOwnCardsByDefault: 'Subscribe to my own cards by default',
|
||||
taskActions_title: 'Task Actions',
|
||||
|
@ -165,6 +175,8 @@ export default {
|
|||
editUsername_title: 'Edit Username',
|
||||
logOut_title: 'Log Out',
|
||||
makeCover_title: 'Make Cover',
|
||||
move: 'Move',
|
||||
moveCard_title: 'Move Card',
|
||||
remove: 'Remove',
|
||||
removeCover_title: 'Remove Cover',
|
||||
removeFromProject: 'Remove from project',
|
||||
|
|
|
@ -37,6 +37,7 @@ export default {
|
|||
attachment: 'Вложение',
|
||||
attachments: 'Вложения',
|
||||
authentication: 'Аутентификация',
|
||||
board: 'Доска',
|
||||
boardNotFound: 'Доска не найдена',
|
||||
cardActions: 'Действия с карточкой',
|
||||
cardNotFound: 'Карточка не найдена',
|
||||
|
@ -86,14 +87,19 @@ export default {
|
|||
hours: 'Часы',
|
||||
invalidCurrentPassword: 'Неверный текущий пароль',
|
||||
labels: 'Метки',
|
||||
list: 'Список',
|
||||
listActions: 'Действия со списком',
|
||||
members: 'Участники',
|
||||
minutes: 'Минуты',
|
||||
moveCard: 'Перемещение карточки',
|
||||
name: 'Имя',
|
||||
newEmail: 'Новый e-mail',
|
||||
newPassword: 'Новый пароль',
|
||||
newUsername: 'Новое имя пользователя',
|
||||
noConnectionToServer: 'Нет соединения с сервером',
|
||||
noBoards: 'Досок нет',
|
||||
noLists: 'Списков нет',
|
||||
noProjects: 'Проектов нет',
|
||||
notifications: 'Уведомления',
|
||||
noUnreadNotifications: 'Уведомлений нет',
|
||||
openBoard: 'Откройте доску',
|
||||
|
@ -103,11 +109,15 @@ export default {
|
|||
preferences: 'Предпочтения',
|
||||
pressPasteShortcutToAddAttachmentFromClipboard:
|
||||
'Совет: нажмите Ctrl-V (Cmd-V на Mac), чтобы добавить вложение из буфера обмена.',
|
||||
projectNotFound: 'Доска не найдена',
|
||||
project: 'Проект',
|
||||
projectNotFound: 'Проект не найден',
|
||||
refreshPageToLoadLastDataAndReceiveUpdates:
|
||||
'<0>Обновите страницу</0>, чтобы загрузить<br />актуальные данные и получать обновления',
|
||||
removeMember: 'Удаление участника',
|
||||
seconds: 'Секунды',
|
||||
selectBoard: 'Выберите доску',
|
||||
selectList: 'Выберите список',
|
||||
selectProject: 'Выберите проект',
|
||||
settings: 'Настройки',
|
||||
subscribeToMyOwnCardsByDefault: 'По умолчанию подписаться на мои собственные карточки',
|
||||
taskActions: 'Действия с задачей',
|
||||
|
@ -166,6 +176,8 @@ export default {
|
|||
editUsername_title: 'Изменить имя пользователя',
|
||||
logOut: 'Выйти',
|
||||
makeCover: 'Сделать обложкой',
|
||||
move: 'Переместить',
|
||||
moveCard: 'Переместить карточку',
|
||||
remove: 'Убрать',
|
||||
removeCover: 'Убрать обложку',
|
||||
removeFromProject: 'Удалить из проекта',
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
import { call, put, select } from 'redux-saga/effects';
|
||||
|
||||
import { goToBoardService, goToProjectService } from './router';
|
||||
import { createBoardRequest, deleteBoardRequest, updateBoardRequest } from '../requests';
|
||||
import {
|
||||
createBoardRequest,
|
||||
deleteBoardRequest,
|
||||
fetchBoardRequest,
|
||||
updateBoardRequest,
|
||||
} from '../requests';
|
||||
import { boardByIdSelector, nextBoardPositionSelector, pathSelector } from '../../../selectors';
|
||||
import { createBoard, deleteBoard, updateBoard } from '../../../actions';
|
||||
import { createLocalId } from '../../../utils/local-id';
|
||||
|
@ -38,6 +43,10 @@ export function* createBoardInCurrentProjectService(data) {
|
|||
yield call(createBoardService, projectId, data);
|
||||
}
|
||||
|
||||
export function* fetchBoard(id) {
|
||||
yield call(fetchBoardRequest, id);
|
||||
}
|
||||
|
||||
export function* updateBoardService(id, data) {
|
||||
yield put(updateBoard(id, data));
|
||||
yield call(updateBoardRequest, id, data);
|
||||
|
|
|
@ -45,6 +45,29 @@ export function* moveCardService(id, listId, index) {
|
|||
});
|
||||
}
|
||||
|
||||
export function* moveCurrentCardService(listId, index) {
|
||||
const { cardId } = yield select(pathSelector);
|
||||
|
||||
yield call(moveCardService, cardId, listId, index);
|
||||
}
|
||||
|
||||
export function* transferCardService(id, boardId, listId, index) {
|
||||
const position = yield select(nextCardPositionSelector, listId, index, id);
|
||||
|
||||
yield call(updateCardService, id, {
|
||||
boardId,
|
||||
listId,
|
||||
position,
|
||||
});
|
||||
}
|
||||
|
||||
export function* transferCurrentCardService(boardId, listId, index) {
|
||||
const { cardId, boardId: currentBoardId } = yield select(pathSelector);
|
||||
|
||||
yield call(goToBoardService, currentBoardId);
|
||||
yield call(transferCardService, cardId, boardId, listId, index);
|
||||
}
|
||||
|
||||
export function* deleteCardService(id) {
|
||||
const { cardId, boardId } = yield select(pathSelector);
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ export function* runPathActionsService(pathsMatch) {
|
|||
switch (pathsMatch.path) {
|
||||
case Paths.BOARDS:
|
||||
case Paths.CARDS: {
|
||||
const currentBoard = yield select(currentBoardSelector);
|
||||
const currentBoard = yield select(currentBoardSelector); // TODO: move to services
|
||||
|
||||
if (currentBoard && currentBoard.isFetching === null) {
|
||||
yield call(fetchBoardRequest, currentBoard.id);
|
||||
|
|
|
@ -3,6 +3,7 @@ import { all, takeLatest } from 'redux-saga/effects';
|
|||
import {
|
||||
createBoardInCurrentProjectService,
|
||||
deleteBoardService,
|
||||
fetchBoard,
|
||||
moveBoardService,
|
||||
updateBoardService,
|
||||
} from '../services';
|
||||
|
@ -13,6 +14,7 @@ export default function* () {
|
|||
takeLatest(EntryActionTypes.BOARD_IN_CURRENT_PROJECT_CREATE, ({ payload: { data } }) =>
|
||||
createBoardInCurrentProjectService(data),
|
||||
),
|
||||
takeLatest(EntryActionTypes.BOARD_FETCH, ({ payload: { id } }) => fetchBoard(id)),
|
||||
takeLatest(EntryActionTypes.BOARD_UPDATE, ({ payload: { id, data } }) =>
|
||||
updateBoardService(id, data),
|
||||
),
|
||||
|
|
|
@ -5,6 +5,9 @@ import {
|
|||
deleteCardService,
|
||||
deleteCurrentCardService,
|
||||
moveCardService,
|
||||
moveCurrentCardService,
|
||||
transferCardService,
|
||||
transferCurrentCardService,
|
||||
updateCardService,
|
||||
updateCurrentCardService,
|
||||
} from '../services';
|
||||
|
@ -24,6 +27,15 @@ export default function* () {
|
|||
takeLatest(EntryActionTypes.CARD_MOVE, ({ payload: { id, listId, index } }) =>
|
||||
moveCardService(id, listId, index),
|
||||
),
|
||||
takeLatest(EntryActionTypes.CURRENT_CARD_MOVE, ({ payload: { listId, index } }) =>
|
||||
moveCurrentCardService(listId, index),
|
||||
),
|
||||
takeLatest(EntryActionTypes.CARD_TRANSFER, ({ payload: { id, boardId, listId, index } }) =>
|
||||
transferCardService(id, boardId, listId, index),
|
||||
),
|
||||
takeLatest(EntryActionTypes.CURRENT_CARD_TRANSFER, ({ payload: { boardId, listId, index } }) =>
|
||||
transferCurrentCardService(boardId, listId, index),
|
||||
),
|
||||
takeLatest(EntryActionTypes.CARD_DELETE, ({ payload: { id } }) => deleteCardService(id)),
|
||||
takeLatest(EntryActionTypes.CURRENT_CARD_DELETE, () => deleteCurrentCardService()),
|
||||
]);
|
||||
|
|
|
@ -63,6 +63,36 @@ export const projectsForCurrentUserSelector = createSelector(
|
|||
},
|
||||
);
|
||||
|
||||
export const projectsToListsForCurrentUserSelector = createSelector(
|
||||
orm,
|
||||
(state) => currentUserIdSelector(state),
|
||||
({ User }, id) => {
|
||||
if (!id) {
|
||||
return id;
|
||||
}
|
||||
|
||||
const userModel = User.withId(id);
|
||||
|
||||
if (!userModel) {
|
||||
return userModel;
|
||||
}
|
||||
|
||||
return userModel
|
||||
.getOrderedProjectMembershipsQuerySet()
|
||||
.toModelArray()
|
||||
.map(({ project: projectModel }) => ({
|
||||
...projectModel.ref,
|
||||
boards: projectModel
|
||||
.getOrderedBoardsQuerySet()
|
||||
.toModelArray()
|
||||
.map((boardModel) => ({
|
||||
...boardModel.ref,
|
||||
lists: boardModel.getOrderedListsQuerySet().toRefArray(),
|
||||
})),
|
||||
}));
|
||||
},
|
||||
);
|
||||
|
||||
export const notificationsForCurrentUserSelector = createSelector(
|
||||
orm,
|
||||
(state) => currentUserIdSelector(state),
|
||||
|
|
|
@ -20,6 +20,10 @@ module.exports = {
|
|||
type: 'string',
|
||||
regex: /^[0-9]+$/,
|
||||
},
|
||||
boardId: {
|
||||
type: 'string',
|
||||
regex: /^[0-9]+$/,
|
||||
},
|
||||
coverAttachmentId: {
|
||||
type: 'string',
|
||||
regex: /^[0-9]+$/,
|
||||
|
@ -71,10 +75,10 @@ module.exports = {
|
|||
.getCardToProjectPath(inputs.id)
|
||||
.intercept('pathNotFound', () => Errors.CARD_NOT_FOUND);
|
||||
|
||||
let { card } = cardToProjectPath;
|
||||
const { list, project } = cardToProjectPath;
|
||||
let { card, project } = cardToProjectPath;
|
||||
const { list } = cardToProjectPath;
|
||||
|
||||
const isUserMemberForProject = await sails.helpers.isUserMemberForProject(
|
||||
let isUserMemberForProject = await sails.helpers.isUserMemberForProject(
|
||||
project.id,
|
||||
currentUser.id,
|
||||
);
|
||||
|
@ -87,12 +91,25 @@ module.exports = {
|
|||
if (!_.isUndefined(inputs.listId) && inputs.listId !== list.id) {
|
||||
toList = await List.findOne({
|
||||
id: inputs.listId,
|
||||
boardId: card.boardId,
|
||||
boardId: inputs.boardId || card.boardId,
|
||||
});
|
||||
|
||||
if (!toList) {
|
||||
throw Errors.LIST_NOT_FOUND;
|
||||
}
|
||||
|
||||
({ project } = await sails.helpers
|
||||
.getListToProjectPath(toList.id)
|
||||
.intercept('pathNotFound', () => Errors.LIST_NOT_FOUND));
|
||||
|
||||
isUserMemberForProject = await sails.helpers.isUserMemberForProject(
|
||||
project.id,
|
||||
currentUser.id,
|
||||
);
|
||||
|
||||
if (!isUserMemberForProject) {
|
||||
throw Errors.LIST_NOT_FOUND; // Forbidden
|
||||
}
|
||||
}
|
||||
|
||||
const values = _.pick(inputs, [
|
||||
|
|
|
@ -40,6 +40,10 @@ module.exports = {
|
|||
delete inputs.toList; // eslint-disable-line no-param-reassign
|
||||
} else {
|
||||
values.listId = inputs.toList.id;
|
||||
|
||||
if (inputs.toList.boardId !== inputs.list.boardId) {
|
||||
values.boardId = inputs.toList.boardId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -92,6 +96,7 @@ module.exports = {
|
|||
);
|
||||
|
||||
if (inputs.toList) {
|
||||
// TODO: add transfer action
|
||||
await sails.helpers.createAction(card, inputs.user, {
|
||||
type: 'moveCard',
|
||||
data: {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue