mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-25 14:08:25 +00:00
Client settings per collective and user
Client settings can be stored at the user and and the collective. The settings used in the application are merged from these two settings, where any user setting takes precedence. The form can now manage both variants. Refs: #838
This commit is contained in:
@ -231,7 +231,7 @@ type Msg
|
||||
| KeyUpPowerSearchbarMsg (Maybe KeyCode)
|
||||
| RequestReprocessSelected
|
||||
| ReprocessSelectedConfirmed
|
||||
| ClientSettingsSaveResp UiSettings (Result Http.Error BasicResult)
|
||||
| ClientSettingsSaveResp (Result Http.Error BasicResult)
|
||||
| RemoveItem String
|
||||
| MergeSelectedItems
|
||||
| MergeItemsMsg Comp.ItemMerge.Msg
|
||||
|
@ -22,7 +22,9 @@ import Comp.LinkTarget exposing (LinkTarget)
|
||||
import Comp.PowerSearchInput
|
||||
import Comp.PublishItems
|
||||
import Comp.SearchMenu
|
||||
import Data.AppEvent exposing (AppEvent(..))
|
||||
import Data.Flags exposing (Flags)
|
||||
import Data.ItemArrange
|
||||
import Data.ItemQuery as Q
|
||||
import Data.ItemSelection
|
||||
import Data.Items
|
||||
@ -44,7 +46,7 @@ type alias UpdateResult =
|
||||
{ model : Model
|
||||
, cmd : Cmd Msg
|
||||
, sub : Sub Msg
|
||||
, newSettings : Maybe UiSettings
|
||||
, appEvent : AppEvent
|
||||
}
|
||||
|
||||
|
||||
@ -74,7 +76,7 @@ update bookmarkId mId key flags texts settings msg model =
|
||||
model
|
||||
|
||||
DoNothing ->
|
||||
UpdateResult model Cmd.none Sub.none Nothing
|
||||
UpdateResult model Cmd.none Sub.none AppNothing
|
||||
|
||||
ResetSearch ->
|
||||
let
|
||||
@ -868,26 +870,26 @@ update bookmarkId mId key flags texts settings msg model =
|
||||
|
||||
TogglePreviewFullWidth ->
|
||||
let
|
||||
newSettings =
|
||||
{ settings | cardPreviewFullWidth = not settings.cardPreviewFullWidth }
|
||||
newSettings s =
|
||||
{ s | cardPreviewFullWidth = Just (not settings.cardPreviewFullWidth) }
|
||||
|
||||
cmd =
|
||||
Api.saveClientSettings flags newSettings (ClientSettingsSaveResp newSettings)
|
||||
Api.saveUserClientSettingsBy flags newSettings ClientSettingsSaveResp
|
||||
in
|
||||
noSub ( { model | viewMenuOpen = False }, cmd )
|
||||
|
||||
ClientSettingsSaveResp newSettings (Ok res) ->
|
||||
ClientSettingsSaveResp (Ok res) ->
|
||||
if res.success then
|
||||
{ model = model
|
||||
, cmd = Cmd.none
|
||||
, sub = Sub.none
|
||||
, newSettings = Just newSettings
|
||||
, appEvent = AppReloadUiSettings
|
||||
}
|
||||
|
||||
else
|
||||
noSub ( model, Cmd.none )
|
||||
|
||||
ClientSettingsSaveResp _ (Err _) ->
|
||||
ClientSettingsSaveResp (Err _) ->
|
||||
noSub ( model, Cmd.none )
|
||||
|
||||
PowerSearchMsg lm ->
|
||||
@ -1015,21 +1017,21 @@ update bookmarkId mId key flags texts settings msg model =
|
||||
|
||||
ToggleShowGroups ->
|
||||
let
|
||||
newSettings =
|
||||
{ settings | itemSearchShowGroups = not settings.itemSearchShowGroups }
|
||||
newSettings s =
|
||||
{ s | itemSearchShowGroups = Just (not settings.itemSearchShowGroups) }
|
||||
|
||||
cmd =
|
||||
Api.saveClientSettings flags newSettings (ClientSettingsSaveResp newSettings)
|
||||
Api.saveUserClientSettingsBy flags newSettings ClientSettingsSaveResp
|
||||
in
|
||||
noSub ( { model | viewMenuOpen = False }, cmd )
|
||||
|
||||
ToggleArrange am ->
|
||||
let
|
||||
newSettings =
|
||||
{ settings | itemSearchArrange = am }
|
||||
newSettings s =
|
||||
{ s | itemSearchArrange = Data.ItemArrange.asString am |> Just }
|
||||
|
||||
cmd =
|
||||
Api.saveClientSettings flags newSettings (ClientSettingsSaveResp newSettings)
|
||||
Api.saveUserClientSettingsBy flags newSettings ClientSettingsSaveResp
|
||||
in
|
||||
noSub ( { model | viewMenuOpen = False }, cmd )
|
||||
|
||||
@ -1201,5 +1203,5 @@ makeResult ( m, c, s ) =
|
||||
{ model = m
|
||||
, cmd = c
|
||||
, sub = s
|
||||
, newSettings = Nothing
|
||||
, appEvent = AppNothing
|
||||
}
|
||||
|
@ -42,10 +42,10 @@ type alias Model =
|
||||
|
||||
|
||||
init : Flags -> UiSettings -> ( Model, Cmd Msg )
|
||||
init flags settings =
|
||||
init flags _ =
|
||||
let
|
||||
( um, uc ) =
|
||||
Comp.UiSettingsManage.init flags settings
|
||||
Comp.UiSettingsManage.init flags
|
||||
|
||||
( otpm, otpc ) =
|
||||
Comp.OtpSetup.init flags
|
||||
@ -107,5 +107,3 @@ type Msg
|
||||
| NotificationHookMsg Comp.NotificationHookManage.Msg
|
||||
| PeriodicQueryMsg Comp.PeriodicQueryTaskManage.Msg
|
||||
| ChannelMsg Comp.NotificationChannelManage.Msg
|
||||
| UpdateSettings
|
||||
| ReceiveBrowserSettings StoredUiSettings
|
||||
|
@ -17,6 +17,7 @@ import Comp.OtpSetup
|
||||
import Comp.PeriodicQueryTaskManage
|
||||
import Comp.ScanMailboxManage
|
||||
import Comp.UiSettingsManage
|
||||
import Data.AppEvent exposing (AppEvent(..))
|
||||
import Data.Flags exposing (Flags)
|
||||
import Data.UiSettings exposing (UiSettings)
|
||||
import Page.UserSettings.Data exposing (..)
|
||||
@ -26,10 +27,15 @@ type alias UpdateResult =
|
||||
{ model : Model
|
||||
, cmd : Cmd Msg
|
||||
, sub : Sub Msg
|
||||
, newSettings : Maybe UiSettings
|
||||
, appEvent : AppEvent
|
||||
}
|
||||
|
||||
|
||||
unit : Model -> UpdateResult
|
||||
unit model =
|
||||
UpdateResult model Cmd.none Sub.none AppNothing
|
||||
|
||||
|
||||
update : Flags -> UiSettings -> Msg -> Model -> UpdateResult
|
||||
update flags settings msg model =
|
||||
case msg of
|
||||
@ -47,7 +53,7 @@ update flags settings msg model =
|
||||
{ model = { m | emailSettingsModel = em }
|
||||
, cmd = Cmd.map EmailSettingsMsg c
|
||||
, sub = Sub.none
|
||||
, newSettings = Nothing
|
||||
, appEvent = AppNothing
|
||||
}
|
||||
|
||||
ImapSettingsTab ->
|
||||
@ -58,18 +64,14 @@ update flags settings msg model =
|
||||
{ model = { m | imapSettingsModel = em }
|
||||
, cmd = Cmd.map ImapSettingsMsg c
|
||||
, sub = Sub.none
|
||||
, newSettings = Nothing
|
||||
, appEvent = AppNothing
|
||||
}
|
||||
|
||||
ChangePassTab ->
|
||||
UpdateResult m Cmd.none Sub.none Nothing
|
||||
unit m
|
||||
|
||||
NotificationTab ->
|
||||
{ model = m
|
||||
, cmd = Cmd.none
|
||||
, sub = Sub.none
|
||||
, newSettings = Nothing
|
||||
}
|
||||
unit m
|
||||
|
||||
NotificationWebhookTab ->
|
||||
let
|
||||
@ -79,7 +81,7 @@ update flags settings msg model =
|
||||
{ model = m
|
||||
, cmd = Cmd.map NotificationHookMsg nc
|
||||
, sub = Sub.none
|
||||
, newSettings = Nothing
|
||||
, appEvent = AppNothing
|
||||
}
|
||||
|
||||
NotificationQueriesTab ->
|
||||
@ -88,7 +90,7 @@ update flags settings msg model =
|
||||
Cmd.map NotificationMsg
|
||||
(Tuple.second (Comp.DueItemsTaskManage.init flags))
|
||||
in
|
||||
UpdateResult m initCmd Sub.none Nothing
|
||||
UpdateResult m initCmd Sub.none AppNothing
|
||||
|
||||
NotificationDueItemsTab ->
|
||||
let
|
||||
@ -96,7 +98,7 @@ update flags settings msg model =
|
||||
Cmd.map NotificationMsg
|
||||
(Tuple.second (Comp.DueItemsTaskManage.init flags))
|
||||
in
|
||||
UpdateResult m initCmd Sub.none Nothing
|
||||
UpdateResult m initCmd Sub.none AppNothing
|
||||
|
||||
ScanMailboxTab ->
|
||||
let
|
||||
@ -104,16 +106,24 @@ update flags settings msg model =
|
||||
Cmd.map ScanMailboxMsg
|
||||
(Tuple.second (Comp.ScanMailboxManage.init flags))
|
||||
in
|
||||
UpdateResult m initCmd Sub.none Nothing
|
||||
UpdateResult m initCmd Sub.none AppNothing
|
||||
|
||||
UiSettingsTab ->
|
||||
UpdateResult m Cmd.none Sub.none Nothing
|
||||
let
|
||||
( um, uc ) =
|
||||
Comp.UiSettingsManage.init flags
|
||||
in
|
||||
{ model = { m | uiSettingsModel = um }
|
||||
, cmd = Cmd.map UiSettingsMsg uc
|
||||
, sub = Sub.none
|
||||
, appEvent = AppNothing
|
||||
}
|
||||
|
||||
OtpTab ->
|
||||
UpdateResult m Cmd.none Sub.none Nothing
|
||||
unit m
|
||||
|
||||
ChannelTab ->
|
||||
UpdateResult m Cmd.none Sub.none Nothing
|
||||
unit m
|
||||
|
||||
ChangePassMsg m ->
|
||||
let
|
||||
@ -123,7 +133,7 @@ update flags settings msg model =
|
||||
{ model = { model | changePassModel = m2 }
|
||||
, cmd = Cmd.map ChangePassMsg c2
|
||||
, sub = Sub.none
|
||||
, newSettings = Nothing
|
||||
, appEvent = AppNothing
|
||||
}
|
||||
|
||||
EmailSettingsMsg m ->
|
||||
@ -134,7 +144,7 @@ update flags settings msg model =
|
||||
{ model = { model | emailSettingsModel = m2 }
|
||||
, cmd = Cmd.map EmailSettingsMsg c2
|
||||
, sub = Sub.none
|
||||
, newSettings = Nothing
|
||||
, appEvent = AppNothing
|
||||
}
|
||||
|
||||
ImapSettingsMsg m ->
|
||||
@ -145,7 +155,7 @@ update flags settings msg model =
|
||||
{ model = { model | imapSettingsModel = m2 }
|
||||
, cmd = Cmd.map ImapSettingsMsg c2
|
||||
, sub = Sub.none
|
||||
, newSettings = Nothing
|
||||
, appEvent = AppNothing
|
||||
}
|
||||
|
||||
NotificationMsg lm ->
|
||||
@ -156,7 +166,7 @@ update flags settings msg model =
|
||||
{ model = { model | notificationModel = m2 }
|
||||
, cmd = Cmd.map NotificationMsg c2
|
||||
, sub = Sub.none
|
||||
, newSettings = Nothing
|
||||
, appEvent = AppNothing
|
||||
}
|
||||
|
||||
ScanMailboxMsg lm ->
|
||||
@ -167,7 +177,7 @@ update flags settings msg model =
|
||||
{ model = { model | scanMailboxModel = m2 }
|
||||
, cmd = Cmd.map ScanMailboxMsg c2
|
||||
, sub = Sub.none
|
||||
, newSettings = Nothing
|
||||
, appEvent = AppNothing
|
||||
}
|
||||
|
||||
UiSettingsMsg lm ->
|
||||
@ -178,7 +188,7 @@ update flags settings msg model =
|
||||
{ model = { model | uiSettingsModel = res.model }
|
||||
, cmd = Cmd.map UiSettingsMsg res.cmd
|
||||
, sub = Sub.map UiSettingsMsg res.sub
|
||||
, newSettings = res.newSettings
|
||||
, appEvent = res.appEvent
|
||||
}
|
||||
|
||||
OtpSetupMsg lm ->
|
||||
@ -189,7 +199,7 @@ update flags settings msg model =
|
||||
{ model = { model | otpSetupModel = otpm }
|
||||
, cmd = Cmd.map OtpSetupMsg otpc
|
||||
, sub = Sub.none
|
||||
, newSettings = Nothing
|
||||
, appEvent = AppNothing
|
||||
}
|
||||
|
||||
NotificationHookMsg lm ->
|
||||
@ -200,7 +210,7 @@ update flags settings msg model =
|
||||
{ model = { model | notificationHookModel = hm }
|
||||
, cmd = Cmd.map NotificationHookMsg hc
|
||||
, sub = Sub.none
|
||||
, newSettings = Nothing
|
||||
, appEvent = AppNothing
|
||||
}
|
||||
|
||||
ChannelMsg lm ->
|
||||
@ -211,22 +221,9 @@ update flags settings msg model =
|
||||
{ model = { model | channelModel = cm }
|
||||
, cmd = Cmd.map ChannelMsg cc
|
||||
, sub = Sub.none
|
||||
, newSettings = Nothing
|
||||
, appEvent = AppNothing
|
||||
}
|
||||
|
||||
UpdateSettings ->
|
||||
update flags
|
||||
settings
|
||||
(UiSettingsMsg Comp.UiSettingsManage.UpdateSettings)
|
||||
model
|
||||
|
||||
ReceiveBrowserSettings sett ->
|
||||
let
|
||||
lm =
|
||||
Comp.UiSettingsManage.ReceiveBrowserSettings sett
|
||||
in
|
||||
update flags settings (UiSettingsMsg lm) model
|
||||
|
||||
PeriodicQueryMsg lm ->
|
||||
let
|
||||
( pqm, pqc, pqs ) =
|
||||
@ -235,5 +232,5 @@ update flags settings msg model =
|
||||
{ model = { model | periodicQueryModel = pqm }
|
||||
, cmd = Cmd.map PeriodicQueryMsg pqc
|
||||
, sub = Sub.map PeriodicQueryMsg pqs
|
||||
, newSettings = Nothing
|
||||
, appEvent = AppNothing
|
||||
}
|
||||
|
Reference in New Issue
Block a user