mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-20 22:49:18 +00:00
refactor: milestone actions in context menu
This commit is contained in:
committed by
Carlos Valente
parent
1e63238cac
commit
126ff61738
@@ -10,7 +10,7 @@
|
|||||||
color: $section-white; // to override inline
|
color: $section-white; // to override inline
|
||||||
|
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 2rem 8rem 1fr auto;
|
grid-template-columns: 2rem 1fr 3fr;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
height: $secondary-block-height;
|
height: $secondary-block-height;
|
||||||
gap: 0.5rem;
|
gap: 0.5rem;
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import { MouseEvent, useCallback, useRef } from 'react';
|
import { MouseEvent, useCallback, useRef } from 'react';
|
||||||
import { IoClose, IoReorderTwo } from 'react-icons/io5';
|
import { IoReorderTwo, IoTrash } from 'react-icons/io5';
|
||||||
import { useSortable } from '@dnd-kit/sortable';
|
import { useSortable } from '@dnd-kit/sortable';
|
||||||
import { CSS } from '@dnd-kit/utilities';
|
import { CSS } from '@dnd-kit/utilities';
|
||||||
import { EntryId } from 'ontime-types';
|
import { EntryId } from 'ontime-types';
|
||||||
|
|
||||||
import Button from '../../../common/components/buttons/Button';
|
|
||||||
import Input from '../../../common/components/input/input/Input';
|
import Input from '../../../common/components/input/input/Input';
|
||||||
import useReactiveTextInput from '../../../common/components/input/text-input/useReactiveTextInput';
|
import useReactiveTextInput from '../../../common/components/input/text-input/useReactiveTextInput';
|
||||||
|
import { useContextMenu } from '../../../common/hooks/useContextMenu';
|
||||||
import { useEntryActions } from '../../../common/hooks/useEntryAction';
|
import { useEntryActions } from '../../../common/hooks/useEntryAction';
|
||||||
import { cx, getAccessibleColour } from '../../../common/utils/styleUtils';
|
import { cx, getAccessibleColour } from '../../../common/utils/styleUtils';
|
||||||
import { useEventSelection } from '../useEventSelection';
|
import { useEventSelection } from '../useEventSelection';
|
||||||
@@ -26,6 +26,15 @@ export default function RundownMilestone({ colour, cue, entryId, hasCursor, titl
|
|||||||
const { updateEntry, deleteEntry } = useEntryActions();
|
const { updateEntry, deleteEntry } = useEntryActions();
|
||||||
const { selectedEvents, setSelectedBlock } = useEventSelection();
|
const { selectedEvents, setSelectedBlock } = useEventSelection();
|
||||||
|
|
||||||
|
const [onContextMenu] = useContextMenu<HTMLDivElement>([
|
||||||
|
{
|
||||||
|
type: 'item',
|
||||||
|
label: 'Delete',
|
||||||
|
icon: IoTrash,
|
||||||
|
onClick: () => deleteEntry([entryId]),
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
attributes: dragAttributes,
|
attributes: dragAttributes,
|
||||||
listeners: dragListeners,
|
listeners: dragListeners,
|
||||||
@@ -59,11 +68,6 @@ export default function RundownMilestone({ colour, cue, entryId, hasCursor, titl
|
|||||||
updateEntry({ id: entryId, [field]: value });
|
updateEntry({ id: entryId, [field]: value });
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDelete = (event: MouseEvent) => {
|
|
||||||
event.stopPropagation();
|
|
||||||
deleteEntry([entryId]);
|
|
||||||
};
|
|
||||||
|
|
||||||
const dragStyle = {
|
const dragStyle = {
|
||||||
zIndex: isDragging ? 2 : 'inherit',
|
zIndex: isDragging ? 2 : 'inherit',
|
||||||
transform: CSS.Translate.toString(transform),
|
transform: CSS.Translate.toString(transform),
|
||||||
@@ -77,6 +81,7 @@ export default function RundownMilestone({ colour, cue, entryId, hasCursor, titl
|
|||||||
className={cx([style.milestone, hasCursor ? style.hasCursor : null])}
|
className={cx([style.milestone, hasCursor ? style.hasCursor : null])}
|
||||||
ref={setNodeRef}
|
ref={setNodeRef}
|
||||||
onClick={handleFocusClick}
|
onClick={handleFocusClick}
|
||||||
|
onContextMenu={onContextMenu}
|
||||||
style={dragStyle}
|
style={dragStyle}
|
||||||
data-testid='rundown-milestone'
|
data-testid='rundown-milestone'
|
||||||
>
|
>
|
||||||
@@ -87,9 +92,6 @@ export default function RundownMilestone({ colour, cue, entryId, hasCursor, titl
|
|||||||
</div>
|
</div>
|
||||||
<MilestoneTextInput field='cue' initialValue={cue} placeholder='Cue' submitHandler={handleUpdate} />
|
<MilestoneTextInput field='cue' initialValue={cue} placeholder='Cue' submitHandler={handleUpdate} />
|
||||||
<MilestoneTextInput field='title' initialValue={title} placeholder='Title' submitHandler={handleUpdate} />
|
<MilestoneTextInput field='title' initialValue={title} placeholder='Title' submitHandler={handleUpdate} />
|
||||||
<Button variant='ghosted-destructive' onClick={handleDelete}>
|
|
||||||
<IoClose /> Cancel
|
|
||||||
</Button>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user