mirror of
https://github.com/plankanban/planka.git
synced 2025-07-29 18:19:46 +02:00
parent
e70b92b52b
commit
3ce2e8ef91
22 changed files with 419 additions and 18 deletions
|
@ -5,15 +5,17 @@ import { Menu } from 'semantic-ui-react';
|
|||
import { Popup } from '../../lib/custom-ui';
|
||||
|
||||
import { useSteps } from '../../hooks';
|
||||
import ListSortStep from '../ListSortStep';
|
||||
import DeleteStep from '../DeleteStep';
|
||||
|
||||
import styles from './ActionsStep.module.scss';
|
||||
|
||||
const StepTypes = {
|
||||
DELETE: 'DELETE',
|
||||
SORT: 'SORT',
|
||||
};
|
||||
|
||||
const ActionsStep = React.memo(({ onNameEdit, onCardAdd, onDelete, onClose }) => {
|
||||
const ActionsStep = React.memo(({ onNameEdit, onCardAdd, onSort, onDelete, onClose }) => {
|
||||
const [t] = useTranslation();
|
||||
const [step, openStep, handleBack] = useSteps();
|
||||
|
||||
|
@ -27,20 +29,41 @@ const ActionsStep = React.memo(({ onNameEdit, onCardAdd, onDelete, onClose }) =>
|
|||
onClose();
|
||||
}, [onCardAdd, onClose]);
|
||||
|
||||
const handleSortClick = useCallback(() => {
|
||||
openStep(StepTypes.SORT);
|
||||
}, [openStep]);
|
||||
|
||||
const handleDeleteClick = useCallback(() => {
|
||||
openStep(StepTypes.DELETE);
|
||||
}, [openStep]);
|
||||
|
||||
if (step && step.type === StepTypes.DELETE) {
|
||||
return (
|
||||
<DeleteStep
|
||||
title="common.deleteList"
|
||||
content="common.areYouSureYouWantToDeleteThisList"
|
||||
buttonContent="action.deleteList"
|
||||
onConfirm={onDelete}
|
||||
onBack={handleBack}
|
||||
/>
|
||||
);
|
||||
const handleSortTypeSelect = useCallback(
|
||||
(type) => {
|
||||
onSort({
|
||||
type,
|
||||
});
|
||||
|
||||
onClose();
|
||||
},
|
||||
[onSort, onClose],
|
||||
);
|
||||
|
||||
if (step && step.type) {
|
||||
switch (step.type) {
|
||||
case StepTypes.SORT:
|
||||
return <ListSortStep onTypeSelect={handleSortTypeSelect} onBack={handleBack} />;
|
||||
case StepTypes.DELETE:
|
||||
return (
|
||||
<DeleteStep
|
||||
title="common.deleteList"
|
||||
content="common.areYouSureYouWantToDeleteThisList"
|
||||
buttonContent="action.deleteList"
|
||||
onConfirm={onDelete}
|
||||
onBack={handleBack}
|
||||
/>
|
||||
);
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
|
@ -62,6 +85,11 @@ const ActionsStep = React.memo(({ onNameEdit, onCardAdd, onDelete, onClose }) =>
|
|||
context: 'title',
|
||||
})}
|
||||
</Menu.Item>
|
||||
<Menu.Item className={styles.menuItem} onClick={handleSortClick}>
|
||||
{t('action.sortList', {
|
||||
context: 'title',
|
||||
})}
|
||||
</Menu.Item>
|
||||
<Menu.Item className={styles.menuItem} onClick={handleDeleteClick}>
|
||||
{t('action.deleteList', {
|
||||
context: 'title',
|
||||
|
@ -77,6 +105,7 @@ ActionsStep.propTypes = {
|
|||
onNameEdit: PropTypes.func.isRequired,
|
||||
onCardAdd: PropTypes.func.isRequired,
|
||||
onDelete: PropTypes.func.isRequired,
|
||||
onSort: PropTypes.func.isRequired,
|
||||
onClose: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
|
|
|
@ -16,7 +16,18 @@ import { ReactComponent as PlusMathIcon } from '../../assets/images/plus-math-ic
|
|||
import styles from './List.module.scss';
|
||||
|
||||
const List = React.memo(
|
||||
({ id, index, name, isPersisted, cardIds, canEdit, onUpdate, onDelete, onCardCreate }) => {
|
||||
({
|
||||
id,
|
||||
index,
|
||||
name,
|
||||
isPersisted,
|
||||
cardIds,
|
||||
canEdit,
|
||||
onUpdate,
|
||||
onDelete,
|
||||
onSort,
|
||||
onCardCreate,
|
||||
}) => {
|
||||
const [t] = useTranslation();
|
||||
const [isAddCardOpened, setIsAddCardOpened] = useState(false);
|
||||
|
||||
|
@ -114,6 +125,7 @@ const List = React.memo(
|
|||
onNameEdit={handleNameEdit}
|
||||
onCardAdd={handleCardAdd}
|
||||
onDelete={onDelete}
|
||||
onSort={onSort}
|
||||
>
|
||||
<Button className={classNames(styles.headerButton, styles.target)}>
|
||||
<Icon fitted name="pencil" size="small" />
|
||||
|
@ -159,6 +171,7 @@ List.propTypes = {
|
|||
cardIds: PropTypes.array.isRequired, // eslint-disable-line react/forbid-prop-types
|
||||
canEdit: PropTypes.bool.isRequired,
|
||||
onUpdate: PropTypes.func.isRequired,
|
||||
onSort: PropTypes.func.isRequired,
|
||||
onDelete: PropTypes.func.isRequired,
|
||||
onCardCreate: PropTypes.func.isRequired,
|
||||
};
|
||||
|
|
61
client/src/components/ListSortStep/ListSortStep.jsx
Normal file
61
client/src/components/ListSortStep/ListSortStep.jsx
Normal file
|
@ -0,0 +1,61 @@
|
|||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Menu } from 'semantic-ui-react';
|
||||
import { Popup } from '../../lib/custom-ui';
|
||||
import { ListSortTypes } from '../../constants/Enums';
|
||||
|
||||
import styles from './ListSortStep.module.scss';
|
||||
|
||||
const ListSortStep = React.memo(({ onTypeSelect, onBack }) => {
|
||||
const [t] = useTranslation();
|
||||
|
||||
return (
|
||||
<>
|
||||
<Popup.Header onBack={onBack}>
|
||||
{t('common.sortList', {
|
||||
context: 'title',
|
||||
})}
|
||||
</Popup.Header>
|
||||
<Popup.Content>
|
||||
<Menu secondary vertical className={styles.menu}>
|
||||
<Menu.Item
|
||||
className={styles.menuItem}
|
||||
onClick={() => onTypeSelect(ListSortTypes.NAME_ASC)}
|
||||
>
|
||||
{t('common.name')}
|
||||
</Menu.Item>
|
||||
<Menu.Item
|
||||
className={styles.menuItem}
|
||||
onClick={() => onTypeSelect(ListSortTypes.DUE_DATE_ASC)}
|
||||
>
|
||||
{t('common.dueDate')}
|
||||
</Menu.Item>
|
||||
<Menu.Item
|
||||
className={styles.menuItem}
|
||||
onClick={() => onTypeSelect(ListSortTypes.CREATED_AT_ASC)}
|
||||
>
|
||||
{t('common.oldestFirst')}
|
||||
</Menu.Item>
|
||||
<Menu.Item
|
||||
className={styles.menuItem}
|
||||
onClick={() => onTypeSelect(ListSortTypes.CREATED_AT_DESC)}
|
||||
>
|
||||
{t('common.newestFirst')}
|
||||
</Menu.Item>
|
||||
</Menu>
|
||||
</Popup.Content>
|
||||
</>
|
||||
);
|
||||
});
|
||||
|
||||
ListSortStep.propTypes = {
|
||||
onTypeSelect: PropTypes.func.isRequired,
|
||||
onBack: PropTypes.func,
|
||||
};
|
||||
|
||||
ListSortStep.defaultProps = {
|
||||
onBack: undefined,
|
||||
};
|
||||
|
||||
export default ListSortStep;
|
11
client/src/components/ListSortStep/ListSortStep.module.scss
Normal file
11
client/src/components/ListSortStep/ListSortStep.module.scss
Normal file
|
@ -0,0 +1,11 @@
|
|||
:global(#app) {
|
||||
.menu {
|
||||
margin: -7px -12px -5px;
|
||||
width: calc(100% + 24px);
|
||||
}
|
||||
|
||||
.menuItem {
|
||||
margin: 0;
|
||||
padding-left: 14px;
|
||||
}
|
||||
}
|
3
client/src/components/ListSortStep/index.js
Normal file
3
client/src/components/ListSortStep/index.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
import ListSortStep from './ListSortStep';
|
||||
|
||||
export default ListSortStep;
|
Loading…
Add table
Add a link
Reference in a new issue