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

create edit page for capture, /capture/idCapture/edit #54

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
1,116 changes: 820 additions & 296 deletions elm.js

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion src/Capture.elm
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type alias Capture =
, text : String
, timers : List Timer
, status : CaptureStatus
, tags : List String
}


Expand All @@ -27,6 +28,7 @@ initCapture =
, text = ""
, timers = []
, status = ToDo
, tags = []
}


Expand All @@ -47,11 +49,12 @@ savedCaptureDecoder =

captureDecoder : JD.Decoder Capture
captureDecoder =
JD.map4 Capture
JD.map5 Capture
(JD.field "capture_id" JD.int)
(JD.field "text" JD.string)
(JD.field "timers" (JD.list timerDecoder))
(JD.field "completed" JD.bool |> JD.andThen captureStatusDecoder)
(JD.field "tags" (JD.list (JD.field "text" JD.string)))


captureStatusDecoder : Bool -> JD.Decoder CaptureStatus
Expand Down Expand Up @@ -92,6 +95,7 @@ captureEncode capture =
JE.object
[ ( "text", JE.string capture.text )
, ( "completed", JE.bool (capture.status == Completed) )
, ( "tags", JE.string (String.join ", " capture.tags) )
]


Expand Down
26 changes: 26 additions & 0 deletions src/Main.elm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Html.Attributes exposing (..)
import Page
import Pages.Auth as Auth
import Pages.Capture as Capture
import Pages.CaptureEdit as CaptureEdit
import Pages.CaptureTimers as CaptureTimers
import Pages.Login as Login
import Pages.Session as PagesSession
Expand Down Expand Up @@ -39,6 +40,7 @@ type Model
| Logout Session.Session
| Login Session.Session
| Capture Capture.Model
| CaptureEdit CaptureEdit.Model
| CaptureTimers CaptureTimers.Model


Expand Down Expand Up @@ -71,6 +73,7 @@ type Msg
| GotAuthMsg Auth.Msg
| GotPagesSessionMsg PagesSession.Msg
| GotCaptureMsg Capture.Msg
| GotCaptureEditMsg CaptureEdit.Msg
| GotCaptureTimersMsg CaptureTimers.Msg
| GotLoginMsg Login.Msg

Expand Down Expand Up @@ -110,6 +113,13 @@ update msg model =
in
( Capture subModel, Cmd.map GotCaptureMsg subMsg )

( GotCaptureEditMsg captureEditMsg, CaptureEdit captureEditModel ) ->
let
( subModel, subMsg ) =
CaptureEdit.update captureEditMsg captureEditModel
in
( CaptureEdit subModel, Cmd.map GotCaptureEditMsg subMsg )

( GotCaptureTimersMsg captureTimersMsg, CaptureTimers captureTimersModel ) ->
let
( subModel, subMsg ) =
Expand Down Expand Up @@ -194,6 +204,13 @@ loadRoute maybeRoute model =
in
( CaptureTimers subModel, Cmd.map GotCaptureTimersMsg subMsg )

Just (Route.CaptureEdit idCapture) ->
let
( subModel, subMsg ) =
CaptureEdit.init session idCapture
in
( CaptureEdit subModel, Cmd.map GotCaptureEditMsg subMsg )


subscriptions : Model -> Sub Msg
subscriptions model =
Expand All @@ -213,6 +230,9 @@ subscriptions model =
Capture captureModel ->
Sub.map GotCaptureMsg (Capture.subscriptions captureModel)

CaptureEdit captureEditModel ->
Sub.map GotCaptureEditMsg (CaptureEdit.subscriptions captureEditModel)

CaptureTimers captureTimersModel ->
Sub.map GotCaptureTimersMsg (CaptureTimers.subscriptions captureTimersModel)

Expand Down Expand Up @@ -251,6 +271,9 @@ view model =
Capture captureModel ->
Page.view GotCaptureMsg (Capture.view captureModel)

CaptureEdit captureEditModel ->
Page.view GotCaptureEditMsg (CaptureEdit.view captureEditModel)

CaptureTimers captureTimersModel ->
Page.view GotCaptureTimersMsg (CaptureTimers.view captureTimersModel)

Expand All @@ -276,6 +299,9 @@ toSession page =
Capture m ->
Capture.toSession m

CaptureEdit m ->
CaptureEdit.toSession m

CaptureTimers m ->
CaptureTimers.toSession m

Expand Down
6 changes: 6 additions & 0 deletions src/Pages/Capture.elm
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,12 @@ showCapture clock capture =
Error e ->
showTimerButton [] e None
]
, el [ padding 5 ] (text <| String.join ", " capture.tags)
, link
[ color UI.teal ]
{ url = Route.routeToString (Route.CaptureEdit capture.idCapture)
, label = text "edit"
}
, el [ width (fill |> maximum 1000), centerX, EltBackground.color UI.lightGrey, height (px 1) ] none
]

Expand Down
Loading