mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-05 22:55:58 +00:00
Update add item view with upload progress info
This commit is contained in:
parent
24caba1457
commit
973847807f
@ -74,7 +74,7 @@ updateWithSub msg model =
|
|||||||
updateNewInvite m model |> noSub
|
updateNewInvite m model |> noSub
|
||||||
|
|
||||||
ItemDetailMsg m ->
|
ItemDetailMsg m ->
|
||||||
updateItemDetail m model |> noSub
|
updateItemDetail m model
|
||||||
|
|
||||||
VersionResp (Ok info) ->
|
VersionResp (Ok info) ->
|
||||||
( { model | version = info }, Cmd.none ) |> noSub
|
( { model | version = info }, Cmd.none ) |> noSub
|
||||||
@ -172,17 +172,20 @@ updateWithSub msg model =
|
|||||||
( { model | navMenuOpen = not model.navMenuOpen }, Cmd.none, Sub.none )
|
( { model | navMenuOpen = not model.navMenuOpen }, Cmd.none, Sub.none )
|
||||||
|
|
||||||
|
|
||||||
updateItemDetail : Page.ItemDetail.Data.Msg -> Model -> ( Model, Cmd Msg )
|
updateItemDetail : Page.ItemDetail.Data.Msg -> Model -> ( Model, Cmd Msg, Sub Msg )
|
||||||
updateItemDetail lmsg model =
|
updateItemDetail lmsg model =
|
||||||
let
|
let
|
||||||
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 ) =
|
( lm, lc, ls ) =
|
||||||
Page.ItemDetail.Update.update model.key model.flags inav.next lmsg model.itemDetailModel
|
Page.ItemDetail.Update.update model.key model.flags inav.next lmsg model.itemDetailModel
|
||||||
in
|
in
|
||||||
( { model | itemDetailModel = lm }
|
( { model
|
||||||
|
| itemDetailModel = lm
|
||||||
|
}
|
||||||
, Cmd.map ItemDetailMsg lc
|
, Cmd.map ItemDetailMsg lc
|
||||||
|
, Sub.map ItemDetailMsg ls
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -341,7 +344,19 @@ initPage model page =
|
|||||||
updateQueue Page.Queue.Data.StopRefresh model
|
updateQueue Page.Queue.Data.StopRefresh model
|
||||||
|
|
||||||
ItemDetailPage id ->
|
ItemDetailPage id ->
|
||||||
updateItemDetail (Page.ItemDetail.Data.Init id) model
|
let
|
||||||
|
updateDetail m__ =
|
||||||
|
let
|
||||||
|
( m, c, s ) =
|
||||||
|
updateItemDetail (Page.ItemDetail.Data.Init id) m__
|
||||||
|
in
|
||||||
|
( { m | subs = Sub.batch [ m.subs, s ] }, c )
|
||||||
|
in
|
||||||
|
Util.Update.andThen1
|
||||||
|
[ updateDetail
|
||||||
|
, updateQueue Page.Queue.Data.StopRefresh
|
||||||
|
]
|
||||||
|
model
|
||||||
|
|
||||||
|
|
||||||
noSub : ( Model, Cmd Msg ) -> ( Model, Cmd Msg, Sub Msg )
|
noSub : ( Model, Cmd Msg ) -> ( Model, Cmd Msg, Sub Msg )
|
||||||
|
@ -393,7 +393,12 @@ isSuccessAll model =
|
|||||||
|> List.all (\id -> Set.member id model.completed)
|
|> List.all (\id -> Set.member id model.completed)
|
||||||
|
|
||||||
|
|
||||||
update : Nav.Key -> Flags -> Maybe String -> Msg -> Model -> ( Model, Cmd Msg )
|
noSub : ( Model, Cmd Msg ) -> ( Model, Cmd Msg, Sub Msg )
|
||||||
|
noSub ( m, c ) =
|
||||||
|
( m, c, Sub.none )
|
||||||
|
|
||||||
|
|
||||||
|
update : Nav.Key -> Flags -> Maybe String -> Msg -> Model -> ( Model, Cmd Msg, Sub Msg )
|
||||||
update key flags next msg model =
|
update key flags next msg model =
|
||||||
case msg of
|
case msg of
|
||||||
Init ->
|
Init ->
|
||||||
@ -404,22 +409,23 @@ update key flags next msg model =
|
|||||||
( im, ic ) =
|
( im, ic ) =
|
||||||
Comp.ItemMail.init flags
|
Comp.ItemMail.init flags
|
||||||
in
|
in
|
||||||
( { model | itemDatePicker = dp, dueDatePicker = dp, itemMail = im, visibleAttach = 0 }
|
noSub
|
||||||
, Cmd.batch
|
( { model | itemDatePicker = dp, dueDatePicker = dp, itemMail = im, visibleAttach = 0 }
|
||||||
[ getOptions flags
|
, Cmd.batch
|
||||||
, Cmd.map ItemDatePickerMsg dpc
|
[ getOptions flags
|
||||||
, Cmd.map DueDatePickerMsg dpc
|
, Cmd.map ItemDatePickerMsg dpc
|
||||||
, Cmd.map ItemMailMsg ic
|
, Cmd.map DueDatePickerMsg dpc
|
||||||
, Api.getSentMails flags model.item.id SentMailsResp
|
, Cmd.map ItemMailMsg ic
|
||||||
]
|
, Api.getSentMails flags model.item.id SentMailsResp
|
||||||
)
|
]
|
||||||
|
)
|
||||||
|
|
||||||
SetItem item ->
|
SetItem item ->
|
||||||
let
|
let
|
||||||
( m1, c1 ) =
|
( m1, c1, s1 ) =
|
||||||
update key flags next (TagDropdownMsg (Comp.Dropdown.SetSelection item.tags)) model
|
update key flags next (TagDropdownMsg (Comp.Dropdown.SetSelection item.tags)) model
|
||||||
|
|
||||||
( m2, c2 ) =
|
( m2, c2, s2 ) =
|
||||||
update key
|
update key
|
||||||
flags
|
flags
|
||||||
next
|
next
|
||||||
@ -433,7 +439,7 @@ update key flags next msg model =
|
|||||||
)
|
)
|
||||||
m1
|
m1
|
||||||
|
|
||||||
( m3, c3 ) =
|
( m3, c3, s3 ) =
|
||||||
update key
|
update key
|
||||||
flags
|
flags
|
||||||
next
|
next
|
||||||
@ -447,7 +453,7 @@ update key flags next msg model =
|
|||||||
)
|
)
|
||||||
m2
|
m2
|
||||||
|
|
||||||
( m4, c4 ) =
|
( m4, c4, s4 ) =
|
||||||
update key
|
update key
|
||||||
flags
|
flags
|
||||||
next
|
next
|
||||||
@ -461,7 +467,7 @@ update key flags next msg model =
|
|||||||
)
|
)
|
||||||
m3
|
m3
|
||||||
|
|
||||||
( m5, c5 ) =
|
( m5, c5, s5 ) =
|
||||||
update key
|
update key
|
||||||
flags
|
flags
|
||||||
next
|
next
|
||||||
@ -475,7 +481,7 @@ update key flags next msg model =
|
|||||||
)
|
)
|
||||||
m4
|
m4
|
||||||
|
|
||||||
( m6, c6 ) =
|
( m6, c6, s6 ) =
|
||||||
update key
|
update key
|
||||||
flags
|
flags
|
||||||
next
|
next
|
||||||
@ -489,7 +495,7 @@ update key flags next msg model =
|
|||||||
)
|
)
|
||||||
m5
|
m5
|
||||||
|
|
||||||
( m7, c7 ) =
|
( m7, c7, s7 ) =
|
||||||
update key flags next AddFilesReset m6
|
update key flags next AddFilesReset m6
|
||||||
|
|
||||||
proposalCmd =
|
proposalCmd =
|
||||||
@ -520,20 +526,21 @@ update key flags next msg model =
|
|||||||
, proposalCmd
|
, proposalCmd
|
||||||
, Api.getSentMails flags item.id SentMailsResp
|
, Api.getSentMails flags item.id SentMailsResp
|
||||||
]
|
]
|
||||||
|
, Sub.batch [ s1, s2, s3, s4, s5, s6, s7 ]
|
||||||
)
|
)
|
||||||
|
|
||||||
SetActiveAttachment pos ->
|
SetActiveAttachment pos ->
|
||||||
( { model | visibleAttach = pos, sentMailsOpen = False }, Cmd.none )
|
noSub ( { model | visibleAttach = pos, sentMailsOpen = False }, Cmd.none )
|
||||||
|
|
||||||
ToggleMenu ->
|
ToggleMenu ->
|
||||||
( { model | menuOpen = not model.menuOpen }, Cmd.none )
|
noSub ( { model | menuOpen = not model.menuOpen }, Cmd.none )
|
||||||
|
|
||||||
ReloadItem ->
|
ReloadItem ->
|
||||||
if model.item.id == "" then
|
if model.item.id == "" then
|
||||||
( model, Cmd.none )
|
noSub ( model, Cmd.none )
|
||||||
|
|
||||||
else
|
else
|
||||||
( model, Api.itemDetail flags model.item.id GetItemResp )
|
noSub ( model, Api.itemDetail flags model.item.id GetItemResp )
|
||||||
|
|
||||||
TagDropdownMsg m ->
|
TagDropdownMsg m ->
|
||||||
let
|
let
|
||||||
@ -550,7 +557,7 @@ update key flags next msg model =
|
|||||||
else
|
else
|
||||||
Cmd.none
|
Cmd.none
|
||||||
in
|
in
|
||||||
( newModel, Cmd.batch [ save, Cmd.map TagDropdownMsg c2 ] )
|
noSub ( newModel, Cmd.batch [ save, Cmd.map TagDropdownMsg c2 ] )
|
||||||
|
|
||||||
DirDropdownMsg m ->
|
DirDropdownMsg m ->
|
||||||
let
|
let
|
||||||
@ -567,7 +574,7 @@ update key flags next msg model =
|
|||||||
else
|
else
|
||||||
Cmd.none
|
Cmd.none
|
||||||
in
|
in
|
||||||
( newModel, Cmd.batch [ save, Cmd.map DirDropdownMsg c2 ] )
|
noSub ( newModel, Cmd.batch [ save, Cmd.map DirDropdownMsg c2 ] )
|
||||||
|
|
||||||
OrgDropdownMsg m ->
|
OrgDropdownMsg m ->
|
||||||
let
|
let
|
||||||
@ -587,7 +594,7 @@ update key flags next msg model =
|
|||||||
else
|
else
|
||||||
Cmd.none
|
Cmd.none
|
||||||
in
|
in
|
||||||
( newModel, Cmd.batch [ save, Cmd.map OrgDropdownMsg c2 ] )
|
noSub ( newModel, Cmd.batch [ save, Cmd.map OrgDropdownMsg c2 ] )
|
||||||
|
|
||||||
CorrPersonMsg m ->
|
CorrPersonMsg m ->
|
||||||
let
|
let
|
||||||
@ -607,7 +614,7 @@ update key flags next msg model =
|
|||||||
else
|
else
|
||||||
Cmd.none
|
Cmd.none
|
||||||
in
|
in
|
||||||
( newModel, Cmd.batch [ save, Cmd.map CorrPersonMsg c2 ] )
|
noSub ( newModel, Cmd.batch [ save, Cmd.map CorrPersonMsg c2 ] )
|
||||||
|
|
||||||
ConcPersonMsg m ->
|
ConcPersonMsg m ->
|
||||||
let
|
let
|
||||||
@ -627,7 +634,7 @@ update key flags next msg model =
|
|||||||
else
|
else
|
||||||
Cmd.none
|
Cmd.none
|
||||||
in
|
in
|
||||||
( newModel, Cmd.batch [ save, Cmd.map ConcPersonMsg c2 ] )
|
noSub ( newModel, Cmd.batch [ save, Cmd.map ConcPersonMsg c2 ] )
|
||||||
|
|
||||||
ConcEquipMsg m ->
|
ConcEquipMsg m ->
|
||||||
let
|
let
|
||||||
@ -647,42 +654,45 @@ update key flags next msg model =
|
|||||||
else
|
else
|
||||||
Cmd.none
|
Cmd.none
|
||||||
in
|
in
|
||||||
( newModel, Cmd.batch [ save, Cmd.map ConcEquipMsg c2 ] )
|
noSub ( newModel, Cmd.batch [ save, Cmd.map ConcEquipMsg c2 ] )
|
||||||
|
|
||||||
SetName str ->
|
SetName str ->
|
||||||
( { model | nameModel = str }, Cmd.none )
|
noSub ( { model | nameModel = str }, Cmd.none )
|
||||||
|
|
||||||
SaveName ->
|
SaveName ->
|
||||||
( model, setName flags model )
|
noSub ( model, setName flags model )
|
||||||
|
|
||||||
SetNotes str ->
|
SetNotes str ->
|
||||||
( { model | notesModel = Util.Maybe.fromString str }
|
noSub
|
||||||
, Cmd.none
|
( { model | notesModel = Util.Maybe.fromString str }
|
||||||
)
|
, Cmd.none
|
||||||
|
)
|
||||||
|
|
||||||
ToggleNotes ->
|
ToggleNotes ->
|
||||||
( { model
|
noSub
|
||||||
| notesField =
|
( { model
|
||||||
if model.notesField == ViewNotes then
|
| notesField =
|
||||||
HideNotes
|
if model.notesField == ViewNotes then
|
||||||
|
HideNotes
|
||||||
|
|
||||||
else
|
else
|
||||||
ViewNotes
|
ViewNotes
|
||||||
}
|
}
|
||||||
, Cmd.none
|
, Cmd.none
|
||||||
)
|
)
|
||||||
|
|
||||||
ToggleEditNotes ->
|
ToggleEditNotes ->
|
||||||
( { model
|
noSub
|
||||||
| notesField =
|
( { model
|
||||||
if isEditNotes model.notesField then
|
| notesField =
|
||||||
ViewNotes
|
if isEditNotes model.notesField then
|
||||||
|
ViewNotes
|
||||||
|
|
||||||
else
|
else
|
||||||
EditNotes Comp.MarkdownInput.init
|
EditNotes Comp.MarkdownInput.init
|
||||||
}
|
}
|
||||||
, Cmd.none
|
, Cmd.none
|
||||||
)
|
)
|
||||||
|
|
||||||
NotesEditMsg lm ->
|
NotesEditMsg lm ->
|
||||||
case model.notesField of
|
case model.notesField of
|
||||||
@ -691,21 +701,25 @@ update key flags next msg model =
|
|||||||
( lm2, str ) =
|
( lm2, str ) =
|
||||||
Comp.MarkdownInput.update (Maybe.withDefault "" model.notesModel) lm em
|
Comp.MarkdownInput.update (Maybe.withDefault "" model.notesModel) lm em
|
||||||
in
|
in
|
||||||
( { model | notesField = EditNotes lm2, notesModel = Util.Maybe.fromString str }
|
noSub
|
||||||
, Cmd.none
|
( { model | notesField = EditNotes lm2, notesModel = Util.Maybe.fromString str }
|
||||||
)
|
, Cmd.none
|
||||||
|
)
|
||||||
|
|
||||||
_ ->
|
HideNotes ->
|
||||||
( model, Cmd.none )
|
noSub ( model, Cmd.none )
|
||||||
|
|
||||||
|
ViewNotes ->
|
||||||
|
noSub ( model, Cmd.none )
|
||||||
|
|
||||||
SaveNotes ->
|
SaveNotes ->
|
||||||
( model, setNotes flags model )
|
noSub ( model, setNotes flags model )
|
||||||
|
|
||||||
ConfirmItem ->
|
ConfirmItem ->
|
||||||
( model, Api.setConfirmed flags model.item.id SaveResp )
|
noSub ( model, Api.setConfirmed flags model.item.id SaveResp )
|
||||||
|
|
||||||
UnconfirmItem ->
|
UnconfirmItem ->
|
||||||
( model, Api.setUnconfirmed flags model.item.id SaveResp )
|
noSub ( model, Api.setUnconfirmed flags model.item.id SaveResp )
|
||||||
|
|
||||||
ItemDatePickerMsg m ->
|
ItemDatePickerMsg m ->
|
||||||
let
|
let
|
||||||
@ -718,13 +732,13 @@ update key flags next msg model =
|
|||||||
newModel =
|
newModel =
|
||||||
{ model | itemDatePicker = dp, itemDate = Just (Comp.DatePicker.midOfDay date) }
|
{ model | itemDatePicker = dp, itemDate = Just (Comp.DatePicker.midOfDay date) }
|
||||||
in
|
in
|
||||||
( newModel, setDate flags newModel newModel.itemDate )
|
noSub ( newModel, setDate flags newModel newModel.itemDate )
|
||||||
|
|
||||||
_ ->
|
_ ->
|
||||||
( { model | itemDatePicker = dp }, Cmd.none )
|
noSub ( { model | itemDatePicker = dp }, Cmd.none )
|
||||||
|
|
||||||
RemoveDate ->
|
RemoveDate ->
|
||||||
( { model | itemDate = Nothing }, setDate flags model Nothing )
|
noSub ( { model | itemDate = Nothing }, setDate flags model Nothing )
|
||||||
|
|
||||||
DueDatePickerMsg m ->
|
DueDatePickerMsg m ->
|
||||||
let
|
let
|
||||||
@ -737,13 +751,13 @@ update key flags next msg model =
|
|||||||
newModel =
|
newModel =
|
||||||
{ model | dueDatePicker = dp, dueDate = Just (Comp.DatePicker.midOfDay date) }
|
{ model | dueDatePicker = dp, dueDate = Just (Comp.DatePicker.midOfDay date) }
|
||||||
in
|
in
|
||||||
( newModel, setDueDate flags newModel newModel.dueDate )
|
noSub ( newModel, setDueDate flags newModel newModel.dueDate )
|
||||||
|
|
||||||
_ ->
|
_ ->
|
||||||
( { model | dueDatePicker = dp }, Cmd.none )
|
noSub ( { model | dueDatePicker = dp }, Cmd.none )
|
||||||
|
|
||||||
RemoveDueDate ->
|
RemoveDueDate ->
|
||||||
( { model | dueDate = Nothing }, setDueDate flags model Nothing )
|
noSub ( { model | dueDate = Nothing }, setDueDate flags model Nothing )
|
||||||
|
|
||||||
DeleteItemConfirm m ->
|
DeleteItemConfirm m ->
|
||||||
let
|
let
|
||||||
@ -757,41 +771,41 @@ update key flags next msg model =
|
|||||||
else
|
else
|
||||||
Cmd.none
|
Cmd.none
|
||||||
in
|
in
|
||||||
( { model | deleteItemConfirm = cm }, cmd )
|
noSub ( { model | deleteItemConfirm = cm }, cmd )
|
||||||
|
|
||||||
RequestDelete ->
|
RequestDelete ->
|
||||||
update key flags next (DeleteItemConfirm Comp.YesNoDimmer.activate) model
|
update key flags next (DeleteItemConfirm Comp.YesNoDimmer.activate) model
|
||||||
|
|
||||||
SetCorrOrgSuggestion idname ->
|
SetCorrOrgSuggestion idname ->
|
||||||
( model, setCorrOrg flags model (Just idname) )
|
noSub ( model, setCorrOrg flags model (Just idname) )
|
||||||
|
|
||||||
SetCorrPersonSuggestion idname ->
|
SetCorrPersonSuggestion idname ->
|
||||||
( model, setCorrPerson flags model (Just idname) )
|
noSub ( model, setCorrPerson flags model (Just idname) )
|
||||||
|
|
||||||
SetConcPersonSuggestion idname ->
|
SetConcPersonSuggestion idname ->
|
||||||
( model, setConcPerson flags model (Just idname) )
|
noSub ( model, setConcPerson flags model (Just idname) )
|
||||||
|
|
||||||
SetConcEquipSuggestion idname ->
|
SetConcEquipSuggestion idname ->
|
||||||
( model, setConcEquip flags model (Just idname) )
|
noSub ( model, setConcEquip flags model (Just idname) )
|
||||||
|
|
||||||
SetItemDateSuggestion date ->
|
SetItemDateSuggestion date ->
|
||||||
( model, setDate flags model (Just date) )
|
noSub ( model, setDate flags model (Just date) )
|
||||||
|
|
||||||
SetDueDateSuggestion date ->
|
SetDueDateSuggestion date ->
|
||||||
( model, setDueDate flags model (Just date) )
|
noSub ( model, setDueDate flags model (Just date) )
|
||||||
|
|
||||||
GetTagsResp (Ok tags) ->
|
GetTagsResp (Ok tags) ->
|
||||||
let
|
let
|
||||||
tagList =
|
tagList =
|
||||||
Comp.Dropdown.SetOptions tags.items
|
Comp.Dropdown.SetOptions tags.items
|
||||||
|
|
||||||
( m1, c1 ) =
|
( m1, c1, s1 ) =
|
||||||
update key flags next (TagDropdownMsg tagList) model
|
update key flags next (TagDropdownMsg tagList) model
|
||||||
in
|
in
|
||||||
( m1, c1 )
|
( m1, c1, s1 )
|
||||||
|
|
||||||
GetTagsResp (Err _) ->
|
GetTagsResp (Err _) ->
|
||||||
( model, Cmd.none )
|
noSub ( model, Cmd.none )
|
||||||
|
|
||||||
GetOrgResp (Ok orgs) ->
|
GetOrgResp (Ok orgs) ->
|
||||||
let
|
let
|
||||||
@ -801,23 +815,23 @@ update key flags next msg model =
|
|||||||
update key flags next (OrgDropdownMsg opts) model
|
update key flags next (OrgDropdownMsg opts) model
|
||||||
|
|
||||||
GetOrgResp (Err _) ->
|
GetOrgResp (Err _) ->
|
||||||
( model, Cmd.none )
|
noSub ( model, Cmd.none )
|
||||||
|
|
||||||
GetPersonResp (Ok ps) ->
|
GetPersonResp (Ok ps) ->
|
||||||
let
|
let
|
||||||
opts =
|
opts =
|
||||||
Comp.Dropdown.SetOptions ps.items
|
Comp.Dropdown.SetOptions ps.items
|
||||||
|
|
||||||
( m1, c1 ) =
|
( m1, c1, s1 ) =
|
||||||
update key flags next (CorrPersonMsg opts) model
|
update key flags next (CorrPersonMsg opts) model
|
||||||
|
|
||||||
( m2, c2 ) =
|
( m2, c2, s2 ) =
|
||||||
update key flags next (ConcPersonMsg opts) m1
|
update key flags next (ConcPersonMsg opts) m1
|
||||||
in
|
in
|
||||||
( m2, Cmd.batch [ c1, c2 ] )
|
( m2, Cmd.batch [ c1, c2 ], Sub.batch [ s1, s2 ] )
|
||||||
|
|
||||||
GetPersonResp (Err _) ->
|
GetPersonResp (Err _) ->
|
||||||
( model, Cmd.none )
|
noSub ( model, Cmd.none )
|
||||||
|
|
||||||
GetEquipResp (Ok equips) ->
|
GetEquipResp (Ok equips) ->
|
||||||
let
|
let
|
||||||
@ -830,44 +844,44 @@ update key flags next msg model =
|
|||||||
update key flags next (ConcEquipMsg opts) model
|
update key flags next (ConcEquipMsg opts) model
|
||||||
|
|
||||||
GetEquipResp (Err _) ->
|
GetEquipResp (Err _) ->
|
||||||
( model, Cmd.none )
|
noSub ( model, Cmd.none )
|
||||||
|
|
||||||
SaveResp (Ok res) ->
|
SaveResp (Ok res) ->
|
||||||
if res.success then
|
if res.success then
|
||||||
( model, Api.itemDetail flags model.item.id GetItemResp )
|
noSub ( model, Api.itemDetail flags model.item.id GetItemResp )
|
||||||
|
|
||||||
else
|
else
|
||||||
( model, Cmd.none )
|
noSub ( model, Cmd.none )
|
||||||
|
|
||||||
SaveResp (Err _) ->
|
SaveResp (Err _) ->
|
||||||
( model, Cmd.none )
|
noSub ( model, Cmd.none )
|
||||||
|
|
||||||
DeleteResp (Ok res) ->
|
DeleteResp (Ok res) ->
|
||||||
if res.success then
|
if res.success then
|
||||||
case next of
|
case next of
|
||||||
Just id ->
|
Just id ->
|
||||||
( model, Page.set key (ItemDetailPage id) )
|
noSub ( model, Page.set key (ItemDetailPage id) )
|
||||||
|
|
||||||
Nothing ->
|
Nothing ->
|
||||||
( model, Page.set key HomePage )
|
noSub ( model, Page.set key HomePage )
|
||||||
|
|
||||||
else
|
else
|
||||||
( model, Cmd.none )
|
noSub ( model, Cmd.none )
|
||||||
|
|
||||||
DeleteResp (Err _) ->
|
DeleteResp (Err _) ->
|
||||||
( model, Cmd.none )
|
noSub ( model, Cmd.none )
|
||||||
|
|
||||||
GetItemResp (Ok item) ->
|
GetItemResp (Ok item) ->
|
||||||
update key flags next (SetItem item) model
|
update key flags next (SetItem item) model
|
||||||
|
|
||||||
GetItemResp (Err _) ->
|
GetItemResp (Err _) ->
|
||||||
( model, Cmd.none )
|
noSub ( model, Cmd.none )
|
||||||
|
|
||||||
GetProposalResp (Ok ip) ->
|
GetProposalResp (Ok ip) ->
|
||||||
( { model | itemProposals = ip }, Cmd.none )
|
noSub ( { model | itemProposals = ip }, Cmd.none )
|
||||||
|
|
||||||
GetProposalResp (Err _) ->
|
GetProposalResp (Err _) ->
|
||||||
( model, Cmd.none )
|
noSub ( model, Cmd.none )
|
||||||
|
|
||||||
ItemMailMsg m ->
|
ItemMailMsg m ->
|
||||||
let
|
let
|
||||||
@ -876,16 +890,17 @@ update key flags next msg model =
|
|||||||
in
|
in
|
||||||
case fa of
|
case fa of
|
||||||
Comp.ItemMail.FormNone ->
|
Comp.ItemMail.FormNone ->
|
||||||
( { model | itemMail = im }, Cmd.map ItemMailMsg ic )
|
noSub ( { model | itemMail = im }, Cmd.map ItemMailMsg ic )
|
||||||
|
|
||||||
Comp.ItemMail.FormCancel ->
|
Comp.ItemMail.FormCancel ->
|
||||||
( { model
|
noSub
|
||||||
| itemMail = Comp.ItemMail.clear im
|
( { model
|
||||||
, mailOpen = False
|
| itemMail = Comp.ItemMail.clear im
|
||||||
, mailSendResult = Nothing
|
, mailOpen = False
|
||||||
}
|
, mailSendResult = Nothing
|
||||||
, Cmd.map ItemMailMsg ic
|
}
|
||||||
)
|
, Cmd.map ItemMailMsg ic
|
||||||
|
)
|
||||||
|
|
||||||
Comp.ItemMail.FormSend sm ->
|
Comp.ItemMail.FormSend sm ->
|
||||||
let
|
let
|
||||||
@ -895,12 +910,13 @@ update key flags next msg model =
|
|||||||
, conn = sm.conn
|
, conn = sm.conn
|
||||||
}
|
}
|
||||||
in
|
in
|
||||||
( { model | mailSending = True }
|
noSub
|
||||||
, Cmd.batch
|
( { model | mailSending = True }
|
||||||
[ Cmd.map ItemMailMsg ic
|
, Cmd.batch
|
||||||
, Api.sendMail flags mail SendMailResp
|
[ Cmd.map ItemMailMsg ic
|
||||||
]
|
, Api.sendMail flags mail SendMailResp
|
||||||
)
|
]
|
||||||
|
)
|
||||||
|
|
||||||
ToggleMail ->
|
ToggleMail ->
|
||||||
let
|
let
|
||||||
@ -914,12 +930,13 @@ update key flags next msg model =
|
|||||||
else
|
else
|
||||||
Nothing
|
Nothing
|
||||||
in
|
in
|
||||||
( { model
|
noSub
|
||||||
| mailOpen = newOpen
|
( { model
|
||||||
, mailSendResult = sendResult
|
| mailOpen = newOpen
|
||||||
}
|
, mailSendResult = sendResult
|
||||||
, Cmd.none
|
}
|
||||||
)
|
, Cmd.none
|
||||||
|
)
|
||||||
|
|
||||||
SendMailResp (Ok br) ->
|
SendMailResp (Ok br) ->
|
||||||
let
|
let
|
||||||
@ -930,56 +947,59 @@ update key flags next msg model =
|
|||||||
else
|
else
|
||||||
model.itemMail
|
model.itemMail
|
||||||
in
|
in
|
||||||
( { model
|
noSub
|
||||||
| itemMail = mm
|
( { model
|
||||||
, mailSending = False
|
| itemMail = mm
|
||||||
, mailSendResult = Just br
|
, mailSending = False
|
||||||
}
|
, mailSendResult = Just br
|
||||||
, if br.success then
|
}
|
||||||
Api.itemDetail flags model.item.id GetItemResp
|
, if br.success then
|
||||||
|
Api.itemDetail flags model.item.id GetItemResp
|
||||||
|
|
||||||
else
|
else
|
||||||
Cmd.none
|
Cmd.none
|
||||||
)
|
)
|
||||||
|
|
||||||
SendMailResp (Err err) ->
|
SendMailResp (Err err) ->
|
||||||
let
|
let
|
||||||
errmsg =
|
errmsg =
|
||||||
Util.Http.errorToString err
|
Util.Http.errorToString err
|
||||||
in
|
in
|
||||||
( { model
|
noSub
|
||||||
| mailSendResult = Just (BasicResult False errmsg)
|
( { model
|
||||||
, mailSending = False
|
| mailSendResult = Just (BasicResult False errmsg)
|
||||||
}
|
, mailSending = False
|
||||||
, Cmd.none
|
}
|
||||||
)
|
, Cmd.none
|
||||||
|
)
|
||||||
|
|
||||||
SentMailsMsg m ->
|
SentMailsMsg m ->
|
||||||
let
|
let
|
||||||
sm =
|
sm =
|
||||||
Comp.SentMails.update m model.sentMails
|
Comp.SentMails.update m model.sentMails
|
||||||
in
|
in
|
||||||
( { model | sentMails = sm }, Cmd.none )
|
noSub ( { model | sentMails = sm }, Cmd.none )
|
||||||
|
|
||||||
ToggleSentMails ->
|
ToggleSentMails ->
|
||||||
( { model | sentMailsOpen = not model.sentMailsOpen, visibleAttach = -1 }, Cmd.none )
|
noSub ( { model | sentMailsOpen = not model.sentMailsOpen, visibleAttach = -1 }, Cmd.none )
|
||||||
|
|
||||||
SentMailsResp (Ok list) ->
|
SentMailsResp (Ok list) ->
|
||||||
let
|
let
|
||||||
sm =
|
sm =
|
||||||
Comp.SentMails.initMails list.items
|
Comp.SentMails.initMails list.items
|
||||||
in
|
in
|
||||||
( { model | sentMails = sm }, Cmd.none )
|
noSub ( { model | sentMails = sm }, Cmd.none )
|
||||||
|
|
||||||
SentMailsResp (Err _) ->
|
SentMailsResp (Err _) ->
|
||||||
( model, Cmd.none )
|
noSub ( model, Cmd.none )
|
||||||
|
|
||||||
AttachMetaClick id ->
|
AttachMetaClick id ->
|
||||||
case Dict.get id model.attachMeta of
|
case Dict.get id model.attachMeta of
|
||||||
Just _ ->
|
Just _ ->
|
||||||
( { model | attachMetaOpen = not model.attachMetaOpen }
|
noSub
|
||||||
, Cmd.none
|
( { model | attachMetaOpen = not model.attachMetaOpen }
|
||||||
)
|
, Cmd.none
|
||||||
|
)
|
||||||
|
|
||||||
Nothing ->
|
Nothing ->
|
||||||
let
|
let
|
||||||
@ -989,9 +1009,10 @@ update key flags next msg model =
|
|||||||
nextMeta =
|
nextMeta =
|
||||||
Dict.insert id am model.attachMeta
|
Dict.insert id am model.attachMeta
|
||||||
in
|
in
|
||||||
( { model | attachMeta = nextMeta, attachMetaOpen = True }
|
noSub
|
||||||
, Cmd.map (AttachMetaMsg id) ac
|
( { model | attachMeta = nextMeta, attachMetaOpen = True }
|
||||||
)
|
, Cmd.map (AttachMetaMsg id) ac
|
||||||
|
)
|
||||||
|
|
||||||
AttachMetaMsg id lmsg ->
|
AttachMetaMsg id lmsg ->
|
||||||
case Dict.get id model.attachMeta of
|
case Dict.get id model.attachMeta of
|
||||||
@ -1000,17 +1021,19 @@ update key flags next msg model =
|
|||||||
am =
|
am =
|
||||||
Comp.AttachmentMeta.update lmsg cm
|
Comp.AttachmentMeta.update lmsg cm
|
||||||
in
|
in
|
||||||
( { model | attachMeta = Dict.insert id am model.attachMeta }
|
noSub
|
||||||
, Cmd.none
|
( { model | attachMeta = Dict.insert id am model.attachMeta }
|
||||||
)
|
, Cmd.none
|
||||||
|
)
|
||||||
|
|
||||||
Nothing ->
|
Nothing ->
|
||||||
( model, Cmd.none )
|
noSub ( model, Cmd.none )
|
||||||
|
|
||||||
TogglePdfNativeView ->
|
TogglePdfNativeView ->
|
||||||
( { model | pdfNativeView = not model.pdfNativeView }
|
noSub
|
||||||
, Cmd.none
|
( { model | pdfNativeView = not model.pdfNativeView }
|
||||||
)
|
, Cmd.none
|
||||||
|
)
|
||||||
|
|
||||||
DeleteAttachConfirm attachId lmsg ->
|
DeleteAttachConfirm attachId lmsg ->
|
||||||
let
|
let
|
||||||
@ -1024,17 +1047,17 @@ update key flags next msg model =
|
|||||||
else
|
else
|
||||||
Cmd.none
|
Cmd.none
|
||||||
in
|
in
|
||||||
( { model | deleteAttachConfirm = cm }, cmd )
|
noSub ( { model | deleteAttachConfirm = cm }, cmd )
|
||||||
|
|
||||||
DeleteAttachResp (Ok res) ->
|
DeleteAttachResp (Ok res) ->
|
||||||
if res.success then
|
if res.success then
|
||||||
update key flags next ReloadItem model
|
update key flags next ReloadItem model
|
||||||
|
|
||||||
else
|
else
|
||||||
( model, Cmd.none )
|
noSub ( model, Cmd.none )
|
||||||
|
|
||||||
DeleteAttachResp (Err _) ->
|
DeleteAttachResp (Err _) ->
|
||||||
( model, Cmd.none )
|
noSub ( model, Cmd.none )
|
||||||
|
|
||||||
RequestDeleteAttachment id ->
|
RequestDeleteAttachment id ->
|
||||||
update key
|
update key
|
||||||
@ -1044,9 +1067,10 @@ update key flags next msg model =
|
|||||||
model
|
model
|
||||||
|
|
||||||
AddFilesToggle ->
|
AddFilesToggle ->
|
||||||
( { model | addFilesOpen = not model.addFilesOpen }
|
noSub
|
||||||
, Cmd.none
|
( { model | addFilesOpen = not model.addFilesOpen }
|
||||||
)
|
, Cmd.none
|
||||||
|
)
|
||||||
|
|
||||||
AddFilesMsg lm ->
|
AddFilesMsg lm ->
|
||||||
let
|
let
|
||||||
@ -1056,20 +1080,22 @@ update key flags next msg model =
|
|||||||
nextFiles =
|
nextFiles =
|
||||||
model.selectedFiles ++ df
|
model.selectedFiles ++ df
|
||||||
in
|
in
|
||||||
( { model | addFilesModel = dm, selectedFiles = nextFiles }
|
noSub
|
||||||
, Cmd.map AddFilesMsg dc
|
( { model | addFilesModel = dm, selectedFiles = nextFiles }
|
||||||
)
|
, Cmd.map AddFilesMsg dc
|
||||||
|
)
|
||||||
|
|
||||||
AddFilesReset ->
|
AddFilesReset ->
|
||||||
( { model
|
noSub
|
||||||
| selectedFiles = []
|
( { model
|
||||||
, addFilesModel = Comp.Dropzone.init Comp.Dropzone.defaultSettings
|
| selectedFiles = []
|
||||||
, completed = Set.empty
|
, addFilesModel = Comp.Dropzone.init Comp.Dropzone.defaultSettings
|
||||||
, errored = Set.empty
|
, completed = Set.empty
|
||||||
, loading = Set.empty
|
, errored = Set.empty
|
||||||
}
|
, loading = Set.empty
|
||||||
, Cmd.none
|
}
|
||||||
)
|
, Cmd.none
|
||||||
|
)
|
||||||
|
|
||||||
AddFilesSubmitUpload ->
|
AddFilesSubmitUpload ->
|
||||||
let
|
let
|
||||||
@ -1085,7 +1111,10 @@ update key flags next msg model =
|
|||||||
( cm2, _, _ ) =
|
( cm2, _, _ ) =
|
||||||
Comp.Dropzone.update (Comp.Dropzone.setActive False) model.addFilesModel
|
Comp.Dropzone.update (Comp.Dropzone.setActive False) model.addFilesModel
|
||||||
in
|
in
|
||||||
( { model | loading = Set.fromList fileids, addFilesModel = cm2 }, uploads )
|
( { model | loading = Set.fromList fileids, addFilesModel = cm2 }
|
||||||
|
, uploads
|
||||||
|
, tracker
|
||||||
|
)
|
||||||
|
|
||||||
AddFilesUploadResp fileid (Ok res) ->
|
AddFilesUploadResp fileid (Ok res) ->
|
||||||
let
|
let
|
||||||
@ -1109,9 +1138,10 @@ update key flags next msg model =
|
|||||||
newModel =
|
newModel =
|
||||||
{ model | completed = compl, errored = errs, loading = load }
|
{ model | completed = compl, errored = errs, loading = load }
|
||||||
in
|
in
|
||||||
( newModel
|
noSub
|
||||||
, Ports.setProgress ( fileid, 100 )
|
( newModel
|
||||||
)
|
, Ports.setProgress ( fileid, 100 )
|
||||||
|
)
|
||||||
|
|
||||||
AddFilesUploadResp fileid (Err _) ->
|
AddFilesUploadResp fileid (Err _) ->
|
||||||
let
|
let
|
||||||
@ -1121,7 +1151,7 @@ update key flags next msg model =
|
|||||||
load =
|
load =
|
||||||
Set.remove fileid model.loading
|
Set.remove fileid model.loading
|
||||||
in
|
in
|
||||||
( { model | errored = errs, loading = load }, Cmd.none )
|
noSub ( { model | errored = errs, loading = load }, Cmd.none )
|
||||||
|
|
||||||
AddFilesProgress fileid progress ->
|
AddFilesProgress fileid progress ->
|
||||||
let
|
let
|
||||||
@ -1142,7 +1172,7 @@ update key flags next msg model =
|
|||||||
else
|
else
|
||||||
Ports.setProgress ( fileid, percent )
|
Ports.setProgress ( fileid, percent )
|
||||||
in
|
in
|
||||||
( model, updateBars )
|
noSub ( model, updateBars )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -58,7 +58,9 @@ init flags url key =
|
|||||||
Nothing ->
|
Nothing ->
|
||||||
Cmd.none
|
Cmd.none
|
||||||
in
|
in
|
||||||
( m, Cmd.batch [ cmd, Api.versionInfo flags VersionResp, sessionCheck ] )
|
( m
|
||||||
|
, Cmd.batch [ cmd, Api.versionInfo flags VersionResp, sessionCheck ]
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
viewDoc : Model -> Document Msg
|
viewDoc : Model -> Document Msg
|
||||||
|
@ -7,25 +7,27 @@ import Data.Flags exposing (Flags)
|
|||||||
import Page.ItemDetail.Data exposing (Model, Msg(..))
|
import Page.ItemDetail.Data exposing (Model, Msg(..))
|
||||||
|
|
||||||
|
|
||||||
update : Nav.Key -> Flags -> Maybe String -> Msg -> Model -> ( Model, Cmd Msg )
|
update : Nav.Key -> Flags -> Maybe String -> Msg -> Model -> ( Model, Cmd Msg, Sub Msg )
|
||||||
update key flags next msg model =
|
update key flags next msg model =
|
||||||
case msg of
|
case msg of
|
||||||
Init id ->
|
Init id ->
|
||||||
let
|
let
|
||||||
( lm, lc ) =
|
( lm, lc, ls ) =
|
||||||
Comp.ItemDetail.update key flags next Comp.ItemDetail.Init model.detail
|
Comp.ItemDetail.update key flags next Comp.ItemDetail.Init model.detail
|
||||||
in
|
in
|
||||||
( { model | detail = lm }
|
( { model | detail = lm }
|
||||||
, Cmd.batch [ Api.itemDetail flags id ItemResp, Cmd.map ItemDetailMsg lc ]
|
, Cmd.batch [ Api.itemDetail flags id ItemResp, Cmd.map ItemDetailMsg lc ]
|
||||||
|
, Sub.map ItemDetailMsg ls
|
||||||
)
|
)
|
||||||
|
|
||||||
ItemDetailMsg lmsg ->
|
ItemDetailMsg lmsg ->
|
||||||
let
|
let
|
||||||
( lm, lc ) =
|
( lm, lc, ls ) =
|
||||||
Comp.ItemDetail.update key flags next lmsg model.detail
|
Comp.ItemDetail.update key flags next lmsg model.detail
|
||||||
in
|
in
|
||||||
( { model | detail = lm }
|
( { model | detail = lm }
|
||||||
, Cmd.map ItemDetailMsg lc
|
, Cmd.map ItemDetailMsg lc
|
||||||
|
, Sub.map ItemDetailMsg ls
|
||||||
)
|
)
|
||||||
|
|
||||||
ItemResp (Ok item) ->
|
ItemResp (Ok item) ->
|
||||||
@ -36,4 +38,4 @@ update key flags next msg model =
|
|||||||
update key flags next (ItemDetailMsg lmsg) model
|
update key flags next (ItemDetailMsg lmsg) model
|
||||||
|
|
||||||
ItemResp (Err _) ->
|
ItemResp (Err _) ->
|
||||||
( model, Cmd.none )
|
( model, Cmd.none, Sub.none )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user