mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-23 10:58:26 +00:00
Select item in detail view
This commit is contained in:
@ -15,7 +15,9 @@ import App.Data exposing (..)
|
||||
import Browser exposing (UrlRequest(..))
|
||||
import Browser.Navigation as Nav
|
||||
import Data.AppEvent exposing (AppEvent(..))
|
||||
import Data.Environment as Env
|
||||
import Data.Flags
|
||||
import Data.ItemIds exposing (ItemIds)
|
||||
import Data.ServerEvent exposing (ServerEvent(..))
|
||||
import Data.UiSettings exposing (UiSettings)
|
||||
import Data.UiTheme
|
||||
@ -346,6 +348,15 @@ updateWithSub msg model =
|
||||
)
|
||||
|
||||
|
||||
modelEnv : Model -> Env.Update
|
||||
modelEnv model =
|
||||
{ key = model.key
|
||||
, selectedItems = model.selectedItems
|
||||
, flags = model.flags
|
||||
, settings = model.uiSettings
|
||||
}
|
||||
|
||||
|
||||
applyClientSettings : Messages -> Model -> UiSettings -> ( Model, Cmd Msg, Sub Msg )
|
||||
applyClientSettings texts model settings =
|
||||
let
|
||||
@ -368,6 +379,18 @@ applyClientSettings texts model settings =
|
||||
{ model | uiSettings = settings }
|
||||
|
||||
|
||||
applySelectionChange : Messages -> Model -> ItemIds -> ( Model, Cmd Msg, Sub Msg )
|
||||
applySelectionChange texts model newSelection =
|
||||
if model.selectedItems == newSelection then
|
||||
( { model | selectedItems = newSelection }, Cmd.none, Sub.none )
|
||||
|
||||
else
|
||||
Util.Update.andThen2
|
||||
[ updateSearch texts Page.Search.Data.ItemSelectionChanged
|
||||
]
|
||||
{ model | selectedItems = newSelection }
|
||||
|
||||
|
||||
updateDashboard : Messages -> Page.Dashboard.Data.Msg -> Model -> ( Model, Cmd Msg, Sub Msg )
|
||||
updateDashboard texts lmsg model =
|
||||
let
|
||||
@ -427,17 +450,16 @@ updateItemDetail texts lmsg model =
|
||||
|
||||
result =
|
||||
Page.ItemDetail.Update.update
|
||||
model.key
|
||||
model.flags
|
||||
inav
|
||||
model.uiSettings
|
||||
(modelEnv model)
|
||||
lmsg
|
||||
model.itemDetailModel
|
||||
|
||||
model_ =
|
||||
{ model
|
||||
| itemDetailModel = result.model
|
||||
}
|
||||
( model_, cmd_, sub_ ) =
|
||||
applySelectionChange
|
||||
texts
|
||||
{ model | itemDetailModel = result.model }
|
||||
result.selectedItems
|
||||
|
||||
( hm, hc, hs ) =
|
||||
updateSearch texts (Page.Search.Data.SetLinkTarget result.linkTarget) model_
|
||||
@ -451,8 +473,8 @@ updateItemDetail texts lmsg model =
|
||||
( hm, hc, hs )
|
||||
in
|
||||
( hm1
|
||||
, Cmd.batch [ Cmd.map ItemDetailMsg result.cmd, hc, hc1 ]
|
||||
, Sub.batch [ Sub.map ItemDetailMsg result.sub, hs, hs1 ]
|
||||
, Cmd.batch [ Cmd.map ItemDetailMsg result.cmd, hc, hc1, cmd_ ]
|
||||
, Sub.batch [ Sub.map ItemDetailMsg result.sub, hs, hs1, sub_ ]
|
||||
)
|
||||
|
||||
|
||||
@ -576,7 +598,7 @@ updateLogin lmsg model =
|
||||
updateSearch : Messages -> Page.Search.Data.Msg -> Model -> ( Model, Cmd Msg, Sub Msg )
|
||||
updateSearch texts lmsg model =
|
||||
let
|
||||
( mid, bmId ) =
|
||||
( lastViewItemId, bookmarkId ) =
|
||||
case model.page of
|
||||
SearchPage bId ->
|
||||
( Util.Maybe.fromString model.itemDetailModel.detail.item.id, bId )
|
||||
@ -585,19 +607,10 @@ updateSearch texts lmsg model =
|
||||
( Nothing, Nothing )
|
||||
|
||||
env =
|
||||
{ bookmarkId = bmId
|
||||
, lastViewedItemId = mid
|
||||
, key = model.key
|
||||
, selectedItems = model.selectedItems
|
||||
, flags = model.flags
|
||||
, settings = model.uiSettings
|
||||
}
|
||||
modelEnv model
|
||||
|
||||
result =
|
||||
Page.Search.Update.update texts.search env lmsg model.searchModel
|
||||
|
||||
model_ =
|
||||
{ model | searchModel = result.model, selectedItems = result.selectedItems }
|
||||
Page.Search.Update.update texts.search bookmarkId lastViewItemId env lmsg model.searchModel
|
||||
|
||||
lc =
|
||||
case result.appEvent of
|
||||
@ -606,15 +619,13 @@ updateSearch texts lmsg model =
|
||||
|
||||
AppNothing ->
|
||||
Cmd.none
|
||||
|
||||
( model_, cmd_, sub_ ) =
|
||||
applySelectionChange texts { model | searchModel = result.model } result.selectedItems
|
||||
in
|
||||
( model_
|
||||
, Cmd.batch
|
||||
[ Cmd.map SearchMsg result.cmd
|
||||
, lc
|
||||
]
|
||||
, Sub.batch
|
||||
[ Sub.map SearchMsg result.sub
|
||||
]
|
||||
, Cmd.batch [ Cmd.map SearchMsg result.cmd, lc, cmd_ ]
|
||||
, Sub.batch [ Sub.map SearchMsg result.sub, sub_ ]
|
||||
)
|
||||
|
||||
|
||||
|
@ -10,6 +10,7 @@ module App.View2 exposing (view)
|
||||
import Api.Model.AuthResult exposing (AuthResult)
|
||||
import App.Data exposing (..)
|
||||
import Comp.Basic as B
|
||||
import Data.Environment as Env
|
||||
import Data.Flags
|
||||
import Data.Icons as Icons
|
||||
import Data.UiSettings
|
||||
@ -485,6 +486,15 @@ dropdownMenu =
|
||||
" absolute right-0 bg-white dark:bg-slate-800 border dark:border-slate-700 dark:text-slate-300 shadow-lg opacity-1 transition duration-200 min-w-max "
|
||||
|
||||
|
||||
modelEnv : Model -> Env.View
|
||||
modelEnv model =
|
||||
{ sidebarVisible = model.sidebarVisible
|
||||
, flags = model.flags
|
||||
, settings = model.uiSettings
|
||||
, selectedItems = model.selectedItems
|
||||
}
|
||||
|
||||
|
||||
viewDashboard : Messages -> Model -> List (Html Msg)
|
||||
viewDashboard texts model =
|
||||
[ Html.map DashboardMsg
|
||||
@ -551,11 +561,7 @@ viewSearch : Messages -> Maybe String -> Model -> List (Html Msg)
|
||||
viewSearch texts bmId model =
|
||||
let
|
||||
env =
|
||||
{ sidebarVisible = model.sidebarVisible
|
||||
, flags = model.flags
|
||||
, settings = model.uiSettings
|
||||
, selectedItems = model.selectedItems
|
||||
}
|
||||
modelEnv model
|
||||
in
|
||||
[ Html.map SearchMsg
|
||||
(Search.viewSidebar texts.search
|
||||
@ -690,19 +696,19 @@ viewItemDetail texts id model =
|
||||
let
|
||||
inav =
|
||||
Page.Search.Data.itemNav id model.searchModel
|
||||
|
||||
env =
|
||||
modelEnv model
|
||||
in
|
||||
[ Html.map ItemDetailMsg
|
||||
(ItemDetail.viewSidebar texts.itemDetail
|
||||
model.sidebarVisible
|
||||
model.flags
|
||||
model.uiSettings
|
||||
env
|
||||
model.itemDetailModel
|
||||
)
|
||||
, Html.map ItemDetailMsg
|
||||
(ItemDetail.viewContent texts.itemDetail
|
||||
inav
|
||||
model.flags
|
||||
model.uiSettings
|
||||
env
|
||||
model.itemDetailModel
|
||||
)
|
||||
]
|
||||
|
Reference in New Issue
Block a user