Update part5
This commit is contained in:
@@ -99,10 +99,16 @@ viewForm model =
|
|||||||
Html.form [ onSubmit Save ]
|
Html.form [ onSubmit Save ]
|
||||||
[ fieldset []
|
[ fieldset []
|
||||||
[ Form.input
|
[ Form.input
|
||||||
-- TODO when the user enters some input in here,
|
{- TODO Sign up for an account (you can enter nonsense for all
|
||||||
-- we want to update the `title` field in the Model.
|
the signup fields) and then click `New Post` in the header to
|
||||||
--
|
view the Article Editor.
|
||||||
-- HINT: look at how the model.description field works.
|
|
||||||
|
When the user enters some input for Article Title,
|
||||||
|
we want to update the `title` field in the Model.
|
||||||
|
|
||||||
|
HINT: We'll need to add something to the definition of Msg to
|
||||||
|
do this. Look at how SetDescription is used in the next field!
|
||||||
|
-}
|
||||||
[ class "form-control-lg"
|
[ class "form-control-lg"
|
||||||
, placeholder "Article Title"
|
, placeholder "Article Title"
|
||||||
, value model.title
|
, value model.title
|
||||||
@@ -122,11 +128,8 @@ viewForm model =
|
|||||||
]
|
]
|
||||||
[]
|
[]
|
||||||
, Form.input
|
, Form.input
|
||||||
-- TODO when the user enters some input in here,
|
|
||||||
-- we want to update the `tags` field in the Model.
|
|
||||||
--
|
|
||||||
-- HINT: this will have the same `view` logic as `title` did.
|
|
||||||
[ placeholder "Enter tags"
|
[ placeholder "Enter tags"
|
||||||
|
, onInput SetTags
|
||||||
, value (String.join " " model.tags)
|
, value (String.join " " model.tags)
|
||||||
]
|
]
|
||||||
[]
|
[]
|
||||||
@@ -144,6 +147,7 @@ type Msg
|
|||||||
= Save
|
= Save
|
||||||
| SetDescription String
|
| SetDescription String
|
||||||
| SetBody String
|
| SetBody String
|
||||||
|
| SetTags String
|
||||||
| CreateCompleted (Result Http.Error (Article Body))
|
| CreateCompleted (Result Http.Error (Article Body))
|
||||||
| EditCompleted (Result Http.Error (Article Body))
|
| EditCompleted (Result Http.Error (Article Body))
|
||||||
|
|
||||||
@@ -170,21 +174,22 @@ update user msg model =
|
|||||||
errors ->
|
errors ->
|
||||||
( { model | errors = errors }, Cmd.none )
|
( { model | errors = errors }, Cmd.none )
|
||||||
|
|
||||||
-- TODO add something here that sets the title based on user input.
|
------------------------------------------------------------------------
|
||||||
--
|
-- --
|
||||||
-- HINT: take a look at how SetDescription does something similar!
|
-- TODO add something here that sets the title based on user input. --
|
||||||
--
|
-- --
|
||||||
|
-- HINT: take a look at how SetDescription does something similar! --
|
||||||
|
-- --
|
||||||
|
------------------------------------------------------------------------
|
||||||
SetDescription description ->
|
SetDescription description ->
|
||||||
( { model | description = description }, Cmd.none )
|
( { model | description = description }, Cmd.none )
|
||||||
|
|
||||||
-- TODO add something here that sets the tags based on user input.
|
|
||||||
--
|
|
||||||
-- HINT: take a look at the tagsFromString function,
|
|
||||||
-- which is at the end of this file!
|
|
||||||
--
|
|
||||||
SetBody body ->
|
SetBody body ->
|
||||||
( { model | body = body }, Cmd.none )
|
( { model | body = body }, Cmd.none )
|
||||||
|
|
||||||
|
SetTags tagsStr ->
|
||||||
|
( { model | tags = tagsFromString tagsStr }, Cmd.none )
|
||||||
|
|
||||||
CreateCompleted (Ok article) ->
|
CreateCompleted (Ok article) ->
|
||||||
Route.Article article.slug
|
Route.Article article.slug
|
||||||
|> Route.modifyUrl
|
|> Route.modifyUrl
|
||||||
|
|||||||
Reference in New Issue
Block a user