module Handler.ReferenceItem where import Import getReferenceItemR :: ReferenceId -> Handler TypedContent getReferenceItemR referenceId = do entity <- runDB $ Entity referenceId <$> get404 referenceId selectRep $ do provideJson entity provideRep (redirect $ ReferenceListingR :#: referenceId :: Handler Html) putReferenceItemR :: ReferenceId -> Handler Value putReferenceItemR referenceId = do Reference{..} <- requireCheckJsonBody returnJson . Entity referenceId =<< runDB (updateGet referenceId [ ReferenceKind =. referenceKind , ReferenceNormKind =. referenceNormKind ]) patchReferenceItemR :: ReferenceId -> Handler Value patchReferenceItemR = putReferenceItemR -- Just one field deleteReferenceItemR :: ReferenceId -> Handler () deleteReferenceItemR = runDB . delete