mirror of
https://github.com/cpvalente/ontime.git
synced 2026-09-01 04:19:12 +00:00
bugfix duration
duration would be invalid when timestart > timeend
This commit is contained in:
@@ -8,10 +8,16 @@ const label = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const TimesDelayed = (props) => {
|
const TimesDelayed = (props) => {
|
||||||
const { handleValidate, actionHandler, delay, timeStart, timeEnd } = props;
|
const {
|
||||||
|
handleValidate,
|
||||||
|
actionHandler,
|
||||||
|
delay,
|
||||||
|
timeStart,
|
||||||
|
timeEnd,
|
||||||
|
duration,
|
||||||
|
} = props;
|
||||||
|
|
||||||
const scheduledStart = stringFromMillis(timeStart, false);
|
const scheduledStart = stringFromMillis(timeStart, false);
|
||||||
|
|
||||||
const scheduledEnd = stringFromMillis(timeEnd, false);
|
const scheduledEnd = stringFromMillis(timeEnd, false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -41,7 +47,7 @@ const TimesDelayed = (props) => {
|
|||||||
name='duration'
|
name='duration'
|
||||||
validate={handleValidate}
|
validate={handleValidate}
|
||||||
actionHandler={actionHandler}
|
actionHandler={actionHandler}
|
||||||
time={timeEnd - timeStart}
|
time={duration}
|
||||||
delay={0}
|
delay={0}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
@@ -49,7 +55,7 @@ const TimesDelayed = (props) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const Times = (props) => {
|
const Times = (props) => {
|
||||||
const { handleValidate, actionHandler, timeStart, timeEnd } = props;
|
const { handleValidate, actionHandler, timeStart, timeEnd, duration } = props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -69,12 +75,12 @@ const Times = (props) => {
|
|||||||
time={timeEnd}
|
time={timeEnd}
|
||||||
delay={0}
|
delay={0}
|
||||||
/>
|
/>
|
||||||
<span style={label}>Duration (min)</span>
|
<span style={label}>Duration</span>
|
||||||
<EditableTimer
|
<EditableTimer
|
||||||
name='durationOverride'
|
name='durationOverride'
|
||||||
validate={handleValidate}
|
validate={handleValidate}
|
||||||
actionHandler={actionHandler}
|
actionHandler={actionHandler}
|
||||||
time={timeEnd - timeStart}
|
time={duration}
|
||||||
delay={0}
|
delay={0}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
@@ -82,7 +88,7 @@ const Times = (props) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default function EventTimesVertical(props) {
|
export default function EventTimesVertical(props) {
|
||||||
const { delay, timeStart, timeEnd } = props;
|
const { delay, timeStart, timeEnd, duration } = props;
|
||||||
const handleValidate = (entry, v) => {
|
const handleValidate = (entry, v) => {
|
||||||
// we dont enforce validation here
|
// we dont enforce validation here
|
||||||
|
|
||||||
@@ -107,6 +113,7 @@ export default function EventTimesVertical(props) {
|
|||||||
delay={delay}
|
delay={delay}
|
||||||
timeStart={timeStart}
|
timeStart={timeStart}
|
||||||
timeEnd={timeEnd}
|
timeEnd={timeEnd}
|
||||||
|
duration={duration}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<Times
|
<Times
|
||||||
@@ -114,6 +121,7 @@ export default function EventTimesVertical(props) {
|
|||||||
actionHandler={props.actionHandler}
|
actionHandler={props.actionHandler}
|
||||||
timeStart={timeStart}
|
timeStart={timeStart}
|
||||||
timeEnd={timeEnd}
|
timeEnd={timeEnd}
|
||||||
|
duration={duration}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,12 @@ const ExpandedBlock = (props) => {
|
|||||||
|
|
||||||
const oscid = data.id.length > 4 ? '...' : data.id;
|
const oscid = data.id.length > 4 ? '...' : data.id;
|
||||||
|
|
||||||
|
// if end is before, assume is the day after
|
||||||
|
const duration =
|
||||||
|
data.timeStart > data.timeEnd
|
||||||
|
? data.timeEnd + 86400000 - data.timeStart
|
||||||
|
: data.timeEnd + 86400000 - data.timeStart;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<span className={style.drag} {...provided.dragHandleProps}>
|
<span className={style.drag} {...provided.dragHandleProps}>
|
||||||
@@ -33,6 +39,7 @@ const ExpandedBlock = (props) => {
|
|||||||
actionHandler={actionHandler}
|
actionHandler={actionHandler}
|
||||||
timeStart={data.timeStart}
|
timeStart={data.timeStart}
|
||||||
timeEnd={data.timeEnd}
|
timeEnd={data.timeEnd}
|
||||||
|
duration={duration}
|
||||||
delay={delay}
|
delay={delay}
|
||||||
className={style.time}
|
className={style.time}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user