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