Switch to search by clicking on correspondent/concerned in detail

This commit is contained in:
Eike Kettner 2020-11-14 12:57:38 +01:00
parent cf578a88d3
commit fe8c122968
8 changed files with 364 additions and 308 deletions

View File

@ -7,6 +7,7 @@ import Api
import App.Data exposing (..) import App.Data exposing (..)
import Browser exposing (UrlRequest(..)) import Browser exposing (UrlRequest(..))
import Browser.Navigation as Nav import Browser.Navigation as Nav
import Comp.LinkTarget
import Data.Flags import Data.Flags
import Page exposing (Page(..)) import Page exposing (Page(..))
import Page.CollectiveSettings.Data import Page.CollectiveSettings.Data
@ -193,7 +194,7 @@ updateItemDetail lmsg model =
inav = inav =
Page.Home.Data.itemNav model.itemDetailModel.detail.item.id model.homeModel Page.Home.Data.itemNav model.itemDetailModel.detail.item.id model.homeModel
( lm, lc, ls ) = result =
Page.ItemDetail.Update.update Page.ItemDetail.Update.update
model.key model.key
model.flags model.flags
@ -201,12 +202,18 @@ updateItemDetail lmsg model =
model.uiSettings model.uiSettings
lmsg lmsg
model.itemDetailModel model.itemDetailModel
model_ =
{ model
| itemDetailModel = result.model
}
( hm, hc, hs ) =
updateHome (Page.Home.Data.SetLinkTarget result.linkTarget) model_
in in
( { model ( hm
| itemDetailModel = lm , Cmd.batch [ Cmd.map ItemDetailMsg result.cmd, hc ]
} , Sub.batch [ Sub.map ItemDetailMsg result.sub, hs ]
, Cmd.map ItemDetailMsg lc
, Sub.map ItemDetailMsg ls
) )

View File

@ -6,7 +6,7 @@ module Comp.ItemDetail exposing
) )
import Browser.Navigation as Nav import Browser.Navigation as Nav
import Comp.ItemDetail.Model exposing (Msg(..)) import Comp.ItemDetail.Model exposing (Msg(..), UpdateResult)
import Comp.ItemDetail.Update import Comp.ItemDetail.Update
import Comp.ItemDetail.View exposing (..) import Comp.ItemDetail.View exposing (..)
import Data.Flags exposing (Flags) import Data.Flags exposing (Flags)
@ -25,7 +25,7 @@ emptyModel =
Comp.ItemDetail.Model.emptyModel Comp.ItemDetail.Model.emptyModel
update : Nav.Key -> Flags -> ItemNav -> UiSettings -> Msg -> Model -> ( Model, Cmd Msg, Sub Msg ) update : Nav.Key -> Flags -> ItemNav -> UiSettings -> Msg -> Model -> UpdateResult
update = update =
Comp.ItemDetail.Update.update Comp.ItemDetail.Update.update

View File

@ -4,8 +4,12 @@ module Comp.ItemDetail.Model exposing
, Msg(..) , Msg(..)
, NotesField(..) , NotesField(..)
, SaveNameState(..) , SaveNameState(..)
, UpdateResult
, emptyModel , emptyModel
, isEditNotes , isEditNotes
, resultModel
, resultModelCmd
, resultModelCmdSub
) )
import Api.Model.BasicResult exposing (BasicResult) import Api.Model.BasicResult exposing (BasicResult)
@ -281,3 +285,26 @@ type SaveNameState
= Saving = Saving
| SaveSuccess | SaveSuccess
| SaveFailed | SaveFailed
type alias UpdateResult =
{ model : Model
, cmd : Cmd Msg
, sub : Sub Msg
, linkTarget : LinkTarget
}
resultModel : Model -> UpdateResult
resultModel model =
UpdateResult model Cmd.none Sub.none Comp.LinkTarget.LinkNone
resultModelCmd : ( Model, Cmd Msg ) -> UpdateResult
resultModelCmd ( model, cmd ) =
UpdateResult model cmd Sub.none Comp.LinkTarget.LinkNone
resultModelCmdSub : ( Model, Cmd Msg, Sub Msg ) -> UpdateResult
resultModelCmdSub ( model, cmd, sub ) =
UpdateResult model cmd sub Comp.LinkTarget.LinkNone

File diff suppressed because it is too large Load Diff

View File

@ -25,6 +25,7 @@ import Comp.FixedDropdown
import Comp.ItemCardList import Comp.ItemCardList
import Comp.ItemDetail.EditMenu exposing (SaveNameState(..)) import Comp.ItemDetail.EditMenu exposing (SaveNameState(..))
import Comp.ItemDetail.FormChange exposing (FormChange) import Comp.ItemDetail.FormChange exposing (FormChange)
import Comp.LinkTarget exposing (LinkTarget)
import Comp.SearchMenu import Comp.SearchMenu
import Comp.YesNoDimmer import Comp.YesNoDimmer
import Data.Flags exposing (Flags) import Data.Flags exposing (Flags)
@ -174,6 +175,7 @@ type Msg
| ReplaceChangedItemsResp (Result Http.Error ItemLightList) | ReplaceChangedItemsResp (Result Http.Error ItemLightList)
| DeleteAllResp (Result Http.Error BasicResult) | DeleteAllResp (Result Http.Error BasicResult)
| UiSettingsUpdated | UiSettingsUpdated
| SetLinkTarget LinkTarget
type SearchType type SearchType

View File

@ -10,7 +10,7 @@ import Comp.ItemCard
import Comp.ItemCardList import Comp.ItemCardList
import Comp.ItemDetail.EditMenu exposing (SaveNameState(..)) import Comp.ItemDetail.EditMenu exposing (SaveNameState(..))
import Comp.ItemDetail.FormChange exposing (FormChange(..)) import Comp.ItemDetail.FormChange exposing (FormChange(..))
import Comp.LinkTarget import Comp.LinkTarget exposing (LinkTarget)
import Comp.SearchMenu import Comp.SearchMenu
import Comp.YesNoDimmer import Comp.YesNoDimmer
import Data.Flags exposing (Flags) import Data.Flags exposing (Flags)
@ -88,6 +88,14 @@ update mId key flags settings msg model =
, s2 , s2
) )
SetLinkTarget lt ->
case linkTargetMsg lt of
Just m ->
update mId key flags settings m model
Nothing ->
( model, Cmd.none, Sub.none )
ItemCardListMsg m -> ItemCardListMsg m ->
let let
result = result =
@ -97,24 +105,8 @@ update mId key flags settings msg model =
model.itemListModel model.itemListModel
searchMsg = searchMsg =
case result.linkTarget of Maybe.map Util.Update.cmdUnit (linkTargetMsg result.linkTarget)
Comp.LinkTarget.LinkNone -> |> Maybe.withDefault Cmd.none
Cmd.none
Comp.LinkTarget.LinkCorrOrg id ->
Util.Update.cmdUnit (SearchMenuMsg (Comp.SearchMenu.SetCorrOrg id))
Comp.LinkTarget.LinkCorrPerson id ->
Util.Update.cmdUnit (SearchMenuMsg (Comp.SearchMenu.SetCorrPerson id))
Comp.LinkTarget.LinkConcPerson id ->
Util.Update.cmdUnit (SearchMenuMsg (Comp.SearchMenu.SetConcPerson id))
Comp.LinkTarget.LinkConcEquip id ->
Util.Update.cmdUnit (SearchMenuMsg (Comp.SearchMenu.SetConcEquip id))
Comp.LinkTarget.LinkFolder id ->
Util.Update.cmdUnit (SearchMenuMsg (Comp.SearchMenu.SetFolder id))
nextView = nextView =
case ( model.viewMode, result.selection ) of case ( model.viewMode, result.selection ) of
@ -665,6 +657,28 @@ doSearch flags settings scroll model =
) )
linkTargetMsg : LinkTarget -> Maybe Msg
linkTargetMsg linkTarget =
case linkTarget of
Comp.LinkTarget.LinkNone ->
Nothing
Comp.LinkTarget.LinkCorrOrg id ->
Just <| SearchMenuMsg (Comp.SearchMenu.SetCorrOrg id)
Comp.LinkTarget.LinkCorrPerson id ->
Just <| SearchMenuMsg (Comp.SearchMenu.SetCorrPerson id)
Comp.LinkTarget.LinkConcPerson id ->
Just <| SearchMenuMsg (Comp.SearchMenu.SetConcPerson id)
Comp.LinkTarget.LinkConcEquip id ->
Just <| SearchMenuMsg (Comp.SearchMenu.SetConcEquip id)
Comp.LinkTarget.LinkFolder id ->
Just <| SearchMenuMsg (Comp.SearchMenu.SetFolder id)
doSearchMore : Flags -> UiSettings -> Model -> ( Model, Cmd Msg ) doSearchMore : Flags -> UiSettings -> Model -> ( Model, Cmd Msg )
doSearchMore flags settings model = doSearchMore flags settings model =
let let

View File

@ -1,9 +1,15 @@
module Page.ItemDetail.Data exposing (Model, Msg(..), emptyModel) module Page.ItemDetail.Data exposing
( Model
, Msg(..)
, UpdateResult
, emptyModel
)
import Api.Model.ItemDetail exposing (ItemDetail) import Api.Model.ItemDetail exposing (ItemDetail)
import Browser.Dom as Dom import Browser.Dom as Dom
import Comp.ItemDetail import Comp.ItemDetail
import Comp.ItemDetail.Model import Comp.ItemDetail.Model
import Comp.LinkTarget exposing (LinkTarget)
import Http import Http
@ -24,3 +30,11 @@ type Msg
| ItemResp (Result Http.Error ItemDetail) | ItemResp (Result Http.Error ItemDetail)
| ScrollResult (Result Dom.Error ()) | ScrollResult (Result Dom.Error ())
| UiSettingsUpdated | UiSettingsUpdated
type alias UpdateResult =
{ model : Model
, cmd : Cmd Msg
, sub : Sub Msg
, linkTarget : LinkTarget
}

View File

@ -4,20 +4,22 @@ import Api
import Browser.Navigation as Nav import Browser.Navigation as Nav
import Comp.ItemDetail import Comp.ItemDetail
import Comp.ItemDetail.Model import Comp.ItemDetail.Model
import Comp.LinkTarget
import Data.Flags exposing (Flags) import Data.Flags exposing (Flags)
import Data.ItemNav exposing (ItemNav) import Data.ItemNav exposing (ItemNav)
import Data.UiSettings exposing (UiSettings) import Data.UiSettings exposing (UiSettings)
import Page.ItemDetail.Data exposing (Model, Msg(..)) import Page exposing (Page(..))
import Page.ItemDetail.Data exposing (Model, Msg(..), UpdateResult)
import Scroll import Scroll
import Task import Task
update : Nav.Key -> Flags -> ItemNav -> UiSettings -> Msg -> Model -> ( Model, Cmd Msg, Sub Msg ) update : Nav.Key -> Flags -> ItemNav -> UiSettings -> Msg -> Model -> UpdateResult
update key flags inav settings msg model = update key flags inav settings msg model =
case msg of case msg of
Init id -> Init id ->
let let
( lm, lc, ls ) = result =
Comp.ItemDetail.update key Comp.ItemDetail.update key
flags flags
inav inav
@ -28,24 +30,35 @@ update key flags inav settings msg model =
task = task =
Scroll.scroll "main-content" 0 0 0 0 Scroll.scroll "main-content" 0 0 0 0
in in
( { model | detail = lm } { model = { model | detail = result.model }
, Cmd.batch , cmd =
[ Api.itemDetail flags id ItemResp Cmd.batch
, Cmd.map ItemDetailMsg lc [ Api.itemDetail flags id ItemResp
, Task.attempt ScrollResult task , Cmd.map ItemDetailMsg result.cmd
] , Task.attempt ScrollResult task
, Sub.map ItemDetailMsg ls ]
) , sub = Sub.map ItemDetailMsg result.sub
, linkTarget = result.linkTarget
}
ItemDetailMsg lmsg -> ItemDetailMsg lmsg ->
let let
( lm, lc, ls ) = result =
Comp.ItemDetail.update key flags inav settings lmsg model.detail Comp.ItemDetail.update key flags inav settings lmsg model.detail
pageSwitch =
case result.linkTarget of
Comp.LinkTarget.LinkNone ->
Cmd.none
_ ->
Page.set key HomePage
in in
( { model | detail = lm } { model = { model | detail = result.model }
, Cmd.map ItemDetailMsg lc , cmd = Cmd.batch [ pageSwitch, Cmd.map ItemDetailMsg result.cmd ]
, Sub.map ItemDetailMsg ls , sub = Sub.map ItemDetailMsg result.sub
) , linkTarget = result.linkTarget
}
ItemResp (Ok item) -> ItemResp (Ok item) ->
let let
@ -55,10 +68,10 @@ update key flags inav settings msg model =
update key flags inav settings (ItemDetailMsg lmsg) model update key flags inav settings (ItemDetailMsg lmsg) model
ItemResp (Err _) -> ItemResp (Err _) ->
( model, Cmd.none, Sub.none ) UpdateResult model Cmd.none Sub.none Comp.LinkTarget.LinkNone
ScrollResult _ -> ScrollResult _ ->
( model, Cmd.none, Sub.none ) UpdateResult model Cmd.none Sub.none Comp.LinkTarget.LinkNone
UiSettingsUpdated -> UiSettingsUpdated ->
let let