diff --git a/client/src/features/editors/list/ActionButtons.jsx b/client/src/features/editors/list/ActionButtons.jsx index 76b108c9e..0c458113b 100644 --- a/client/src/features/editors/list/ActionButtons.jsx +++ b/client/src/features/editors/list/ActionButtons.jsx @@ -17,10 +17,10 @@ export default function ActionButtons(props) { aria-label='Options' size='xs' icon={} - _hover={{ bg: 'pink.500' }} - _expanded={{ bg: 'pink.300' }} + _expanded={{ bg: 'pink.300', color: 'white' }} _focus={{ boxShadow: 'none' }} - colorScheme='pink' + backgroundColor={'orange.200'} + color={'orange.500'} /> {showDel && ( diff --git a/client/src/features/editors/list/Block.module.css b/client/src/features/editors/list/Block.module.css index 5e74eb029..eb704ae02 100644 --- a/client/src/features/editors/list/Block.module.css +++ b/client/src/features/editors/list/Block.module.css @@ -6,6 +6,8 @@ .delay { position: relative; margin: 0.2em 0; + padding: 0.2em 0.5em; + width: 100%; border-radius: 8px; font-size: 15px; @@ -14,7 +16,6 @@ .block, .delay { - padding: 0.2em 1em; box-sizing: border-box; display: flex; gap: 1em; @@ -27,6 +28,7 @@ gap: 0.5em; align-content: center; align-self: flex-start; + opacity: 0.8; transition: linear 0.1s; } @@ -47,7 +49,6 @@ .eventRow, .eventRowActive { - padding: 0.2em 0.5em; padding-left: 1em; display: grid; diff --git a/client/src/features/editors/list/BlockBlock.jsx b/client/src/features/editors/list/BlockBlock.jsx index 759484daa..3ede535fc 100644 --- a/client/src/features/editors/list/BlockBlock.jsx +++ b/client/src/features/editors/list/BlockBlock.jsx @@ -1,3 +1,4 @@ +import DeleteIconBtn from '../../../common/components/buttons/DeleteIconBtn'; import ActionButtons from './ActionButtons'; import style from './Block.module.css'; @@ -17,14 +18,12 @@ export default function BlockBlock(props) { return (
+
diff --git a/client/src/features/editors/list/DelayBlock.jsx b/client/src/features/editors/list/DelayBlock.jsx index f5120a43c..89a9688a2 100644 --- a/client/src/features/editors/list/DelayBlock.jsx +++ b/client/src/features/editors/list/DelayBlock.jsx @@ -2,6 +2,7 @@ import { millisToMinutes } from '../../../common/dateConfig'; import TimeInput from '../../../common/input/TimeInput'; import style from './Block.module.css'; import ActionButtons from './ActionButtons'; +import DeleteIconBtn from '../../../common/components/buttons/DeleteIconBtn'; export default function DelayBlock(props) { const { data, eventsHandler, index } = props; @@ -12,7 +13,6 @@ export default function DelayBlock(props) { const submitHandler = (value) => { // convert to ms and patch - console.log('debug adding', { id: data.id, duration: value * 1000 * 60 }); eventsHandler('patch', { id: data.id, duration: value * 1000 * 60 }); }; @@ -27,12 +27,8 @@ export default function DelayBlock(props) { submitHandler={submitHandler} />
- + +
); diff --git a/client/src/features/editors/list/EventBlock.jsx b/client/src/features/editors/list/EventBlock.jsx index ba9b4ff0d..9b481ec57 100644 --- a/client/src/features/editors/list/EventBlock.jsx +++ b/client/src/features/editors/list/EventBlock.jsx @@ -7,6 +7,7 @@ import EditableText from '../../../common/input/EditableText'; import DelayValue from '../../../common/input/DelayValue'; import ActionButtons from './ActionButtons'; import VisibleIconBtn from '../../../common/components/buttons/VisibleIconBtn'; +import DeleteIconBtn from '../../../common/components/buttons/DeleteIconBtn'; export default function EventBlock(props) { const { data, selected, delay, index, eventsHandler } = props; @@ -115,16 +116,14 @@ export default function EventBlock(props) { clickHandler={() => setVisible(!visible)} active={visible} /> + diff --git a/server/classes/EventTimer.js b/server/classes/EventTimer.js index b5fb6b4c5..608dc6930 100644 --- a/server/classes/EventTimer.js +++ b/server/classes/EventTimer.js @@ -80,20 +80,20 @@ class EventTimer extends Timer { update() { // if there is nothing selected, no nothing - if (!this.selectedEventId) return; + if (this.selectedEventId == null) return; super.update(); } start() { // if there is nothing selected, no nothing - if (!this.selectedEventId) return; - super.start() + if (this.selectedEventId == null) return; + super.start(); } pause() { // if there is nothing selected, no nothing - if (!this.selectedEventId) return; - super.pause() + if (this.selectedEventId == null) return; + super.pause(); } _setterManager(action, payload) { @@ -475,7 +475,7 @@ class EventTimer extends Timer { if (this.numEvents < 1) return; // if there is no event running, go to first - if (!this.selectedEvent) { + if (this.selectedEvent == null) { this.goto(0); return; } @@ -490,7 +490,7 @@ class EventTimer extends Timer { if (this.numEvents < 1) return; // if there is no event running, go to first - if (!this.selectedEvent) { + if (this.selectedEvent == null) { this.goto(0); return; } diff --git a/server/controllers/eventsController.js b/server/controllers/eventsController.js index c6809f0e4..12a7ba301 100644 --- a/server/controllers/eventsController.js +++ b/server/controllers/eventsController.js @@ -6,31 +6,27 @@ const { nanoid } = require('nanoid'); const eventDefs = require('../data/eventsDefinition.js'); // incrementFrom -async function incrementFrom(start, incr = 1) { - try { - let entries = db.get('events').sortBy('order').value(); +function incrementFrom(start, incr = 1) { + let entries = db.get('events').sortBy('order').value(); - entries.map((e) => { - if (e.order < start) return; - db.get('events') - .find({ id: e.id }) - .assign({ order: e.order + incr }) - .write(); - }); - } catch (error) { - console.log('error on increment function', error); - } + entries.map((e) => { + if (e.order < start) return; + db.get('events') + .find({ id: e.id }) + .assign({ order: e.order + incr }) + .write(); + }); } -async function _getEventsCount() { +function _getEventsCount() { return db.get('events').size().value(); } -async function _pushNew(entry) { +function _pushNew(entry) { return db.get('events').push(entry).write(); } -async function _removeById(eventId) { +function _removeById(eventId) { return db.get('events').remove({ id: eventId }).write(); } @@ -95,12 +91,18 @@ exports.eventsPost = async (req, res) => { try { // increment count if necessary - const c = await _getEventsCount(); + const c = _getEventsCount(); - if (newEvent.order < c) await incrementFrom(newEvent.order); + if (newEvent.order < c) incrementFrom(newEvent.order); - // add new event, update timer, reply - await _pushNew(newEvent).then(_updateTimers()).then(res.sendStatus(201)); + // add new event + _pushNew(newEvent); + + // update timers + _updateTimers(); + + // reply OK + res.sendStatus(201); } catch (error) { res.status(400).send(error); } @@ -185,7 +187,6 @@ exports.eventsDelete = async (req, res) => { _removeById(req.params.eventId); // update timer - // TODO: update single values when possible _updateTimers(); res.sendStatus(201);