mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-07-04 16:48:26 +00:00
Allow the user to set time zone
Fix timezone handling for periodic tasks
This commit is contained in:
@ -18,6 +18,7 @@ import Api.Model.CalEventCheck exposing (CalEventCheck)
|
||||
import Api.Model.CalEventCheckResult exposing (CalEventCheckResult)
|
||||
import Data.CalEvent exposing (CalEvent)
|
||||
import Data.Flags exposing (Flags)
|
||||
import Data.TimeZone exposing (TimeZone)
|
||||
import Data.Validated exposing (Validated(..))
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
@ -109,8 +110,8 @@ isCheckError model =
|
||||
False
|
||||
|
||||
|
||||
update : Flags -> Maybe CalEvent -> Msg -> Model -> ( Model, Cmd Msg, Maybe CalEvent )
|
||||
update flags mev msg model =
|
||||
update : Flags -> TimeZone -> Maybe CalEvent -> Msg -> Model -> ( Model, Cmd Msg, Maybe CalEvent )
|
||||
update flags tz mev msg model =
|
||||
let
|
||||
ev =
|
||||
Maybe.withDefault model.inner mev
|
||||
@ -153,7 +154,7 @@ update flags mev msg model =
|
||||
( m
|
||||
, Cmd.none
|
||||
, if res.success then
|
||||
Just event
|
||||
Just { event | timeZone = tz }
|
||||
|
||||
else
|
||||
Nothing
|
||||
|
@ -26,6 +26,7 @@ import Data.DropdownStyle as DS
|
||||
import Data.Flags exposing (Flags)
|
||||
import Data.ListType exposing (ListType)
|
||||
import Data.TagOrder
|
||||
import Data.TimeZone exposing (TimeZone)
|
||||
import Data.UiSettings exposing (UiSettings)
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
@ -111,8 +112,8 @@ getSettings model =
|
||||
model.schedule
|
||||
|
||||
|
||||
update : Flags -> Msg -> Model -> ( Model, Cmd Msg )
|
||||
update flags msg model =
|
||||
update : Flags -> TimeZone -> Msg -> Model -> ( Model, Cmd Msg )
|
||||
update flags tz msg model =
|
||||
case msg of
|
||||
GetTagsResp (Ok tl) ->
|
||||
let
|
||||
@ -123,7 +124,7 @@ update flags msg model =
|
||||
lm =
|
||||
Comp.Dropdown.SetOptions categories
|
||||
in
|
||||
update flags (CategoryListMsg lm) model
|
||||
update flags tz (CategoryListMsg lm) model
|
||||
|
||||
GetTagsResp (Err _) ->
|
||||
( model, Cmd.none )
|
||||
@ -133,6 +134,7 @@ update flags msg model =
|
||||
( cm, cc, ce ) =
|
||||
Comp.CalEventInput.update
|
||||
flags
|
||||
tz
|
||||
model.schedule
|
||||
lmsg
|
||||
model.scheduleModel
|
||||
|
@ -26,6 +26,7 @@ import Comp.StringListInput
|
||||
import Data.DropdownStyle as DS
|
||||
import Data.Flags exposing (Flags)
|
||||
import Data.Language exposing (Language)
|
||||
import Data.TimeZone exposing (TimeZone)
|
||||
import Data.UiSettings exposing (UiSettings)
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
@ -143,8 +144,8 @@ type Msg
|
||||
| PasswordMsg Comp.StringListInput.Msg
|
||||
|
||||
|
||||
update : Flags -> Msg -> Model -> ( Model, Cmd Msg, Maybe CollectiveSettings )
|
||||
update flags msg model =
|
||||
update : Flags -> TimeZone -> Msg -> Model -> ( Model, Cmd Msg, Maybe CollectiveSettings )
|
||||
update flags tz msg model =
|
||||
case msg of
|
||||
LangDropdownMsg m ->
|
||||
let
|
||||
@ -207,7 +208,7 @@ update flags msg model =
|
||||
ClassifierSettingMsg lmsg ->
|
||||
let
|
||||
( cm, cc ) =
|
||||
Comp.ClassifierSettingsForm.update flags lmsg model.classifierModel
|
||||
Comp.ClassifierSettingsForm.update flags tz lmsg model.classifierModel
|
||||
in
|
||||
( { model
|
||||
| classifierModel = cm
|
||||
@ -219,7 +220,7 @@ update flags msg model =
|
||||
EmptyTrashMsg lmsg ->
|
||||
let
|
||||
( cm, cc ) =
|
||||
Comp.EmptyTrashForm.update flags lmsg model.emptyTrashModel
|
||||
Comp.EmptyTrashForm.update flags tz lmsg model.emptyTrashModel
|
||||
in
|
||||
( { model
|
||||
| emptyTrashModel = cm
|
||||
|
@ -29,6 +29,7 @@ import Data.CalEvent exposing (CalEvent)
|
||||
import Data.DropdownStyle as DS
|
||||
import Data.Flags exposing (Flags)
|
||||
import Data.TagOrder
|
||||
import Data.TimeZone exposing (TimeZone)
|
||||
import Data.UiSettings exposing (UiSettings)
|
||||
import Data.Validated exposing (Validated(..))
|
||||
import Html exposing (..)
|
||||
@ -237,8 +238,8 @@ withValidSettings mkcmd model =
|
||||
)
|
||||
|
||||
|
||||
update : Flags -> Msg -> Model -> ( Model, Action, Cmd Msg )
|
||||
update flags msg model =
|
||||
update : Flags -> TimeZone -> Msg -> Model -> ( Model, Action, Cmd Msg )
|
||||
update flags tz msg model =
|
||||
case msg of
|
||||
ChannelMsg lm ->
|
||||
let
|
||||
@ -254,6 +255,7 @@ update flags msg model =
|
||||
let
|
||||
( cm, cc, cs ) =
|
||||
Comp.CalEventInput.update flags
|
||||
tz
|
||||
model.schedule
|
||||
lmsg
|
||||
model.scheduleModel
|
||||
|
@ -20,6 +20,7 @@ import Comp.DueItemsTaskForm
|
||||
import Comp.DueItemsTaskList
|
||||
import Comp.MenuBar as MB
|
||||
import Data.Flags exposing (Flags)
|
||||
import Data.TimeZone exposing (TimeZone)
|
||||
import Data.UiSettings exposing (UiSettings)
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
@ -81,8 +82,8 @@ init flags =
|
||||
--- Update
|
||||
|
||||
|
||||
update : Flags -> Msg -> Model -> ( Model, Cmd Msg )
|
||||
update flags msg model =
|
||||
update : Flags -> TimeZone -> Msg -> Model -> ( Model, Cmd Msg )
|
||||
update flags tz msg model =
|
||||
case msg of
|
||||
GetDataResp (Ok items) ->
|
||||
( { model
|
||||
@ -126,7 +127,7 @@ update flags msg model =
|
||||
Just dm ->
|
||||
let
|
||||
( mm, action, mc ) =
|
||||
Comp.DueItemsTaskForm.update flags lm dm
|
||||
Comp.DueItemsTaskForm.update flags tz lm dm
|
||||
|
||||
( model_, cmd_ ) =
|
||||
case action of
|
||||
|
@ -19,6 +19,7 @@ import Comp.CalEventInput
|
||||
import Comp.IntField
|
||||
import Data.CalEvent exposing (CalEvent)
|
||||
import Data.Flags exposing (Flags)
|
||||
import Data.TimeZone exposing (TimeZone)
|
||||
import Data.UiSettings exposing (UiSettings)
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
@ -81,14 +82,15 @@ getSettings model =
|
||||
model.minAgeDays
|
||||
|
||||
|
||||
update : Flags -> Msg -> Model -> ( Model, Cmd Msg )
|
||||
update flags msg model =
|
||||
update : Flags -> TimeZone -> Msg -> Model -> ( Model, Cmd Msg )
|
||||
update flags tz msg model =
|
||||
case msg of
|
||||
ScheduleMsg lmsg ->
|
||||
let
|
||||
( cm, cc, ce ) =
|
||||
Comp.CalEventInput.update
|
||||
flags
|
||||
tz
|
||||
model.schedule
|
||||
lmsg
|
||||
model.scheduleModel
|
||||
|
@ -25,6 +25,7 @@ import Comp.MenuBar as MB
|
||||
import Comp.PowerSearchInput
|
||||
import Data.CalEvent exposing (CalEvent)
|
||||
import Data.Flags exposing (Flags)
|
||||
import Data.TimeZone exposing (TimeZone)
|
||||
import Data.UiSettings exposing (UiSettings)
|
||||
import Data.Validated exposing (Validated(..))
|
||||
import Html exposing (..)
|
||||
@ -254,13 +255,14 @@ withValidSettings mkcmd model =
|
||||
}
|
||||
|
||||
|
||||
update : Flags -> Msg -> Model -> UpdateResult
|
||||
update flags msg model =
|
||||
update : Flags -> TimeZone -> Msg -> Model -> UpdateResult
|
||||
update flags tz msg model =
|
||||
case msg of
|
||||
CalEventMsg lmsg ->
|
||||
let
|
||||
( cm, cc, cs ) =
|
||||
Comp.CalEventInput.update flags
|
||||
tz
|
||||
model.schedule
|
||||
lmsg
|
||||
model.scheduleModel
|
||||
|
@ -20,6 +20,7 @@ import Comp.MenuBar as MB
|
||||
import Comp.PeriodicQueryTaskForm
|
||||
import Comp.PeriodicQueryTaskList
|
||||
import Data.Flags exposing (Flags)
|
||||
import Data.TimeZone exposing (TimeZone)
|
||||
import Data.UiSettings exposing (UiSettings)
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
@ -81,8 +82,8 @@ init flags =
|
||||
--- Update
|
||||
|
||||
|
||||
update : Flags -> Msg -> Model -> ( Model, Cmd Msg, Sub Msg )
|
||||
update flags msg model =
|
||||
update : Flags -> TimeZone -> Msg -> Model -> ( Model, Cmd Msg, Sub Msg )
|
||||
update flags tz msg model =
|
||||
case msg of
|
||||
GetDataResp (Ok items) ->
|
||||
( { model
|
||||
@ -130,7 +131,7 @@ update flags msg model =
|
||||
let
|
||||
--( mm, action, mc ) =
|
||||
result =
|
||||
Comp.PeriodicQueryTaskForm.update flags lm dm
|
||||
Comp.PeriodicQueryTaskForm.update flags tz lm dm
|
||||
|
||||
( model_, cmd_ ) =
|
||||
case result.action of
|
||||
|
@ -40,6 +40,7 @@ import Data.Flags exposing (Flags)
|
||||
import Data.FolderOrder
|
||||
import Data.Language exposing (Language)
|
||||
import Data.TagOrder
|
||||
import Data.TimeZone exposing (TimeZone)
|
||||
import Data.UiSettings exposing (UiSettings)
|
||||
import Data.Validated exposing (Validated(..))
|
||||
import Html exposing (..)
|
||||
@ -183,7 +184,7 @@ initWith flags s =
|
||||
|> Maybe.withDefault []
|
||||
|
||||
( nm, _, nc ) =
|
||||
update flags (ConnMsg (Comp.Dropdown.SetSelection imap)) im
|
||||
update flags Data.TimeZone.utc (ConnMsg (Comp.Dropdown.SetSelection imap)) im
|
||||
|
||||
newSchedule =
|
||||
Data.CalEvent.fromEvent s.schedule
|
||||
@ -354,13 +355,14 @@ withValidSettings mkAction model =
|
||||
)
|
||||
|
||||
|
||||
update : Flags -> Msg -> Model -> ( Model, Action, Cmd Msg )
|
||||
update flags msg model =
|
||||
update : Flags -> TimeZone -> Msg -> Model -> ( Model, Action, Cmd Msg )
|
||||
update flags tz msg model =
|
||||
case msg of
|
||||
CalEventMsg lmsg ->
|
||||
let
|
||||
( cm, cc, cs ) =
|
||||
Comp.CalEventInput.update flags
|
||||
tz
|
||||
model.schedule
|
||||
lmsg
|
||||
model.scheduleModel
|
||||
@ -585,8 +587,8 @@ update flags msg model =
|
||||
( a, NoAction, b )
|
||||
in
|
||||
Util.Update.andThen1
|
||||
[ update flags (FolderDropdownMsg opts) >> removeAction
|
||||
, update flags (FolderDropdownMsg (Comp.Dropdown.SetSelection sel)) >> removeAction
|
||||
[ update flags tz (FolderDropdownMsg opts) >> removeAction
|
||||
, update flags tz (FolderDropdownMsg (Comp.Dropdown.SetSelection sel)) >> removeAction
|
||||
]
|
||||
model_
|
||||
|> addNoAction
|
||||
|
@ -21,6 +21,7 @@ import Comp.MenuBar as MB
|
||||
import Comp.ScanMailboxForm
|
||||
import Comp.ScanMailboxList
|
||||
import Data.Flags exposing (Flags)
|
||||
import Data.TimeZone exposing (TimeZone)
|
||||
import Data.UiSettings exposing (UiSettings)
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
@ -82,8 +83,8 @@ init flags =
|
||||
--- Update
|
||||
|
||||
|
||||
update : Flags -> Msg -> Model -> ( Model, Cmd Msg )
|
||||
update flags msg model =
|
||||
update : Flags -> TimeZone -> Msg -> Model -> ( Model, Cmd Msg )
|
||||
update flags tz msg model =
|
||||
case msg of
|
||||
GetDataResp (Ok res) ->
|
||||
( { model
|
||||
@ -127,7 +128,7 @@ update flags msg model =
|
||||
Just dm ->
|
||||
let
|
||||
( mm, action, mc ) =
|
||||
Comp.ScanMailboxForm.update flags lm dm
|
||||
Comp.ScanMailboxForm.update flags tz lm dm
|
||||
|
||||
( model_, cmd_ ) =
|
||||
case action of
|
||||
|
@ -19,6 +19,7 @@ import Api
|
||||
import Api.Model.TagList exposing (TagList)
|
||||
import Comp.BasicSizeField
|
||||
import Comp.ColorTagger
|
||||
import Comp.Dropdown
|
||||
import Comp.FieldListSelect
|
||||
import Comp.FixedDropdown
|
||||
import Comp.IntField
|
||||
@ -32,7 +33,7 @@ import Data.Flags exposing (Flags)
|
||||
import Data.ItemTemplate as IT exposing (ItemTemplate)
|
||||
import Data.Pdf exposing (PdfMode)
|
||||
import Data.TagOrder
|
||||
import Data.TimeZone
|
||||
import Data.TimeZone exposing (TimeZone)
|
||||
import Data.UiSettings exposing (ItemPattern, StoredUiSettings, UiSettings)
|
||||
import Dict exposing (Dict)
|
||||
import Html exposing (..)
|
||||
@ -75,6 +76,7 @@ type alias Model =
|
||||
, powerSearchEnabled : Bool
|
||||
, uiLangModel : Comp.FixedDropdown.Model UiLanguage
|
||||
, uiLang : UiLanguage
|
||||
, timezoneDropdown : Comp.Dropdown.Model String
|
||||
, openTabs : Set String
|
||||
, defaults : UiSettings
|
||||
}
|
||||
@ -170,6 +172,11 @@ initModel flags storedSettings defaults =
|
||||
, uiLang = settings.uiLang
|
||||
, uiLangModel =
|
||||
Comp.FixedDropdown.init Messages.UiLanguage.all
|
||||
, timezoneDropdown =
|
||||
Comp.Dropdown.makeSingleList
|
||||
{ options = Data.TimeZone.listAll
|
||||
, selected = Just (Data.TimeZone.toName settings.timeZone)
|
||||
}
|
||||
, openTabs = Set.empty
|
||||
, defaults = defaults
|
||||
}
|
||||
@ -209,6 +216,7 @@ type Msg
|
||||
| TogglePowerSearch
|
||||
| UiLangMsg (Comp.FixedDropdown.Msg UiLanguage)
|
||||
| PdfModeMsg (Comp.FixedDropdown.Msg PdfMode)
|
||||
| TimeZoneMsg (Comp.Dropdown.Msg String)
|
||||
| ToggleAllTabs
|
||||
| ResetTab AkkordionTab
|
||||
|
||||
@ -599,6 +607,27 @@ update flags sett msg model =
|
||||
in
|
||||
( { nm | openTabs = model.openTabs }, Just newSettings )
|
||||
|
||||
TimeZoneMsg lm ->
|
||||
let
|
||||
( tm, tcmd ) =
|
||||
Comp.Dropdown.update lm model.timezoneDropdown
|
||||
|
||||
tz =
|
||||
if Comp.Dropdown.isDropdownChangeMsg lm then
|
||||
Comp.Dropdown.getSelected tm |> List.head
|
||||
|
||||
else
|
||||
sett.timeZone
|
||||
|
||||
newSett =
|
||||
if sett.timeZone == tz then
|
||||
Nothing
|
||||
|
||||
else
|
||||
Just { sett | timeZone = tz }
|
||||
in
|
||||
( { model | timezoneDropdown = tm }, newSett )
|
||||
|
||||
|
||||
|
||||
--- View2
|
||||
@ -670,6 +699,9 @@ settingFormTabs texts flags _ model =
|
||||
[ i [ class "fa fa-eraser mr-1" ] []
|
||||
, text texts.resetLabel
|
||||
]
|
||||
|
||||
uiSettings =
|
||||
Data.UiSettings.defaults
|
||||
in
|
||||
[ { name = akkordionTabName GeneralTab
|
||||
, title = texts.general
|
||||
@ -695,6 +727,22 @@ settingFormTabs texts flags _ model =
|
||||
model.uiLangModel
|
||||
)
|
||||
]
|
||||
, div [ class "mb-4" ]
|
||||
[ label [ class S.inputLabel ] [ text "Timezone" ]
|
||||
, Html.map TimeZoneMsg
|
||||
(Comp.Dropdown.view2
|
||||
{ makeOption = \s -> { text = s, additional = "" }
|
||||
, placeholder = ""
|
||||
, labelColor = \_ -> \_ -> ""
|
||||
, style = DS.mainStyle
|
||||
}
|
||||
uiSettings
|
||||
model.timezoneDropdown
|
||||
)
|
||||
, span [ class "opacity-75 text-sm" ]
|
||||
[ text "Used to format date-time values."
|
||||
]
|
||||
]
|
||||
]
|
||||
}
|
||||
, { name = akkordionTabName SearchTab
|
||||
|
Reference in New Issue
Block a user