Skip to content

Commit

Permalink
Use one day as default plan duration (#1110)
Browse files Browse the repository at this point in the history
* Use one day as default plan duration
  • Loading branch information
AaronPlave authored Feb 1, 2024
1 parent d2e7d20 commit b586dee
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion e2e-tests/tests/plans.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ test.describe.serial('Plans', () => {
await plans.fillInputStartTime();

const endTime = await plans.inputEndTime.inputValue();
expect(endTime).toEqual(plans.startTime);
expect(endTime).toEqual('2022-002T00:00:00');
});

test('Entering an invalid start should not prepopulate the end time', async () => {
Expand Down
11 changes: 8 additions & 3 deletions src/routes/plans/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import { removeQueryParam } from '../../utilities/generic';
import { permissionHandler } from '../../utilities/permissionHandler';
import { featurePermissions } from '../../utilities/permissions';
import { convertUsToDurationString, getShortISOForDate, getUnixEpochTime } from '../../utilities/time';
import { convertUsToDurationString, getDoyTime, getShortISOForDate, getUnixEpochTime } from '../../utilities/time';
import { min, required, timestamp } from '../../utilities/validators';
import type { PageData } from './$types';
Expand Down Expand Up @@ -293,10 +293,15 @@
goto(`${base}/plans/${plan.id}`);
}
function onStartTimeChanged() {
async function onStartTimeChanged() {
if ($startTimeDoyField.value && $startTimeDoyField.valid && $endTimeDoyField.value === '') {
endTimeDoyField.set($startTimeDoyField);
// Set end time as start time plus a day by default
const startTimeDate = new Date(getUnixEpochTime($startTimeDoyField.value));
startTimeDate.setDate(startTimeDate.getDate() + 1);
const newEndTimeDoy = getDoyTime(startTimeDate, false);
await endTimeDoyField.validateAndSet(newEndTimeDoy);
}
updateDurationString();
}
Expand Down

0 comments on commit b586dee

Please sign in to comment.