Ticket list page

This commit is contained in:
fr33domlover 2016-04-30 23:02:44 +00:00
parent 09b767a037
commit eaadbc050c
3 changed files with 49 additions and 4 deletions

View file

@ -54,8 +54,8 @@
/u/#Text/p/#Text ProjectR GET /u/#Text/p/#Text ProjectR GET
/u/#Text/p/#Text/t TicketsR GET POST /u/#Text/p/#Text/t TicketsR GET POST
/u/#Text/p/#Text/t/new TicketNewR GET /u/#Text/p/#Text/t/!new TicketNewR GET
-- /u/#Text/p/#Text/t/#Int TicketR GET /u/#Text/p/#Text/t/#Int TicketR GET
-- /u/#Text/p/#Text/w WikiR GET -- /u/#Text/p/#Text/w WikiR GET
-- /u/#Text/p/#Text/w/+Texts WikiPageR GET -- /u/#Text/p/#Text/w/+Texts WikiPageR GET

View file

@ -17,13 +17,14 @@ module Vervis.Handler.Ticket
( getTicketsR ( getTicketsR
, postTicketsR , postTicketsR
, getTicketNewR , getTicketNewR
, getTicketR
) )
where where
import Prelude import Prelude
import Data.Text (Text) import Data.Text (Text)
import Database.Persist.Types (Entity (..)) import Database.Persist
import Text.Blaze.Html (Html, toHtml) import Text.Blaze.Html (Html, toHtml)
import Yesod.Core (defaultLayout) import Yesod.Core (defaultLayout)
import Yesod.Core.Handler (notFound) import Yesod.Core.Handler (notFound)
@ -39,7 +40,14 @@ import Vervis.Model
import Vervis.Settings (widgetFile) import Vervis.Settings (widgetFile)
getTicketsR :: Text -> Text -> Handler Html getTicketsR :: Text -> Text -> Handler Html
getTicketsR shar proj = notFound getTicketsR shar proj = do
tickets <- runDB $ do
Entity sid _sharer <- getBy404 $ UniqueSharerIdent shar
Entity pid _project <- getBy404 $ UniqueProject proj sid
selectList [TicketProject ==. pid] [Asc TicketNumber]
defaultLayout $ do
setTitle $ toHtml $ T.intercalate " :: " [shar, proj, "Tickes"]
$(widgetFile "ticket/list")
postTicketsR :: Text -> Text -> Handler Html postTicketsR :: Text -> Text -> Handler Html
postTicketsR shar proj = notFound postTicketsR shar proj = notFound
@ -54,3 +62,6 @@ getTicketNewR shar proj = do
defaultLayout $ do defaultLayout $ do
setTitle $ toHtml $ T.intercalate " :: " [shar, proj, "New ticket"] setTitle $ toHtml $ T.intercalate " :: " [shar, proj, "New ticket"]
$(widgetFile "ticket/new") $(widgetFile "ticket/new")
getTicketR :: Text -> Text -> Int -> Handler Html
getTicketR shar proj num = notFound

View file

@ -0,0 +1,34 @@
$# 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/>.
<h1>#{shar} :: #{proj} :: Tickets
<p>
<a href=@{TicketNewR shar proj}>Create new…
<table>
<tr>
<th>Number
<th>Title
<th>Done
$forall Entity _tid ticket <- tickets
<tr>
<td>
<a href=@{TicketR shar proj $ ticketNumber ticket}>
#{ticketNumber ticket}
<td>
<a href=@{TicketR shar proj $ ticketNumber ticket}>
#{ticketTitle ticket}
<td>
#{ticketDone ticket}