focus tags input when editing bookmark

This commit is contained in:
Jon Schoning 2020-01-20 11:14:46 -06:00
parent 01afd5efad
commit 0546de274d
9 changed files with 19 additions and 11 deletions

1
.gitignore vendored
View file

@ -30,3 +30,4 @@ tmp
tags
purs/docset/purescript-local.docset/
.ghc.environment.x86_64-linux-8.6.5
.vscode

View file

@ -97,7 +97,7 @@ addbmark b' =
[ td_ [ label [ for "title" ] [ text "title" ] ]
, td [class_ "flex"]
[ input [ type_ InputText , id_ "title", class_ "w-100 mv1 flex-auto" , name "title" , value (edit_bm.title) , onValueChange (editField Etitle)]
, button [ disabled s.loading, type_ ButtonButton, onClick \_ -> Just BLookupTitle, class_ ("ml2 input-reset ba b--navy pointer f6 di dim pa1 ma1 mr0 " <> guard s.loading "bg-light-silver") ] [ text "Fetch" ]
, button [ disabled s.loading, type_ ButtonButton, onClick \_ -> Just BLookupTitle, class_ ("ml2 input-reset ba b--navy pointer f6 di dim pa1 ma1 mr0 " <> guard s.loading "bg-light-silver") ] [ text "fetch" ]
]
]
, tr_

View file

@ -13,7 +13,7 @@ import Data.String (null, split, take) as S
import Data.String.Pattern (Pattern(..))
import Data.Symbol (SProxy(..))
import Effect.Aff (Aff)
import Globals (app')
import Globals (app', setFocus)
import Halogen as H
import Halogen.HTML (HTML, a, br_, button, div, div_, form, input, label, span, text, textarea)
import Halogen.HTML as HH
@ -155,24 +155,20 @@ bmark b' =
[ div_ [ text "url" ]
, input [ type_ InputUrl , class_ "url w-100 mb2 pt1 f7 edit_form_input" , required true , name "url"
, value (edit_bm.url) , onValueChange (editField Eurl) ]
, br_
, div_ [ text "title" ]
, div [class_ "flex"]
[input [ type_ InputText , class_ "title w-100 mb2 pt1 f7 edit_form_input" , name "title"
, value (edit_bm.title) , onValueChange (editField Etitle) ]
, button [ disabled s.loading, type_ ButtonButton, onClick \_ -> Just BLookupTitle, class_ ("ml1 pa1 mb2 dark-gray ba b--moon-gray bg-near-white pointer rdim f7 " <> guard s.loading "bg-light-silver") ] [ text "Fetch" ]
, button [ disabled s.loading, type_ ButtonButton, onClick \_ -> Just BLookupTitle, class_ ("ml1 pa1 mb2 dark-gray ba b--moon-gray bg-near-white pointer rdim f7 " <> guard s.loading "bg-light-silver") ] [ text "fetch" ]
]
, br_
, div_ [ text "description" ]
, textarea [ class_ "description w-100 mb1 pt1 f7 edit_form_input" , name "description", rows 5
, value (edit_bm.description) , onValueChange (editField Edescription) ]
, br_
, div [ id_ "tags_input_box"]
[ div_ [ text "tags" ]
, input [ type_ InputText , class_ "tags w-100 mb1 pt1 f7 edit_form_input" , name "tags"
, input [ id_ (tagid edit_bm), type_ InputText , class_ "tags w-100 mb1 pt1 f7 edit_form_input" , name "tags"
, autocomplete false, attr "autocapitalize" "off"
, value (edit_bm.tags) , onValueChange (editField Etags) ]
, br_
]
, div [ class_ "edit_form_checkboxes mv3"]
[ input [ type_ InputCheckbox , class_ "private pointer" , id_ "edit_private", name "private"
@ -184,7 +180,6 @@ bmark b' =
, checked (edit_bm.toread) , onChecked (editField Etoread) ]
, text " "
, label [ for "edit_toread" ] [ text "to-read" ]
, br_
]
, input [ type_ InputSubmit , class_ "mr1 pv1 ph2 dark-gray ba b--moon-gray bg-near-white pointer rdim" , value "save" ]
, text " "
@ -200,6 +195,8 @@ bmark b' =
linkToFilterTag tag = fromNullableStr app.userR <> "/t:" <> tag
shtime = S.take 16 bm.time `append` "Z"
tagid bm = show bm.bid <> "_tags"
handleAction :: BAction -> H.HalogenM BState BAction ChildSlots BMessage Aff Unit
-- | Star
@ -230,6 +227,7 @@ bmark b' =
bm <- use _bm
_edit_bm .= bm
_edit .= e
H.liftEffect $ whenM (pure e) (setFocus (tagid bm))
-- | Update Form Field
handleAction (BEditField f) = do

View file

@ -65,3 +65,7 @@ exports._mmoment8601 = function(just, nothing, tuple, s) {
exports._closeWindow = function (window) {
window.close();
};
exports._setFocus = function(elemId) {
document.getElementById(elemId).focus();
};

View file

@ -95,3 +95,8 @@ closeWindow win = pure $ runFn1 _closeWindow win
newtype RawHTML = RawHTML String
derive instance newtypeRawHTML :: Newtype RawHTML _
foreign import _setFocus :: Fn1 String Unit
setFocus :: String -> Effect Unit
setFocus s = pure $ runFn1 _setFocus s

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.