mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-02-15 20:33:26 +00:00
Use share ui settings
This commit is contained in:
parent
1ca64f09d1
commit
3710f525d1
@ -22,6 +22,7 @@ module Api exposing
|
||||
, changeFolderName
|
||||
, changePassword
|
||||
, checkCalEvent
|
||||
, clientSettingsShare
|
||||
, confirmMultiple
|
||||
, confirmOtp
|
||||
, createChannel
|
||||
@ -2820,6 +2821,23 @@ itemDetailShare flags token itemId receive =
|
||||
}
|
||||
|
||||
|
||||
clientSettingsShare : Flags -> String -> (Result Http.Error UiSettings -> msg) -> Cmd msg
|
||||
clientSettingsShare flags token receive =
|
||||
let
|
||||
defaults =
|
||||
Data.UiSettings.defaults
|
||||
|
||||
decoder =
|
||||
JsonDecode.map (\s -> Data.UiSettings.merge s defaults)
|
||||
Data.UiSettings.storedUiSettingsDecoder
|
||||
in
|
||||
Http2.shareGet
|
||||
{ url = flags.config.baseUrl ++ "/api/v1/share/clientSettings/webClient"
|
||||
, token = token
|
||||
, expect = Http.expectJson receive decoder
|
||||
}
|
||||
|
||||
|
||||
shareSendMail :
|
||||
Flags
|
||||
-> { conn : String, mail : SimpleShareMail }
|
||||
|
@ -18,6 +18,7 @@ import Comp.SearchMenu
|
||||
import Comp.SharePasswordForm
|
||||
import Data.Flags exposing (Flags)
|
||||
import Data.ItemArrange exposing (ItemArrange)
|
||||
import Data.UiSettings exposing (UiSettings)
|
||||
import Http
|
||||
import Page.Search.Data exposing (Msg(..))
|
||||
import Set exposing (Set)
|
||||
@ -53,6 +54,7 @@ type alias Model =
|
||||
, initialized : Bool
|
||||
, contentSearch : Maybe String
|
||||
, searchMode : SearchBarMode
|
||||
, uiSettings : UiSettings
|
||||
, viewMode :
|
||||
{ menuOpen : Bool
|
||||
, showGroups : Bool
|
||||
@ -75,6 +77,7 @@ emptyModel flags =
|
||||
, initialized = False
|
||||
, contentSearch = Nothing
|
||||
, searchMode = SearchBarContent
|
||||
, uiSettings = Data.UiSettings.defaults
|
||||
, viewMode =
|
||||
{ menuOpen = False
|
||||
, showGroups = True
|
||||
@ -107,6 +110,7 @@ type Msg
|
||||
= VerifyResp (Result Http.Error ShareVerifyResult)
|
||||
| SearchResp (Result Http.Error ItemLightList)
|
||||
| StatsResp Bool (Result Http.Error SearchStats)
|
||||
| UiSettingsResp (Result Http.Error UiSettings)
|
||||
| PasswordMsg Comp.SharePasswordForm.Msg
|
||||
| SearchMenuMsg Comp.SearchMenu.Msg
|
||||
| PowerSearchMsg Comp.PowerSearchInput.Msg
|
||||
|
@ -10,7 +10,6 @@ module Page.Share.Sidebar exposing (..)
|
||||
import Comp.SearchMenu
|
||||
import Comp.Tabs
|
||||
import Data.Flags exposing (Flags)
|
||||
import Data.UiSettings exposing (UiSettings)
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
import Messages.Page.Share exposing (Texts)
|
||||
@ -18,8 +17,8 @@ import Page.Share.Data exposing (Model, Msg(..))
|
||||
import Util.ItemDragDrop
|
||||
|
||||
|
||||
view : Texts -> Flags -> UiSettings -> Model -> Html Msg
|
||||
view texts flags settings model =
|
||||
view : Texts -> Flags -> Model -> Html Msg
|
||||
view texts flags model =
|
||||
let
|
||||
hideTrashTab tab default =
|
||||
case tab of
|
||||
@ -41,7 +40,7 @@ view texts flags settings model =
|
||||
ddDummy
|
||||
flags
|
||||
searchMenuCfg
|
||||
settings
|
||||
model.uiSettings
|
||||
model.searchMenuModel
|
||||
)
|
||||
]
|
||||
|
@ -43,7 +43,10 @@ update flags settings shareId msg model =
|
||||
, verifyResult = res
|
||||
, searchInProgress = True
|
||||
}
|
||||
, makeSearchCmd flags True model
|
||||
, Cmd.batch
|
||||
[ makeSearchCmd flags True model
|
||||
, Api.clientSettingsShare flags res.token UiSettingsResp
|
||||
]
|
||||
)
|
||||
|
||||
else if res.passwordRequired then
|
||||
@ -242,6 +245,12 @@ update flags settings shareId msg model =
|
||||
in
|
||||
noSub ( { model | viewMode = next }, Cmd.none )
|
||||
|
||||
UiSettingsResp (Ok s) ->
|
||||
noSub ( { model | uiSettings = s }, Cmd.none )
|
||||
|
||||
UiSettingsResp (Err _) ->
|
||||
noSub ( model, Cmd.none )
|
||||
|
||||
|
||||
noSub : ( Model, Cmd Msg ) -> UpdateResult
|
||||
noSub ( m, c ) =
|
||||
|
@ -11,11 +11,9 @@ import Api.Model.VersionInfo exposing (VersionInfo)
|
||||
import Comp.Basic as B
|
||||
import Comp.SharePasswordForm
|
||||
import Data.Flags exposing (Flags)
|
||||
import Data.Items
|
||||
import Data.UiSettings exposing (UiSettings)
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
import Html.Events exposing (onInput, onSubmit)
|
||||
import Messages.Page.Share exposing (Texts)
|
||||
import Page.Share.Data exposing (..)
|
||||
import Page.Share.Menubar as Menubar
|
||||
@ -25,19 +23,19 @@ import Styles as S
|
||||
|
||||
|
||||
viewSidebar : Texts -> Bool -> Flags -> UiSettings -> Model -> Html Msg
|
||||
viewSidebar texts visible flags settings model =
|
||||
viewSidebar texts visible flags _ model =
|
||||
div
|
||||
[ id "sidebar"
|
||||
, class S.sidebar
|
||||
, class S.sidebarBg
|
||||
, classList [ ( "hidden", not visible || model.mode /= ModeShare ) ]
|
||||
]
|
||||
[ Sidebar.view texts flags settings model
|
||||
[ Sidebar.view texts flags model
|
||||
]
|
||||
|
||||
|
||||
viewContent : Texts -> Flags -> VersionInfo -> UiSettings -> String -> Model -> Html Msg
|
||||
viewContent texts flags versionInfo uiSettings shareId model =
|
||||
viewContent texts flags versionInfo _ shareId model =
|
||||
case model.mode of
|
||||
ModeInitial ->
|
||||
div
|
||||
@ -60,15 +58,15 @@ viewContent texts flags versionInfo uiSettings shareId model =
|
||||
passwordContent texts flags versionInfo model
|
||||
|
||||
ModeShare ->
|
||||
mainContent texts flags uiSettings shareId model
|
||||
mainContent texts flags shareId model
|
||||
|
||||
|
||||
|
||||
--- Helpers
|
||||
|
||||
|
||||
mainContent : Texts -> Flags -> UiSettings -> String -> Model -> Html Msg
|
||||
mainContent texts flags settings shareId model =
|
||||
mainContent : Texts -> Flags -> String -> Model -> Html Msg
|
||||
mainContent texts flags shareId model =
|
||||
div
|
||||
[ id "content"
|
||||
, class "h-full flex flex-col"
|
||||
@ -82,7 +80,7 @@ mainContent texts flags settings shareId model =
|
||||
]
|
||||
, Menubar.view texts flags model
|
||||
, errorMessage texts model
|
||||
, Results.view texts settings flags shareId model
|
||||
, Results.view texts model.uiSettings flags shareId model
|
||||
]
|
||||
|
||||
|
||||
|
@ -14,6 +14,7 @@ import Api.Model.ShareVerifyResult exposing (ShareVerifyResult)
|
||||
import Comp.SharePasswordForm
|
||||
import Comp.UrlCopy
|
||||
import Data.Flags exposing (Flags)
|
||||
import Data.UiSettings exposing (UiSettings)
|
||||
import Http
|
||||
|
||||
|
||||
@ -37,12 +38,14 @@ type alias Model =
|
||||
, pageError : PageError
|
||||
, attachMenuOpen : Bool
|
||||
, visibleAttach : Int
|
||||
, uiSettings : UiSettings
|
||||
}
|
||||
|
||||
|
||||
type Msg
|
||||
= VerifyResp (Result Http.Error ShareVerifyResult)
|
||||
| GetItemResp (Result Http.Error ItemDetail)
|
||||
| UiSettingsResp (Result Http.Error UiSettings)
|
||||
| PasswordMsg Comp.SharePasswordForm.Msg
|
||||
| SelectActiveAttachment Int
|
||||
| ToggleSelectAttach
|
||||
@ -58,6 +61,7 @@ emptyModel vm =
|
||||
, pageError = PageErrorNone
|
||||
, attachMenuOpen = False
|
||||
, visibleAttach = 0
|
||||
, uiSettings = Data.UiSettings.defaults
|
||||
}
|
||||
|
||||
|
||||
|
@ -25,7 +25,10 @@ update shareId itemId flags msg model =
|
||||
, viewMode = ViewLoading
|
||||
, verifyResult = res
|
||||
}
|
||||
, Api.itemDetailShare flags res.token itemId GetItemResp
|
||||
, Cmd.batch
|
||||
[ Api.itemDetailShare flags res.token itemId GetItemResp
|
||||
, Api.clientSettingsShare flags res.token UiSettingsResp
|
||||
]
|
||||
)
|
||||
|
||||
else if res.passwordRequired then
|
||||
@ -93,3 +96,9 @@ update shareId itemId flags msg model =
|
||||
Comp.UrlCopy.update lm
|
||||
in
|
||||
( model, cmd )
|
||||
|
||||
UiSettingsResp (Ok s) ->
|
||||
( { model | uiSettings = s }, Cmd.none )
|
||||
|
||||
UiSettingsResp (Err _) ->
|
||||
( model, Cmd.none )
|
||||
|
@ -16,7 +16,7 @@ import Comp.UrlCopy
|
||||
import Data.Fields
|
||||
import Data.Flags exposing (Flags)
|
||||
import Data.Icons as Icons
|
||||
import Data.ItemTemplate as IT exposing (ItemTemplate)
|
||||
import Data.ItemTemplate as IT
|
||||
import Data.UiSettings exposing (UiSettings)
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
@ -33,7 +33,7 @@ import Util.String
|
||||
|
||||
|
||||
viewSidebar : Texts -> Bool -> Flags -> UiSettings -> String -> String -> Model -> Html Msg
|
||||
viewSidebar texts visible flags settings shareId itemId model =
|
||||
viewSidebar texts visible flags _ shareId itemId model =
|
||||
div
|
||||
[ id "sidebar"
|
||||
, classList [ ( "hidden", not visible || model.viewMode /= ViewNormal ) ]
|
||||
@ -103,6 +103,7 @@ itemData texts flags model shareId itemId =
|
||||
div
|
||||
[ class "flex ml-2 mt-1 font-semibold hover:opacity-75"
|
||||
, class S.basicLabel
|
||||
, class (Data.UiSettings.tagColorString2 tag model.uiSettings)
|
||||
]
|
||||
[ i [ class "fa fa-tag mr-2" ] []
|
||||
, text tag.name
|
||||
|
Loading…
Reference in New Issue
Block a user