mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-07-04 16:48:26 +00:00
Introduce ui settings and let user set page size for item search
This commit is contained in:
@ -10,7 +10,9 @@ import Comp.EmailSettingsManage
|
||||
import Comp.ImapSettingsManage
|
||||
import Comp.NotificationForm
|
||||
import Comp.ScanMailboxManage
|
||||
import Comp.UiSettingsManage
|
||||
import Data.Flags exposing (Flags)
|
||||
import Data.UiSettings exposing (UiSettings)
|
||||
|
||||
|
||||
type alias Model =
|
||||
@ -20,6 +22,7 @@ type alias Model =
|
||||
, imapSettingsModel : Comp.ImapSettingsManage.Model
|
||||
, notificationModel : Comp.NotificationForm.Model
|
||||
, scanMailboxModel : Comp.ScanMailboxManage.Model
|
||||
, uiSettingsModel : Comp.UiSettingsManage.Model
|
||||
}
|
||||
|
||||
|
||||
@ -31,6 +34,7 @@ emptyModel flags =
|
||||
, imapSettingsModel = Comp.ImapSettingsManage.emptyModel
|
||||
, notificationModel = Tuple.first (Comp.NotificationForm.init flags)
|
||||
, scanMailboxModel = Tuple.first (Comp.ScanMailboxManage.init flags)
|
||||
, uiSettingsModel = Comp.UiSettingsManage.init Data.UiSettings.defaults
|
||||
}
|
||||
|
||||
|
||||
@ -40,6 +44,7 @@ type Tab
|
||||
| ImapSettingsTab
|
||||
| NotificationTab
|
||||
| ScanMailboxTab
|
||||
| UiSettingsTab
|
||||
|
||||
|
||||
type Msg
|
||||
@ -49,3 +54,5 @@ type Msg
|
||||
| NotificationMsg Comp.NotificationForm.Msg
|
||||
| ImapSettingsMsg Comp.ImapSettingsManage.Msg
|
||||
| ScanMailboxMsg Comp.ScanMailboxManage.Msg
|
||||
| GetUiSettings UiSettings
|
||||
| UiSettingsMsg Comp.UiSettingsManage.Msg
|
||||
|
@ -5,75 +5,76 @@ import Comp.EmailSettingsManage
|
||||
import Comp.ImapSettingsManage
|
||||
import Comp.NotificationForm
|
||||
import Comp.ScanMailboxManage
|
||||
import Comp.UiSettingsManage
|
||||
import Data.Flags exposing (Flags)
|
||||
import Page.UserSettings.Data exposing (..)
|
||||
|
||||
|
||||
update : Flags -> Msg -> Model -> ( Model, Cmd Msg )
|
||||
update : Flags -> Msg -> Model -> ( Model, Cmd Msg, Sub Msg )
|
||||
update flags msg model =
|
||||
case msg of
|
||||
SetTab t ->
|
||||
let
|
||||
m =
|
||||
{ model | currentTab = Just t }
|
||||
|
||||
( m2, cmd ) =
|
||||
case t of
|
||||
EmailSettingsTab ->
|
||||
let
|
||||
( em, c ) =
|
||||
Comp.EmailSettingsManage.init flags
|
||||
in
|
||||
( { m | emailSettingsModel = em }, Cmd.map EmailSettingsMsg c )
|
||||
|
||||
ImapSettingsTab ->
|
||||
let
|
||||
( em, c ) =
|
||||
Comp.ImapSettingsManage.init flags
|
||||
in
|
||||
( { m | imapSettingsModel = em }, Cmd.map ImapSettingsMsg c )
|
||||
|
||||
ChangePassTab ->
|
||||
( m, Cmd.none )
|
||||
|
||||
NotificationTab ->
|
||||
let
|
||||
initCmd =
|
||||
Cmd.map NotificationMsg
|
||||
(Tuple.second (Comp.NotificationForm.init flags))
|
||||
in
|
||||
( m, initCmd )
|
||||
|
||||
ScanMailboxTab ->
|
||||
let
|
||||
initCmd =
|
||||
Cmd.map ScanMailboxMsg
|
||||
(Tuple.second (Comp.ScanMailboxManage.init flags))
|
||||
in
|
||||
( m, initCmd )
|
||||
in
|
||||
( m2, cmd )
|
||||
case t of
|
||||
EmailSettingsTab ->
|
||||
let
|
||||
( em, c ) =
|
||||
Comp.EmailSettingsManage.init flags
|
||||
in
|
||||
( { m | emailSettingsModel = em }, Cmd.map EmailSettingsMsg c, Sub.none )
|
||||
|
||||
ImapSettingsTab ->
|
||||
let
|
||||
( em, c ) =
|
||||
Comp.ImapSettingsManage.init flags
|
||||
in
|
||||
( { m | imapSettingsModel = em }, Cmd.map ImapSettingsMsg c, Sub.none )
|
||||
|
||||
ChangePassTab ->
|
||||
( m, Cmd.none, Sub.none )
|
||||
|
||||
NotificationTab ->
|
||||
let
|
||||
initCmd =
|
||||
Cmd.map NotificationMsg
|
||||
(Tuple.second (Comp.NotificationForm.init flags))
|
||||
in
|
||||
( m, initCmd, Sub.none )
|
||||
|
||||
ScanMailboxTab ->
|
||||
let
|
||||
initCmd =
|
||||
Cmd.map ScanMailboxMsg
|
||||
(Tuple.second (Comp.ScanMailboxManage.init flags))
|
||||
in
|
||||
( m, initCmd, Sub.none )
|
||||
|
||||
UiSettingsTab ->
|
||||
( m, Cmd.none, Sub.none )
|
||||
|
||||
ChangePassMsg m ->
|
||||
let
|
||||
( m2, c2 ) =
|
||||
Comp.ChangePasswordForm.update flags m model.changePassModel
|
||||
in
|
||||
( { model | changePassModel = m2 }, Cmd.map ChangePassMsg c2 )
|
||||
( { model | changePassModel = m2 }, Cmd.map ChangePassMsg c2, Sub.none )
|
||||
|
||||
EmailSettingsMsg m ->
|
||||
let
|
||||
( m2, c2 ) =
|
||||
Comp.EmailSettingsManage.update flags m model.emailSettingsModel
|
||||
in
|
||||
( { model | emailSettingsModel = m2 }, Cmd.map EmailSettingsMsg c2 )
|
||||
( { model | emailSettingsModel = m2 }, Cmd.map EmailSettingsMsg c2, Sub.none )
|
||||
|
||||
ImapSettingsMsg m ->
|
||||
let
|
||||
( m2, c2 ) =
|
||||
Comp.ImapSettingsManage.update flags m model.imapSettingsModel
|
||||
in
|
||||
( { model | imapSettingsModel = m2 }, Cmd.map ImapSettingsMsg c2 )
|
||||
( { model | imapSettingsModel = m2 }, Cmd.map ImapSettingsMsg c2, Sub.none )
|
||||
|
||||
NotificationMsg lm ->
|
||||
let
|
||||
@ -82,6 +83,7 @@ update flags msg model =
|
||||
in
|
||||
( { model | notificationModel = m2 }
|
||||
, Cmd.map NotificationMsg c2
|
||||
, Sub.none
|
||||
)
|
||||
|
||||
ScanMailboxMsg lm ->
|
||||
@ -91,4 +93,21 @@ update flags msg model =
|
||||
in
|
||||
( { model | scanMailboxModel = m2 }
|
||||
, Cmd.map ScanMailboxMsg c2
|
||||
, Sub.none
|
||||
)
|
||||
|
||||
GetUiSettings settings ->
|
||||
( { model | uiSettingsModel = Comp.UiSettingsManage.init settings }
|
||||
, Cmd.none
|
||||
, Sub.none
|
||||
)
|
||||
|
||||
UiSettingsMsg lm ->
|
||||
let
|
||||
( m2, c2, s2 ) =
|
||||
Comp.UiSettingsManage.update flags lm model.uiSettingsModel
|
||||
in
|
||||
( { model | uiSettingsModel = m2 }
|
||||
, Cmd.map UiSettingsMsg c2
|
||||
, Sub.map UiSettingsMsg s2
|
||||
)
|
||||
|
@ -5,6 +5,7 @@ import Comp.EmailSettingsManage
|
||||
import Comp.ImapSettingsManage
|
||||
import Comp.NotificationForm
|
||||
import Comp.ScanMailboxManage
|
||||
import Comp.UiSettingsManage
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
import Html.Events exposing (onClick)
|
||||
@ -26,6 +27,7 @@ view model =
|
||||
, makeTab model ImapSettingsTab "E-Mail Settings (IMAP)" "mail icon"
|
||||
, makeTab model NotificationTab "Notification Task" "bullhorn icon"
|
||||
, makeTab model ScanMailboxTab "Scan Mailbox Task" "envelope open outline icon"
|
||||
, makeTab model UiSettingsTab "UI Settings" "cog icon"
|
||||
]
|
||||
]
|
||||
]
|
||||
@ -47,6 +49,9 @@ view model =
|
||||
Just ScanMailboxTab ->
|
||||
viewScanMailboxManage model
|
||||
|
||||
Just UiSettingsTab ->
|
||||
viewUiSettings model
|
||||
|
||||
Nothing ->
|
||||
[]
|
||||
)
|
||||
@ -66,6 +71,20 @@ makeTab model tab header icon =
|
||||
]
|
||||
|
||||
|
||||
viewUiSettings : Model -> List (Html Msg)
|
||||
viewUiSettings model =
|
||||
[ h2 [ class "ui header" ]
|
||||
[ i [ class "cog icon" ] []
|
||||
, text "UI Settings"
|
||||
]
|
||||
, p []
|
||||
[ text "These settings only affect the web ui. They are stored in the browser, "
|
||||
, text "so they are separated between browsers and devices."
|
||||
]
|
||||
, Html.map UiSettingsMsg (Comp.UiSettingsManage.view "ui segment" model.uiSettingsModel)
|
||||
]
|
||||
|
||||
|
||||
viewEmailSettings : Model -> List (Html Msg)
|
||||
viewEmailSettings model =
|
||||
[ h2 [ class "ui header" ]
|
||||
|
Reference in New Issue
Block a user