diff options
-rw-r--r-- | Application.hs | 1 | ||||
-rw-r--r-- | Handler/LowItem.hs | 11 | ||||
-rw-r--r-- | bar.cabal | 1 | ||||
-rw-r--r-- | config/routes | 1 | ||||
-rw-r--r-- | shell.nix | 2 | ||||
-rw-r--r-- | stack.yaml | 2 | ||||
-rw-r--r-- | templates/default-layout.cassius | 4 | ||||
-rw-r--r-- | templates/inventoryListing.cassius | 4 | ||||
-rw-r--r-- | templates/inventoryListing.hamlet | 32 |
9 files changed, 44 insertions, 14 deletions
diff --git a/Application.hs b/Application.hs index 46dc4c1..0f86dd4 100644 --- a/Application.hs +++ b/Application.hs | |||
@@ -36,6 +36,7 @@ import System.Log.FastLogger (defaultBufSize, newStdoutLoggerSet, | |||
36 | import Handler.InventoryListing | 36 | import Handler.InventoryListing |
37 | import Handler.UpdateItem | 37 | import Handler.UpdateItem |
38 | import Handler.OpenItem | 38 | import Handler.OpenItem |
39 | import Handler.LowItem | ||
39 | import Handler.DeleteItem | 40 | import Handler.DeleteItem |
40 | import Handler.Item | 41 | import Handler.Item |
41 | import Handler.ReferenceListing | 42 | import Handler.ReferenceListing |
diff --git a/Handler/LowItem.hs b/Handler/LowItem.hs new file mode 100644 index 0000000..969e62a --- /dev/null +++ b/Handler/LowItem.hs | |||
@@ -0,0 +1,11 @@ | |||
1 | module Handler.LowItem where | ||
2 | |||
3 | import Import | ||
4 | |||
5 | postLowItemR :: ItemId -> Handler TypedContent | ||
6 | postLowItemR itemId = do | ||
7 | result <- fmap (Entity itemId) . runDB $ updateGet itemId [ ItemRunningLow =. True | ||
8 | ] | ||
9 | selectRep $ do | ||
10 | provideJson result | ||
11 | provideRep (redirect $ InventoryListingR :#: itemId :: Handler Html) | ||
@@ -26,6 +26,7 @@ library | |||
26 | Handler.InventoryListing | 26 | Handler.InventoryListing |
27 | Handler.UpdateItem | 27 | Handler.UpdateItem |
28 | Handler.OpenItem | 28 | Handler.OpenItem |
29 | Handler.LowItem | ||
29 | Handler.DeleteItem | 30 | Handler.DeleteItem |
30 | Handler.Item | 31 | Handler.Item |
31 | Handler.ReferenceListing | 32 | Handler.ReferenceListing |
diff --git a/config/routes b/config/routes index 1ad940d..57c515f 100644 --- a/config/routes +++ b/config/routes | |||
@@ -4,6 +4,7 @@ | |||
4 | /inv/#ItemId/edit UpdateItemR GET POST | 4 | /inv/#ItemId/edit UpdateItemR GET POST |
5 | /inv/#ItemId/open OpenItemR POST | 5 | /inv/#ItemId/open OpenItemR POST |
6 | /inv/#ItemId/delete DeleteItemR POST | 6 | /inv/#ItemId/delete DeleteItemR POST |
7 | /inv/#ItemId/low LowItemR POST | ||
7 | /inv/#ItemId ItemR GET PUT PATCH DELETE | 8 | /inv/#ItemId ItemR GET PUT PATCH DELETE |
8 | 9 | ||
9 | /ref ReferenceListingR GET POST PUT | 10 | /ref ReferenceListingR GET POST PUT |
@@ -10,7 +10,7 @@ let | |||
10 | drv = haskellPackages.callPackage ./bar.nix {}; | 10 | drv = haskellPackages.callPackage ./bar.nix {}; |
11 | in | 11 | in |
12 | pkgs.stdenv.lib.overrideDerivation drv.env (oldAttrs: { | 12 | pkgs.stdenv.lib.overrideDerivation drv.env (oldAttrs: { |
13 | nativeBuildInputs = oldAttrs.nativeBuildInputs ++ (with pkgs; [ cabal2nix gup ]) ++ (with haskellPackages; [ hlint stack yesod-bin alex ]); | 13 | nativeBuildInputs = oldAttrs.nativeBuildInputs ++ (with pkgs; [ cabal2nix gup postgresql ]) ++ (with haskellPackages; [ hlint stack yesod-bin alex ]); |
14 | shellHook = '' | 14 | shellHook = '' |
15 | ${oldAttrs.shellHook} | 15 | ${oldAttrs.shellHook} |
16 | export PROMPT_INFO="${oldAttrs.name}" | 16 | export PROMPT_INFO="${oldAttrs.name}" |
@@ -65,7 +65,7 @@ system-ghc: true | |||
65 | # Allow a newer minor version of GHC than the snapshot specifies | 65 | # Allow a newer minor version of GHC than the snapshot specifies |
66 | # compiler-check: newer-minor | 66 | # compiler-check: newer-minor |
67 | nix: | 67 | nix: |
68 | #enable: true | 68 | enable: false |
69 | packages: | 69 | packages: |
70 | - postgresql | 70 | - postgresql |
71 | - zlib | 71 | - zlib |
diff --git a/templates/default-layout.cassius b/templates/default-layout.cassius index c622901..31389d8 100644 --- a/templates/default-layout.cassius +++ b/templates/default-layout.cassius | |||
@@ -1,4 +1,4 @@ | |||
1 | .main | 1 | main |
2 | min-width: 20em | 2 | min-width: 20em |
3 | .table, table | 3 | .table, table |
4 | display: table | 4 | display: table |
@@ -62,7 +62,7 @@ table table td, table table th, .table table td, .table table th | |||
62 | li:first-child::before | 62 | li:first-child::before |
63 | content: "" | 63 | content: "" |
64 | button | 64 | button |
65 | width: 6em | 65 | width: 8em |
66 | display: inline-block | 66 | display: inline-block |
67 | .sepBelow, .sepAbove | 67 | .sepBelow, .sepAbove |
68 | border: 2px none #ddd | 68 | border: 2px none #ddd |
diff --git a/templates/inventoryListing.cassius b/templates/inventoryListing.cassius index 5116667..dc01471 100644 --- a/templates/inventoryListing.cassius +++ b/templates/inventoryListing.cassius | |||
@@ -26,4 +26,6 @@ div.itemId | |||
26 | padding: 0 | 26 | padding: 0 |
27 | margin: 0 | 27 | margin: 0 |
28 | input | 28 | input |
29 | vertical-align: middle \ No newline at end of file | 29 | vertical-align: middle |
30 | .actions .td | ||
31 | width: 8em \ No newline at end of file | ||
diff --git a/templates/inventoryListing.hamlet b/templates/inventoryListing.hamlet index cc1c9ce..8eee3e7 100644 --- a/templates/inventoryListing.hamlet +++ b/templates/inventoryListing.hamlet | |||
@@ -36,12 +36,14 @@ | |||
36 | <hr> | 36 | <hr> |
37 | $of DateKnown d | 37 | $of DateKnown d |
38 | #{dayFormat d} | 38 | #{dayFormat d} |
39 | $of DateNever | ||
39 | <div .td .day> | 40 | <div .td .day> |
40 | $case itemExpires | 41 | $case itemExpires |
41 | $of DateNever | 42 | $of DateNever |
42 | <hr> | 43 | <hr> |
43 | $of DateKnown d | 44 | $of DateKnown d |
44 | <span :d < today:.expired :d < addDays 7 today:.expireWeek :d < addGregorianMonthsRollOver 1 today:.expireMonth>#{dayFormat d} | 45 | <span :d < today:.expired :d < addDays 7 today:.expireWeek :d < addGregorianMonthsRollOver 1 today:.expireMonth>#{dayFormat d} |
46 | $of DateUnknown | ||
45 | <div .td .day> | 47 | <div .td .day> |
46 | $case itemOpened | 48 | $case itemOpened |
47 | $of DateKnown d | 49 | $of DateKnown d |
@@ -49,17 +51,29 @@ | |||
49 | $of DateUnknown | 51 | $of DateUnknown |
50 | Yes | 52 | Yes |
51 | $of DateNever | 53 | $of DateNever |
52 | <form method=post action=@{OpenItemR itemId}> | ||
53 | <button type=submit> | ||
54 | Open | ||
55 | <div .td> | 54 | <div .td> |
56 | <ul .status> | 55 | <ul .status> |
57 | $if itemRunningLow | 56 | $if itemRunningLow |
58 | <li>Running low | 57 | <li>Running low |
59 | <div .td> | 58 | <div .td> |
60 | <form method=get action=@{UpdateItemR itemId}##{toPathPiece itemId}> | 59 | <div .table .actions> |
61 | <button type=submit> | 60 | <div .tr> |
62 | Edit | 61 | $if isNever itemOpened |
63 | <form method=post action=@{DeleteItemR itemId}> | 62 | <form method=post action=@{OpenItemR itemId}> |
64 | <button type=submit> | 63 | <button type=submit> |
65 | Delete | 64 | Open |
65 | $else | ||
66 | <div .td> | ||
67 | <form method=get action=@{UpdateItemR itemId}##{toPathPiece itemId} .td> | ||
68 | <button type=submit> | ||
69 | Edit | ||
70 | <div .tr> | ||
71 | $if not itemRunningLow | ||
72 | <form method=post action=@{LowItemR itemId} .td> | ||
73 | <button type=submit> | ||
74 | Running low | ||
75 | $else | ||
76 | <div .td> | ||
77 | <form method=post action=@{DeleteItemR itemId} .td> | ||
78 | <button type=submit> | ||
79 | Delete | ||