Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(README): Add build badge #43

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# ![RealWorld Example App](https://cloud.githubusercontent.com/assets/556934/25448178/3e7dc5c0-2a7d-11e7-8069-06da5169dae6.png)

[![Build Status](https://travis-ci.org/rtfeldman/elm-spa-example.svg?branch=master)](https://travis-ci.org/rtfeldman/elm-spa-example)

👉 I gave a talk, [**Scaling Elm Apps**](https://www.youtube.com/watch?v=DoA4Txr4GUs),
to explain the principles I used to build this. I highly recommend [watching it](https://www.youtube.com/watch?v=DoA4Txr4GUs)!

Expand Down
19 changes: 14 additions & 5 deletions src/Page/Article/Editor.elm
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type alias Model =
, body : String
, description : String
, tags : List String
, isSaving : Bool
}


Expand All @@ -38,6 +39,7 @@ initNew =
, body = ""
, description = ""
, tags = []
, isSaving = False
}


Expand All @@ -59,6 +61,7 @@ initEdit session slug =
, body = Article.bodyToMarkdownString article.body
, description = article.description
, tags = article.tags
, isSaving = False
}
)

Expand Down Expand Up @@ -121,7 +124,7 @@ viewForm model =
, defaultValue (String.join " " model.tags)
]
[]
, button [ class "btn btn-lg pull-xs-right btn-primary" ]
, button [ class "btn btn-lg pull-xs-right btn-primary", disabled model.isSaving ]
[ text saveButtonText ]
]
]
Expand Down Expand Up @@ -152,13 +155,13 @@ update user msg model =
user.token
|> Request.Article.create model
|> Http.send CreateCompleted
|> pair { model | errors = [] }
|> pair { model | errors = [], isSaving = True }

Just slug ->
user.token
|> Request.Article.update slug model
|> Http.send EditCompleted
|> pair { model | errors = [] }
|> pair { model | errors = [], isSaving = True }

errors ->
{ model | errors = errors } => Cmd.none
Expand All @@ -181,7 +184,10 @@ update user msg model =
|> pair model

CreateCompleted (Err error) ->
{ model | errors = model.errors ++ [ Form => "Server error while attempting to publish article" ] }
{ model
| errors = model.errors ++ [ Form => "Server error while attempting to publish article" ]
, isSaving = False
}
=> Cmd.none

EditCompleted (Ok article) ->
Expand All @@ -190,7 +196,10 @@ update user msg model =
|> pair model

EditCompleted (Err error) ->
{ model | errors = model.errors ++ [ Form => "Server error while attempting to save article" ] }
{ model
| errors = model.errors ++ [ Form => "Server error while attempting to save article" ]
, isSaving = False
}
=> Cmd.none


Expand Down