diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2017-03-15 14:47:31 +0100 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2017-03-15 14:47:31 +0100 |
commit | fe5cd6ad6c61eb13ca99acd1b69cd09b84051404 (patch) | |
tree | 4afc8cb5ae4171047d6af17082fb74d49c726abe /Handler/ReferenceItem.hs | |
parent | 668961c90368b55a3409ae93b96e288f8ebe33a4 (diff) | |
download | bar-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.hs | 17 |
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 | ||
5 | getReferenceItemR :: ReferenceId -> Handler TypedContent | 5 | getReferenceItemR :: ReferenceId -> Handler TypedContent |
6 | getReferenceItemR referenceId = do | 6 | getReferenceItemR 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 | ||
13 | putReferenceItemR :: ReferenceId -> Handler Value | 13 | putReferenceItemR :: ReferenceId -> Handler Value |
14 | putReferenceItemR referenceId = do | 14 | putReferenceItemR 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 ] | |
21 | patchReferenceItemR :: ReferenceId -> Handler Value | 21 | withType entity |
22 | patchReferenceItemR = putReferenceItemR -- Just one field | ||
23 | 22 | ||
24 | deleteReferenceItemR :: ReferenceId -> Handler () | 23 | deleteReferenceItemR :: ReferenceId -> Handler () |
25 | deleteReferenceItemR = runDB . delete | 24 | deleteReferenceItemR = runDB . delete |