mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-23 02:48:26 +00:00
Starting with mail settings
This commit is contained in:
68
modules/webapp/src/main/elm/Comp/EmailSettingsForm.elm
Normal file
68
modules/webapp/src/main/elm/Comp/EmailSettingsForm.elm
Normal file
@ -0,0 +1,68 @@
|
||||
module Comp.EmailSettingsForm exposing
|
||||
( Model
|
||||
, Msg
|
||||
, emptyModel
|
||||
, update
|
||||
, view
|
||||
)
|
||||
|
||||
import Api.Model.EmailSettings exposing (EmailSettings)
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
import Html.Events exposing (onInput)
|
||||
|
||||
|
||||
type alias Model =
|
||||
{ settings : EmailSettings
|
||||
, name : String
|
||||
}
|
||||
|
||||
|
||||
emptyModel : Model
|
||||
emptyModel =
|
||||
{ settings = Api.Model.EmailSettings.empty
|
||||
, name = ""
|
||||
}
|
||||
|
||||
|
||||
init : EmailSettings -> Model
|
||||
init ems =
|
||||
{ settings = ems
|
||||
, name = ems.name
|
||||
}
|
||||
|
||||
|
||||
type Msg
|
||||
= SetName String
|
||||
|
||||
|
||||
isValid : Model -> Bool
|
||||
isValid model =
|
||||
True
|
||||
|
||||
|
||||
update : Msg -> Model -> ( Model, Cmd Msg )
|
||||
update msg model =
|
||||
( model, Cmd.none )
|
||||
|
||||
|
||||
view : Model -> Html Msg
|
||||
view model =
|
||||
div
|
||||
[ classList
|
||||
[ ( "ui form", True )
|
||||
, ( "error", not (isValid model) )
|
||||
, ( "success", isValid model )
|
||||
]
|
||||
]
|
||||
[ div [ class "required field" ]
|
||||
[ label [] [ text "Name" ]
|
||||
, input
|
||||
[ type_ "text"
|
||||
, value model.name
|
||||
, onInput SetName
|
||||
, placeholder "Connection name"
|
||||
]
|
||||
[]
|
||||
]
|
||||
]
|
70
modules/webapp/src/main/elm/Comp/EmailSettingsManage.elm
Normal file
70
modules/webapp/src/main/elm/Comp/EmailSettingsManage.elm
Normal file
@ -0,0 +1,70 @@
|
||||
module Comp.EmailSettingsManage exposing
|
||||
( Model
|
||||
, Msg
|
||||
, emptyModel
|
||||
, init
|
||||
, update
|
||||
, view
|
||||
)
|
||||
|
||||
import Api
|
||||
import Api.Model.BasicResult exposing (BasicResult)
|
||||
import Api.Model.EmailSettings exposing (EmailSettings)
|
||||
import Api.Model.EmailSettingsList exposing (EmailSettingsList)
|
||||
import Comp.EmailSettingsForm
|
||||
import Comp.EmailSettingsTable
|
||||
import Comp.YesNoDimmer
|
||||
import Data.Flags exposing (Flags)
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
|
||||
|
||||
type alias Model =
|
||||
{ tableModel : Comp.EmailSettingsTable.Model
|
||||
, formModel : Comp.EmailSettingsForm.Model
|
||||
, viewMode : ViewMode
|
||||
, formError : Maybe String
|
||||
, loading : Bool
|
||||
, deleteConfirm : Comp.YesNoDimmer.Model
|
||||
}
|
||||
|
||||
|
||||
emptyModel : Model
|
||||
emptyModel =
|
||||
{ tableModel = Comp.EmailSettingsTable.emptyModel
|
||||
, formModel = Comp.EmailSettingsForm.emptyModel
|
||||
, viewMode = Table
|
||||
, formError = Nothing
|
||||
, loading = False
|
||||
, deleteConfirm = Comp.YesNoDimmer.emptyModel
|
||||
}
|
||||
|
||||
|
||||
init : ( Model, Cmd Msg )
|
||||
init =
|
||||
( emptyModel, Cmd.none )
|
||||
|
||||
|
||||
type ViewMode
|
||||
= Table
|
||||
| Form
|
||||
|
||||
|
||||
type Msg
|
||||
= TableMsg Comp.EmailSettingsTable.Msg
|
||||
| FormMsg Comp.EmailSettingsForm.Msg
|
||||
|
||||
|
||||
update : Flags -> Msg -> Model -> ( Model, Cmd Msg )
|
||||
update flags msg model =
|
||||
( model, Cmd.none )
|
||||
|
||||
|
||||
view : Model -> Html Msg
|
||||
view model =
|
||||
case model.viewMode of
|
||||
Table ->
|
||||
Html.map TableMsg (Comp.EmailSettingsTable.view model.tableModel)
|
||||
|
||||
Form ->
|
||||
Html.map FormMsg (Comp.EmailSettingsForm.view model.formModel)
|
49
modules/webapp/src/main/elm/Comp/EmailSettingsTable.elm
Normal file
49
modules/webapp/src/main/elm/Comp/EmailSettingsTable.elm
Normal file
@ -0,0 +1,49 @@
|
||||
module Comp.EmailSettingsTable exposing
|
||||
( Model
|
||||
, Msg
|
||||
, emptyModel
|
||||
, update
|
||||
, view
|
||||
)
|
||||
|
||||
import Api.Model.EmailSettings exposing (EmailSettings)
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
|
||||
|
||||
type alias Model =
|
||||
{ emailSettings : List EmailSettings
|
||||
}
|
||||
|
||||
|
||||
emptyModel : Model
|
||||
emptyModel =
|
||||
init []
|
||||
|
||||
|
||||
init : List EmailSettings -> Model
|
||||
init ems =
|
||||
{ emailSettings = ems
|
||||
}
|
||||
|
||||
|
||||
type Msg
|
||||
= Select EmailSettings
|
||||
|
||||
|
||||
update : Msg -> Model -> ( Model, Cmd Msg )
|
||||
update msg model =
|
||||
( model, Cmd.none )
|
||||
|
||||
|
||||
view : Model -> Html Msg
|
||||
view model =
|
||||
table [ class "ui table" ]
|
||||
[ thead []
|
||||
[ th [] [ text "Name" ]
|
||||
, th [] [ text "Host/Port" ]
|
||||
, th [] [ text "From" ]
|
||||
]
|
||||
, tbody []
|
||||
[]
|
||||
]
|
Reference in New Issue
Block a user