barcode: switch to location with user

This commit is contained in:
Astro 2015-07-21 01:14:21 +02:00
parent 38e91a20b5
commit fafb1548cb
6 changed files with 19 additions and 1 deletions

View File

@ -36,6 +36,7 @@ import Handler.Summary
import Handler.Modify
import Handler.CashCheck
import Handler.Avatar
import Handler.Barcode
-- This line actually creates our YesodDispatch instance. It is the second half
-- of the call to mkYesodData which occurs in Foundation.hs. Please see the

10
Handler/Barcode.hs Normal file
View File

@ -0,0 +1,10 @@
module Handler.Barcode where
import Import
import Handler.Common
import qualified Data.Text as T
import Text.Blaze.Internal
import Text.Shakespeare.Text
getBarcodeR :: UserId -> Text -> Handler Html
getBarcodeR uId barcode = undefined

View File

@ -30,3 +30,4 @@
/avatar/#AvatarId/modify ModifyAvatarR GET POST
/avatar/#AvatarId/delete AvatarDeleteR GET
/newavatar NewAvatarR GET POST
/user/#UserId/barcode/#Text BarcodeR GET

View File

@ -11,7 +11,10 @@ function showBarcode(text) {
function barcodeKeyPress(event) {
var key = String.fromCharCode(event.charCode)
if (event.keyCode === 13) {
// window.location = "" + barcodeBuf
var uid = document.getElementById('uid').getAttribute('value')
if (uid) {
window.location = "/user/" + encodeURIComponent(uid) + "/barcode/" + encodeURIComponent(barcodeBuf)
}
barcodeBuf = ""
event.preventDefault()
} else {

View File

@ -25,3 +25,5 @@ $forall (Entity bId bev) <- beverages
$else
<a href=@{BuyR uId bId}>
<p>#{beverageIdent bev}
<input type=hidden id=uid value=#{toPathPiece uId}>

View File

@ -31,6 +31,7 @@ library
Handler.Modify
Handler.CashCheck
Handler.Avatar
Handler.Barcode
if flag(dev) || flag(library-only)
cpp-options: -DDEVELOPMENT