Handle post visibility. (#14)

This commit is contained in:
Nicolas Perriault 2017-04-21 14:03:39 +02:00 committed by GitHub
parent 126f3318ee
commit 9b1520ffbc
2 changed files with 38 additions and 3 deletions

View File

@ -17,6 +17,7 @@ type DraftMsg
| UpdateSensitive Bool
| UpdateSpoiler String
| UpdateStatus String
| UpdateVisibility String
type Msg
@ -189,6 +190,9 @@ updateDraft draftMsg draft =
UpdateStatus status ->
{ draft | status = status }
UpdateVisibility visibility ->
{ draft | visibility = visibility }
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =

View File

@ -1,5 +1,6 @@
module View exposing (view)
import Dict
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
@ -9,6 +10,16 @@ import Mastodon
import Model exposing (Model, DraftMsg(..), Msg(..))
visibilities : Dict.Dict String String
visibilities =
Dict.fromList
[ ( "public", "post to public timelines" )
, ( "unlisted", "do not show in public timelines" )
, ( "private", "post to followers only" )
, ( "direct", "post to mentioned users only" )
]
replace : String -> String -> String -> String
replace from to str =
String.split from str |> String.join to
@ -101,6 +112,10 @@ draftView { draft } =
Just _ ->
True
visibilityOptionView ( visibility, description ) =
option [ value visibility ]
[ text <| visibility ++ ": " ++ description ]
in
div [ class "col-md-3" ]
[ div [ class "panel panel-default" ]
@ -148,7 +163,7 @@ draftView { draft } =
, rows 8
, placeholder <|
if hasSpoiler then
"This text with be hidden by default, as you have enabled a spoiler."
"This text will be hidden by default, as you have enabled a spoiler."
else
"Once upon a time..."
, onInput <| DraftEvent << UpdateStatus
@ -157,6 +172,19 @@ draftView { draft } =
]
[]
]
, div [ class "form-group" ]
[ label [ for "visibility" ] [ text "Visibility" ]
, select
[ id "visibility"
, class "form-control"
, onInput <| DraftEvent << UpdateVisibility
, required True
, value draft.visibility
]
<|
List.map visibilityOptionView <|
Dict.toList visibilities
]
, div [ class "form-group checkbox" ]
[ label []
[ input
@ -165,7 +193,7 @@ draftView { draft } =
, checked draft.sensitive
]
[]
, text " NSFW"
, text " This post is NSFW"
]
]
, p [ class "text-right" ]
@ -209,7 +237,10 @@ authView model =
]
[]
, p [ class "help-block" ]
[ text "You'll be redirected to that server to authenticate yourself. We don't have access to your password." ]
[ text <|
"You'll be redirected to that server to authenticate yourself. "
++ "We don't have access to your password."
]
]
, button [ class "btn btn-primary", type_ "submit" ]
[ text "Sign into Tooty" ]