From 50f8b56871e3b52b8215446c3fa2a8b3b4174040 Mon Sep 17 00:00:00 2001 From: "Daniel J. Summers" Date: Sat, 16 Mar 2019 21:41:56 -0500 Subject: [PATCH] Added page size and as-of date display to prefs page --- src/PrayerTracker.Data/Entities.fs | 3 +-- src/PrayerTracker.UI/Resources/Common.es.resx | 15 +++++++++++++ src/PrayerTracker.UI/SmallGroup.fs | 19 ++++++++++++++--- src/PrayerTracker.UI/ViewModels.fs | 21 +++++++++++++++---- 4 files changed, 49 insertions(+), 9 deletions(-) diff --git a/src/PrayerTracker.Data/Entities.fs b/src/PrayerTracker.Data/Entities.fs index 76a1f60..e881d13 100644 --- a/src/PrayerTracker.Data/Entities.fs +++ b/src/PrayerTracker.Data/Entities.fs @@ -61,7 +61,6 @@ with | LongDate -> "L" -[] module Converters = open Microsoft.EntityFrameworkCore.Storage.ValueConversion open Microsoft.FSharp.Linq.RuntimeHelpers @@ -325,7 +324,7 @@ and [] ListPreferences = |> ignore) |> ignore mb.Model.FindEntityType(typeof).FindProperty("asOfDateDisplay") - .SetValueConverter(AsOfDateDisplayConverter ()) + .SetValueConverter(Converters.AsOfDateDisplayConverter ()) /// A member of a small group diff --git a/src/PrayerTracker.UI/Resources/Common.es.resx b/src/PrayerTracker.UI/Resources/Common.es.resx index f00ca4c..2f3f9eb 100644 --- a/src/PrayerTracker.UI/Resources/Common.es.resx +++ b/src/PrayerTracker.UI/Resources/Common.es.resx @@ -798,10 +798,25 @@ Buscar + + Mostrar una fecha “como de” completa + + + Mostrar una fecha “como de” corta + + + No se muestran la fecha “como de” + + + Tamaño de Página + Petición de Oración Resultados de la Búsqueda + + Visualización de la Fecha “Como de” + \ No newline at end of file diff --git a/src/PrayerTracker.UI/SmallGroup.fs b/src/PrayerTracker.UI/SmallGroup.fs index 007ea6e..15a92ef 100644 --- a/src/PrayerTracker.UI/SmallGroup.fs +++ b/src/PrayerTracker.UI/SmallGroup.fs @@ -284,7 +284,7 @@ let members (mbrs : Member list) (emailTyps : Map) ctx let overview m vi = let s = I18N.localizer.Force () let linkSpacer = rawText "  " - let typs = ReferenceList.requestTypeList s |> Map.ofList + let typs = ReferenceList.requestTypeList s |> dict article [ _class "pt-overview" ] [ section [] [ header [ _role "heading" ] [ @@ -350,7 +350,7 @@ let preferences (m : EditPreferences) (tzs : TimeZone list) ctx vi = use sw = new StringWriter () let raw = rawLocText sw [ form [ _action "/small-group/preferences/save"; _method "post"; _class "pt-center-columns" ] [ - style [ _scoped ] [ rawText "#expireDays, #daysToKeepNew, #longTermUpdateWeeks, #headingFontSize, #listFontSize { width: 3rem; } #emailFromAddress { width: 20rem; } #listFonts { width: 40rem; } @media screen and (max-width: 40rem) { #listFonts { width: 100%; } }" ] + style [ _scoped ] [ rawText "#expireDays, #daysToKeepNew, #longTermUpdateWeeks, #headingFontSize, #listFontSize, #pageSize { width: 3rem; } #emailFromAddress { width: 20rem; } #listFonts { width: 40rem; } @media screen and (max-width: 40rem) { #listFonts { width: 100%; } }" ] csrfToken ctx fieldset [] [ legend [] [ strong [] [ icon "date_range"; rawText "  "; locStr s.["Dates"] ] ] @@ -479,7 +479,7 @@ let preferences (m : EditPreferences) (tzs : TimeZone list) ctx vi = legend [] [ strong [] [ icon "settings"; rawText "  "; locStr s.["Other Settings"] ] ] div [ _class "pt-field-row" ] [ div [ _class "pt-field" ] [ - label [ _for "TimeZone" ] [ locStr s.["Time Zone"] ] + label [ _for "timeZone" ] [ locStr s.["Time Zone"] ] seq { yield "", selectDefault s.["Select"].Value yield! tzs |> List.map (fun tz -> tz.timeZoneId, (TimeZones.name tz.timeZoneId s).Value) @@ -511,6 +511,19 @@ let preferences (m : EditPreferences) (tzs : TimeZone list) ctx vi = _value (match m.groupPassword with Some x -> x | None -> "") ] ] ] + div [ _class "pt-field-row" ] [ + div [ _class "pt-field" ] [ + label [ _for "pageSize" ] [ locStr s.["Page Size"] ] + input [ _type "number"; _name "pageSize"; _id "pageSize"; _min "10"; _max "255"; _required + _value (string m.pageSize) ] + ] + div [ _class "pt-field" ] [ + label [ _for "asOfDate" ] [ locStr s.["“As of” Date Display"] ] + ReferenceList.asOfDateList s + |> List.map (fun (code, desc) -> code, desc.Value) + |> selectList "asOfDate" m.asOfDate [ _required ] + ] + ] div [ _class "pt-field-row" ] [ submit [] "save" s.["Save Preferences"] ] ] ] diff --git a/src/PrayerTracker.UI/ViewModels.fs b/src/PrayerTracker.UI/ViewModels.fs index 023b093..d1f1248 100644 --- a/src/PrayerTracker.UI/ViewModels.fs +++ b/src/PrayerTracker.UI/ViewModels.fs @@ -10,6 +10,13 @@ open System /// Helper module to return localized reference lists module ReferenceList = + /// A localized list of the AsOfDateDisplay DU cases + let asOfDateList (s : IStringLocalizer) = + [ NoDisplay.toCode (), s.["Do not display the “as of” date"] + ShortDate.toCode (), s.["Display a short “as of” date"] + LongDate.toCode (), s.["Display a full “as of” date"] + ] + /// A list of e-mail type options let emailTypeList def (s : IStringLocalizer) = // Localize the default type @@ -27,12 +34,10 @@ module ReferenceList = /// A list of expiration options let expirationList (s : IStringLocalizer) includeExpireNow = - seq { - yield "N", s.["Expire Normally"] + [ yield "N", s.["Expire Normally"] yield "Y", s.["Request Never Expires"] match includeExpireNow with true -> yield "X", s.["Expire Immediately"] | false -> () - } - |> List.ofSeq + ] /// A list of request types let requestTypeList (s : IStringLocalizer) = @@ -273,6 +278,10 @@ type EditPreferences = listVisibility : int /// The small group password groupPassword : string option + /// The page size for search / inactive requests + pageSize : int + /// How the as-of date should be displayed + asOfDate : string } with static member fromPreferences (prefs : ListPreferences) = @@ -293,6 +302,8 @@ with listFontSize = prefs.textFontSize timeZone = prefs.timeZoneId groupPassword = Some prefs.groupPassword + pageSize = prefs.pageSize + asOfDate = prefs.asOfDateDisplay.toCode () listVisibility = match true with | _ when prefs.isPublic -> RequestVisibility.``public`` @@ -323,6 +334,8 @@ with timeZoneId = this.timeZone isPublic = isPublic groupPassword = grpPw + pageSize = this.pageSize + asOfDateDisplay = AsOfDateDisplay.fromCode this.asOfDate }