Per-project list of ticket claim requests

This commit is contained in:
fr33domlover 2016-06-07 15:29:26 +00:00
parent 574b47a72a
commit 047b9c00c9
5 changed files with 98 additions and 34 deletions

View file

@ -102,6 +102,7 @@
/s/#ShrIdent/p/#PrjIdent/t/#Int/unclaim TicketUnclaimR POST
/s/#ShrIdent/p/#PrjIdent/t/#Int/assign TicketAssignR GET POST
/s/#ShrIdent/p/#PrjIdent/t/#Int/unassign TicketUnassignR POST
/s/#ShrIdent/p/#PrjIdent/tcr TicketClaimRequestsR GET
/s/#ShrIdent/p/#PrjIdent/t/#Int/d TicketDiscussionR GET POST
/s/#ShrIdent/p/#PrjIdent/t/#Int/d/#Int TicketMessageR GET POST
/s/#ShrIdent/p/#PrjIdent/t/#Int/d/!reply TicketTopReplyR GET

View file

@ -454,6 +454,9 @@ instance YesodBreadcrumbs App where
, Just $ TicketR shr prj num
)
TicketUnassignR _shr _prj _num -> ("", Nothing)
TicketClaimRequestsR shr prj -> ( "Ticket Claim Requests"
, Just $ ProjectR shr prj
)
TicketDiscussionR shar proj num -> ( "Discussion"
, Just $ TicketR shar proj num
)

View file

@ -30,6 +30,7 @@ module Vervis.Handler.Ticket
, postTicketAssignR
, postTicketUnassignR
, getClaimRequestsR
, getTicketClaimRequestsR
, getTicketDiscussionR
, postTicketDiscussionR
, getTicketMessageR
@ -386,6 +387,8 @@ postTicketUnassignR shr prj num = do
setMessage $ fromMaybe "The ticket is now unassigned." mmsg
redirect $ TicketR shr prj num
-- | The logged-in user gets a list of the ticket claim requests they have
-- opened, in any project.
getClaimRequestsR :: Handler Html
getClaimRequestsR = do
pid <- requireAuthId
@ -405,6 +408,31 @@ getClaimRequestsR = do
)
defaultLayout $(widgetFile "person/claim-requests")
-- | Get a list of ticket claim requests for a given project.
getTicketClaimRequestsR :: ShrIdent -> PrjIdent -> Handler Html
getTicketClaimRequestsR shr prj = do
rqs <- runDB $ do
Entity sid _ <- getBy404 $ UniqueSharer shr
Entity jid _ <- getBy404 $ UniqueProject prj sid
select $ from $
\ ( tcr `InnerJoin`
ticket `InnerJoin`
person `InnerJoin`
sharer
) -> do
on $ person ^. PersonIdent E.==. sharer ^. SharerId
on $ tcr ^. TicketClaimRequestPerson E.==. person ^. PersonId
on $ tcr ^. TicketClaimRequestTicket E.==. ticket ^. TicketId
where_ $ ticket ^. TicketProject E.==. val jid
orderBy [desc $ tcr ^. TicketClaimRequestCreated]
return
( sharer
, ticket ^. TicketNumber
, ticket ^. TicketTitle
, tcr ^. TicketClaimRequestCreated
)
defaultLayout $(widgetFile "ticket/claim-request/list")
selectDiscussionId :: ShrIdent -> PrjIdent -> Int -> AppDB DiscussionId
selectDiscussionId shar proj tnum = do
Entity sid _sharer <- getBy404 $ UniqueSharer shar

View file

@ -26,6 +26,8 @@ $# <http://creativecommons.org/publicdomain/zero/1.0/>.
Description: #{fromMaybe "(none)" $ projectDesc project}
<li>
<a href=@{TicketsR shar proj}>Tickets
<li>
<a href=@{TicketClaimRequestsR shar proj}>Ticket claim requests
<h2>Collaborators

View file

@ -0,0 +1,30 @@
$# This file is part of Vervis.
$#
$# Written in 2016 by fr33domlover <fr33domlover@riseup.net>.
$#
$# ♡ Copying is an act of love. Please copy, reuse and share.
$#
$# The author(s) have dedicated all copyright and related and neighboring
$# rights to this software to the public domain worldwide. This software is
$# distributed without any warranty.
$#
$# You should have received a copy of the CC0 Public Domain Dedication along
$# with this software. If not, see
$# <http://creativecommons.org/publicdomain/zero/1.0/>.
<table>
<tr>
<th>Opened on
<th>Opened by
<th>#
<th>Title
$forall (Entity _ sharer, Value num, Value title, Value time) <- rqs
<tr>
<td>
#{showDate time}
<td>
^{personLinkW sharer}
<td>
<a href=@{TicketR shr prj num}>#{num}
<td>
<a href=@{TicketR shr prj num}>#{title}