diff --git a/src/Vervis/Foundation.hs b/src/Vervis/Foundation.hs index 5e1cd5c..291f812 100644 --- a/src/Vervis/Foundation.hs +++ b/src/Vervis/Foundation.hs @@ -951,6 +951,7 @@ instance YesodBreadcrumbs App where TicketNewR d -> ("New Ticket", Just $ DeckR d) TicketCloseR _ _ -> ("", Nothing) + TicketOpenR _ _ -> ("", Nothing) TicketFollowR _ _ -> ("", Nothing) TicketUnfollowR _ _ -> ("", Nothing) TicketReplyR d t -> ("Reply", Just $ TicketR d t) diff --git a/src/Vervis/Handler/Ticket.hs b/src/Vervis/Handler/Ticket.hs index 07a3b32..5d4c513 100644 --- a/src/Vervis/Handler/Ticket.hs +++ b/src/Vervis/Handler/Ticket.hs @@ -27,6 +27,7 @@ module Vervis.Handler.Ticket , getTicketNewR , postTicketNewR , postTicketCloseR + , postTicketOpenR , postTicketFollowR , postTicketUnfollowR @@ -520,6 +521,36 @@ postTicketCloseR deckHash taskHash = do setMessage "Resolve activity sent" redirect $ TicketR deckHash taskHash +postTicketOpenR :: KeyHashid Deck -> KeyHashid TicketDeck -> Handler () +postTicketOpenR deckHash taskHash = do + deckID <- decodeKeyHashid404 deckHash + taskID <- decodeKeyHashid404 taskHash + + personEntity@(Entity personID person) <- requireAuth + personHash <- encodeKeyHashid personID + encodeRouteHome <- getEncodeRouteHome + let uTicket = encodeRouteHome $ TicketR deckHash taskHash + result <- runExceptT $ do + (maybeSummary, audience, undo) <- C.unresolve personHash uTicket + grantID <- do + maybeItem <- lift $ runDB $ getGrant CollabTopicDeckCollab CollabTopicDeckDeck deckID personID + fromMaybeE maybeItem "You need to be a collaborator in the Deck to reopen tickets" + grantHash <- encodeKeyHashid grantID + let uCap = encodeRouteHome $ DeckOutboxItemR deckHash grantHash + (localRecips, remoteRecips, fwdHosts, action) <- + C.makeServerInput (Just uCap) maybeSummary audience $ AP.UndoActivity undo + let cap = + Left (LocalActorDeck deckID, LocalActorDeck deckHash, grantID) + handleViaActor personID (Just cap) localRecips remoteRecips fwdHosts action + + case result of + Left e -> do + setMessage $ toHtml e + redirect $ TicketR deckHash taskHash + Right resolveID -> do + setMessage "Undo activity sent" + redirect $ TicketR deckHash taskHash + postTicketFollowR :: KeyHashid Deck -> KeyHashid TicketDeck -> Handler () postTicketFollowR _ = error "Temporarily disabled" diff --git a/templates/ticket/one.hamlet b/templates/ticket/one.hamlet index aeeffcc..002a477 100644 --- a/templates/ticket/one.hamlet +++ b/templates/ticket/one.hamlet @@ -69,7 +69,7 @@ $# . Status: # $maybe (closed, closer) <- resolved Closed on #{showDate closed} by ^{personLinkFedW closer} -$# ^{buttonW POST "Reopen this ticket" (ProjectTicketOpenR deckHash ticketHash)} + ^{buttonW POST "Reopen this ticket" (TicketOpenR deckHash ticketHash)} $nothing Open ^{buttonW POST "Close this ticket" (TicketCloseR deckHash ticketHash)} diff --git a/th/routes b/th/routes index 861e61a..71d01bc 100644 --- a/th/routes +++ b/th/routes @@ -240,7 +240,7 @@ -- /decks/#DeckKeyHashid/tickets/#TicketDeckKeyHashid/edit TicketEditR GET POST -- /decks/#DeckKeyHashid/tickets/#TicketDeckKeyHashid/delete TicketDeleteR POST /decks/#DeckKeyHashid/tickets/#TicketDeckKeyHashid/close TicketCloseR POST --- /decks/#DeckKeyHashid/tickets/#TicketDeckKeyHashid/open TicketOpenR POST +/decks/#DeckKeyHashid/tickets/#TicketDeckKeyHashid/open TicketOpenR POST -- /decks/#DeckKeyHashid/tickets/#TicketDeckKeyHashid/claim TicketClaimR POST -- /decks/#DeckKeyHashid/tickets/#TicketDeckKeyHashid/unclaim TicketUnclaimR POST -- /decks/#DeckKeyHashid/tickets/#TicketDeckKeyHashid/assign TicketAssignR GET POST