mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 02:18:26 +00:00
Prepare notification form
This commit is contained in:
42
modules/webapp/src/main/elm/Comp/NotificationForm.elm
Normal file
42
modules/webapp/src/main/elm/Comp/NotificationForm.elm
Normal file
@ -0,0 +1,42 @@
|
||||
module Comp.NotificationForm exposing
|
||||
( Model
|
||||
, Msg
|
||||
, init
|
||||
, update
|
||||
, view
|
||||
)
|
||||
|
||||
import Api.Model.NotificationSettings exposing (NotificationSettings)
|
||||
import Data.Flags exposing (Flags)
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
|
||||
|
||||
type alias Model =
|
||||
{ settings : NotificationSettings
|
||||
}
|
||||
|
||||
|
||||
type Msg
|
||||
= Submit
|
||||
|
||||
|
||||
init : Model
|
||||
init =
|
||||
{ settings = Api.Model.NotificationSettings.empty
|
||||
}
|
||||
|
||||
|
||||
update : Flags -> Msg -> Model -> ( Model, Cmd Msg )
|
||||
update flags msg model =
|
||||
( model, Cmd.none )
|
||||
|
||||
|
||||
view : Model -> Html Msg
|
||||
view model =
|
||||
div
|
||||
[ classList
|
||||
[ ( "ui form", True )
|
||||
]
|
||||
]
|
||||
[]
|
@ -7,12 +7,14 @@ module Page.UserSettings.Data exposing
|
||||
|
||||
import Comp.ChangePasswordForm
|
||||
import Comp.EmailSettingsManage
|
||||
import Comp.NotificationForm
|
||||
|
||||
|
||||
type alias Model =
|
||||
{ currentTab : Maybe Tab
|
||||
, changePassModel : Comp.ChangePasswordForm.Model
|
||||
, emailSettingsModel : Comp.EmailSettingsManage.Model
|
||||
, notificationModel : Comp.NotificationForm.Model
|
||||
}
|
||||
|
||||
|
||||
@ -21,15 +23,18 @@ emptyModel =
|
||||
{ currentTab = Nothing
|
||||
, changePassModel = Comp.ChangePasswordForm.emptyModel
|
||||
, emailSettingsModel = Comp.EmailSettingsManage.emptyModel
|
||||
, notificationModel = Comp.NotificationForm.init
|
||||
}
|
||||
|
||||
|
||||
type Tab
|
||||
= ChangePassTab
|
||||
| EmailSettingsTab
|
||||
| NotificationTab
|
||||
|
||||
|
||||
type Msg
|
||||
= SetTab Tab
|
||||
| ChangePassMsg Comp.ChangePasswordForm.Msg
|
||||
| EmailSettingsMsg Comp.EmailSettingsManage.Msg
|
||||
| NotificationMsg Comp.NotificationForm.Msg
|
||||
|
@ -2,6 +2,7 @@ module Page.UserSettings.Update exposing (update)
|
||||
|
||||
import Comp.ChangePasswordForm
|
||||
import Comp.EmailSettingsManage
|
||||
import Comp.NotificationForm
|
||||
import Data.Flags exposing (Flags)
|
||||
import Page.UserSettings.Data exposing (..)
|
||||
|
||||
@ -25,6 +26,10 @@ update flags msg model =
|
||||
|
||||
ChangePassTab ->
|
||||
( m, Cmd.none )
|
||||
|
||||
NotificationTab ->
|
||||
-- todo: get initial settings
|
||||
( m, Cmd.none )
|
||||
in
|
||||
( m2, cmd )
|
||||
|
||||
@ -41,3 +46,12 @@ update flags msg model =
|
||||
Comp.EmailSettingsManage.update flags m model.emailSettingsModel
|
||||
in
|
||||
( { model | emailSettingsModel = m2 }, Cmd.map EmailSettingsMsg c2 )
|
||||
|
||||
NotificationMsg lm ->
|
||||
let
|
||||
( m2, c2 ) =
|
||||
Comp.NotificationForm.update flags lm model.notificationModel
|
||||
in
|
||||
( { model | notificationModel = m2 }
|
||||
, Cmd.map NotificationMsg c2
|
||||
)
|
||||
|
@ -2,6 +2,7 @@ module Page.UserSettings.View exposing (view)
|
||||
|
||||
import Comp.ChangePasswordForm
|
||||
import Comp.EmailSettingsManage
|
||||
import Comp.NotificationForm
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
import Html.Events exposing (onClick)
|
||||
@ -18,22 +19,9 @@ view model =
|
||||
]
|
||||
, div [ class "ui attached fluid segment" ]
|
||||
[ div [ class "ui fluid vertical secondary menu" ]
|
||||
[ a
|
||||
[ classActive (model.currentTab == Just ChangePassTab) "link icon item"
|
||||
, onClick (SetTab ChangePassTab)
|
||||
, href "#"
|
||||
]
|
||||
[ i [ class "user secret icon" ] []
|
||||
, text "Change Password"
|
||||
]
|
||||
, a
|
||||
[ classActive (model.currentTab == Just EmailSettingsTab) "link icon item"
|
||||
, onClick (SetTab EmailSettingsTab)
|
||||
, href "#"
|
||||
]
|
||||
[ i [ class "mail icon" ] []
|
||||
, text "E-Mail Settings"
|
||||
]
|
||||
[ makeTab model ChangePassTab "Change Password" "user secret icon"
|
||||
, makeTab model EmailSettingsTab "E-Mail Settings" "mail icon"
|
||||
, makeTab model NotificationTab "Notifications" "bullhorn icon"
|
||||
]
|
||||
]
|
||||
]
|
||||
@ -46,6 +34,9 @@ view model =
|
||||
Just EmailSettingsTab ->
|
||||
viewEmailSettings model
|
||||
|
||||
Just NotificationTab ->
|
||||
viewNotificationForm model
|
||||
|
||||
Nothing ->
|
||||
[]
|
||||
)
|
||||
@ -53,6 +44,18 @@ view model =
|
||||
]
|
||||
|
||||
|
||||
makeTab : Model -> Tab -> String -> String -> Html Msg
|
||||
makeTab model tab header icon =
|
||||
a
|
||||
[ classActive (model.currentTab == Just tab) "link icon item"
|
||||
, onClick (SetTab tab)
|
||||
, href "#"
|
||||
]
|
||||
[ i [ class icon ] []
|
||||
, text header
|
||||
]
|
||||
|
||||
|
||||
viewEmailSettings : Model -> List (Html Msg)
|
||||
viewEmailSettings model =
|
||||
[ h2 [ class "ui header" ]
|
||||
@ -75,3 +78,15 @@ viewChangePassword model =
|
||||
]
|
||||
, Html.map ChangePassMsg (Comp.ChangePasswordForm.view model.changePassModel)
|
||||
]
|
||||
|
||||
|
||||
viewNotificationForm : Model -> List (Html Msg)
|
||||
viewNotificationForm model =
|
||||
[ h2 [ class "ui header" ]
|
||||
[ i [ class "ui bullhorn icon" ] []
|
||||
, div [ class "content" ]
|
||||
[ text "Notification"
|
||||
]
|
||||
]
|
||||
, Html.map NotificationMsg (Comp.NotificationForm.view model.notificationModel)
|
||||
]
|
||||
|
Reference in New Issue
Block a user