Select item in detail view

This commit is contained in:
eikek 2022-02-27 22:31:17 +01:00
parent adcfe10460
commit 834ce7773c
17 changed files with 449 additions and 340 deletions

View File

@ -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_ ]
)

View File

@ -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
)
]

View File

@ -12,10 +12,10 @@ module Comp.ItemDetail exposing
, view2
)
import Browser.Navigation as Nav
import Comp.ItemDetail.Model exposing (Msg(..), UpdateResult)
import Comp.ItemDetail.Update
import Comp.ItemDetail.View2
import Data.Environment as Env
import Data.Flags exposing (Flags)
import Data.ItemNav exposing (ItemNav)
import Data.UiSettings exposing (UiSettings)
@ -33,11 +33,11 @@ emptyModel =
Comp.ItemDetail.Model.emptyModel
update : Nav.Key -> Flags -> ItemNav -> UiSettings -> Msg -> Model -> UpdateResult
update : ItemNav -> Env.Update -> Msg -> Model -> UpdateResult
update =
Comp.ItemDetail.Update.update
view2 : Texts -> Flags -> ItemNav -> UiSettings -> Model -> Html Msg
view2 : Texts -> ItemNav -> Env.View -> Model -> Html Msg
view2 =
Comp.ItemDetail.View2.view

View File

@ -57,6 +57,7 @@ import Comp.SimpleTextInput
import Comp.TagDropdown
import Data.Direction exposing (Direction)
import Data.Fields exposing (Field)
import Data.ItemIds exposing (ItemIdChange)
import DatePicker exposing (DatePicker)
import Dict exposing (Dict)
import File exposing (File)
@ -367,6 +368,7 @@ type Msg
| ToggleShowQrAttach String
| PrintElement String
| SetNameMsg Comp.SimpleTextInput.Msg
| ToggleSelectItem
type SaveNameState
@ -381,22 +383,23 @@ type alias UpdateResult =
, sub : Sub Msg
, linkTarget : LinkTarget
, removedItem : Maybe String
, selectionChange : ItemIdChange
}
resultModel : Model -> UpdateResult
resultModel model =
UpdateResult model Cmd.none Sub.none Comp.LinkTarget.LinkNone Nothing
UpdateResult model Cmd.none Sub.none Comp.LinkTarget.LinkNone Nothing Data.ItemIds.noChange
resultModelCmd : ( Model, Cmd Msg ) -> UpdateResult
resultModelCmd ( model, cmd ) =
UpdateResult model cmd Sub.none Comp.LinkTarget.LinkNone Nothing
UpdateResult model cmd Sub.none Comp.LinkTarget.LinkNone Nothing Data.ItemIds.noChange
resultModelCmdSub : ( Model, Cmd Msg, Sub Msg ) -> UpdateResult
resultModelCmdSub ( model, cmd, sub ) =
UpdateResult model cmd sub Comp.LinkTarget.LinkNone Nothing
UpdateResult model cmd sub Comp.LinkTarget.LinkNone Nothing Data.ItemIds.noChange
personMatchesOrg : Model -> Bool

View File

@ -20,7 +20,6 @@ import Api.Model.OptionalDate exposing (OptionalDate)
import Api.Model.OptionalId exposing (OptionalId)
import Api.Model.OptionalText exposing (OptionalText)
import Api.Model.StringList exposing (StringList)
import Browser.Navigation as Nav
import Comp.AttachmentMeta
import Comp.CustomFieldMultiInput
import Comp.DatePicker
@ -58,10 +57,12 @@ import Comp.SimpleTextInput
import Comp.TagDropdown
import Data.CustomFieldChange exposing (CustomFieldChange(..))
import Data.Direction
import Data.Environment as Env
import Data.EquipmentOrder
import Data.Fields exposing (Field)
import Data.Flags exposing (Flags)
import Data.FolderOrder
import Data.ItemIds
import Data.ItemNav exposing (ItemNav)
import Data.PersonOrder
import Data.PersonUse
@ -74,7 +75,6 @@ import Http
import Page exposing (Page(..))
import Ports
import Set exposing (Set)
import Time
import Util.File exposing (makeFileId)
import Util.List
import Util.Maybe
@ -82,8 +82,8 @@ import Util.String
import Util.Tag
update : Nav.Key -> Flags -> ItemNav -> UiSettings -> Msg -> Model -> UpdateResult
update key flags inav settings msg model =
update : ItemNav -> Env.Update -> Msg -> Model -> UpdateResult
update inav env msg model =
case msg of
Init ->
let
@ -91,10 +91,10 @@ update key flags inav settings msg model =
Comp.DatePicker.init
( im, ic ) =
Comp.ItemMail.init flags
Comp.ItemMail.init env.flags
( cm, cc ) =
Comp.CustomFieldMultiInput.init flags
Comp.CustomFieldMultiInput.init env.flags
in
resultModelCmd
( { model
@ -106,30 +106,26 @@ update key flags inav settings msg model =
, customFieldsModel = cm
}
, Cmd.batch
[ getOptions flags
[ getOptions env.flags
, Cmd.map ItemDatePickerMsg dpc
, Cmd.map DueDatePickerMsg dpc
, Cmd.map ItemMailMsg ic
, Cmd.map CustomFieldMsg cc
, Api.getSentMails flags model.item.id SentMailsResp
, Api.getSentMails env.flags model.item.id SentMailsResp
]
)
SetItem item ->
let
res1 =
update key
flags
inav
settings
update inav
env
(TagDropdownMsg (Comp.TagDropdown.setSelected item.tags))
model
res2 =
update key
flags
inav
settings
update inav
env
(DirDropdownMsg
(Comp.Dropdown.SetSelection
(Data.Direction.fromString item.direction
@ -141,10 +137,8 @@ update key flags inav settings msg model =
res1.model
res3 =
update key
flags
inav
settings
update inav
env
(OrgDropdownMsg
(Comp.Dropdown.SetSelection
(item.corrOrg
@ -156,10 +150,8 @@ update key flags inav settings msg model =
res2.model
res4 =
update key
flags
inav
settings
update inav
env
(CorrPersonMsg
(Comp.Dropdown.SetSelection
(item.corrPerson
@ -171,10 +163,8 @@ update key flags inav settings msg model =
res3.model
res5 =
update key
flags
inav
settings
update inav
env
(ConcPersonMsg
(Comp.Dropdown.SetSelection
(item.concPerson
@ -186,10 +176,8 @@ update key flags inav settings msg model =
res4.model
res6 =
update key
flags
inav
settings
update inav
env
(ConcEquipMsg
(Comp.Dropdown.SetSelection
(item.concEquipment
@ -201,13 +189,11 @@ update key flags inav settings msg model =
res5.model
res7 =
update key flags inav settings AddFilesReset res6.model
update inav env AddFilesReset res6.model
res8 =
update key
flags
inav
settings
update inav
env
(FolderDropdownMsg
(Comp.Dropdown.SetSelection
(item.folder
@ -219,16 +205,14 @@ update key flags inav settings msg model =
res7.model
res9 =
update key
flags
inav
settings
update inav
env
(CustomFieldMsg (Comp.CustomFieldMultiInput.setValues item.customfields))
res8.model
proposalCmd =
if item.state == "created" then
Api.getItemProposals flags item.id GetProposalResp
Api.getItemProposals env.flags item.id GetProposalResp
else
Cmd.none
@ -265,11 +249,11 @@ update key flags inav settings msg model =
, res7.cmd
, res8.cmd
, res9.cmd
, getOptions flags
, getOptions env.flags
, proposalCmd
, Api.getSentMails flags item.id SentMailsResp
, Api.getPersons flags "" Data.PersonOrder.NameAsc GetPersonResp
, Cmd.map CustomFieldMsg (Comp.CustomFieldMultiInput.initCmd flags)
, Api.getSentMails env.flags item.id SentMailsResp
, Api.getPersons env.flags "" Data.PersonOrder.NameAsc GetPersonResp
, Cmd.map CustomFieldMsg (Comp.CustomFieldMultiInput.initCmd env.flags)
]
, sub =
Sub.batch
@ -285,6 +269,7 @@ update key flags inav settings msg model =
]
, linkTarget = Comp.LinkTarget.LinkNone
, removedItem = Nothing
, selectionChange = Data.ItemIds.noChange
}
SetActiveAttachment pos ->
@ -322,7 +307,7 @@ update key flags inav settings msg model =
resultModel model
else
resultModelCmd ( model, Api.itemDetail flags model.item.id GetItemResp )
resultModelCmd ( model, Api.itemDetail env.flags model.item.id GetItemResp )
FolderDropdownMsg m ->
let
@ -337,7 +322,7 @@ update key flags inav settings msg model =
save =
if isDropdownChangeMsg m then
setFolder flags newModel idref
setFolder env.flags newModel idref
else
Cmd.none
@ -354,7 +339,7 @@ update key flags inav settings msg model =
save =
if Comp.TagDropdown.isChangeMsg m then
saveTags flags newModel
saveTags env.flags newModel
else
Cmd.none
@ -371,7 +356,7 @@ update key flags inav settings msg model =
save =
if isDropdownChangeMsg m then
setDirection flags newModel
setDirection env.flags newModel
else
Cmd.none
@ -393,7 +378,7 @@ update key flags inav settings msg model =
save =
if isDropdownChangeMsg m then
setCorrOrg flags newModel idref
setCorrOrg env.flags newModel idref
else
Cmd.none
@ -413,7 +398,7 @@ update key flags inav settings msg model =
save =
if isDropdownChangeMsg m then
setCorrPerson flags newModel idref
setCorrPerson env.flags newModel idref
else
Cmd.none
@ -433,7 +418,7 @@ update key flags inav settings msg model =
save =
if isDropdownChangeMsg m then
setConcPerson flags newModel idref
setConcPerson env.flags newModel idref
else
Cmd.none
@ -453,7 +438,7 @@ update key flags inav settings msg model =
save =
if isDropdownChangeMsg m then
setConcEquip flags newModel idref
setConcEquip env.flags newModel idref
else
Cmd.none
@ -468,7 +453,7 @@ update key flags inav settings msg model =
( setter, value, save ) =
case result.change of
Comp.SimpleTextInput.ValueUpdated v ->
( setName flags { model | nameModel = Maybe.withDefault "" v }, v, Saving )
( setName env.flags { model | nameModel = Maybe.withDefault "" v }, v, Saving )
Comp.SimpleTextInput.ValueUnchanged ->
( Cmd.none, Nothing, model.nameState )
@ -478,6 +463,7 @@ update key flags inav settings msg model =
, sub = Sub.map SetNameMsg result.sub
, linkTarget = Comp.LinkTarget.LinkNone
, removedItem = Nothing
, selectionChange = Data.ItemIds.noChange
}
SetNotes str ->
@ -509,22 +495,22 @@ update key flags inav settings msg model =
resultModel model
SaveNotes ->
resultModelCmd ( model, setNotes flags model )
resultModelCmd ( model, setNotes env.flags model )
ConfirmItem ->
let
resetCmds =
resetHiddenFields settings flags model.item.id ResetHiddenMsg
resetHiddenFields env.settings env.flags model.item.id ResetHiddenMsg
in
resultModelCmd
( { model | mobileItemMenuOpen = False }
, Cmd.batch (Api.setConfirmed flags model.item.id SaveResp :: resetCmds)
, Cmd.batch (Api.setConfirmed env.flags model.item.id SaveResp :: resetCmds)
)
UnconfirmItem ->
resultModelCmd
( { model | mobileItemMenuOpen = False }
, Api.setUnconfirmed flags model.item.id SaveResp
, Api.setUnconfirmed env.flags model.item.id SaveResp
)
ItemDatePickerMsg m ->
@ -538,13 +524,13 @@ update key flags inav settings msg model =
newModel =
{ model | itemDatePicker = dp, itemDate = Just (Comp.DatePicker.midOfDay date) }
in
resultModelCmd ( newModel, setDate flags newModel newModel.itemDate )
resultModelCmd ( newModel, setDate env.flags newModel newModel.itemDate )
_ ->
resultModel { model | itemDatePicker = dp }
RemoveDate ->
resultModelCmd ( { model | itemDate = Nothing }, setDate flags model Nothing )
resultModelCmd ( { model | itemDate = Nothing }, setDate env.flags model Nothing )
DueDatePickerMsg m ->
let
@ -557,18 +543,18 @@ update key flags inav settings msg model =
newModel =
{ model | dueDatePicker = dp, dueDate = Just (Comp.DatePicker.midOfDay date) }
in
resultModelCmd ( newModel, setDueDate flags newModel newModel.dueDate )
resultModelCmd ( newModel, setDueDate env.flags newModel newModel.dueDate )
_ ->
resultModel { model | dueDatePicker = dp }
RemoveDueDate ->
resultModelCmd ( { model | dueDate = Nothing }, setDueDate flags model Nothing )
resultModelCmd ( { model | dueDate = Nothing }, setDueDate env.flags model Nothing )
DeleteItemConfirmed ->
let
cmd =
Api.deleteItem flags model.item.id (DeleteResp model.item.id)
Api.deleteItem env.flags model.item.id (DeleteResp model.item.id)
in
resultModelCmd ( { model | itemModal = Nothing }, cmd )
@ -583,22 +569,22 @@ update key flags inav settings msg model =
}
SetCorrOrgSuggestion idname ->
resultModelCmd ( model, setCorrOrg flags model (Just idname) )
resultModelCmd ( model, setCorrOrg env.flags model (Just idname) )
SetCorrPersonSuggestion idname ->
resultModelCmd ( model, setCorrPerson flags model (Just idname) )
resultModelCmd ( model, setCorrPerson env.flags model (Just idname) )
SetConcPersonSuggestion idname ->
resultModelCmd ( model, setConcPerson flags model (Just idname) )
resultModelCmd ( model, setConcPerson env.flags model (Just idname) )
SetConcEquipSuggestion idname ->
resultModelCmd ( model, setConcEquip flags model (Just idname) )
resultModelCmd ( model, setConcEquip env.flags model (Just idname) )
SetItemDateSuggestion date ->
resultModelCmd ( model, setDate flags model (Just date) )
resultModelCmd ( model, setDate env.flags model (Just date) )
SetDueDateSuggestion date ->
resultModelCmd ( model, setDueDate flags model (Just date) )
resultModelCmd ( model, setDueDate env.flags model (Just date) )
GetFolderResp (Ok fs) ->
let
@ -613,7 +599,7 @@ update key flags inav settings msg model =
|> List.map mkIdName
|> Comp.Dropdown.SetOptions
in
update key flags inav settings (FolderDropdownMsg opts) model_
update inav env (FolderDropdownMsg opts) model_
GetFolderResp (Err _) ->
resultModel model
@ -636,7 +622,7 @@ update key flags inav settings msg model =
opts =
Comp.Dropdown.SetOptions orgs.items
in
update key flags inav settings (OrgDropdownMsg opts) model
update inav env (OrgDropdownMsg opts) model
GetOrgResp (Err _) ->
resultModel model
@ -673,18 +659,14 @@ update key flags inav settings msg model =
{ model | allPersons = personDict }
res1 =
update key
flags
inav
settings
update inav
env
(CorrPersonMsg (Comp.Dropdown.SetOptions corrRefs))
model_
res2 =
update key
flags
inav
settings
update inav
env
(ConcPersonMsg (Comp.Dropdown.SetOptions concRefs))
res1.model
in
@ -693,6 +675,7 @@ update key flags inav settings msg model =
, sub = Sub.batch [ res1.sub, res2.sub ]
, linkTarget = Comp.LinkTarget.LinkNone
, removedItem = Nothing
, selectionChange = Data.ItemIds.noChange
}
GetPersonResp (Err _) ->
@ -706,14 +689,14 @@ update key flags inav settings msg model =
equips.items
)
in
update key flags inav settings (ConcEquipMsg opts) model
update inav env (ConcEquipMsg opts) model
GetEquipResp (Err _) ->
resultModel model
SaveResp (Ok res) ->
if res.success then
resultModelCmd ( model, Api.itemDetail flags model.item.id GetItemResp )
resultModelCmd ( model, Api.itemDetail env.flags model.item.id GetItemResp )
else
resultModel model
@ -742,10 +725,10 @@ update key flags inav settings msg model =
result_ =
case inav.next of
Just id ->
resultModelCmd ( model, Page.set key (ItemDetailPage id) )
resultModelCmd ( model, Page.set env.key (ItemDetailPage id) )
Nothing ->
resultModelCmd ( model, Page.set key (SearchPage Nothing) )
resultModelCmd ( model, Page.set env.key (SearchPage Nothing) )
in
{ result_ | removedItem = Just removedId }
@ -756,7 +739,7 @@ update key flags inav settings msg model =
resultModel model
GetItemResp (Ok item) ->
update key flags inav settings (SetItem item) model
update inav env (SetItem item) model
GetItemResp (Err _) ->
resultModel model
@ -770,7 +753,7 @@ update key flags inav settings msg model =
ItemMailMsg m ->
let
( im, ic, fa ) =
Comp.ItemMail.update flags m model.itemMail
Comp.ItemMail.update env.flags m model.itemMail
in
case fa of
Comp.ItemMail.FormNone ->
@ -798,7 +781,7 @@ update key flags inav settings msg model =
( { model | mailSending = True }
, Cmd.batch
[ Cmd.map ItemMailMsg ic
, Api.sendMail flags mail SendMailResp
, Api.sendMail env.flags mail SendMailResp
]
)
@ -850,7 +833,7 @@ update key flags inav settings msg model =
MailSendFailed br.message
}
, if br.success then
Api.itemDetail flags model.item.id GetItemResp
Api.itemDetail env.flags model.item.id GetItemResp
else
Cmd.none
@ -895,7 +878,7 @@ update key flags inav settings msg model =
Nothing ->
let
( am, ac ) =
Comp.AttachmentMeta.init flags id
Comp.AttachmentMeta.init env.flags id
nextMeta =
Dict.insert id am model.attachMeta
@ -925,7 +908,7 @@ update key flags inav settings msg model =
DeleteAttachConfirmed attachId ->
let
cmd =
Api.deleteAttachment flags attachId DeleteAttachResp
Api.deleteAttachment env.flags attachId DeleteAttachResp
in
resultModelCmd ( { model | attachModal = Nothing }, cmd )
@ -934,7 +917,7 @@ update key flags inav settings msg model =
DeleteAttachResp (Ok res) ->
if res.success then
update key flags inav settings ReloadItem model
update inav env ReloadItem model
else
resultModel model
@ -980,7 +963,7 @@ update key flags inav settings msg model =
SelectView svm ->
let
cmd =
Api.deleteAttachments flags svm.ids DeleteAttachResp
Api.deleteAttachments env.flags svm.ids DeleteAttachResp
in
resultModelCmd ( { model | attachModal = Nothing, viewMode = SimpleView }, cmd )
@ -1029,7 +1012,7 @@ update key flags inav settings msg model =
List.map makeFileId model.selectedFiles
uploads =
Cmd.batch (Api.uploadAmend flags model.item.id model.selectedFiles AddFilesUploadResp)
Cmd.batch (Api.uploadAmend env.flags model.item.id model.selectedFiles AddFilesUploadResp)
tracker =
Sub.batch <| List.map (\id -> Http.track id (AddFilesProgress id)) fileids
@ -1112,7 +1095,7 @@ update key flags inav settings msg model =
case result of
Just ( src, trg, _ ) ->
if src /= trg then
Api.moveAttachmentBefore flags
Api.moveAttachmentBefore env.flags
model.item.id
(MoveAttachment src trg)
SaveResp
@ -1130,7 +1113,7 @@ update key flags inav settings msg model =
Just mm ->
let
( mm_, mc_, mv ) =
Comp.DetailEdit.update flags lm mm
Comp.DetailEdit.update env.flags lm mm
( model_, cmd_ ) =
case mv of
@ -1138,7 +1121,7 @@ update key flags inav settings msg model =
( { model | modalEdit = Nothing }, Cmd.none )
Just _ ->
( model, Api.itemDetail flags model.item.id GetItemResp )
( model, Api.itemDetail env.flags model.item.id GetItemResp )
Nothing ->
( { model | modalEdit = Just mm_ }, Cmd.none )
@ -1180,7 +1163,7 @@ update key flags inav settings msg model =
Just oid ->
let
( m, c ) =
Comp.DetailEdit.editOrg flags oid Comp.OrgForm.emptyModel
Comp.DetailEdit.editOrg env.flags oid Comp.OrgForm.emptyModel
in
resultModelCmd ( { model | modalEdit = Just m }, Cmd.map ModalEditMsg c )
@ -1198,7 +1181,7 @@ update key flags inav settings msg model =
Just eid ->
let
( m, c ) =
Comp.DetailEdit.editEquip flags eid Comp.EquipmentForm.emptyModel
Comp.DetailEdit.editEquip env.flags eid Comp.EquipmentForm.emptyModel
in
resultModelCmd ( { model | modalEdit = Just m }, Cmd.map ModalEditMsg c )
@ -1209,7 +1192,7 @@ update key flags inav settings msg model =
let
( pm, pc ) =
Comp.DetailEdit.initCorrPerson
flags
env.flags
model.item.id
Comp.PersonForm.emptyModel
in
@ -1222,7 +1205,7 @@ update key flags inav settings msg model =
let
( p, c ) =
Comp.DetailEdit.initConcPerson
flags
env.flags
model.item.id
Comp.PersonForm.emptyModel
in
@ -1242,7 +1225,7 @@ update key flags inav settings msg model =
Just pid ->
let
( m, c ) =
Comp.DetailEdit.editPerson flags pid Comp.PersonForm.emptyModel
Comp.DetailEdit.editPerson env.flags pid Comp.PersonForm.emptyModel
in
resultModelCmd ( { model | modalEdit = Just m }, Cmd.map ModalEditMsg c )
@ -1318,7 +1301,7 @@ update key flags inav settings msg model =
resultModelCmd
( model
, Api.setAttachmentName
flags
env.flags
m.id
(Util.Maybe.fromString m.newName)
EditAttachNameResp
@ -1370,15 +1353,15 @@ update key flags inav settings msg model =
in
if keys == Just Comp.KeyInput.ctrlC then
if model.item.state == "created" then
update key flags inav settings ConfirmItem model_
update inav env ConfirmItem model_
else
update key flags inav settings UnconfirmItem model_
update inav env UnconfirmItem model_
else if keys == Just Comp.KeyInput.ctrlPoint then
case inav.next of
Just id ->
resultModelCmd ( model_, Page.set key (ItemDetailPage id) )
resultModelCmd ( model_, Page.set env.key (ItemDetailPage id) )
Nothing ->
resultModel model_
@ -1386,7 +1369,7 @@ update key flags inav settings msg model =
else if keys == Just Comp.KeyInput.ctrlComma then
case inav.prev of
Just id ->
resultModelCmd ( model_, Page.set key (ItemDetailPage id) )
resultModelCmd ( model_, Page.set env.key (ItemDetailPage id) )
Nothing ->
resultModel model_
@ -1405,7 +1388,7 @@ update key flags inav settings msg model =
let
model_ =
{ model
| menuOpen = settings.sideMenuVisible
| menuOpen = env.settings.sideMenuVisible
}
in
resultModel model_
@ -1416,12 +1399,13 @@ update key flags inav settings msg model =
, sub = Sub.none
, linkTarget = lt
, removedItem = Nothing
, selectionChange = Data.ItemIds.noChange
}
CustomFieldMsg lm ->
let
result =
Comp.CustomFieldMultiInput.update flags lm model.customFieldsModel
Comp.CustomFieldMultiInput.update env.flags lm model.customFieldsModel
cmd_ =
Cmd.map CustomFieldMsg result.cmd
@ -1438,7 +1422,7 @@ update key flags inav settings msg model =
( Cmd.none, model.customFieldSavingIcon )
FieldValueRemove field ->
( Api.deleteCustomValue flags
( Api.deleteCustomValue env.flags
model.item.id
field.id
(CustomFieldRemoveResp field.id)
@ -1446,7 +1430,7 @@ update key flags inav settings msg model =
)
FieldValueChange field value ->
( Api.putCustomValue flags
( Api.putCustomValue env.flags
model.item.id
(CustomFieldValue field.id value)
(CustomFieldSaveResp field value)
@ -1497,7 +1481,7 @@ update key flags inav settings msg model =
if res.success then
resultModelCmd
( model_
, Api.itemDetail flags model.item.id GetItemResp
, Api.itemDetail env.flags model.item.id GetItemResp
)
else
@ -1551,7 +1535,7 @@ update key flags inav settings msg model =
ReprocessFileConfirmed id ->
let
cmd =
Api.reprocessItem flags model.item.id [ id ] ReprocessFileResp
Api.reprocessItem env.flags model.item.id [ id ] ReprocessFileResp
in
resultModelCmd ( { model | attachModal = Nothing }, cmd )
@ -1572,7 +1556,7 @@ update key flags inav settings msg model =
ReprocessItemConfirmed ->
let
cmd =
Api.reprocessItem flags model.item.id [] ReprocessFileResp
Api.reprocessItem env.flags model.item.id [] ReprocessFileResp
in
resultModelCmd ( { model | itemModal = Nothing }, cmd )
@ -1594,9 +1578,9 @@ update key flags inav settings msg model =
)
RestoreItem ->
resultModelCmd ( model, Api.restoreItem flags model.item.id SaveResp )
resultModelCmd ( model, Api.restoreItem env.flags model.item.id SaveResp )
ToggleShowQrItem id ->
ToggleShowQrItem _ ->
let
sqm =
model.showQrModel
@ -1606,7 +1590,7 @@ update key flags inav settings msg model =
in
resultModel { model | showQrModel = next, mobileItemMenuOpen = False }
ToggleShowQrAttach id ->
ToggleShowQrAttach _ ->
let
sqm =
model.showQrModel
@ -1619,6 +1603,16 @@ update key flags inav settings msg model =
PrintElement id ->
resultModelCmd ( model, Ports.printElement id )
ToggleSelectItem ->
let
res =
resultModel { model | mobileItemMenuOpen = False }
newSelection =
Data.ItemIds.toggle env.selectedItems model.item.id
in
{ res | selectionChange = newSelection }
--- Helper

View File

@ -27,8 +27,10 @@ import Comp.ItemDetail.SingleAttachment
import Comp.ItemMail
import Comp.MenuBar as MB
import Comp.SentMails
import Data.Environment as Env
import Data.Flags exposing (Flags)
import Data.Icons as Icons
import Data.ItemIds
import Data.ItemNav exposing (ItemNav)
import Data.UiSettings exposing (UiSettings)
import Html exposing (..)
@ -39,13 +41,13 @@ import Page exposing (Page(..))
import Styles as S
view : Texts -> Flags -> ItemNav -> UiSettings -> Model -> Html Msg
view texts flags inav settings model =
view : Texts -> ItemNav -> Env.View -> Model -> Html Msg
view texts inav env model =
div [ class "flex flex-col h-full" ]
[ header texts settings inav model
[ header texts inav env model
-- , menuBar texts inav settings model
, body texts flags inav settings model
, body texts env.flags inav env.settings model
, itemModal texts model
]
@ -60,25 +62,35 @@ itemModal texts model =
span [ class "hidden" ] []
header : Texts -> UiSettings -> ItemNav -> Model -> Html Msg
header texts settings inav model =
header : Texts -> ItemNav -> Env.View -> Model -> Html Msg
header texts inav env model =
div [ class "my-3" ]
[ Comp.ItemDetail.ItemInfoHeader.view texts.itemInfoHeader
settings
env.settings
model
(menuBar texts inav settings model)
(menuBar texts inav env model)
]
menuBar : Texts -> ItemNav -> UiSettings -> Model -> Html Msg
menuBar texts inav settings model =
menuBar : Texts -> ItemNav -> Env.View -> Model -> Html Msg
menuBar texts inav env model =
let
keyDescr name =
if settings.itemDetailShortcuts && model.menuOpen then
if env.settings.itemDetailShortcuts && model.menuOpen then
" " ++ texts.key ++ "'" ++ name ++ "'."
else
""
isSelected =
Data.ItemIds.isMember env.selectedItems model.item.id
foldSelected fsel funsel =
if isSelected then
fsel
else
funsel
in
MB.view
{ start =
@ -210,7 +222,18 @@ menuBar texts inav settings model =
, toggleMenu = ToggleMobileItemMenu
, menuOpen = model.mobileItemMenuOpen
, items =
[ { icon = i [ class "fa fa-envelope font-thin" ] []
[ { icon =
foldSelected
(i [ class "fa fa-check-square dark:text-lime-400 text-lime-600" ] [])
(i [ class "fa fa-tasks" ] [])
, label = foldSelected texts.deselectItem texts.selectItem
, disabled = False
, attrs =
[ href "#"
, onClick ToggleSelectItem
]
}
, { icon = i [ class "fa fa-envelope font-thin" ] []
, label = texts.sendMail
, disabled = False
, attrs =
@ -281,13 +304,28 @@ menuBar texts inav settings model =
]
, end =
[ MB.CustomElement <|
a
[ href "#"
, onClick ToggleSelectItem
, title (foldSelected texts.deselectItem texts.selectItem)
, class "hidden md:flex flex-row items-center h-full "
, classList
[ ( S.greenButton, isSelected )
, ( S.secondaryBasicButton, not isSelected )
]
]
[ foldSelected
(i [ class "fa fa-square-check" ] [])
(i [ class "fa fa-list-check" ] [])
]
, MB.CustomElement <|
a
[ class S.secondaryBasicButton
, href "#"
, onClick UnconfirmItem
, title texts.unconfirmItemMetadata
, classList [ ( "hidden", model.item.state == "created" ) ]
, class "hidden md:block"
, class "hidden"
, classList [ ( "md:block", model.item.state /= "created" ) ]
]
[ i [ class "fa fa-eye-slash font-thin" ] []
]

View File

@ -1594,8 +1594,8 @@ searchTabs texts ddd flags settings selectedItems model =
i [ class "fa fa-check mr-2" ] []
else
i [ class "fa fa-list mr-2" ] []
, text "Show selection"
i [ class "fa fa-list-check mr-2" ] []
, text texts.showSelection
]
, a
[ class "flex flex-row items-center"
@ -1604,7 +1604,7 @@ searchTabs texts ddd flags settings selectedItems model =
, Html.Events.onClick ClearSelection
]
[ i [ class "fa fa-times mr-2" ] []
, text "Clear selection"
, text texts.clearSelection
]
]
]

View File

@ -14,9 +14,7 @@ import Data.UiSettings exposing (UiSettings)
type alias Update =
{ bookmarkId : Maybe String
, lastViewedItemId : Maybe String
, key : Nav.Key
{ key : Nav.Key
, selectedItems : ItemIds
, flags : Flags
, settings : UiSettings

View File

@ -57,6 +57,8 @@ type alias Texts =
, mailSendSuccessful : String
, showQrCode : String
, close : String
, selectItem : String
, deselectItem : String
}
@ -93,6 +95,8 @@ gb =
, mailSendSuccessful = "Mail sent."
, showQrCode = "Show URL as QR code"
, close = "Close"
, selectItem = "Select this item"
, deselectItem = "Deselect this item"
}
@ -115,7 +119,7 @@ de =
, addMoreFiles = "Diesem Dokument weitere Dateien anfügen"
, confirmItemMetadata = "Metadaten bestätigen"
, confirm = "Bestätige"
, unconfirmItemMetadata = "Widerrufe"
, unconfirmItemMetadata = "Widerrufe Bestätigung"
, reprocessItem = "Das Dokument erneut verarbeiten"
, deleteThisItem = "Das Dokument löschen"
, undeleteThisItem = "Das Dokument wiederherstellen"
@ -129,4 +133,6 @@ de =
, mailSendSuccessful = "E-Mail wurde versendet."
, showQrCode = "Link als QR code anzeigen"
, close = "Schließen"
, selectItem = "Zur Auswahl hinzufügen"
, deselectItem = "Aus Auswahl entfernen"
}

View File

@ -64,7 +64,7 @@ de =
, chooseDirection = "Wähle eine Richtung"
, confirmUnconfirm = "Bestätige/Widerrufe Metadaten"
, confirm = "Bestätige"
, unconfirm = "Widerrufe"
, unconfirm = "Widerrufe Bestätigung"
, changeTagMode = "Wechsel den Änderungsmodus für Tags"
, dueDateTab = "Fälligkeitsdatum"
, direction = Messages.Data.Direction.de

View File

@ -51,6 +51,8 @@ type alias Texts =
, trashcan : String
, bookmarks : String
, selection : String
, showSelection : String
, clearSelection : String
}
@ -86,6 +88,8 @@ gb =
, trashcan = "Trash"
, bookmarks = "Bookmarks"
, selection = "Selection"
, showSelection = "Show selection"
, clearSelection = "Clear selection"
}
@ -121,4 +125,6 @@ de =
, trashcan = "Papierkorb"
, bookmarks = "Bookmarks"
, selection = "Auswahl"
, showSelection = "Auswahl anzeigen"
, clearSelection = "Auswahl aufheben"
}

View File

@ -17,6 +17,7 @@ import Browser.Dom as Dom
import Comp.ItemDetail
import Comp.ItemDetail.Model
import Comp.LinkTarget exposing (LinkTarget)
import Data.ItemIds exposing (ItemIds)
import Http
@ -45,4 +46,5 @@ type alias UpdateResult =
, sub : Sub Msg
, linkTarget : LinkTarget
, removedItem : Maybe String
, selectedItems : ItemIds
}

View File

@ -8,29 +8,26 @@
module Page.ItemDetail.Update exposing (update)
import Api
import Browser.Navigation as Nav
import Comp.ItemDetail
import Comp.ItemDetail.Model
import Comp.LinkTarget
import Data.Flags exposing (Flags)
import Data.Environment as Env
import Data.ItemIds
import Data.ItemNav exposing (ItemNav)
import Data.UiSettings exposing (UiSettings)
import Page exposing (Page(..))
import Page.ItemDetail.Data exposing (Model, Msg(..), UpdateResult)
import Scroll
import Task
update : Nav.Key -> Flags -> ItemNav -> UiSettings -> Msg -> Model -> UpdateResult
update key flags inav settings msg model =
update : ItemNav -> Env.Update -> Msg -> Model -> UpdateResult
update inav env msg model =
case msg of
Init id ->
let
result =
Comp.ItemDetail.update key
flags
inav
settings
Comp.ItemDetail.update inav
env
Comp.ItemDetail.Model.Init
model.detail
@ -40,19 +37,20 @@ update key flags inav settings msg model =
{ model = { model | detail = result.model }
, cmd =
Cmd.batch
[ Api.itemDetail flags id ItemResp
[ Api.itemDetail env.flags id ItemResp
, Cmd.map ItemDetailMsg result.cmd
, Task.attempt ScrollResult task
]
, sub = Sub.map ItemDetailMsg result.sub
, linkTarget = result.linkTarget
, removedItem = result.removedItem
, selectedItems = env.selectedItems
}
ItemDetailMsg lmsg ->
let
result =
Comp.ItemDetail.update key flags inav settings lmsg model.detail
Comp.ItemDetail.update inav env lmsg model.detail
pageSwitch =
case result.linkTarget of
@ -60,13 +58,14 @@ update key flags inav settings msg model =
Cmd.none
_ ->
Page.set key (SearchPage Nothing)
Page.set env.key (SearchPage Nothing)
in
{ model = { model | detail = result.model }
, cmd = Cmd.batch [ pageSwitch, Cmd.map ItemDetailMsg result.cmd ]
, sub = Sub.map ItemDetailMsg result.sub
, linkTarget = result.linkTarget
, removedItem = result.removedItem
, selectedItems = Data.ItemIds.apply env.selectedItems result.selectionChange
}
ItemResp (Ok item) ->
@ -74,17 +73,28 @@ update key flags inav settings msg model =
lmsg =
Comp.ItemDetail.Model.SetItem item
in
update key flags inav settings (ItemDetailMsg lmsg) model
update inav env (ItemDetailMsg lmsg) model
ItemResp (Err _) ->
UpdateResult model Cmd.none Sub.none Comp.LinkTarget.LinkNone Nothing
unit env model
ScrollResult _ ->
UpdateResult model Cmd.none Sub.none Comp.LinkTarget.LinkNone Nothing
unit env model
UiSettingsUpdated ->
let
lmsg =
ItemDetailMsg Comp.ItemDetail.Model.UiSettingsUpdated
in
update key flags inav settings lmsg model
update inav env lmsg model
unit : Env.Update -> Model -> UpdateResult
unit env model =
{ model = model
, cmd = Cmd.none
, sub = Sub.none
, linkTarget = Comp.LinkTarget.LinkNone
, removedItem = Nothing
, selectedItems = env.selectedItems
}

View File

@ -12,6 +12,7 @@ import Comp.ItemDetail
import Comp.ItemDetail.EditForm
import Comp.ItemDetail.Model
import Comp.MenuBar as MB
import Data.Environment as Env
import Data.Flags exposing (Flags)
import Data.ItemNav exposing (ItemNav)
import Data.UiSettings exposing (UiSettings)
@ -23,13 +24,13 @@ import Page.ItemDetail.Data exposing (..)
import Styles as S
viewSidebar : Texts -> Bool -> Flags -> UiSettings -> Model -> Html Msg
viewSidebar texts visible flags settings model =
viewSidebar : Texts -> Env.View -> Model -> Html Msg
viewSidebar texts env model =
div
[ id "sidebar"
, class S.sidebar
, class S.sidebarBg
, classList [ ( "hidden", not visible ) ]
, classList [ ( "hidden", not env.sidebarVisible ) ]
]
[ div
[ class S.header2
@ -57,16 +58,16 @@ viewSidebar texts visible flags settings model =
, sticky = True
}
, Html.map ItemDetailMsg
(Comp.ItemDetail.EditForm.view2 texts.editForm flags settings model.detail)
(Comp.ItemDetail.EditForm.view2 texts.editForm env.flags env.settings model.detail)
]
viewContent : Texts -> ItemNav -> Flags -> UiSettings -> Model -> Html Msg
viewContent texts inav flags settings model =
viewContent : Texts -> ItemNav -> Env.View -> Model -> Html Msg
viewContent texts inav env model =
div
[ id "content"
, class S.content
]
[ Html.map ItemDetailMsg
(Comp.ItemDetail.view2 texts.itemDetail flags inav settings model.detail)
(Comp.ItemDetail.view2 texts.itemDetail inav env model.detail)
]

View File

@ -234,6 +234,7 @@ type Msg
| ToggleExpandCollapseRows
| ToggleBookmarkCurrentQueryView
| BookmarkQueryMsg Comp.BookmarkQueryManage.Msg
| ItemSelectionChanged
type SearchType

View File

@ -50,8 +50,8 @@ type alias UpdateResult =
}
update : Texts -> Env.Update -> Msg -> Model -> UpdateResult
update texts env msg model =
update : Texts -> Maybe String -> Maybe String -> Env.Update -> Msg -> Model -> UpdateResult
update texts bookmarkId lastViewedItemId env msg model =
case msg of
Init ->
let
@ -65,14 +65,14 @@ update texts env msg model =
}
setBookmark =
Maybe.map (\bmId -> SearchMenuMsg <| Comp.SearchMenu.SetBookmark bmId) env.bookmarkId
Maybe.map (\bmId -> SearchMenuMsg <| Comp.SearchMenu.SetBookmark bmId) bookmarkId
|> Maybe.withDefault DoNothing
in
makeResult env <|
makeResult env.selectedItems <|
Util.Update.andThen3
[ update texts env (SearchMenuMsg Comp.SearchMenu.Init)
, update texts env setBookmark
, doSearch env searchParam
[ update texts bookmarkId lastViewedItemId env (SearchMenuMsg Comp.SearchMenu.Init)
, update texts bookmarkId lastViewedItemId env setBookmark
, doSearch env.selectedItems searchParam
]
model
@ -84,7 +84,7 @@ update texts env msg model =
nm =
{ model | searchOffset = 0, powerSearchInput = Comp.PowerSearchInput.init }
in
update texts env (SearchMenuMsg Comp.SearchMenu.ResetForm) nm
update texts bookmarkId lastViewedItemId env (SearchMenuMsg Comp.SearchMenu.ResetForm) nm
SearchMenuMsg m ->
let
@ -125,10 +125,10 @@ update texts env msg model =
result =
if nextState.stateChange && not model.searchInProgress then
doSearch env searchParam newModel
doSearch env.selectedItems searchParam newModel
else
resultModelCmd env ( newModel, Cmd.none )
resultModelCmd env.selectedItems ( newModel, Cmd.none )
in
{ result
| cmd =
@ -144,10 +144,10 @@ update texts env msg model =
SetLinkTarget lt ->
case linkTargetMsg lt of
Just m ->
update texts env m model
update texts bookmarkId lastViewedItemId env m model
Nothing ->
makeResult env ( model, Cmd.none, Sub.none )
makeResult env.selectedItems ( model, Cmd.none, Sub.none )
ItemCardListMsg m ->
let
@ -197,7 +197,7 @@ update texts env msg model =
else
Set.empty
in
resultModelCmd env ( { model | itemRowsOpen = itemRows, viewMenuOpen = False }, Cmd.none )
resultModelCmd env.selectedItems ( { model | itemRowsOpen = itemRows, viewMenuOpen = False }, Cmd.none )
ItemSearchResp scroll (Ok list) ->
let
@ -211,14 +211,14 @@ update texts env msg model =
, moreAvailable = list.groups /= []
}
in
makeResult env <|
makeResult env.selectedItems <|
Util.Update.andThen3
[ update texts env (ItemCardListMsg (Comp.ItemCardList.SetResults list))
[ update texts bookmarkId lastViewedItemId env (ItemCardListMsg (Comp.ItemCardList.SetResults list))
, if scroll then
scrollToCard env
scrollToCard env.selectedItems lastViewedItemId
else
\next -> makeResult env ( next, Cmd.none, Sub.none )
\next -> makeResult env.selectedItems ( next, Cmd.none, Sub.none )
]
m
@ -235,10 +235,10 @@ update texts env msg model =
, moreAvailable = list.groups /= []
}
in
update texts env (ItemCardListMsg (Comp.ItemCardList.AddResults list)) m
update texts bookmarkId lastViewedItemId env (ItemCardListMsg (Comp.ItemCardList.AddResults list)) m
ItemSearchAddResp (Err _) ->
resultModelCmd env
resultModelCmd env.selectedItems
( { model
| moreInProgress = False
}
@ -246,7 +246,7 @@ update texts env msg model =
)
ItemSearchResp _ (Err _) ->
resultModelCmd env
resultModelCmd env.selectedItems
( { model
| searchInProgress = False
}
@ -268,10 +268,10 @@ update texts env msg model =
}
in
if model.searchInProgress then
resultModelCmd env ( model, Cmd.none )
resultModelCmd env.selectedItems ( model, Cmd.none )
else
doSearch env param nm
doSearch env.selectedItems param nm
RefreshView ->
let
@ -285,10 +285,10 @@ update texts env msg model =
}
in
if model.searchInProgress then
resultModelCmd env ( model, Cmd.none )
resultModelCmd env.selectedItems ( model, Cmd.none )
else
doSearch env param model
doSearch env.selectedItems param model
ToggleSelectView ->
let
@ -303,45 +303,45 @@ update texts env msg model =
PublishView q ->
( PublishView q, Cmd.none )
in
resultModelCmd env ( { model | viewMode = nextView }, cmd )
resultModelCmd env.selectedItems ( { model | viewMode = nextView }, cmd )
LoadMore ->
if model.moreAvailable then
doSearchMore env model |> resultModelCmd env
doSearchMore env model |> resultModelCmd env.selectedItems
else
resultModelCmd env ( model, Cmd.none )
resultModelCmd env.selectedItems ( model, Cmd.none )
SetBasicSearch str ->
let
smMsg =
SearchMenuMsg (Comp.SearchMenu.SetTextSearch str)
in
update texts env smMsg model
update texts bookmarkId lastViewedItemId env smMsg model
ToggleSearchType ->
case model.searchTypeDropdownValue of
BasicSearch ->
update texts env (SearchMenuMsg Comp.SearchMenu.SetFulltextSearch) model
update texts bookmarkId lastViewedItemId env (SearchMenuMsg Comp.SearchMenu.SetFulltextSearch) model
ContentOnlySearch ->
update texts env (SearchMenuMsg Comp.SearchMenu.SetNamesSearch) model
update texts bookmarkId lastViewedItemId env (SearchMenuMsg Comp.SearchMenu.SetNamesSearch) model
KeyUpSearchbarMsg (Just Enter) ->
update texts env (DoSearch model.searchTypeDropdownValue) model
update texts bookmarkId lastViewedItemId env (DoSearch model.searchTypeDropdownValue) model
KeyUpSearchbarMsg _ ->
resultModelCmd env ( model, Cmd.none )
resultModelCmd env.selectedItems ( model, Cmd.none )
ScrollResult _ ->
let
cmd =
Process.sleep 800 |> Task.perform (always ClearItemDetailId)
in
resultModelCmd env ( model, cmd )
resultModelCmd env.selectedItems ( model, cmd )
ClearItemDetailId ->
resultModelCmd env ( { model | scrollToCard = Nothing }, Cmd.none )
resultModelCmd env.selectedItems ( { model | scrollToCard = Nothing }, Cmd.none )
SelectAllItems ->
let
@ -352,16 +352,12 @@ update texts env msg model =
Data.ItemIds.apply env.selectedItems (Data.ItemIds.selectAll visible)
res_ =
resultModelCmd env ( model, Cmd.none )
resultModelCmd env.selectedItems ( model, Cmd.none )
in
{ res_ | selectedItems = itemIds }
SelectNoItems ->
let
result =
update texts env (SearchMenuMsg <| Comp.SearchMenu.setIncludeSelection False) model
in
{ result | selectedItems = Data.ItemIds.empty }
resultModelCmd Data.ItemIds.empty ( model, Cmd.none )
DeleteSelectedConfirmed ->
case model.viewMode of
@ -370,7 +366,7 @@ update texts env msg model =
cmd =
Api.deleteAllItems env.flags (Data.ItemIds.toList env.selectedItems) DeleteAllResp
in
resultModelCmd env
resultModelCmd env.selectedItems
( { model
| viewMode =
SelectView
@ -383,7 +379,7 @@ update texts env msg model =
)
_ ->
resultModelCmd env ( model, Cmd.none )
resultModelCmd env.selectedItems ( model, Cmd.none )
RestoreSelectedConfirmed ->
case model.viewMode of
@ -392,7 +388,7 @@ update texts env msg model =
cmd =
Api.restoreAllItems env.flags (Data.ItemIds.toList env.selectedItems) DeleteAllResp
in
resultModelCmd env
resultModelCmd env.selectedItems
( { model
| viewMode =
SelectView
@ -405,7 +401,7 @@ update texts env msg model =
)
_ ->
resultModelCmd env ( model, Cmd.none )
resultModelCmd env.selectedItems ( model, Cmd.none )
DeleteAllResp (Ok res) ->
if res.success then
@ -422,19 +418,19 @@ update texts env msg model =
, selectedItems = env.selectedItems
}
in
doSearch env param nm
doSearch env.selectedItems param nm
else
resultModelCmd env ( model, Cmd.none )
resultModelCmd env.selectedItems ( model, Cmd.none )
DeleteAllResp (Err _) ->
resultModelCmd env ( model, Cmd.none )
resultModelCmd env.selectedItems ( model, Cmd.none )
RequestReprocessSelected ->
case model.viewMode of
SelectView svm ->
if Data.ItemIds.isEmpty env.selectedItems then
resultModelCmd env ( model, Cmd.none )
resultModelCmd env.selectedItems ( model, Cmd.none )
else
let
@ -448,15 +444,15 @@ update texts env msg model =
}
}
in
resultModelCmd env ( model_, Cmd.none )
resultModelCmd env.selectedItems ( model_, Cmd.none )
_ ->
resultModelCmd env ( model, Cmd.none )
resultModelCmd env.selectedItems ( model, Cmd.none )
CloseConfirmModal ->
case model.viewMode of
SelectView svm ->
resultModelCmd env
resultModelCmd env.selectedItems
( { model
| viewMode = SelectView { svm | confirmModal = Nothing, action = NoneAction }
}
@ -464,20 +460,20 @@ update texts env msg model =
)
_ ->
resultModelCmd env ( model, Cmd.none )
resultModelCmd env.selectedItems ( model, Cmd.none )
ReprocessSelectedConfirmed ->
case model.viewMode of
SelectView svm ->
if Data.ItemIds.isEmpty env.selectedItems then
resultModelCmd env ( model, Cmd.none )
resultModelCmd env.selectedItems ( model, Cmd.none )
else
let
cmd =
Api.reprocessMultiple env.flags (Data.ItemIds.toList env.selectedItems) DeleteAllResp
in
resultModelCmd env
resultModelCmd env.selectedItems
( { model
| viewMode =
SelectView
@ -490,13 +486,13 @@ update texts env msg model =
)
_ ->
resultModelCmd env ( model, Cmd.none )
resultModelCmd env.selectedItems ( model, Cmd.none )
RequestDeleteSelected ->
case model.viewMode of
SelectView svm ->
if Data.ItemIds.isEmpty env.selectedItems then
resultModelCmd env ( model, Cmd.none )
resultModelCmd env.selectedItems ( model, Cmd.none )
else
let
@ -510,16 +506,16 @@ update texts env msg model =
}
}
in
resultModelCmd env ( model_, Cmd.none )
resultModelCmd env.selectedItems ( model_, Cmd.none )
_ ->
resultModelCmd env ( model, Cmd.none )
resultModelCmd env.selectedItems ( model, Cmd.none )
RequestRestoreSelected ->
case model.viewMode of
SelectView svm ->
if Data.ItemIds.isEmpty env.selectedItems then
resultModelCmd env ( model, Cmd.none )
resultModelCmd env.selectedItems ( model, Cmd.none )
else
let
@ -533,37 +529,37 @@ update texts env msg model =
}
}
in
resultModelCmd env ( model_, Cmd.none )
resultModelCmd env.selectedItems ( model_, Cmd.none )
_ ->
resultModelCmd env ( model, Cmd.none )
resultModelCmd env.selectedItems ( model, Cmd.none )
EditSelectedItems ->
case model.viewMode of
SelectView svm ->
if svm.action == EditSelected then
resultModelCmd env
resultModelCmd env.selectedItems
( { model | viewMode = SelectView { svm | action = NoneAction } }
, Cmd.none
)
else if Data.ItemIds.isEmpty env.selectedItems then
resultModelCmd env ( model, Cmd.none )
resultModelCmd env.selectedItems ( model, Cmd.none )
else
resultModelCmd env
resultModelCmd env.selectedItems
( { model | viewMode = SelectView { svm | action = EditSelected } }
, Cmd.none
)
_ ->
resultModelCmd env ( model, Cmd.none )
resultModelCmd env.selectedItems ( model, Cmd.none )
MergeSelectedItems ->
case model.viewMode of
SelectView svm ->
if svm.action == MergeSelected then
resultModelCmd env
resultModelCmd env.selectedItems
( { model
| viewMode =
SelectView
@ -582,7 +578,7 @@ update texts env msg model =
( mm, mc ) =
Comp.ItemMerge.initQuery env.flags model.searchMenuModel.searchMode q
in
resultModelCmd env
resultModelCmd env.selectedItems
( { model
| viewMode =
SelectView
@ -595,10 +591,10 @@ update texts env msg model =
)
Nothing ->
resultModelCmd env ( model, Cmd.none )
resultModelCmd env.selectedItems ( model, Cmd.none )
_ ->
resultModelCmd env ( model, Cmd.none )
resultModelCmd env.selectedItems ( model, Cmd.none )
MergeItemsMsg lmsg ->
case model.viewMode of
@ -623,18 +619,20 @@ update texts env msg model =
in
if result.outcome == Comp.ItemMerge.OutcomeMerged then
update texts
bookmarkId
lastViewedItemId
env
(DoSearch model.searchTypeDropdownValue)
model_
else
resultModelCmd env
resultModelCmd env.selectedItems
( model_
, Cmd.map MergeItemsMsg result.cmd
)
_ ->
resultModelCmd env ( model, Cmd.none )
resultModelCmd env.selectedItems ( model, Cmd.none )
PublishSelectedItems ->
case model.viewMode of
@ -644,7 +642,7 @@ update texts env msg model =
( mm, mc ) =
Comp.PublishItems.init env.flags
in
resultModelCmd env
resultModelCmd env.selectedItems
( { model
| viewMode =
SelectView
@ -663,7 +661,7 @@ update texts env msg model =
( mm, mc ) =
Comp.PublishItems.initQuery env.flags q
in
resultModelCmd env
resultModelCmd env.selectedItems
( { model
| viewMode =
SelectView
@ -676,10 +674,10 @@ update texts env msg model =
)
Nothing ->
resultModelCmd env ( model, Cmd.none )
resultModelCmd env.selectedItems ( model, Cmd.none )
_ ->
resultModelCmd env ( model, Cmd.none )
resultModelCmd env.selectedItems ( model, Cmd.none )
PublishItemsMsg lmsg ->
case model.viewMode of
@ -701,18 +699,20 @@ update texts env msg model =
in
if result.outcome == Comp.PublishItems.OutcomeDone then
update texts
bookmarkId
lastViewedItemId
env
(DoSearch model.searchTypeDropdownValue)
model_
else
resultModelCmd env
resultModelCmd env.selectedItems
( model_
, Cmd.map PublishItemsMsg result.cmd
)
_ ->
resultModelCmd env ( model, Cmd.none )
resultModelCmd env.selectedItems ( model, Cmd.none )
EditMenuMsg lmsg ->
case model.viewMode of
@ -755,14 +755,14 @@ update texts env msg model =
res.change
(MultiUpdateResp res.change)
in
makeResult env
makeResult env.selectedItems
( { model | viewMode = SelectView svm_ }
, Cmd.batch [ cmd_, upCmd ]
, sub_
)
_ ->
resultModelCmd env ( model, Cmd.none )
resultModelCmd env.selectedItems ( model, Cmd.none )
MultiUpdateResp change (Ok res) ->
let
@ -771,23 +771,23 @@ update texts env msg model =
in
if res.success then
-- replace changed items in the view
resultModelCmd env ( nm, loadChangedItems env.flags model.searchMenuModel.searchMode env.selectedItems )
resultModelCmd env.selectedItems ( nm, loadChangedItems env.flags model.searchMenuModel.searchMode env.selectedItems )
else
resultModelCmd env ( nm, Cmd.none )
resultModelCmd env.selectedItems ( nm, Cmd.none )
MultiUpdateResp change (Err _) ->
makeResult env
makeResult env.selectedItems
( updateSelectViewNameState False model change
, Cmd.none
, Sub.none
)
ReplaceChangedItemsResp (Ok items) ->
resultModelCmd env ( replaceItems model items, Cmd.none )
resultModelCmd env.selectedItems ( replaceItems model items, Cmd.none )
ReplaceChangedItemsResp (Err _) ->
resultModelCmd env ( model, Cmd.none )
resultModelCmd env.selectedItems ( model, Cmd.none )
UiSettingsUpdated ->
let
@ -805,7 +805,7 @@ update texts env msg model =
model_ =
{ model | viewMode = viewMode }
in
update texts env (DoSearch model.lastSearchType) model_
update texts bookmarkId lastViewedItemId env (DoSearch model.lastSearchType) model_
SearchStatsResp result ->
let
@ -815,7 +815,7 @@ update texts env msg model =
stats =
Result.withDefault model.searchStats result
in
update texts env lm { model | searchStats = stats }
update texts bookmarkId lastViewedItemId env lm { model | searchStats = stats }
TogglePreviewFullWidth ->
let
@ -825,7 +825,7 @@ update texts env msg model =
cmd =
Api.saveUserClientSettingsBy env.flags newSettings ClientSettingsSaveResp
in
resultModelCmd env ( { model | viewMenuOpen = False }, cmd )
resultModelCmd env.selectedItems ( { model | viewMenuOpen = False }, cmd )
ClientSettingsSaveResp (Ok res) ->
if res.success then
@ -837,10 +837,10 @@ update texts env msg model =
}
else
resultModelCmd env ( model, Cmd.none )
resultModelCmd env.selectedItems ( model, Cmd.none )
ClientSettingsSaveResp (Err _) ->
resultModelCmd env ( model, Cmd.none )
resultModelCmd env.selectedItems ( model, Cmd.none )
PowerSearchMsg lm ->
let
@ -855,19 +855,19 @@ update texts env msg model =
in
case result.action of
Comp.PowerSearchInput.NoAction ->
makeResult env ( model_, cmd_, Sub.map PowerSearchMsg result.subs )
makeResult env.selectedItems ( model_, cmd_, Sub.map PowerSearchMsg result.subs )
Comp.PowerSearchInput.SubmitSearch ->
update texts env (DoSearch model_.searchTypeDropdownValue) model_
update texts bookmarkId lastViewedItemId env (DoSearch model_.searchTypeDropdownValue) model_
KeyUpPowerSearchbarMsg (Just Enter) ->
update texts env (DoSearch model.searchTypeDropdownValue) model
update texts bookmarkId lastViewedItemId env (DoSearch model.searchTypeDropdownValue) model
KeyUpPowerSearchbarMsg _ ->
resultModelCmd env ( model, Cmd.none )
resultModelCmd env.selectedItems ( model, Cmd.none )
RemoveItem id ->
update texts env (ItemCardListMsg (Comp.ItemCardList.RemoveItem id)) model
update texts bookmarkId lastViewedItemId env (ItemCardListMsg (Comp.ItemCardList.RemoveItem id)) model
TogglePublishCurrentQueryView ->
case createQuery env.selectedItems model of
@ -876,30 +876,33 @@ update texts env msg model =
( pm, pc ) =
Comp.PublishItems.initQuery env.flags q
in
resultModelCmd env ( { model | viewMode = PublishView pm, viewMenuOpen = False }, Cmd.map PublishViewMsg pc )
resultModelCmd env.selectedItems
( { model | viewMode = PublishView pm, viewMenuOpen = False }
, Cmd.map PublishViewMsg pc
)
Nothing ->
resultModelCmd env ( model, Cmd.none )
resultModelCmd env.selectedItems ( model, Cmd.none )
ToggleBookmarkCurrentQueryView ->
case createQuery env.selectedItems model of
Just q ->
case model.topWidgetModel of
BookmarkQuery _ ->
resultModelCmd env ( { model | topWidgetModel = TopWidgetHidden, viewMenuOpen = False }, Cmd.none )
resultModelCmd env.selectedItems ( { model | topWidgetModel = TopWidgetHidden, viewMenuOpen = False }, Cmd.none )
TopWidgetHidden ->
let
( qm, qc ) =
Comp.BookmarkQueryManage.init (Q.render q)
in
resultModelCmd env
resultModelCmd env.selectedItems
( { model | topWidgetModel = BookmarkQuery qm, viewMenuOpen = False }
, Cmd.map BookmarkQueryMsg qc
)
Nothing ->
resultModelCmd env ( model, Cmd.none )
resultModelCmd env.selectedItems ( model, Cmd.none )
BookmarkQueryMsg lm ->
case model.topWidgetModel of
@ -927,7 +930,7 @@ update texts env msg model =
else
Cmd.none
in
makeResult env
makeResult env.selectedItems
( { model | topWidgetModel = nextModel }
, Cmd.batch
[ Cmd.map BookmarkQueryMsg res.cmd
@ -937,7 +940,7 @@ update texts env msg model =
)
TopWidgetHidden ->
resultModelCmd env ( model, Cmd.none )
resultModelCmd env.selectedItems ( model, Cmd.none )
PublishViewMsg lmsg ->
case model.viewMode of
@ -948,22 +951,22 @@ update texts env msg model =
in
case result.outcome of
Comp.PublishItems.OutcomeInProgress ->
resultModelCmd env
resultModelCmd env.selectedItems
( { model | viewMode = PublishView result.model }
, Cmd.map PublishViewMsg result.cmd
)
Comp.PublishItems.OutcomeDone ->
resultModelCmd env
resultModelCmd env.selectedItems
( { model | viewMode = SearchView }
, Cmd.map SearchMenuMsg (Comp.SearchMenu.refreshBookmarks env.flags)
)
_ ->
resultModelCmd env ( model, Cmd.none )
resultModelCmd env.selectedItems ( model, Cmd.none )
ToggleViewMenu ->
resultModelCmd env ( { model | viewMenuOpen = not model.viewMenuOpen }, Cmd.none )
resultModelCmd env.selectedItems ( { model | viewMenuOpen = not model.viewMenuOpen }, Cmd.none )
ToggleShowGroups ->
let
@ -973,7 +976,7 @@ update texts env msg model =
cmd =
Api.saveUserClientSettingsBy env.flags newSettings ClientSettingsSaveResp
in
resultModelCmd env ( { model | viewMenuOpen = False }, cmd )
resultModelCmd env.selectedItems ( { model | viewMenuOpen = False }, cmd )
ToggleArrange am ->
let
@ -983,7 +986,19 @@ update texts env msg model =
cmd =
Api.saveUserClientSettingsBy env.flags newSettings ClientSettingsSaveResp
in
resultModelCmd env ( { model | viewMenuOpen = False }, cmd )
resultModelCmd env.selectedItems ( { model | viewMenuOpen = False }, cmd )
ItemSelectionChanged ->
if Data.ItemIds.isEmpty env.selectedItems then
update texts
bookmarkId
lastViewedItemId
env
(SearchMenuMsg <| Comp.SearchMenu.setIncludeSelection False)
model
else
resultModelCmd env.selectedItems ( model, Cmd.none )
@ -1068,16 +1083,16 @@ loadChangedItems flags smode ids =
Api.itemSearch flags search ReplaceChangedItemsResp
scrollToCard : Env.Update -> Model -> UpdateResult
scrollToCard env model =
scrollToCard : ItemIds -> Maybe String -> Model -> UpdateResult
scrollToCard selection lastViewedItemId model =
let
scroll id =
Scroll.scrollElementY "item-card-list" id 0.5 0.5
in
makeResult env <|
case env.lastViewedItemId of
makeResult selection <|
case lastViewedItemId of
Just id ->
( { model | scrollToCard = env.lastViewedItemId }
( { model | scrollToCard = lastViewedItemId }
, Task.attempt ScrollResult (scroll id)
, Sub.none
)
@ -1091,8 +1106,8 @@ loadEditModel flags =
Cmd.map EditMenuMsg (Comp.ItemDetail.MultiEditMenu.loadModel flags)
doSearch : Env.Update -> SearchParam -> Model -> UpdateResult
doSearch env param model =
doSearch : ItemIds -> SearchParam -> Model -> UpdateResult
doSearch selection param model =
let
param_ =
{ param | offset = 0 }
@ -1100,7 +1115,7 @@ doSearch env param model =
searchCmd =
doSearchCmd param_ model
in
resultModelCmd env
resultModelCmd selection
( { model
| searchInProgress = True
, searchOffset = 0
@ -1135,16 +1150,16 @@ doSearchMore env model =
)
resultModelCmd : Env.Update -> ( Model, Cmd Msg ) -> UpdateResult
resultModelCmd env ( m, c ) =
makeResult env ( m, c, Sub.none )
resultModelCmd : ItemIds -> ( Model, Cmd Msg ) -> UpdateResult
resultModelCmd selection ( m, c ) =
makeResult selection ( m, c, Sub.none )
makeResult : Env.Update -> ( Model, Cmd Msg, Sub Msg ) -> UpdateResult
makeResult env ( m, c, s ) =
makeResult : ItemIds -> ( Model, Cmd Msg, Sub Msg ) -> UpdateResult
makeResult selection ( m, c, s ) =
{ model = m
, cmd = c
, sub = s
, appEvent = AppNothing
, selectedItems = env.selectedItems
, selectedItems = selection
}

View File

@ -189,6 +189,26 @@ secondaryButtonHover =
" hover:bg-gray-400 dark:hover:bg-slate-300 "
--- Secondary Basic Button
secondaryBasicButtonNoColor : String
secondaryBasicButtonNoColor =
" my-auto whitespace-nowrap text-center shadow-none focus:outline-none focus:ring focus:ring-opacity-75 "
secondaryBasicButtonMain : String
secondaryBasicButtonMain =
secondaryBasicButtonNoColor
++ " border-gray-500 dark:border-slate-500 text-gray-500 dark:text-slate-400 "
secondaryBasicButtonHover : String
secondaryBasicButtonHover =
" hover:bg-gray-600 hover:text-white dark:hover:text-white dark:hover:bg-slate-500 dark:hover:text-slate-100 "
secondaryBasicButton : String
secondaryBasicButton =
secondaryBasicButtonRounded ++ secondaryBasicButtonPlain
@ -205,20 +225,6 @@ secondaryBasicButtonRounded =
--- Secondary Basic Button
secondaryBasicButtonMain : String
secondaryBasicButtonMain =
" my-auto whitespace-nowrap border-gray-500 dark:border-slate-500 text-gray-500 dark:text-slate-400 text-center shadow-none focus:outline-none focus:ring focus:ring-opacity-75 "
secondaryBasicButtonHover : String
secondaryBasicButtonHover =
" hover:bg-gray-600 hover:text-white dark:hover:text-white dark:hover:bg-slate-500 dark:hover:text-slate-100 "
--- Delete Button
@ -248,6 +254,18 @@ deleteLabel =
--- Green Button
greenButton : String
greenButton =
secondaryBasicButtonNoColor
++ secondaryBasicButtonRounded
++ " dark:bg-lime-600 dark:bg-opacity-30 dark:border-lime-600 dark:text-lime-400 "
++ " bg-lime-600 border-lime-600 text-white"
--- Others