From 9edf074ebdf101fdb16321b9e4c3d520f8ec75e2 Mon Sep 17 00:00:00 2001 From: Gisle Aune Date: Sat, 8 Oct 2022 14:47:19 +0200 Subject: [PATCH] fix scheduled items not showing in history. --- .../lib/components/history/HistoryGroupList.svelte | 2 +- .../src/lib/components/project/ItemSubSection.svelte | 4 ++-- frontend/src/lib/utils/timeinterval.ts | 11 ++++++++++- .../routes/[scope=prettyid]/history/[interval].svelte | 4 ++-- usecases/items/groups.go | 2 +- 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/frontend/src/lib/components/history/HistoryGroupList.svelte b/frontend/src/lib/components/history/HistoryGroupList.svelte index 6ee2628..4ca6357 100644 --- a/frontend/src/lib/components/history/HistoryGroupList.svelte +++ b/frontend/src/lib/components/history/HistoryGroupList.svelte @@ -15,7 +15,7 @@ {#each $groups as group (group.label)} - {#if (group.label >= interval.min && group.label <= interval.max)} + {#if (group.label >= interval.min)} {/if} {/each} \ No newline at end of file diff --git a/frontend/src/lib/components/project/ItemSubSection.svelte b/frontend/src/lib/components/project/ItemSubSection.svelte index 7d5bec2..adcb5ef 100644 --- a/frontend/src/lib/components/project/ItemSubSection.svelte +++ b/frontend/src/lib/components/project/ItemSubSection.svelte @@ -11,7 +11,7 @@ import Icon from "../layout/Icon.svelte"; import { formatTime } from "$lib/utils/date"; import RequirementReference from "./RequirementReference.svelte"; -import ItemTimeInfo from "./ItemTimeInfo.svelte"; + import ItemTimeInfo from "./ItemTimeInfo.svelte"; export let item: Item; export let event: "created" | "scheduled" | "acquired" | "none" = "none"; @@ -33,7 +33,7 @@ import ItemTimeInfo from "./ItemTimeInfo.svelte"; eventText = (showAcquiredTime || event === "acquired") ? formatTime(item.acquiredTime) : void(0) } } else if (event === "scheduled") { - if (item.acquiredTime) { + if (!item.acquiredTime) { icon = "hourglass"; status = Status.Blocked; eventText = "scheduled" diff --git a/frontend/src/lib/utils/timeinterval.ts b/frontend/src/lib/utils/timeinterval.ts index 80a3518..1e793a4 100644 --- a/frontend/src/lib/utils/timeinterval.ts +++ b/frontend/src/lib/utils/timeinterval.ts @@ -1,5 +1,5 @@ import type { TimeInterval } from "../models/common"; -import { addDays, addMonths, addYears, formatDate, startOfDay, startOfMonth, startOfWeek, startOfYear } from "./date"; +import { addDays, addMonths, addYears, endOfYear, formatDate, startOfDay, startOfMonth, startOfWeek, startOfYear } from "./date"; export default function parseInterval(s: string, date: Date): TimeInterval { const [verb, args] = s.split(";")[0].split(":") @@ -114,6 +114,15 @@ export function datesOf(interval: TimeInterval): TimeInterval): TimeInterval { + const res = datesOf(interval); + if (res != null) { + res.max = formatDate(endOfYear(addYears(new Date(interval.max), 2))) + } + + return res; +} + function capitalize(s: string) { return `${s.charAt(0).toLocaleUpperCase()}${s.slice(1)}` } diff --git a/frontend/src/routes/[scope=prettyid]/history/[interval].svelte b/frontend/src/routes/[scope=prettyid]/history/[interval].svelte index ae30170..86c71dc 100644 --- a/frontend/src/routes/[scope=prettyid]/history/[interval].svelte +++ b/frontend/src/routes/[scope=prettyid]/history/[interval].svelte @@ -2,7 +2,7 @@ import type { Load } from "@sveltejs/kit/types/internal"; import { sl3 } from "$lib/clients/sl3"; - import parseInterval, { datesOf } from "$lib/utils/timeinterval"; + import parseInterval, { scheduledDatesOf } from "$lib/utils/timeinterval"; import type Item from "$lib/models/item"; import type { ItemFilter, ItemGroup } from "$lib/models/item"; @@ -13,7 +13,7 @@ const filter = { createdTime: interval, acquiredTime: interval, - scheduledDate: datesOf(interval), + scheduledDate: scheduledDatesOf(interval), }; const {items, groups} = await sl3(fetch).listItems(scopeId, filter, true, session.groupOptions); diff --git a/usecases/items/groups.go b/usecases/items/groups.go index 44acf8d..2a55c94 100644 --- a/usecases/items/groups.go +++ b/usecases/items/groups.go @@ -34,7 +34,7 @@ func GenerateGroups(items []Result, opts GroupOptions) []Group { if !opts.HideCreated && (item.AcquiredTime == nil || item.AcquiredTime.After(item.CreatedTime)) { addItem(groups, i, "created", item.CreatedTime, tz) } - if !opts.HideScheduled && item.ScheduledDate != nil { + if !opts.HideScheduled && item.ScheduledDate != nil && item.AcquiredTime == nil { addItem(groups, i, "scheduled", item.ScheduledDate.WithTimeAndLocation(23, 59, 59, tz), tz) } if !opts.HideAcquired && item.AcquiredTime != nil {