Version 3.1 #71
|
@ -207,6 +207,9 @@ type JournalRequest =
|
||||||
/// The last time action was taken on the request
|
/// The last time action was taken on the request
|
||||||
AsOf : Instant
|
AsOf : Instant
|
||||||
|
|
||||||
|
/// The last time a request was marked as prayed
|
||||||
|
LastPrayed : Instant option
|
||||||
|
|
||||||
/// The last status for the request
|
/// The last status for the request
|
||||||
LastStatus : RequestAction
|
LastStatus : RequestAction
|
||||||
|
|
||||||
|
@ -233,13 +236,16 @@ module JournalRequest =
|
||||||
let ofRequestLite (req : Request) =
|
let ofRequestLite (req : Request) =
|
||||||
let lastHistory = req.History |> Array.sortByDescending (fun it -> it.AsOf) |> Array.tryHead
|
let lastHistory = req.History |> Array.sortByDescending (fun it -> it.AsOf) |> Array.tryHead
|
||||||
// Requests are sorted by the "as of" field in this record; for sorting to work properly, we will put the
|
// Requests are sorted by the "as of" field in this record; for sorting to work properly, we will put the
|
||||||
// larger of either the last prayed date or the "show after" date; if neither of those are filled, we will use
|
// largest of the last prayed date, the "snoozed until". or the "show after" date; if none of those are filled,
|
||||||
// the last activity date. This will mean that:
|
// we will use the last activity date. This will mean that:
|
||||||
// - Immediately shown requests will be at the top of the list, in order from least recently prayed to most.
|
// - Immediately shown requests will be at the top of the list, in order from least recently prayed to most.
|
||||||
// - Non-immediate requests will enter the list as if they were marked as prayed at that time; this will put
|
// - Non-immediate requests will enter the list as if they were marked as prayed at that time; this will put
|
||||||
// them at the bottom of the list.
|
// them at the bottom of the list.
|
||||||
|
// - Snoozed requests will reappear at the bottom of the list when they return.
|
||||||
// - New requests will go to the bottom of the list, but will rise as others are marked as prayed.
|
// - New requests will go to the bottom of the list, but will rise as others are marked as prayed.
|
||||||
let lastActivity = lastHistory |> Option.map (fun it -> it.AsOf) |> Option.defaultValue Instant.MinValue
|
let lastActivity = lastHistory |> Option.map (fun it -> it.AsOf) |> Option.defaultValue Instant.MinValue
|
||||||
|
let showAfter = defaultArg req.ShowAfter Instant.MinValue
|
||||||
|
let snoozedUntil = defaultArg req.SnoozedUntil Instant.MinValue
|
||||||
let lastPrayed =
|
let lastPrayed =
|
||||||
req.History
|
req.History
|
||||||
|> Array.sortByDescending (fun it -> it.AsOf)
|
|> Array.sortByDescending (fun it -> it.AsOf)
|
||||||
|
@ -247,11 +253,7 @@ module JournalRequest =
|
||||||
|> Array.tryHead
|
|> Array.tryHead
|
||||||
|> Option.map (fun it -> it.AsOf)
|
|> Option.map (fun it -> it.AsOf)
|
||||||
|> Option.defaultValue Instant.MinValue
|
|> Option.defaultValue Instant.MinValue
|
||||||
let showAfter = defaultArg req.ShowAfter Instant.MinValue
|
let asOf = List.max [ lastPrayed; showAfter; snoozedUntil ]
|
||||||
let asOf =
|
|
||||||
if lastPrayed > showAfter then lastPrayed
|
|
||||||
elif showAfter > lastPrayed then showAfter
|
|
||||||
else lastActivity
|
|
||||||
{ RequestId = req.Id
|
{ RequestId = req.Id
|
||||||
UserId = req.UserId
|
UserId = req.UserId
|
||||||
Text = req.History
|
Text = req.History
|
||||||
|
@ -260,7 +262,8 @@ module JournalRequest =
|
||||||
|> Array.tryHead
|
|> Array.tryHead
|
||||||
|> Option.map (fun h -> Option.get h.Text)
|
|> Option.map (fun h -> Option.get h.Text)
|
||||||
|> Option.defaultValue ""
|
|> Option.defaultValue ""
|
||||||
AsOf = asOf
|
AsOf = if asOf > Instant.MinValue then asOf else lastActivity
|
||||||
|
LastPrayed = if lastPrayed = Instant.MinValue then None else Some lastPrayed
|
||||||
LastStatus = match lastHistory with Some h -> h.Status | None -> Created
|
LastStatus = match lastHistory with Some h -> h.Status | None -> Created
|
||||||
SnoozedUntil = req.SnoozedUntil
|
SnoozedUntil = req.SnoozedUntil
|
||||||
ShowAfter = req.ShowAfter
|
ShowAfter = req.ShowAfter
|
||||||
|
|
|
@ -48,7 +48,11 @@ let journalCard now req =
|
||||||
p [ _class "request-text" ] [ str req.Text ]
|
p [ _class "request-text" ] [ str req.Text ]
|
||||||
]
|
]
|
||||||
div [ _class "card-footer text-end text-muted px-1 py-0" ] [
|
div [ _class "card-footer text-end text-muted px-1 py-0" ] [
|
||||||
em [] [ str "last activity "; relativeDate req.AsOf now ]
|
em [] [
|
||||||
|
match req.LastPrayed with
|
||||||
|
| Some dt -> str "last prayed "; relativeDate dt now
|
||||||
|
| None -> str "last activity "; relativeDate req.AsOf now
|
||||||
|
]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
@ -129,7 +133,8 @@ let journalItems now items =
|
||||||
|> section [ _id "journalItems"
|
|> section [ _id "journalItems"
|
||||||
_class "row row-cols-1 row-cols-md-2 row-cols-lg-3 row-cols-xl-4 g-3"
|
_class "row row-cols-1 row-cols-md-2 row-cols-lg-3 row-cols-xl-4 g-3"
|
||||||
_hxTarget "this"
|
_hxTarget "this"
|
||||||
_hxSwap HxSwap.OuterHtml ]
|
_hxSwap HxSwap.OuterHtml
|
||||||
|
_ariaLabel "Prayer Requests" ]
|
||||||
|
|
||||||
/// The notes edit modal body
|
/// The notes edit modal body
|
||||||
let notesEdit requestId =
|
let notesEdit requestId =
|
||||||
|
|
Loading…
Reference in New Issue
Block a user