Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

temp sched dialog: fix soft limits while typing #3478

Merged
merged 2 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions web/src/app/schedules/ScheduleOverrideForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export default function ScheduleOverrideForm(
required
name='start'
softMax={props.value.end}
softMaxLabel='end time'
softMaxLabel='Must be before end time.'
disabled={!zone}
hint={isLocalZone ? '' : fmtLocal(value.start)}
/>
Expand All @@ -148,7 +148,7 @@ export default function ScheduleOverrideForm(
name='end'
required
softMin={props.value.start}
softMinLabel='start time'
softMinLabel='Must be after start time.'
disabled={!zone}
hint={isLocalZone ? '' : fmtLocal(value.end)}
/>
Expand Down
12 changes: 9 additions & 3 deletions web/src/app/schedules/temp-sched/TempSchedDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,11 @@ export default function TempSchedDialog({
.plus({ year: 1 })
.toISO()}
softMax={value.end}
softMaxLabel='end time'
softMaxLabel='Must be before end time.'
softMin={DateTime.fromISO(value.end)
.plus({ month: -3 })
.toISO()}
softMinLabel='Must be within 3 months of end time.'
validate={() => validate()}
timeZone={zone}
disabled={q.loading}
Expand All @@ -316,11 +320,13 @@ export default function TempSchedDialog({
required
name='end'
label='Schedule End'
min={now}
softMin={value.start}
softMinLabel='start time'
max={DateTime.fromISO(value.start, { zone })
softMinLabel='Must be after start time.'
softMax={DateTime.fromISO(value.start)
.plus({ month: 3 })
.toISO()}
softMaxLabel='Must be within 3 months of start time.'
validate={() => validate()}
timeZone={zone}
disabled={q.loading}
Expand Down
4 changes: 2 additions & 2 deletions web/src/app/util/ISOPickers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ function ISOPicker(props: ISOPickerProps): JSX.Element {
if (softMin) {
const sMin = DateTime.fromISO(softMin)
if (dt < sMin) {
return `Value must be after ${softMinLabel || sMin.toFormat(format)}`
return softMinLabel || `Value must be after ${sMin.toFormat(format)}`
}
}
if (softMax) {
const sMax = DateTime.fromISO(softMax)
if (dt > sMax) {
return `Value must be before ${softMaxLabel || sMax.toFormat(format)}`
return softMaxLabel || `Value must be before ${sMax.toFormat(format)}`
}
}

Expand Down