Fix bug to select other attachments

This commit is contained in:
Eike Kettner
2020-03-17 22:37:43 +01:00
parent f0449dd2ce
commit 10f3d5b7ed

View File

@ -336,7 +336,7 @@ 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 } ( { model | itemDatePicker = dp, dueDatePicker = dp, itemMail = im, visibleAttach = 0 }
, Cmd.batch , Cmd.batch
[ getOptions flags [ getOptions flags
, Cmd.map ItemDatePickerMsg dpc , Cmd.map ItemDatePickerMsg dpc
@ -435,6 +435,7 @@ update key flags next msg model =
, notesField = ViewNotes , notesField = ViewNotes
, itemDate = item.itemDate , itemDate = item.itemDate
, dueDate = item.dueDate , dueDate = item.dueDate
, visibleAttach = 0
} }
, Cmd.batch , Cmd.batch
[ c1 [ c1
@ -1127,6 +1128,15 @@ renderNotes model =
] ]
attachmentVisible : Model -> Int -> Bool
attachmentVisible model pos =
if model.visibleAttach >= List.length model.item.attachments then
pos == 0
else
model.visibleAttach == pos
renderAttachmentsTabMenu : Model -> Html Msg renderAttachmentsTabMenu : Model -> Html Msg
renderAttachmentsTabMenu model = renderAttachmentsTabMenu model =
let let
@ -1153,9 +1163,10 @@ renderAttachmentsTabMenu model =
a a
[ classList [ classList
[ ( "item", True ) [ ( "item", True )
, ( "active", pos == model.visibleAttach ) , ( "active", attachmentVisible model pos )
] ]
, title (Maybe.withDefault "No Name" el.name) , title (Maybe.withDefault "No Name" el.name)
, href ""
, onClick (SetActiveAttachment pos) , onClick (SetActiveAttachment pos)
] ]
[ Maybe.map (Util.String.ellipsis 20) el.name [ Maybe.map (Util.String.ellipsis 20) el.name
@ -1180,7 +1191,7 @@ renderAttachmentView model pos attach =
div div
[ classList [ classList
[ ( "ui attached tab segment", True ) [ ( "ui attached tab segment", True )
, ( "active", pos == model.visibleAttach ) , ( "active", attachmentVisible model pos )
] ]
] ]
[ div [ class "ui small secondary menu" ] [ div [ class "ui small secondary menu" ]