Skip to content
This repository has been archived by the owner on Dec 29, 2019. It is now read-only.

Commit

Permalink
Current time used as default publis time for materials and slides.
Browse files Browse the repository at this point in the history
  • Loading branch information
keyraphi committed Apr 30, 2019
1 parent 15bbaa9 commit 0bbbb5e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 27 deletions.
55 changes: 30 additions & 25 deletions src/Pages/MaterialEditor.elm
Original file line number Diff line number Diff line change
Expand Up @@ -108,28 +108,37 @@ type alias Model =
}


initModel : ( Model, Cmd Msg )
initModel =
initModel : SharedState -> ( Model, Cmd Msg )
initModel sharedState =
let
( publishedDatePicker, publishedDatePickerFx ) =
DatePicker.init
publishedDatePicker =
DatePicker.initFromDate <| Date.fromPosix (Maybe.withDefault Time.utc sharedState.timezone) (Maybe.withDefault (Time.millisToPosix 0) sharedState.currentTime)

( lectureDatePicker, lectureDatePickerFx ) =
DatePicker.init
lectureDatePicker =
DatePicker.initFromDate <| Date.fromPosix (Maybe.withDefault Time.utc sharedState.timezone) (Maybe.withDefault (Time.millisToPosix 0) sharedState.currentTime)

pickerTime =
DTU.pickerTimeFromPosix (Maybe.withDefault Time.utc sharedState.timezone) (Maybe.withDefault (Time.millisToPosix 0) sharedState.currentTime)

pickerDate =
Date.fromPosix (Maybe.withDefault Time.utc sharedState.timezone) (Maybe.withDefault (Time.millisToPosix 0) sharedState.currentTime)

currentTime =
Maybe.withDefault (Time.millisToPosix 0) sharedState.currentTime
in
( { course_id = 0
, id = 0
, name = ""
, publishedTimePicker = TimePicker.init Nothing
, publishedTimePicker = TimePicker.init <| Just pickerTime
, publishedDatePicker = publishedDatePicker
, publishedAtDate = Nothing
, publishedAtTime = Nothing
, publishedPosix = Nothing
, lectureTimePicker = TimePicker.init Nothing
, publishedAtDate = Just pickerDate
, publishedAtTime = Just pickerTime
, publishedPosix = Just currentTime
, lectureTimePicker = TimePicker.init <| Just pickerTime
, lectureDatePicker = lectureDatePicker
, lectureAtDate = Nothing
, lectureAtTime = Nothing
, lecturePosix = Nothing
, lectureAtDate = Just pickerDate
, lectureAtTime = Just pickerTime
, lecturePosix = Just currentTime
, utcOffsetPos = DTU.utcZeroOffsetIndex
, materialResponse = NotAsked
, createMaterial = True
Expand All @@ -142,28 +151,24 @@ initModel =
, toasties = Toasty.initialState
, deleteMaterialDialogState = False
}
, Cmd.batch
[ Cmd.map PublishedDatePickerMsg publishedDatePickerFx
, Cmd.map LectureDatePickerMsg lectureDatePickerFx
, perform GetRealOffset
]
, perform GetRealOffset
)


initCreate : Int -> ( Model, Cmd Msg )
initCreate courseId =
initCreate : Int -> SharedState -> ( Model, Cmd Msg )
initCreate courseId sharedModel =
let
( model, cmd ) =
initModel
initModel sharedModel
in
( { model | course_id = courseId }, cmd )


initEdit : Int -> Int -> ( Model, Cmd Msg )
initEdit courseId id =
initEdit : Int -> Int -> SharedState -> ( Model, Cmd Msg )
initEdit courseId id sharedState =
let
( model, cmd ) =
initModel
initModel sharedState
in
( { model
| createMaterial = False
Expand Down
4 changes: 2 additions & 2 deletions src/Routing/Router.elm
Original file line number Diff line number Diff line change
Expand Up @@ -354,10 +354,10 @@ navigateTo route sharedState model =
SheetEditor.initEdit courseId id |> initWith SheetEditorModel SheetEditorMsg model NoUpdate

CreateMaterialRoute courseId ->
MaterialEditor.initCreate courseId |> initWith MaterialEditorModel MaterialEditorMsg model NoUpdate
MaterialEditor.initCreate courseId sharedState |> initWith MaterialEditorModel MaterialEditorMsg model NoUpdate

EditMaterialRoute courseId id ->
MaterialEditor.initEdit courseId id |> initWith MaterialEditorModel MaterialEditorMsg model NoUpdate
MaterialEditor.initEdit courseId id sharedState |> initWith MaterialEditorModel MaterialEditorMsg model NoUpdate

SheetDetailRoute courseId id ->
SheetDetail.init courseId id |> initWith SheetDetailModel SheetDetailMsg model NoUpdate
Expand Down

0 comments on commit 0bbbb5e

Please sign in to comment.