From c587d9772f7d42015bbafec10d17cb490a5ffbb8 Mon Sep 17 00:00:00 2001 From: "Daniel J. Summers" Date: Tue, 30 Jul 2019 23:56:34 -0500 Subject: [PATCH] A lot is working... ...but a lot is not. The JSON for the journal is not including the Id field; I suspect the majority of the problems reside with that issue. --- src/MyPrayerJournal.Api/Data.fs | 307 +++++------------- src/MyPrayerJournal.Api/Domain.fs | 52 +-- src/MyPrayerJournal.Api/Handlers.fs | 84 ++--- src/MyPrayerJournal.Api/Program.fs | 6 +- src/app/package.json | 8 +- src/app/src/components/Journal.vue | 2 +- .../src/components/request/ActiveRequests.vue | 2 +- .../components/request/AnsweredRequests.vue | 2 +- .../src/components/request/EditRequest.vue | 2 +- src/app/src/components/request/NotesEdit.vue | 2 +- .../src/components/request/RequestCard.vue | 6 +- .../components/request/RequestListItem.vue | 8 +- .../components/request/SnoozedRequests.vue | 2 +- src/app/src/store/index.js | 4 +- src/app/vue.config.js | 2 +- 15 files changed, 179 insertions(+), 310 deletions(-) diff --git a/src/MyPrayerJournal.Api/Data.fs b/src/MyPrayerJournal.Api/Data.fs index be15843..b173112 100644 --- a/src/MyPrayerJournal.Api/Data.fs +++ b/src/MyPrayerJournal.Api/Data.fs @@ -63,6 +63,7 @@ module Indexes = userId = req.userId, text = req.history.Where(hist => hist.text != null).OrderByDescending(hist => hist.asOf).First().text, asOf = req.history.OrderByDescending(hist => hist.asOf).First().asOf, + lastStatus = req.history.OrderByDescending(hist => hist.asOf).First().status, snoozedUntil = req.snoozedUntil, showAfter = req.showAfter, recurType = req.recurType, @@ -70,8 +71,9 @@ module Indexes = })" ] this.Fields <- - [ "text", IndexFieldOptions (Storage = Nullable FieldStorage.Yes) - "asOf", IndexFieldOptions (Storage = Nullable FieldStorage.Yes) + [ "text", IndexFieldOptions (Storage = Nullable FieldStorage.Yes) + "asOf", IndexFieldOptions (Storage = Nullable FieldStorage.Yes) + "lastStatus", IndexFieldOptions (Storage = Nullable FieldStorage.Yes) ] |> dict |> Dictionary @@ -105,244 +107,103 @@ module Extensions = r.Values.["Item"] <- item PatchCommandData (docId, null, r, null) - // Extensions for the RavenDB session type - type IAsyncDocumentSession with - - /// Add a history entry - member this.AddHistory (reqId : RequestId) (hist : History) = - listPush "history" (RequestId.toString reqId) hist - |> this.Advanced.Defer - /// Add a note - member this.AddNote (reqId : RequestId) (note : Note) = - listPush "notes" (RequestId.toString reqId) note - |> this.Advanced.Defer - - /// Add a request - member this.AddRequest req = - this.StoreAsync (req, req.Id) - - /// Retrieve all answered requests for the given user - // TODO: not right - member this.AnsweredRequests (userId : UserId) = - sprintf "%s where userId = '%s' and lastStatus = 'Answered' order by asOf as long desc" - (fromIndex typeof) (UserId.toString userId) - |> this.Advanced.AsyncRawQuery - - /// Retrieve the user's current journal - // TODO: probably not right either - member this.JournalByUserId (userId : UserId) = - sprintf "%s where userId = '%s' and lastStatus <> 'Answered' order by showAfter as long" - (fromIndex typeof) (UserId.toString userId) - |> this.Advanced.AsyncRawQuery - - /// Retrieve a request, including its history and notes, by its ID and user ID - member this.TryFullRequestById (reqId : RequestId) userId = - task { - let! req = RequestId.toString reqId |> this.LoadAsync - match Option.fromObject req with - | Some r when r.userId = userId -> return Some r - | _ -> return None - } - - /// Retrieve a request by its ID and user ID (without notes and history) - member this.TryRequestById reqId userId = - task { - match! this.TryFullRequestById reqId userId with - | Some r -> return Some { r with history = []; notes = [] } - | _ -> return None - } - - /// Retrieve notes for a request by its ID and user ID - member this.NotesById reqId userId = - task { - match! this.TryRequestById reqId userId with - | Some req -> return req.notes - | None -> return [] - } - - /// Retrieve a journal request by its ID and user ID - member this.TryJournalById (reqId : RequestId) userId = - task { - let! req = - this.Query() - .Where(fun x -> x.Id = (RequestId.toString reqId) && x.userId = userId) - .ProjectInto() - .FirstOrDefaultAsync () - return Option.fromObject req - } - - /// Update the recurrence for a request - member this.UpdateRecurrence (reqId : RequestId) (recurType : Recurrence) (recurCount : int16) = - let r = PatchRequest() - r.Script <- "this.recurType = args.Type; this.recurCount = args.Count" - r.Values.["Type"] <- string recurType - r.Values.["Count"] <- recurCount - PatchCommandData (RequestId.toString reqId, null, r, null) |> this.Advanced.Defer - - /// Update the "show after" timestamp for a request - member this.UpdateShowAfter (reqId : RequestId) (showAfter : Ticks) = - fieldUpdate "showAfter" (RequestId.toString reqId) (Ticks.toLong showAfter) - |> this.Advanced.Defer - - /// Update a snoozed request - member this.UpdateSnoozed (reqId : RequestId) (until : Ticks) = - let r = PatchRequest() - r.Script <- "this.snoozedUntil = args.Item; this.showAfter = args.Item" - r.Values.["Item"] <- Ticks.toLong until - PatchCommandData (RequestId.toString reqId, null, r, null) |> this.Advanced.Defer - - - - (* -/// Entity Framework configuration for myPrayerJournal -module internal EFConfig = +/// All data manipulations within myPrayerJournal +module Data = - open FSharp.EFCore.OptionConverter - open System.Collections.Generic + open Indexes + open Raven.Client.Documents.Session - /// Configure EF properties for all entity types - let configure (mb : ModelBuilder) = - mb.Entity ( - fun m -> - m.ToTable "history" |> ignore - m.HasKey ("requestId", "asOf") |> ignore - m.Property(fun e -> e.requestId).IsRequired () |> ignore - m.Property(fun e -> e.asOf).IsRequired () |> ignore - m.Property(fun e -> e.status).IsRequired() |> ignore - m.Property(fun e -> e.text) |> ignore) - |> ignore - mb.Model.FindEntityType(typeof).FindProperty("text").SetValueConverter (OptionConverter ()) - - mb.Entity ( - fun m -> - m.ToTable "note" |> ignore - m.HasKey ("requestId", "asOf") |> ignore - m.Property(fun e -> e.requestId).IsRequired () |> ignore - m.Property(fun e -> e.asOf).IsRequired () |> ignore - m.Property(fun e -> e.notes).IsRequired () |> ignore) - |> ignore - - mb.Entity ( - fun m -> - m.ToTable "request" |> ignore - m.HasKey(fun e -> e.requestId :> obj) |> ignore - m.Property(fun e -> e.requestId).IsRequired () |> ignore - m.Property(fun e -> e.enteredOn).IsRequired () |> ignore - m.Property(fun e -> e.userId).IsRequired () |> ignore - m.Property(fun e -> e.snoozedUntil).IsRequired () |> ignore - m.Property(fun e -> e.showAfter).IsRequired () |> ignore - m.Property(fun e -> e.recurType).IsRequired() |> ignore - m.Property(fun e -> e.recurCount).IsRequired() |> ignore - m.HasMany(fun e -> e.history :> IEnumerable) - .WithOne() - .HasForeignKey(fun e -> e.requestId :> obj) - |> ignore - m.HasMany(fun e -> e.notes :> IEnumerable) - .WithOne() - .HasForeignKey(fun e -> e.requestId :> obj) - |> ignore) - |> ignore - - mb.Query ( - fun m -> - m.ToView "journal" |> ignore - m.Ignore(fun e -> e.history :> obj) |> ignore - m.Ignore(fun e -> e.notes :> obj) |> ignore) - |> ignore - - -open System.Linq - -/// Data context -type AppDbContext (opts : DbContextOptions) = - inherit DbContext (opts) - - [] - val mutable private history : DbSet - [] - val mutable private notes : DbSet - [] - val mutable private requests : DbSet - [] - val mutable private journal : DbQuery - - member this.History - with get () = this.history - and set v = this.history <- v - member this.Notes - with get () = this.notes - and set v = this.notes <- v - member this.Requests - with get () = this.requests - and set v = this.requests <- v - member this.Journal - with get () = this.journal - and set v = this.journal <- v + /// Add a history entry + let addHistory reqId (hist : History) (sess : IAsyncDocumentSession) = + sess.Advanced.Patch ( + RequestId.toString reqId, + (fun r -> r.history :> IEnumerable), + fun (h : JavaScriptArray) -> h.Add (hist) :> obj) - override __.OnModelCreating (mb : ModelBuilder) = - base.OnModelCreating mb - EFConfig.configure mb - - /// Register a disconnected entity with the context, having the given state - member private this.RegisterAs<'TEntity when 'TEntity : not struct> state e = - this.Entry<'TEntity>(e).State <- state + /// Add a note + let addNote reqId (note : Note) (sess : IAsyncDocumentSession) = + sess.Advanced.Patch ( + RequestId.toString reqId, + (fun r -> r.notes :> IEnumerable), + fun (h : JavaScriptArray) -> h.Add (note) :> obj) - /// Add an entity instance to the context - member this.AddEntry e = - this.RegisterAs EntityState.Added e - - /// Update the entity instance's values - member this.UpdateEntry e = - this.RegisterAs EntityState.Modified e + /// Add a request + let addRequest req (sess : IAsyncDocumentSession) = + sess.StoreAsync (req, req.Id) /// Retrieve all answered requests for the given user - member this.AnsweredRequests userId : JournalRequest seq = - upcast this.Journal + let answeredRequests userId (sess : IAsyncDocumentSession) = + sess.Query() .Where(fun r -> r.userId = userId && r.lastStatus = "Answered") .OrderByDescending(fun r -> r.asOf) - + .ProjectInto() + .ToListAsync() + /// Retrieve the user's current journal - member this.JournalByUserId userId : JournalRequest seq = - upcast this.Journal - .Where(fun r -> r.userId = userId && r.lastStatus <> "Answered") - .OrderBy(fun r -> r.showAfter) - - /// Retrieve a request by its ID and user ID - member this.TryRequestById reqId userId = + let journalByUserId userId (sess : IAsyncDocumentSession) = task { - let! req = this.Requests.AsNoTracking().FirstOrDefaultAsync(fun r -> r.requestId = reqId && r.userId = userId) - return Option.fromObject req + let! jrnl = + sess.Query() + .Where(fun r -> r.userId = userId && r.lastStatus <> "Answered") + .OrderBy(fun r -> r.asOf) + .ProjectInto() + .ToListAsync() + return + jrnl + |> List.ofSeq + |> List.map (fun r -> r.history <- []; r.notes <- []; r) } - /// Retrieve notes for a request by its ID and user ID - member this.NotesById reqId userId = + /// Save changes in the current document session + let saveChanges (sess : IAsyncDocumentSession) = + sess.SaveChangesAsync () + + /// Retrieve a request, including its history and notes, by its ID and user ID + let tryFullRequestById reqId userId (sess : IAsyncDocumentSession) = task { - match! this.TryRequestById reqId userId with - | Some _ -> return this.Notes.AsNoTracking().Where(fun n -> n.requestId = reqId) |> List.ofSeq + let! req = RequestId.toString reqId |> sess.LoadAsync + return match Option.fromObject req with Some r when r.userId = userId -> Some r | _ -> None + } + + + /// Retrieve a request by its ID and user ID (without notes and history) + let tryRequestById reqId userId (sess : IAsyncDocumentSession) = + task { + match! tryFullRequestById reqId userId sess with + | Some r -> return Some { r with history = []; notes = [] } + | _ -> return None + } + + /// Retrieve notes for a request by its ID and user ID + let notesById reqId userId (sess : IAsyncDocumentSession) = + task { + match! tryFullRequestById reqId userId sess with + | Some req -> return req.notes | None -> return [] } - + /// Retrieve a journal request by its ID and user ID - member this.TryJournalById reqId userId = + let tryJournalById reqId userId (sess : IAsyncDocumentSession) = task { - let! req = this.Journal.FirstOrDefaultAsync(fun r -> r.requestId = reqId && r.userId = userId) + let! req = + sess.Query() + .Where(fun x -> x.Id = (RequestId.toString reqId) && x.userId = userId) + .ProjectInto() + .FirstOrDefaultAsync () return Option.fromObject req } - - /// Retrieve a request, including its history and notes, by its ID and user ID - member this.TryFullRequestById requestId userId = - task { - match! this.TryJournalById requestId userId with - | Some req -> - let! fullReq = - this.Requests.AsNoTracking() - .Include(fun r -> r.history) - .Include(fun r -> r.notes) - .FirstOrDefaultAsync(fun r -> r.requestId = requestId && r.userId = userId) - match Option.fromObject fullReq with - | Some _ -> return Some { req with history = List.ofSeq fullReq.history; notes = List.ofSeq fullReq.notes } - | None -> return None - | None -> return None - } -*) \ No newline at end of file + + /// Update the recurrence for a request + let updateRecurrence reqId recurType recurCount (sess : IAsyncDocumentSession) = + sess.Advanced.Patch (RequestId.toString reqId, (fun r -> r.recurType), recurType) + sess.Advanced.Patch (RequestId.toString reqId, (fun r -> r.recurCount), recurCount) + + /// Update a snoozed request + let updateSnoozed reqId until (sess : IAsyncDocumentSession) = + sess.Advanced.Patch (RequestId.toString reqId, (fun r -> r.snoozedUntil), until) + sess.Advanced.Patch (RequestId.toString reqId, (fun r -> r.showAfter), until) + + /// Update the "show after" timestamp for a request + let updateShowAfter reqId showAfter (sess : IAsyncDocumentSession) = + sess.Advanced.Patch (RequestId.toString reqId, (fun r -> r.showAfter), showAfter) diff --git a/src/MyPrayerJournal.Api/Domain.fs b/src/MyPrayerJournal.Api/Domain.fs index b2179b2..5c96e9f 100644 --- a/src/MyPrayerJournal.Api/Domain.fs +++ b/src/MyPrayerJournal.Api/Domain.fs @@ -155,29 +155,29 @@ with } /// JournalRequest is the form of a prayer request returned for the request journal display. It also contains -/// properties that may be filled for history and notes -[] -type JournalRequest = - { /// The ID of the request - requestId : RequestId - /// The ID of the user to whom the request belongs - userId : UserId - /// The current text of the request - text : string - /// The last time action was taken on the request - asOf : Ticks - /// The last status for the request - lastStatus : string - /// The time that this request should reappear in the user's journal - snoozedUntil : Ticks - /// The time after which this request should reappear in the user's journal by configured recurrence - showAfter : Ticks - /// The type of recurrence for this request - recurType : Recurrence - /// How many of the recurrence intervals should occur between appearances in the journal - recurCount : int16 - /// History entries for the request - history : History list - /// Note entries for the request - notes : Note list - } +/// properties that may be filled for history and notes. +// RavenDB doesn't like the "@"-suffixed properties from record types in a ProjectInto clause +[] +type JournalRequest () = + /// The ID of the request + [] val mutable requestId : RequestId + /// The ID of the user to whom the request belongs + [] val mutable userId : UserId + /// The current text of the request + [] val mutable text : string + /// The last time action was taken on the request + [] val mutable asOf : Ticks + /// The last status for the request + [] val mutable lastStatus : string + /// The time that this request should reappear in the user's journal + [] val mutable snoozedUntil : Ticks + /// The time after which this request should reappear in the user's journal by configured recurrence + [] val mutable showAfter : Ticks + /// The type of recurrence for this request + [] val mutable recurType : Recurrence + /// How many of the recurrence intervals should occur between appearances in the journal + [] val mutable recurCount : int16 + /// History entries for the request + [] val mutable history : History list + /// Note entries for the request + [] val mutable notes : Note list diff --git a/src/MyPrayerJournal.Api/Handlers.fs b/src/MyPrayerJournal.Api/Handlers.fs index 8fb55ae..c494713 100644 --- a/src/MyPrayerJournal.Api/Handlers.fs +++ b/src/MyPrayerJournal.Api/Handlers.fs @@ -143,8 +143,9 @@ module Journal = authorize >=> fun next ctx -> task { - use sess = session ctx - let! jrnl = ((userId >> sess.JournalByUserId) ctx).ToListAsync () + use sess = session ctx + let usrId = userId ctx + let! jrnl = Data.journalByUserId usrId sess return! json jrnl next ctx } @@ -164,7 +165,7 @@ module Request = let reqId = (Cuid.Generate >> toReqId) () let usrId = userId ctx let now = jsNow () - do! sess.AddRequest + do! Data.addRequest { Request.empty with Id = RequestId.toString reqId userId = usrId @@ -173,15 +174,14 @@ module Request = recurType = Recurrence.fromString r.recurType recurCount = r.recurCount history = [ - { History.empty with - asOf = now - status = Created - text = Some r.requestText + { asOf = now + status = Created + text = Some r.requestText } ] - } - do! sess.SaveChangesAsync () - match! sess.TryJournalById reqId usrId with + } sess + do! Data.saveChanges sess + match! Data.tryJournalById reqId usrId sess with | Some req -> return! (setStatusCode 201 >=> json req) next ctx | None -> return! Error.notFound next ctx } @@ -192,24 +192,24 @@ module Request = >=> fun next ctx -> task { use sess = session ctx + let usrId = userId ctx let reqId = toReqId requestId - match! sess.TryRequestById reqId (userId ctx) with + match! Data.tryRequestById reqId usrId sess with | Some req -> let! hist = ctx.BindJsonAsync () let now = jsNow () let act = RequestAction.fromString hist.status - { History.empty with - asOf = now + Data.addHistory reqId + { asOf = now status = act text = match hist.updateText with null | "" -> None | x -> Some x - } - |> sess.AddHistory reqId + } sess match act with | Prayed -> - (Ticks.toLong now) + (Recurrence.duration req.recurType * int64 req.recurCount) - |> (Ticks >> sess.UpdateShowAfter reqId) + let nextShow = (Ticks.toLong now) + (Recurrence.duration req.recurType * int64 req.recurCount) + Data.updateShowAfter reqId (Ticks nextShow) sess | _ -> () - do! sess.SaveChangesAsync () + do! Data.saveChanges sess return! created next ctx | None -> return! Error.notFound next ctx } @@ -220,12 +220,13 @@ module Request = >=> fun next ctx -> task { use sess = session ctx + let usrId = userId ctx let reqId = toReqId requestId - match! sess.TryRequestById reqId (userId ctx) with + match! Data.tryRequestById reqId usrId sess with | Some _ -> let! notes = ctx.BindJsonAsync () - sess.AddNote reqId { asOf = jsNow (); notes = notes.notes } - do! sess.SaveChangesAsync () + Data.addNote reqId { asOf = jsNow (); notes = notes.notes } sess + do! Data.saveChanges sess return! created next ctx | None -> return! Error.notFound next ctx } @@ -235,8 +236,9 @@ module Request = authorize >=> fun next ctx -> task { - use sess = session ctx - let! reqs = ((userId >> sess.AnsweredRequests) ctx).ToListAsync () + use sess = session ctx + let usrId = userId ctx + let! reqs = Data.answeredRequests usrId sess return! json reqs next ctx } @@ -245,8 +247,9 @@ module Request = authorize >=> fun next ctx -> task { - use sess = session ctx - match! sess.TryJournalById (toReqId requestId) (userId ctx) with + use sess = session ctx + let usrId = userId ctx + match! Data.tryJournalById (toReqId requestId) usrId sess with | Some req -> return! json req next ctx | None -> return! Error.notFound next ctx } @@ -256,8 +259,9 @@ module Request = authorize >=> fun next ctx -> task { - use sess = session ctx - match! sess.TryFullRequestById (toReqId requestId) (userId ctx) with + use sess = session ctx + let usrId = userId ctx + match! Data.tryFullRequestById (toReqId requestId) usrId sess with | Some req -> return! json req next ctx | None -> return! Error.notFound next ctx } @@ -267,8 +271,9 @@ module Request = authorize >=> fun next ctx -> task { - use sess = session ctx - let! notes = sess.NotesById (toReqId requestId) (userId ctx) + use sess = session ctx + let usrId = userId ctx + let! notes = Data.notesById (toReqId requestId) usrId sess return! json notes next ctx } @@ -278,12 +283,13 @@ module Request = >=> fun next ctx -> task { use sess = session ctx + let usrId = userId ctx let reqId = toReqId requestId - match! sess.TryRequestById reqId (userId ctx) with + match! Data.tryRequestById reqId usrId sess with | Some _ -> let! show = ctx.BindJsonAsync () - sess.UpdateShowAfter reqId (Ticks show.showAfter) - do! sess.SaveChangesAsync () + Data.updateShowAfter reqId (Ticks show.showAfter) sess + do! Data.saveChanges sess return! setStatusCode 204 next ctx | None -> return! Error.notFound next ctx } @@ -294,12 +300,13 @@ module Request = >=> fun next ctx -> task { use sess = session ctx + let usrId = userId ctx let reqId = toReqId requestId - match! sess.TryRequestById reqId (userId ctx) with + match! Data.tryRequestById reqId usrId sess with | Some _ -> let! until = ctx.BindJsonAsync () - sess.UpdateSnoozed reqId (Ticks until.until) - do! sess.SaveChangesAsync () + Data.updateSnoozed reqId (Ticks until.until) sess + do! Data.saveChanges sess return! setStatusCode 204 next ctx | None -> return! Error.notFound next ctx } @@ -310,12 +317,13 @@ module Request = >=> fun next ctx -> task { use sess = session ctx + let usrId = userId ctx let reqId = toReqId requestId - match! sess.TryRequestById reqId (userId ctx) with + match! Data.tryRequestById reqId usrId sess with | Some _ -> let! recur = ctx.BindJsonAsync () - sess.UpdateRecurrence reqId (Recurrence.fromString recur.recurType) recur.recurCount - do! sess.SaveChangesAsync () + Data.updateRecurrence reqId (Recurrence.fromString recur.recurType) recur.recurCount sess + do! Data.saveChanges sess return! setStatusCode 204 next ctx | None -> return! Error.notFound next ctx } diff --git a/src/MyPrayerJournal.Api/Program.fs b/src/MyPrayerJournal.Api/Program.fs index b4fff2e..f0e0b11 100644 --- a/src/MyPrayerJournal.Api/Program.fs +++ b/src/MyPrayerJournal.Api/Program.fs @@ -27,9 +27,9 @@ module Configure = /// Configure Kestrel from appsettings.json let kestrel (bldr : IWebHostBuilder) = - let kestrel (ctx : WebHostBuilderContext) (opts : KestrelServerOptions) = + let kestrelOpts (ctx : WebHostBuilderContext) (opts : KestrelServerOptions) = (ctx.Configuration.GetSection >> opts.Configure >> ignore) "Kestrel" - bldr.ConfigureKestrel kestrel + bldr.UseKestrel().ConfigureKestrel kestrelOpts /// Configure the web root directory let webRoot pathSegments (bldr : IWebHostBuilder) = @@ -176,6 +176,6 @@ module Program = [] let main _ = let appRoot = Directory.GetCurrentDirectory () - use host = WebHostBuilder () |> (Configure.webHost appRoot [| "wwwroot" |] >> Configure.buildHost) + use host = WebHostBuilder() |> (Configure.webHost appRoot [| "wwwroot" |] >> Configure.buildHost) host.Run () exitCode diff --git a/src/app/package.json b/src/app/package.json index 1cf6264..090e64b 100644 --- a/src/app/package.json +++ b/src/app/package.json @@ -1,6 +1,6 @@ { "name": "my-prayer-journal", - "version": "1.2.2", + "version": "2.0.0", "description": "myPrayerJournal - Front End", "author": "Daniel J. Summers ", "private": true, @@ -8,9 +8,9 @@ "serve": "vue-cli-service serve", "build": "vue-cli-service build --modern", "lint": "vue-cli-service lint", - "apistart": "cd ../api/MyPrayerJournal.Api && dotnet run", - "vue": "vue-cli-service build --modern && cd ../api/MyPrayerJournal.Api && dotnet run", - "publish": "vue-cli-service build --modern && cd ../api/MyPrayerJournal.Api && dotnet publish -c Release" + "apistart": "cd ../MyPrayerJournal.Api && dotnet run", + "vue": "vue-cli-service build --modern && cd ../MyPrayerJournal.Api && dotnet run", + "publish": "vue-cli-service build --modern && cd ../MyPrayerJournal.Api && dotnet publish -c Release" }, "dependencies": { "auth0-js": "^9.7.3", diff --git a/src/app/src/components/Journal.vue b/src/app/src/components/Journal.vue index f891dac..e8429bd 100644 --- a/src/app/src/components/Journal.vue +++ b/src/app/src/components/Journal.vue @@ -10,7 +10,7 @@ article.mpj-main-content-wide(role='main') br .mpj-journal(v-if='journal.length > 0') request-card(v-for='request in journal' - :key='request.requestId' + :key='request.Id' :request='request' :events='eventBus' :toast='toast') diff --git a/src/app/src/components/request/ActiveRequests.vue b/src/app/src/components/request/ActiveRequests.vue index a5d67b7..5d29752 100644 --- a/src/app/src/components/request/ActiveRequests.vue +++ b/src/app/src/components/request/ActiveRequests.vue @@ -5,7 +5,7 @@ article.mpj-main-content(role='main') p.mpj-text-center(v-if='requests.length === 0'): em. No active requests found; return to #[router-link(:to='{ name: "Journal" } ') your journal] request-list-item(v-for='req in requests' - :key='req.requestId' + :key='req.Id' :request='req' :toast='toast') p(v-else) Loading journal... diff --git a/src/app/src/components/request/AnsweredRequests.vue b/src/app/src/components/request/AnsweredRequests.vue index 260ffb9..56956e6 100644 --- a/src/app/src/components/request/AnsweredRequests.vue +++ b/src/app/src/components/request/AnsweredRequests.vue @@ -5,7 +5,7 @@ article.mpj-main-content(role='main') p.text-center(v-if='requests.length === 0'): em. No answered requests found; once you have marked one as “Answered”, it will appear here request-list-item(v-for='req in requests' - :key='req.requestId' + :key='req.Id' :request='req' :toast='toast') p(v-else) Loading answered requests... diff --git a/src/app/src/components/request/EditRequest.vue b/src/app/src/components/request/EditRequest.vue index 9221e26..9563ceb 100644 --- a/src/app/src/components/request/EditRequest.vue +++ b/src/app/src/components/request/EditRequest.vue @@ -134,7 +134,7 @@ export default { if (this.journal.length === 0) { await this.$store.dispatch(actions.LOAD_JOURNAL, this.$Progress) } - const req = this.journal.filter(r => r.requestId === this.id)[0] + const req = this.journal.filter(r => r.Id === this.id)[0] this.form.requestId = this.id this.form.requestText = req.text this.form.status = 'Updated' diff --git a/src/app/src/components/request/NotesEdit.vue b/src/app/src/components/request/NotesEdit.vue index 85c28e1..9818154 100644 --- a/src/app/src/components/request/NotesEdit.vue +++ b/src/app/src/components/request/NotesEdit.vue @@ -85,7 +85,7 @@ export default { } }, openDialog (request) { - this.form.requestId = request.requestId + this.form.requestId = request.Id this.notesVisible = true }, async saveNotes () { diff --git a/src/app/src/components/request/RequestCard.vue b/src/app/src/components/request/RequestCard.vue index e287784..a8ab47c 100644 --- a/src/app/src/components/request/RequestCard.vue +++ b/src/app/src/components/request/RequestCard.vue @@ -36,20 +36,20 @@ export default { async markPrayed () { await this.$store.dispatch(actions.UPDATE_REQUEST, { progress: this.$Progress, - requestId: this.request.requestId, + requestId: this.request.Id, status: 'Prayed', updateText: '' }) this.toast.showToast('Request marked as prayed', { theme: 'success' }) }, showEdit () { - this.$router.push({ name: 'EditRequest', params: { id: this.request.requestId } }) + this.$router.push({ name: 'EditRequest', params: { id: this.request.Id } }) }, showNotes () { this.events.$emit('notes', this.request) }, snooze () { - this.events.$emit('snooze', this.request.requestId) + this.events.$emit('snooze', this.request.Id) } } } diff --git a/src/app/src/components/request/RequestListItem.vue b/src/app/src/components/request/RequestListItem.vue index b855ebe..db53ff7 100644 --- a/src/app/src/components/request/RequestListItem.vue +++ b/src/app/src/components/request/RequestListItem.vue @@ -60,26 +60,26 @@ export default { async cancelSnooze () { await this.$store.dispatch(actions.SNOOZE_REQUEST, { progress: this.$Progress, - requestId: this.request.requestId, + requestId: this.request.Id, until: 0 }) this.toast.showToast('Request un-snoozed', { theme: 'success' }) this.$parent.$emit('requestUnsnoozed') }, editRequest () { - this.$router.push({ name: 'EditRequest', params: { id: this.request.requestId } }) + this.$router.push({ name: 'EditRequest', params: { id: this.request.Id } }) }, async showNow () { await this.$store.dispatch(actions.SHOW_REQUEST_NOW, { progress: this.$Progress, - requestId: this.request.requestId, + requestId: this.request.Id, showAfter: Date.now() }) this.toast.showToast('Recurrence skipped; request now shows in journal', { theme: 'success' }) this.$parent.$emit('requestNowShown') }, viewFull () { - this.$router.push({ name: 'FullRequest', params: { id: this.request.requestId } }) + this.$router.push({ name: 'FullRequest', params: { id: this.request.Id } }) } } } diff --git a/src/app/src/components/request/SnoozedRequests.vue b/src/app/src/components/request/SnoozedRequests.vue index bec1909..fe844a8 100644 --- a/src/app/src/components/request/SnoozedRequests.vue +++ b/src/app/src/components/request/SnoozedRequests.vue @@ -5,7 +5,7 @@ article.mpj-main-content(role='main') p.mpj-text-center(v-if='requests.length === 0'): em. No snoozed requests found; return to #[router-link(:to='{ name: "Journal" } ') your journal] request-list-item(v-for='req in requests' - :key='req.requestId' + :key='req.Id' :request='req' :toast='toast') p(v-else) Loading journal... diff --git a/src/app/src/store/index.js b/src/app/src/store/index.js index b7d0e6b..8b5a625 100644 --- a/src/app/src/store/index.js +++ b/src/app/src/store/index.js @@ -56,7 +56,7 @@ export default new Vuex.Store({ state.journal.push(newRequest) }, [mutations.REQUEST_UPDATED] (state, request) { - let jrnl = state.journal.filter(it => it.requestId !== request.requestId) + let jrnl = state.journal.filter(it => it.Id !== request.Id) if (request.lastStatus !== 'Answered') jrnl.push(request) state.journal = jrnl }, @@ -103,7 +103,7 @@ export default new Vuex.Store({ async [actions.UPDATE_REQUEST] ({ commit, state }, { progress, requestId, status, updateText, recurType, recurCount }) { progress.start() try { - let oldReq = (state.journal.filter(req => req.requestId === requestId) || [])[0] || {} + let oldReq = (state.journal.filter(req => req.Id === requestId) || [])[0] || {} if (!(status === 'Prayed' && updateText === '')) { if (status !== 'Answered' && (oldReq.recurType !== recurType || oldReq.recurCount !== recurCount)) { await api.updateRecurrence(requestId, recurType, recurCount) diff --git a/src/app/vue.config.js b/src/app/vue.config.js index 63fc1a7..df4d8dc 100644 --- a/src/app/vue.config.js +++ b/src/app/vue.config.js @@ -1,6 +1,6 @@ const webpack = require('webpack') module.exports = { - outputDir: '../api/MyPrayerJournal.Api/wwwroot', + outputDir: '../MyPrayerJournal.Api/wwwroot', configureWebpack: { plugins: [ new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/)