mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-21 06:59:09 +00:00
event menu is component
This commit is contained in:
@@ -1,31 +1,22 @@
|
|||||||
import {
|
import { useContext, useEffect } from 'react';
|
||||||
AddIcon,
|
|
||||||
AttachmentIcon,
|
|
||||||
ChevronDownIcon,
|
|
||||||
DownloadIcon,
|
|
||||||
} from '@chakra-ui/icons';
|
|
||||||
import {
|
|
||||||
Button,
|
|
||||||
ButtonGroup,
|
|
||||||
IconButton,
|
|
||||||
Menu,
|
|
||||||
MenuButton,
|
|
||||||
MenuItem,
|
|
||||||
MenuList,
|
|
||||||
} from '@chakra-ui/react';
|
|
||||||
import { useContext } from 'react';
|
|
||||||
import { EventContext } from '../../../app/context/eventContext';
|
import { EventContext } from '../../../app/context/eventContext';
|
||||||
import { EventListContext } from '../../../app/context/eventListContext';
|
import { EventListContext } from '../../../app/context/eventListContext';
|
||||||
import EventListItem from './EventListItem';
|
import EventListItem from './EventListItem';
|
||||||
import style from './List.module.css';
|
import style from './List.module.css';
|
||||||
import DelayBlock from './DelayBlock';
|
import DelayBlock from './DelayBlock';
|
||||||
import BlockBlock from './BlockBlock';
|
import BlockBlock from './BlockBlock';
|
||||||
|
import EventListMenu from '../../menu/EventListMenu';
|
||||||
|
|
||||||
export default function EventList() {
|
|
||||||
|
export default function EventList(props) {
|
||||||
const [events, setEvents] = useContext(EventListContext);
|
const [events, setEvents] = useContext(EventListContext);
|
||||||
const [event] = useContext(EventContext);
|
const [event] = useContext(EventContext);
|
||||||
|
|
||||||
const selected = event?.id || -1;
|
// update number of events
|
||||||
|
useEffect(() => {
|
||||||
|
const f = events.filter((e) => e.type === 'event');
|
||||||
|
props.updatePlayback({ numEvents: f.length });
|
||||||
|
}, [events]);
|
||||||
|
|
||||||
const insertItemAt = (item, index) => {
|
const insertItemAt = (item, index) => {
|
||||||
// handle insert at beggining of array
|
// handle insert at beggining of array
|
||||||
@@ -116,63 +107,21 @@ export default function EventList() {
|
|||||||
|
|
||||||
console.log('events in event list', events);
|
console.log('events in event list', events);
|
||||||
let cumulativeDelay = 0;
|
let cumulativeDelay = 0;
|
||||||
|
let eventCount = -1;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className={style.headerButtons}>
|
<EventListMenu createEvent={createEvent} />
|
||||||
<Menu>
|
|
||||||
<ButtonGroup isAttached>
|
|
||||||
<Button size='sm' variant='outline'>
|
|
||||||
Upload
|
|
||||||
</Button>
|
|
||||||
<MenuButton
|
|
||||||
as={Button}
|
|
||||||
leftIcon={<AttachmentIcon />}
|
|
||||||
size='sm'
|
|
||||||
variant='outline'
|
|
||||||
>
|
|
||||||
<ChevronDownIcon />
|
|
||||||
</MenuButton>
|
|
||||||
</ButtonGroup>
|
|
||||||
<MenuList>
|
|
||||||
<MenuItem>Upload Excel</MenuItem>
|
|
||||||
<MenuItem>Upload CSV</MenuItem>
|
|
||||||
</MenuList>
|
|
||||||
</Menu>
|
|
||||||
<Menu>
|
|
||||||
<ButtonGroup isAttached>
|
|
||||||
<Button size='sm' variant='outline'>
|
|
||||||
Save
|
|
||||||
</Button>
|
|
||||||
<MenuButton
|
|
||||||
as={Button}
|
|
||||||
leftIcon={<DownloadIcon />}
|
|
||||||
size='sm'
|
|
||||||
variant='outline'
|
|
||||||
>
|
|
||||||
<ChevronDownIcon />
|
|
||||||
</MenuButton>
|
|
||||||
</ButtonGroup>
|
|
||||||
<MenuList>
|
|
||||||
<MenuItem>Download Excel</MenuItem>
|
|
||||||
<MenuItem>Download CSV</MenuItem>
|
|
||||||
</MenuList>
|
|
||||||
</Menu>
|
|
||||||
<IconButton
|
|
||||||
size='sm'
|
|
||||||
icon={<AddIcon />}
|
|
||||||
colorScheme='blue'
|
|
||||||
onClick={() => createEvent()}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className={style.eventContainer}>
|
<div className={style.eventContainer}>
|
||||||
{events.map((e, index) => {
|
{events.map((e, index) => {
|
||||||
if (e.type === 'event') {
|
if (e.type === 'event') {
|
||||||
|
eventCount = eventCount + 1;
|
||||||
return (
|
return (
|
||||||
<EventListItem
|
<EventListItem
|
||||||
key={e.id}
|
key={e.id}
|
||||||
index={index}
|
index={index}
|
||||||
data={e}
|
data={e}
|
||||||
selected={e.id === selected}
|
selected={props.selected === eventCount}
|
||||||
createEvent={createEvent}
|
createEvent={createEvent}
|
||||||
deleteEvent={deleteEvent}
|
deleteEvent={deleteEvent}
|
||||||
createDelay={createDelay}
|
createDelay={createDelay}
|
||||||
|
|||||||
@@ -1,11 +1,4 @@
|
|||||||
/* ============= EVENT LIST ============= */
|
/* ============= EVENT LIST ============= */
|
||||||
.headerButtons {
|
|
||||||
display: flex;
|
|
||||||
gap: 0.5em;
|
|
||||||
align-content: center;
|
|
||||||
justify-content: flex-end;
|
|
||||||
}
|
|
||||||
|
|
||||||
.eventContainer {
|
.eventContainer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20,7 +13,8 @@
|
|||||||
left: 0;
|
left: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: auto auto 5em 1fr auto;
|
grid-template-columns: auto 5em 1fr auto;
|
||||||
|
padding-left: 1em;
|
||||||
gap: 0.5em;
|
gap: 0.5em;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-content: center;
|
align-content: center;
|
||||||
@@ -31,10 +25,14 @@
|
|||||||
|
|
||||||
.eventRow {
|
.eventRow {
|
||||||
background-color: #0001;
|
background-color: #0001;
|
||||||
|
border-top: 2px solid #0001;
|
||||||
|
border-bottom: 2px solid #0001;
|
||||||
}
|
}
|
||||||
|
|
||||||
.eventRowActive {
|
.eventRowActive {
|
||||||
background-color: #b2f5eaaa;
|
background-color: #b2f5eaaa;
|
||||||
|
border-top: 2px solid #b2f5ea;
|
||||||
|
border-bottom: 2px solid #b2f5ea;
|
||||||
}
|
}
|
||||||
|
|
||||||
.arm,
|
.arm,
|
||||||
@@ -136,12 +134,11 @@
|
|||||||
top: 1em;
|
top: 1em;
|
||||||
margin: 0.2em 0;
|
margin: 0.2em 0;
|
||||||
padding: 0.2em 1em;
|
padding: 0.2em 1em;
|
||||||
width: 100%;
|
|
||||||
background-color: #ecc94baa;
|
background-color: #ecc94baa;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
color: white;
|
color: white;
|
||||||
border: 1px solid #0001;
|
border: 1px solid #0001;
|
||||||
border-top: 8px solid #ecc94b;
|
border-top: 4px solid #ecc94b;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
import { AddIcon, ChevronDownIcon } from '@chakra-ui/icons';
|
||||||
|
import {
|
||||||
|
Button,
|
||||||
|
ButtonGroup,
|
||||||
|
IconButton,
|
||||||
|
Menu,
|
||||||
|
MenuButton,
|
||||||
|
MenuItem,
|
||||||
|
MenuList,
|
||||||
|
} from '@chakra-ui/react';
|
||||||
|
import style from './EventListMenu.module.css';
|
||||||
|
|
||||||
|
export default function EventListMenu(props) {
|
||||||
|
const buttonProps = {
|
||||||
|
size: 'sm',
|
||||||
|
variant: 'outline',
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<div className={style.headerButtons}>
|
||||||
|
<Menu>
|
||||||
|
<ButtonGroup isAttached>
|
||||||
|
<Button size='sm' variant='outline'>
|
||||||
|
Upload
|
||||||
|
</Button>
|
||||||
|
<MenuButton as={Button} {...buttonProps}>
|
||||||
|
<ChevronDownIcon />
|
||||||
|
</MenuButton>
|
||||||
|
</ButtonGroup>
|
||||||
|
<MenuList>
|
||||||
|
<MenuItem>Upload Excel</MenuItem>
|
||||||
|
<MenuItem>Upload CSV</MenuItem>
|
||||||
|
</MenuList>
|
||||||
|
</Menu>
|
||||||
|
<Menu>
|
||||||
|
<ButtonGroup isAttached>
|
||||||
|
<Button {...buttonProps}>Save</Button>
|
||||||
|
<MenuButton as={Button} {...buttonProps}>
|
||||||
|
<ChevronDownIcon />
|
||||||
|
</MenuButton>
|
||||||
|
</ButtonGroup>
|
||||||
|
<MenuList>
|
||||||
|
<MenuItem>Download Excel</MenuItem>
|
||||||
|
<MenuItem>Download CSV</MenuItem>
|
||||||
|
</MenuList>
|
||||||
|
</Menu>
|
||||||
|
<IconButton
|
||||||
|
size='sm'
|
||||||
|
icon={<AddIcon />}
|
||||||
|
colorScheme='blue'
|
||||||
|
onClick={() => props.createEvent()}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
.headerButtons {
|
||||||
|
display: flex;
|
||||||
|
gap: 0.5em;
|
||||||
|
align-content: center;
|
||||||
|
justify-content: flex-end;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user