summaryrefslogtreecommitdiff
path: root/Handler/ReferenceItem.hs
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2017-03-15 14:47:31 +0100
committerGregor Kleen <gkleen@yggdrasil.li>2017-03-15 14:47:31 +0100
commitfe5cd6ad6c61eb13ca99acd1b69cd09b84051404 (patch)
tree4afc8cb5ae4171047d6af17082fb74d49c726abe /Handler/ReferenceItem.hs
parent668961c90368b55a3409ae93b96e288f8ebe33a4 (diff)
downloadbar-fe5cd6ad6c61eb13ca99acd1b69cd09b84051404.tar
bar-fe5cd6ad6c61eb13ca99acd1b69cd09b84051404.tar.gz
bar-fe5cd6ad6c61eb13ca99acd1b69cd09b84051404.tar.bz2
bar-fe5cd6ad6c61eb13ca99acd1b69cd09b84051404.tar.xz
bar-fe5cd6ad6c61eb13ca99acd1b69cd09b84051404.zip
Support types
Diffstat (limited to 'Handler/ReferenceItem.hs')
-rw-r--r--Handler/ReferenceItem.hs17
1 files changed, 8 insertions, 9 deletions
diff --git a/Handler/ReferenceItem.hs b/Handler/ReferenceItem.hs
index 738c9f3..44cd0a8 100644
--- a/Handler/ReferenceItem.hs
+++ b/Handler/ReferenceItem.hs
@@ -4,7 +4,7 @@ import Import
4 4
5getReferenceItemR :: ReferenceId -> Handler TypedContent 5getReferenceItemR :: ReferenceId -> Handler TypedContent
6getReferenceItemR referenceId = do 6getReferenceItemR referenceId = do
7 entity <- runDB $ Entity referenceId <$> get404 referenceId 7 entity <- runDB $ withType =<< Entity referenceId <$> get404 referenceId
8 selectRep $ do 8 selectRep $ do
9 provideJson entity 9 provideJson entity
10 provideRep (redirect $ ReferenceListingR :#: referenceId :: Handler Html) 10 provideRep (redirect $ ReferenceListingR :#: referenceId :: Handler Html)
@@ -12,14 +12,13 @@ getReferenceItemR referenceId = do
12 12
13putReferenceItemR :: ReferenceId -> Handler Value 13putReferenceItemR :: ReferenceId -> Handler Value
14putReferenceItemR referenceId = do 14putReferenceItemR referenceId = do
15 Reference{..} <- requireCheckJsonBody 15 (Reference{..} `WithType` t) <- requireCheckJsonBody
16 returnJson . Entity referenceId =<< runDB 16 returnJson <=< runDB $ do
17 (updateGet referenceId [ ReferenceKind =. referenceKind 17 entity <- Entity referenceId <$> updateGet referenceId [ ReferenceKind =. referenceKind
18 , ReferenceNormKind =. referenceNormKind 18 , ReferenceNormKind =. referenceNormKind
19 ]) 19 ]
20 20 update (referenceFkType $ entityVal entity) [ KindType =. t ]
21patchReferenceItemR :: ReferenceId -> Handler Value 21 withType entity
22patchReferenceItemR = putReferenceItemR -- Just one field
23 22
24deleteReferenceItemR :: ReferenceId -> Handler () 23deleteReferenceItemR :: ReferenceId -> Handler ()
25deleteReferenceItemR = runDB . delete 24deleteReferenceItemR = runDB . delete