diff --git a/src/PrayerTracker.Data/Entities.fs b/src/PrayerTracker.Data/Entities.fs index 50043d0..76a1f60 100644 --- a/src/PrayerTracker.Data/Entities.fs +++ b/src/PrayerTracker.Data/Entities.fs @@ -37,6 +37,51 @@ module RequestType = (*-- SUPPORT TYPES --*) +/// How as-of dates should (or should not) be displayed with requests +type AsOfDateDisplay = + /// No as-of date should be displayed + | NoDisplay + /// The as-of date should be displayed in the culture's short date format + | ShortDate + /// The as-of date should be displayed in the culture's long date format + | LongDate +with + /// Convert to a DU case from a single-character string + static member fromCode code = + match code with + | "N" -> NoDisplay + | "S" -> ShortDate + | "L" -> LongDate + | _ -> invalidArg "code" (sprintf "Unknown code %s" code) + /// Convert this DU case to a single-character string + member this.toCode () = + match this with + | NoDisplay -> "N" + | ShortDate -> "S" + | LongDate -> "L" + + +[] +module Converters = + open Microsoft.EntityFrameworkCore.Storage.ValueConversion + open Microsoft.FSharp.Linq.RuntimeHelpers + open System.Linq.Expressions + + let private fromDU = + <@ Func(fun (x : AsOfDateDisplay) -> x.toCode ()) @> + |> LeafExpressionConverter.QuotationToExpression + |> unbox>> + + let private toDU = + <@ Func(AsOfDateDisplay.fromCode) @> + |> LeafExpressionConverter.QuotationToExpression + |> unbox>> + + /// Conversion between a string and an AsOfDateDisplay DU value + type AsOfDateDisplayConverter () = + inherit ValueConverter (fromDU, toDU) + + /// Statistics for churches [] type ChurchStats = @@ -158,6 +203,8 @@ and [] ListPreferences = timeZone : TimeZone /// The number of requests displayed per page pageSize : int + /// How the as-of date should be automatically displayed + asOfDateDisplay : AsOfDateDisplay } with /// A set of preferences with their default values @@ -180,6 +227,7 @@ and [] ListPreferences = timeZoneId = "America/Denver" timeZone = TimeZone.empty pageSize = 100 + asOfDateDisplay = NoDisplay } /// Configure EF for this entity static member internal configureEF (mb : ModelBuilder) = @@ -268,8 +316,16 @@ and [] ListPreferences = .HasColumnName("PageSize") .IsRequired() .HasDefaultValue 100 + |> ignore + m.Property(fun e -> e.asOfDateDisplay) + .HasColumnName("AsOfDateDisplay") + .IsRequired() + .HasMaxLength(1) + .HasDefaultValue NoDisplay |> ignore) |> ignore + mb.Model.FindEntityType(typeof).FindProperty("asOfDateDisplay") + .SetValueConverter(AsOfDateDisplayConverter ()) /// A member of a small group diff --git a/src/PrayerTracker.Data/Migrations/20161217153124_InitialDatabase.fs b/src/PrayerTracker.Data/Migrations/20161217153124_InitialDatabase.fs index 14f6ddb..53e02dc 100644 --- a/src/PrayerTracker.Data/Migrations/20161217153124_InitialDatabase.fs +++ b/src/PrayerTracker.Data/Migrations/20161217153124_InitialDatabase.fs @@ -38,6 +38,7 @@ type ListPreferencesTable = textFontSize : OperationBuilder timeZoneId : OperationBuilder pageSize : OperationBuilder + asOfDateDisplay : OperationBuilder } type MemberTable = @@ -192,6 +193,7 @@ type InitialDatabase () = textFontSize = table.Column (name = "TextFontSize", nullable = false, defaultValue = 12) timeZoneId = table.Column (name = "TimeZoneId", nullable = false, defaultValue = "America/Denver") pageSize = table.Column (name = "PageSize", nullable = false, defaultValue = 100) + asOfDateDisplay = table.Column (name = "AsOfDateDisplay", nullable = false, defaultValue = "N", maxLength = Nullable 1) }), constraints = fun table -> @@ -359,9 +361,11 @@ type InitialDatabase () = b.Property("lineColor").IsRequired().ValueGeneratedOnAdd().HasDefaultValue("navy") |> ignore b.Property("listFonts").IsRequired().ValueGeneratedOnAdd().HasDefaultValue("Century Gothic,Tahoma,Luxi Sans,sans-serif") |> ignore b.Property("longTermUpdateWeeks").ValueGeneratedOnAdd().HasDefaultValue(4) |> ignore - b.Property("requestSort").IsRequired().ValueGeneratedOnAdd().HasDefaultValue("D").HasMaxLength(1) |> ignore + b.Property("requestSort").IsRequired().ValueGeneratedOnAdd().HasDefaultValue("D").HasMaxLength(1) |> ignore b.Property("textFontSize").ValueGeneratedOnAdd().HasDefaultValue(12) |> ignore b.Property("timeZoneId").IsRequired().ValueGeneratedOnAdd().HasDefaultValue("America/Denver") |> ignore + b.Property("pageSize").IsRequired().ValueGeneratedOnAdd().HasDefaultValue(100) |> ignore + b.Property("asOfDateDisplay").IsRequired().ValueGeneratedOnAdd().HasDefaultValue("N").HasMaxLength(1) |> ignore b.HasKey("smallGroupId") |> ignore b.HasIndex("timeZoneId") |> ignore b.ToTable("ListPreference") |> ignore) diff --git a/src/PrayerTracker.Data/Migrations/AppDbContextModelSnapshot.fs b/src/PrayerTracker.Data/Migrations/AppDbContextModelSnapshot.fs index 1c707ce..6df9c1c 100644 --- a/src/PrayerTracker.Data/Migrations/AppDbContextModelSnapshot.fs +++ b/src/PrayerTracker.Data/Migrations/AppDbContextModelSnapshot.fs @@ -46,10 +46,11 @@ type AppDbContextModelSnapshot () = b.Property("lineColor").IsRequired().ValueGeneratedOnAdd().HasDefaultValue("navy") |> ignore b.Property("listFonts").IsRequired().ValueGeneratedOnAdd().HasDefaultValue("Century Gothic,Tahoma,Luxi Sans,sans-serif") |> ignore b.Property("longTermUpdateWeeks").ValueGeneratedOnAdd().HasDefaultValue(4) |> ignore - b.Property("requestSort").IsRequired().ValueGeneratedOnAdd().HasDefaultValue("D").HasMaxLength(1) |> ignore + b.Property("requestSort").IsRequired().ValueGeneratedOnAdd().HasDefaultValue("D").HasMaxLength(1) |> ignore b.Property("textFontSize").ValueGeneratedOnAdd().HasDefaultValue(12) |> ignore b.Property("timeZoneId").IsRequired().ValueGeneratedOnAdd().HasDefaultValue("America/Denver") |> ignore b.Property("pageSize").IsRequired().ValueGeneratedOnAdd().HasDefaultValue(100) |> ignore + b.Property("asOfDateDisplay").IsRequired().ValueGeneratedOnAdd().HasDefaultValue("N").HasMaxLength(1) |> ignore b.HasKey("smallGroupId") |> ignore b.HasIndex("timeZoneId") |> ignore b.ToTable("ListPreference") |> ignore) diff --git a/src/PrayerTracker.Data/PrayerTracker.Data.fsproj b/src/PrayerTracker.Data/PrayerTracker.Data.fsproj index b915c43..d58b0cc 100644 --- a/src/PrayerTracker.Data/PrayerTracker.Data.fsproj +++ b/src/PrayerTracker.Data/PrayerTracker.Data.fsproj @@ -2,8 +2,8 @@ netstandard2.0 - 7.0.0.0 - 7.0.0.0 + 7.3.0.0 + 7.3.0.0 diff --git a/src/PrayerTracker.Tests/Data/EntitiesTests.fs b/src/PrayerTracker.Tests/Data/EntitiesTests.fs index 64bec37..688abbe 100644 --- a/src/PrayerTracker.Tests/Data/EntitiesTests.fs +++ b/src/PrayerTracker.Tests/Data/EntitiesTests.fs @@ -45,6 +45,7 @@ let listPreferencesTests = Expect.equal mt.timeZoneId "America/Denver" "The default time zone should have been America/Denver" Expect.equal mt.timeZone.timeZoneId "" "The default preferences should have included an empty time zone" Expect.equal mt.pageSize 100 "The default page size should have been 100" + Expect.equal mt.asOfDateDisplay NoDisplay "The as-of date display should have been No Display" } ] diff --git a/src/PrayerTracker.Tests/PrayerTracker.Tests.fsproj b/src/PrayerTracker.Tests/PrayerTracker.Tests.fsproj index e0281fe..ba90d4e 100644 --- a/src/PrayerTracker.Tests/PrayerTracker.Tests.fsproj +++ b/src/PrayerTracker.Tests/PrayerTracker.Tests.fsproj @@ -3,6 +3,8 @@ Exe netcoreapp2.2 + 7.3.0.0 + 7.3.0.0 diff --git a/src/PrayerTracker.UI/PrayerTracker.UI.fsproj b/src/PrayerTracker.UI/PrayerTracker.UI.fsproj index 5bf0a24..85fd473 100644 --- a/src/PrayerTracker.UI/PrayerTracker.UI.fsproj +++ b/src/PrayerTracker.UI/PrayerTracker.UI.fsproj @@ -2,7 +2,7 @@ netstandard2.0 - 7.0.0.0 + 7.3.0.0 7.0.0.0 diff --git a/src/PrayerTracker/PrayerTracker.fsproj b/src/PrayerTracker/PrayerTracker.fsproj index 516089e..1d3308e 100644 --- a/src/PrayerTracker/PrayerTracker.fsproj +++ b/src/PrayerTracker/PrayerTracker.fsproj @@ -2,8 +2,8 @@ netcoreapp2.2 - 7.2.0.0 - 7.0.0.0 + 7.3.0.0 + 7.3.0.0 Bit Badger Solutions diff --git a/src/search-sql.txt b/src/search-sql.txt index 801748d..d03bcec 100644 --- a/src/search-sql.txt +++ b/src/search-sql.txt @@ -3,3 +3,4 @@ set search_path=pt,public; create index "IX_PrayerRequest_Requestor_TRGM" on "PrayerRequest" using GIN (COALESCE("Requestor", '') gin_trgm_ops); create index "IX_PrayerRequest_Text_TRGM" on "PrayerRequest" using GIN ("Text" gin_trgm_ops); alter table "ListPreference" add column "PageSize" int not null default 100; +alter table "ListPreference" add column "AsOfDateDisplay" varchar(1) not null default 'N';