web: drop old dependency on json (#1190)
This commit is contained in:
parent
13f95327e3
commit
b7bea5698e
@ -22,7 +22,6 @@ import Data.Text (Text)
|
|||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
import Data.Time (Day)
|
import Data.Time (Day)
|
||||||
import Text.Blaze.Internal (Markup, preEscapedString)
|
import Text.Blaze.Internal (Markup, preEscapedString)
|
||||||
import Text.JSON
|
|
||||||
import Text.Megaparsec (bundleErrors, eof, parseErrorTextPretty, runParser)
|
import Text.Megaparsec (bundleErrors, eof, parseErrorTextPretty, runParser)
|
||||||
import Yesod
|
import Yesod
|
||||||
|
|
||||||
@ -71,13 +70,16 @@ addForm j today = identifyForm "add" $ \extra -> do
|
|||||||
(amtRes, _) <- mreq listField amtFS Nothing
|
(amtRes, _) <- mreq listField amtFS Nothing
|
||||||
let (postRes, displayRows) = validatePostings acctRes amtRes
|
let (postRes, displayRows) = validatePostings acctRes amtRes
|
||||||
|
|
||||||
|
-- bindings used in add-form.hamlet
|
||||||
let descriptions = sort $ nub $ tdescription <$> jtxns j
|
let descriptions = sort $ nub $ tdescription <$> jtxns j
|
||||||
escapeJSSpecialChars = regexReplaceCI "</script>" "<\\/script>" -- #236
|
|
||||||
listToJsonValueObjArrayStr = preEscapedString . escapeJSSpecialChars .
|
|
||||||
encode . JSArray . fmap (\a -> JSObject $ toJSObject [("value", showJSON a)])
|
|
||||||
journals = fst <$> jfiles j
|
journals = fst <$> jfiles j
|
||||||
|
listToJsonArray :: [Text] -> Markup
|
||||||
|
listToJsonArray = preEscapedString . escapeJSSpecialChars . show . toJSON
|
||||||
|
where
|
||||||
|
escapeJSSpecialChars = regexReplaceCI "</script>" "<\\/script>" -- #236
|
||||||
|
|
||||||
pure (validateTransaction dateRes descRes postRes, $(widgetFile "add-form"))
|
pure (validateTransaction dateRes descRes postRes, $(widgetFile "add-form"))
|
||||||
|
|
||||||
where
|
where
|
||||||
dateFS = FieldSettings "date" Nothing Nothing (Just "date")
|
dateFS = FieldSettings "date" Nothing Nothing (Just "date")
|
||||||
[("class", "form-control input-lg"), ("placeholder", "Date")]
|
[("class", "form-control input-lg"), ("placeholder", "Date")]
|
||||||
|
|||||||
@ -4,7 +4,7 @@ cabal-version: 1.12
|
|||||||
--
|
--
|
||||||
-- see: https://github.com/sol/hpack
|
-- see: https://github.com/sol/hpack
|
||||||
--
|
--
|
||||||
-- hash: 0678e65f66ec6915e930f6224b0bf3c0558464f3f7aafefe57a84574c60506be
|
-- hash: c5289bad9f5862e797248b10b6b30083a281d125eeec3964a43284e56d197f08
|
||||||
|
|
||||||
name: hledger-web
|
name: hledger-web
|
||||||
version: 1.16
|
version: 1.16
|
||||||
@ -174,7 +174,6 @@ library
|
|||||||
, http-client
|
, http-client
|
||||||
, http-conduit
|
, http-conduit
|
||||||
, http-types
|
, http-types
|
||||||
, json
|
|
||||||
, megaparsec >=7.0.0 && <8
|
, megaparsec >=7.0.0 && <8
|
||||||
, mtl >=2.2.1
|
, mtl >=2.2.1
|
||||||
, semigroups
|
, semigroups
|
||||||
|
|||||||
@ -118,7 +118,6 @@ library:
|
|||||||
- http-conduit
|
- http-conduit
|
||||||
- http-client
|
- http-client
|
||||||
- http-types
|
- http-types
|
||||||
- json
|
|
||||||
- megaparsec >=7.0.0 && <8
|
- megaparsec >=7.0.0 && <8
|
||||||
- mtl >=2.2.1
|
- mtl >=2.2.1
|
||||||
- semigroups
|
- semigroups
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
<script>
|
<script>
|
||||||
jQuery(document).ready(function() {
|
jQuery(document).ready(function() {
|
||||||
descriptionsSuggester = new Bloodhound({
|
descriptionsSuggester = new Bloodhound({
|
||||||
local:#{listToJsonValueObjArrayStr descriptions},
|
local:#{listToJsonArray descriptions},
|
||||||
limit:100,
|
limit:100,
|
||||||
datumTokenizer: function(d) { return [d.value]; },
|
datumTokenizer: function(d) { return [d.value]; },
|
||||||
queryTokenizer: function(q) { return [q]; }
|
queryTokenizer: function(q) { return [q]; }
|
||||||
@ -9,7 +9,7 @@
|
|||||||
descriptionsSuggester.initialize();
|
descriptionsSuggester.initialize();
|
||||||
|
|
||||||
accountsSuggester = new Bloodhound({
|
accountsSuggester = new Bloodhound({
|
||||||
local:#{listToJsonValueObjArrayStr (journalAccountNamesDeclaredOrImplied j)},
|
local:#{listToJsonArray (journalAccountNamesDeclaredOrImplied j)},
|
||||||
limit:100,
|
limit:100,
|
||||||
datumTokenizer: function(d) { return [d.value]; },
|
datumTokenizer: function(d) { return [d.value]; },
|
||||||
queryTokenizer: function(q) { return [q]; }
|
queryTokenizer: function(q) { return [q]; }
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user