propagate crementing

This commit is contained in:
nek0 2015-04-13 14:09:47 +02:00
parent 86ad058107
commit f410d9e350
7 changed files with 12 additions and 5 deletions

View file

@ -115,6 +115,9 @@ instance Yesod App where
[ css_bootstrap_css [ css_bootstrap_css
, css_main_css , css_main_css
]) ])
$(combineScripts 'StaticR
[ js_crementing_js
])
$(widgetFile "default-layout") $(widgetFile "default-layout")
withUrlRenderer $(hamletFile "templates/default-layout-wrapper.hamlet") withUrlRenderer $(hamletFile "templates/default-layout-wrapper.hamlet")

View file

@ -65,7 +65,7 @@ amountField = Field
Right (a, "") -> Right a Right (a, "") -> Right a
_ -> Left $ MsgInvalidInteger s _ -> Left $ MsgInvalidInteger s
, fieldView = \theId name attr val req -> toWidget [hamlet|$newline never , fieldView = \theId name attr val req -> toWidget [hamlet|$newline never
<input id=#{theId} name=#{name} *{attr} type="number" step=1 min=0 :req:required="" value="#{showVal val}"> <input id="crement" id=#{theId} name=#{name} *{attr} type="number" step=1 min=1 :req:required="" value="#{showVal val}">
|] |]
, fieldEnctype = UrlEncoded , fieldEnctype = UrlEncoded
} }

View file

@ -46,7 +46,7 @@ postUpstockR bId = do
upstockForm :: Form Int upstockForm :: Form Int
upstockForm = renderDivs upstockForm = renderDivs
$ areq amountField (fieldSettingsLabel MsgAmountAdded) (Just 0) $ areq amountField (fieldSettingsLabel MsgAmountAdded) (Just 1)
getNewArticleR :: Handler Html getNewArticleR :: Handler Html
getNewArticleR = do getNewArticleR = do

View file

@ -8,5 +8,5 @@ calling like
*/ */
function crmnt( e, i ) { /* read: in-/decrement ( dom-element, signed-integer ) */ function crmnt( e, i ) { /* read: in-/decrement ( dom-element, signed-integer ) */
var d = parseInt( e.value ) + i; var d = parseInt( e.value ) + i;
e.value = ( d < 0 )? 0 : e.value = d; e.value = ( d < 1 )? 1 : e.value = d;
} }

View file

@ -9,3 +9,5 @@ $doctype 5
^{buyWidget} ^{buyWidget}
<div> <div>
<input type=submit value="_{MsgPurchase}"> <input type=submit value="_{MsgPurchase}">
<input onclick="crmnt( document.getElementById('crement'), 1 )" value="_{MsgIncrement}" type="button">
<input onclick="crmnt( document.getElementById('crement'), -1 )" value="_{MsgDecrement}" type="button">

View file

@ -9,3 +9,5 @@ $doctype 5
^{buyCashWidget} ^{buyCashWidget}
<div> <div>
<input type=submit value="_{MsgPurchase}"> <input type=submit value="_{MsgPurchase}">
<input onclick="crmnt( document.getElementById('crement'), 1 )" value="_{MsgIncrement}" type="button">
<input onclick="crmnt( document.getElementById('crement'), -1 )" value="_{MsgDecrement}" type="button">

View file

@ -9,5 +9,5 @@ $doctype 5
^{upstockWidget} ^{upstockWidget}
<div> <div>
<input type=submit value="_{MsgFillup}"> <input type=submit value="_{MsgFillup}">
<input onclick="crmnt( document.getElementById('hident2'), 1 )" value="_{MsgIncrement}" type="button"> <input onclick="crmnt( document.getElementById('crement'), 1 )" value="_{MsgIncrement}" type="button">
<input onclick="crmnt( document.getElementById('hident2'), -1 )" value="_{MsgDecrement}" type="button"> <input onclick="crmnt( document.getElementById('crement'), -1 )" value="_{MsgDecrement}" type="button">