-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHolidayPlan.elm
78 lines (68 loc) · 2.77 KB
/
HolidayPlan.elm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
port module HolidayPlan exposing (..)
import Devs.Ports as P exposing (setDataFromStore, setDimOfElement)
import Browser exposing (..)
import Html exposing (..)
import Html.Attributes as Attr exposing ( .. )
import Html.Events as Ev exposing ( on )
import Json.Decode as Json
import Devs.Objects as O exposing (Model, initialModel)
import Devs.Update as U exposing ( update )
import Devs.TypeObject as TO exposing ( .. )
import Templates.Month as TM exposing ( getMonth, getSummeryDiv )
import Templates.Utils as TU exposing ( getActionButton, showOptionButton )
import Templates.Forms as TF exposing ( getConfigForm, getHolidayForm,geLoginForm )
import Debug exposing (log)
-- Methods
-- View
view : O.Model -> Html TO.Msg
view model =
Html.div [ ] (
List.concat [
[ TF.getConfigForm model
, TF.getHolidayForm model
, TF.geLoginForm model
, Html.h1 [][
Html.text "Kalender des Jahres "
, Html.span [ Attr.class "nobreak" ][
TU.getActionButton "<" True (TO.ShiftYear O.Down)
, Html.text (" " ++ (String.fromInt model.calendar.name) ++ " ")
, TU.getActionButton ">" True (TO.ShiftYear O.Up)
]
]
, Html.div [][
Html.span [ Attr.style "margin-left" "5pt" ][]
,TU.getActionButton "Konfiguration" (TU.showOptionButton model) (TO.ToggleConfigForm)
, Html.span [ Attr.style "margin-left" "5pt" ][]
, TU.getActionButton "Abwesenheiten" (TU.showOptionButton model) (TO.ToggleHolidayForm)
, Html.span [ Attr.style "margin-left" "5pt" ][]
, TU.getActionButton "Export" (TU.showOptionButton model) (TO.DownloadDB)
, Html.span [ Attr.style "margin-left" "5pt" ][]
, TU.getActionButton "Import" True (TO.ImportDB)
, Html.span [ Attr.style "margin-left" "5pt" ][]
, TU.getActionButton "Login" (model.config.password /= Nothing && not model.config.loggedIn) (TO.ToggleLoginForm)
, TU.getActionButton "Logout" (model.config.password /= Nothing && model.config.loggedIn) (TO.Logout)
]
]
, ( List.map TM.getMonth model.calendar.months )
, [ TM.getSummeryDiv model ]
]
)
main : Program () O.Model TO.Msg
main =
Browser.element
{ init = \() -> init
, view = view
, update = U.update
, subscriptions = subscriptions
}
subscriptions : O.Model -> Sub TO.Msg
subscriptions model = Sub.batch [
P.setDataFromStore TO.ReadDataFromPublish
, P.setDimOfElement TO.SetDomDim
]
init : ( O.Model, Cmd Msg )
init = ( O.initialModel, Cmd.batch [
P.pushDataToStore {config=O.initialModel.config, holList=O.initialModel.holList, init=True}
, P.getDimOfElement "app"
]
)