prevent user entering commas to separate tags

This commit is contained in:
Jon Schoning 2020-07-22 11:52:11 -05:00
parent 6377d229d1
commit ef2fd93a66
6 changed files with 9 additions and 7 deletions

View file

@ -9,8 +9,8 @@ import Data.Lens (Lens', lens, use, (%=), (.=))
import Data.Maybe (Maybe(..), fromMaybe, isJust)
import Data.Monoid (guard)
import Data.Nullable (toMaybe)
import Data.String (null, split, take) as S
import Data.String.Pattern (Pattern(..))
import Data.String (null, split, take, replaceAll) as S
import Data.String.Pattern (Pattern(..), Replacement(..))
import Data.Symbol (SProxy(..))
import Effect.Aff (Aff)
import Globals (app', setFocus, toLocaleDateString)
@ -256,6 +256,7 @@ bmark b' =
handleAction (BEditSubmit e) = do
H.liftEffect (preventDefault e)
edit_bm <- use _edit_bm
void $ H.liftAff (editBookmark edit_bm)
_bm .= edit_bm
let edit_bm' = edit_bm { tags = S.replaceAll (Pattern ",") (Replacement " ") edit_bm.tags }
void $ H.liftAff (editBookmark edit_bm')
_bm .= edit_bm'
_edit .= false

View file

@ -3,6 +3,7 @@ module Handler.Add where
import Import
import Handler.Archive
import Data.List (nub)
import qualified Data.Text as T (replace)
-- View
@ -72,7 +73,7 @@ _handleFormSuccess bookmarkForm = do
pure (res, kbid)
where
mkbid = BookmarkKey <$> _bid bookmarkForm
tags = maybe [] (nub . words) (_tags bookmarkForm)
tags = maybe [] (nub . words . T.replace "," " ") (_tags bookmarkForm)
postLookupTitleR :: Handler ()
postLookupTitleR = do

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.