diff --git a/src/Guide/Handlers.hs b/src/Guide/Handlers.hs index 31433da..ae4cb31 100644 --- a/src/Guide/Handlers.hs +++ b/src/Guide/Handlers.hs @@ -244,14 +244,14 @@ setMethods = Spock.subcomponent "set" $ do ("modified" :: Text, modified), ("merged" :: Text, merge original content' modified)] -- Trait - Spock.post (itemVar categoryVar traitVar) $ \itemId catId traitId -> do + Spock.post (itemVar traitVar) $ \itemId traitId -> do original <- param' "original" content' <- param' "content" modified <- view (content.mdText) <$> dbQuery (GetTrait itemId traitId) if modified == original then do trait <- uncache (CacheItemTraits itemId) $ do - (edit, trait) <- dbUpdate (SetTraitContent itemId catId traitId content') + (edit, trait) <- dbUpdate (SetTraitContent itemId traitId content') addEdit edit return trait lucidIO $ renderTrait itemId trait diff --git a/src/Guide/ServerStuff.hs b/src/Guide/ServerStuff.hs index 70e20bc..7a6e59c 100644 --- a/src/Guide/ServerStuff.hs +++ b/src/Guide/ServerStuff.hs @@ -231,11 +231,11 @@ undoEdit (Edit'SetItemEcosystem itemId old new) = do if now /= new then return (Left "ecosystem has been changed further") else Right () <$ dbUpdate (SetItemEcosystem itemId old) -undoEdit (Edit'SetTraitContent itemId catId traitId old new) = do +undoEdit (Edit'SetTraitContent itemId traitId old new) = do now <- view (content.mdText) <$> dbQuery (GetTrait itemId traitId) if now /= new then return (Left "trait has been changed further") - else Right () <$ dbUpdate (SetTraitContent itemId catId traitId old) + else Right () <$ dbUpdate (SetTraitContent itemId traitId old) undoEdit (Edit'DeleteCategory catId pos) = do dbUpdate (RestoreCategory catId pos) undoEdit (Edit'DeleteItem itemId pos) = do @@ -291,7 +291,7 @@ invalidateCacheForEdit ed = do [CacheItemNotes itemId] Edit'SetItemEcosystem itemId _ _ -> [CacheItemEcosystem itemId] - Edit'SetTraitContent itemId _ _ _ _ -> + Edit'SetTraitContent itemId _ _ _ -> [CacheItemTraits itemId] Edit'DeleteCategory catId _ -> [CacheCategory catId] diff --git a/src/Guide/State.hs b/src/Guide/State.hs index 41a6b9d..a4a2024 100644 --- a/src/Guide/State.hs +++ b/src/Guide/State.hs @@ -456,11 +456,11 @@ setItemEcosystem itemId ecosystem' = do (oldEcosystem ^. mdText) ecosystem' (edit,) <$> use (itemById itemId) -setTraitContent :: Uid Item -> Uid Category -> Uid Trait -> Text -> Acid.Update GlobalState (Edit, Trait) -setTraitContent itemId catId traitId content' = do +setTraitContent :: Uid Item -> Uid Trait -> Text -> Acid.Update GlobalState (Edit, Trait) +setTraitContent itemId traitId content' = do oldContent <- itemById itemId . traitById traitId . content <<.= toMarkdownInline content' - let edit = Edit'SetTraitContent itemId catId traitId + let edit = Edit'SetTraitContent itemId traitId (oldContent ^. mdText) content' (edit,) <$> use (itemById itemId . traitById traitId) diff --git a/src/Guide/Types/Edit.hs b/src/Guide/Types/Edit.hs index 6925907..8576fc7 100644 --- a/src/Guide/Types/Edit.hs +++ b/src/Guide/Types/Edit.hs @@ -106,7 +106,6 @@ data Edit -- Change trait properties | Edit'SetTraitContent { editItemUid :: Uid Item, - editCategoryUid :: Uid Category, editTraitUid :: Uid Trait, editTraitContent :: Text, editTraitNewContent :: Text } diff --git a/src/Guide/Views.hs b/src/Guide/Views.hs index 0dc3fb8..48fab6d 100644 --- a/src/Guide/Views.hs +++ b/src/Guide/Views.hs @@ -390,9 +390,9 @@ renderEdit globalState edit = do -- Add Edit'AddCategory _catId title' -> p_ $ do "added category " >> quote (toHtml title') - Edit'AddItem catId _itemId _ -> p_ $ do + Edit'AddItem catId _itemId name' -> p_ $ do "added item " >> printItem _itemId - + " (initially called " >> quote (toHtml name') >> ")" " to category " >> printCategory catId Edit'AddPro itemId _traitId content' -> do p_ $ "added pro to item " >> printItem itemId @@ -473,9 +473,10 @@ renderEdit globalState edit = do td_ $ blockquote_ $ toHtml (toMarkdownBlock newEcosystem) -- Change trait properties - Edit'SetTraitContent itemId catId _traitId oldContent newContent -> do + Edit'SetTraitContent itemId _traitId oldContent newContent -> do p_ $ (if T.null oldContent then "added" else "changed") >> - " trait of item " >> printItem itemId >> " from category " >> printCategory catId + " trait of item " >> printItem itemId >> + " from category " >> printCategory (findItem itemId ^. _1.uid) table_ $ tr_ $ do unless (T.null oldContent) $ td_ $ blockquote_ $ p_ (toHtml (toMarkdownInline oldContent))