diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2017-03-28 13:53:46 +0200 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2017-03-28 13:53:46 +0200 |
commit | de1513a40da72632b500c710c5254c8e3639b7bd (patch) | |
tree | d5e4cb9847642b05a1ffbbfed774dc7caeb618f7 | |
parent | 72b9f29c057eb45d022b9bbc1562d7b84ccc165b (diff) | |
download | bar-de1513a40da72632b500c710c5254c8e3639b7bd.tar bar-de1513a40da72632b500c710c5254c8e3639b7bd.tar.gz bar-de1513a40da72632b500c710c5254c8e3639b7bd.tar.bz2 bar-de1513a40da72632b500c710c5254c8e3639b7bd.tar.xz bar-de1513a40da72632b500c710c5254c8e3639b7bd.zip |
Fix updating running low
-rw-r--r-- | Handler/Common.hs | 2 | ||||
-rw-r--r-- | Handler/Item.hs | 1 | ||||
-rw-r--r-- | Handler/UpdateItem.hs | 1 | ||||
-rw-r--r-- | Model.hs | 3 | ||||
-rw-r--r-- | config/settings.yml | 2 | ||||
-rw-r--r-- | templates/inventoryListing.cassius | 8 |
6 files changed, 12 insertions, 5 deletions
diff --git a/Handler/Common.hs b/Handler/Common.hs index 799f692..4f02e3c 100644 --- a/Handler/Common.hs +++ b/Handler/Common.hs | |||
@@ -91,7 +91,7 @@ itemForm proto identView = do | |||
91 | <div .td>^{openedWidget} | 91 | <div .td>^{openedWidget} |
92 | <div .td> | 92 | <div .td> |
93 | <ul .status> | 93 | <ul .status> |
94 | <li>^{fvInput runningLowWidget} # | 94 | <li>^{fvInput runningLowWidget} |
95 | <label for=#{fvId runningLowWidget}> | 95 | <label for=#{fvId runningLowWidget}> |
96 | Running low | 96 | Running low |
97 | |] | 97 | |] |
diff --git a/Handler/Item.hs b/Handler/Item.hs index abb1b12..2530275 100644 --- a/Handler/Item.hs +++ b/Handler/Item.hs | |||
@@ -18,6 +18,7 @@ putItemR itemId = do | |||
18 | , ItemBought =. itemBought | 18 | , ItemBought =. itemBought |
19 | , ItemExpires =. itemExpires | 19 | , ItemExpires =. itemExpires |
20 | , ItemOpened =. itemOpened | 20 | , ItemOpened =. itemOpened |
21 | , ItemRunningLow =. itemRunningLow | ||
21 | ]) | 22 | ]) |
22 | update (itemFkType $ entityVal entity) [ KindType =. t ] | 23 | update (itemFkType $ entityVal entity) [ KindType =. t ] |
23 | withType entity | 24 | withType entity |
diff --git a/Handler/UpdateItem.hs b/Handler/UpdateItem.hs index b4c8713..ce6b30d 100644 --- a/Handler/UpdateItem.hs +++ b/Handler/UpdateItem.hs | |||
@@ -19,6 +19,7 @@ postUpdateItemR fsUpdateId = do | |||
19 | , ItemBought =. itemBought | 19 | , ItemBought =. itemBought |
20 | , ItemExpires =. itemExpires | 20 | , ItemExpires =. itemExpires |
21 | , ItemOpened =. itemOpened | 21 | , ItemOpened =. itemOpened |
22 | , ItemRunningLow =. itemRunningLow | ||
22 | ] | 23 | ] |
23 | return () | 24 | return () |
24 | FormFailure errors -> mapM_ (addMessage "formError" . toHtml) errors | 25 | FormFailure errors -> mapM_ (addMessage "formError" . toHtml) errors |
@@ -128,6 +128,7 @@ data ItemDiff = DiffKind Text | |||
128 | | DiffBought ItemDate | 128 | | DiffBought ItemDate |
129 | | DiffExpires ItemDate | 129 | | DiffExpires ItemDate |
130 | | DiffOpened ItemDate | 130 | | DiffOpened ItemDate |
131 | | DiffRunningLow Bool | ||
131 | 132 | ||
132 | newtype ItemDiffs = ItemDiffs [ItemDiff] | 133 | newtype ItemDiffs = ItemDiffs [ItemDiff] |
133 | 134 | ||
@@ -138,6 +139,7 @@ instance FromJSON ItemDiffs where | |||
138 | tell =<< maybe [] (pure . DiffBought) <$> lift (obj .:! "bought") | 139 | tell =<< maybe [] (pure . DiffBought) <$> lift (obj .:! "bought") |
139 | tell =<< maybe [] (pure . DiffExpires) <$> lift (obj .:! "expires") | 140 | tell =<< maybe [] (pure . DiffExpires) <$> lift (obj .:! "expires") |
140 | tell =<< maybe [] (pure . DiffOpened) <$> lift (obj .:! "opened") | 141 | tell =<< maybe [] (pure . DiffOpened) <$> lift (obj .:! "opened") |
142 | tell =<< maybe [] (pure . DiffRunningLow) <$> lift (obj .:? "running-low") | ||
141 | 143 | ||
142 | toUpdate :: ItemDiffs -> ([Update Item], [Update Kind]) | 144 | toUpdate :: ItemDiffs -> ([Update Item], [Update Kind]) |
143 | toUpdate (ItemDiffs ds) = mconcat $ do | 145 | toUpdate (ItemDiffs ds) = mconcat $ do |
@@ -150,6 +152,7 @@ toUpdate (ItemDiffs ds) = mconcat $ do | |||
150 | DiffBought d -> (, []) [ ItemBought =. d ] | 152 | DiffBought d -> (, []) [ ItemBought =. d ] |
151 | DiffExpires d -> (, []) [ ItemExpires =. d ] | 153 | DiffExpires d -> (, []) [ ItemExpires =. d ] |
152 | DiffOpened d -> (, []) [ ItemOpened =. d ] | 154 | DiffOpened d -> (, []) [ ItemOpened =. d ] |
155 | DiffRunningLow b -> (, []) [ ItemRunningLow =. b ] | ||
153 | 156 | ||
154 | data WithType a = WithType { typedVal :: a, valType :: Text } | 157 | data WithType a = WithType { typedVal :: a, valType :: Text } |
155 | deriving (Eq, Ord, Show, Functor) | 158 | deriving (Eq, Ord, Show, Functor) |
diff --git a/config/settings.yml b/config/settings.yml index f6332bd..078fa19 100644 --- a/config/settings.yml +++ b/config/settings.yml | |||
@@ -1,6 +1,6 @@ | |||
1 | static-dir: "_env:STATIC_DIR:static" | 1 | static-dir: "_env:STATIC_DIR:static" |
2 | approot: "_env:APPROOT:" | 2 | approot: "_env:APPROOT:" |
3 | host: "_env:HOST:*4" # any IPv4 host | 3 | host: "_env:HOST:*" # any IPv4 host |
4 | port: "_env:PORT:3000" | 4 | port: "_env:PORT:3000" |
5 | ip-from-header: "_env:IP_FROM_HEADER:false" | 5 | ip-from-header: "_env:IP_FROM_HEADER:false" |
6 | 6 | ||
diff --git a/templates/inventoryListing.cassius b/templates/inventoryListing.cassius index 1da6e13..5116667 100644 --- a/templates/inventoryListing.cassius +++ b/templates/inventoryListing.cassius | |||
@@ -22,6 +22,8 @@ div.itemId | |||
22 | padding: 0 | 22 | padding: 0 |
23 | margin: 0 | 23 | margin: 0 |
24 | list-style-type: none | 24 | list-style-type: none |
25 | .status li | 25 | li |
26 | padding: 0 | 26 | padding: 0 |
27 | margin: 0 \ No newline at end of file | 27 | margin: 0 |
28 | input | ||
29 | vertical-align: middle \ No newline at end of file | ||