Fix selecting items in multi-edit mode

For some to me unknown reason, changing the dom slightly (removing
hidden elements), resulted in a different event dispatching. The cards
while being attached to an event would reload the page as if the event
is propagated. This happned by commit #8d7b3c7d in Home/View.elm.
Adding the hidden nodes back into the dom, "fixed" it.

This change now gives a better fix in assuring that every anchor has
either a sensible `href` or an event and a `href #`.
This commit is contained in:
Eike Kettner 2020-12-17 21:02:23 +01:00
parent 6346bf6a34
commit c9d4e8ec46

View File

@ -148,10 +148,13 @@ view cfg settings model item =
cardAction = cardAction =
case cfg.selection of case cfg.selection of
Data.ItemSelection.Inactive -> Data.ItemSelection.Inactive ->
Page.href (ItemDetailPage item.id) [ Page.href (ItemDetailPage item.id)
]
Data.ItemSelection.Active ids -> Data.ItemSelection.Active ids ->
onClick (ToggleSelectItem ids item.id) [ onClick (ToggleSelectItem ids item.id)
, href "#"
]
selectedDimmer = selectedDimmer =
div div
@ -162,8 +165,7 @@ view cfg settings model item =
] ]
[ div [ class "content" ] [ div [ class "content" ]
[ a [ a
[ cardAction cardAction
]
[ i [ class "huge icons purple" ] [ i [ class "huge icons purple" ]
[ i [ class "big circle outline icon" ] [] [ i [ class "big circle outline icon" ] []
, i [ class "check icon" ] [] , i [ class "check icon" ] []
@ -311,7 +313,7 @@ notesContent settings item =
] ]
mainContent : Attribute Msg -> String -> Bool -> UiSettings -> ViewConfig -> ItemLight -> Html Msg mainContent : List (Attribute Msg) -> String -> Bool -> UiSettings -> ViewConfig -> ItemLight -> Html Msg
mainContent cardAction cardColor isConfirmed settings _ item = mainContent cardAction cardColor isConfirmed settings _ item =
let let
dirIcon = dirIcon =
@ -327,10 +329,7 @@ mainContent cardAction cardColor isConfirmed settings _ item =
settings.cardSubtitleTemplate.template settings.cardSubtitleTemplate.template
in in
a a
[ class "content" (class "content" :: cardAction)
, href "#"
, cardAction
]
[ if fieldHidden Data.Fields.Direction then [ if fieldHidden Data.Fields.Direction then
div [ class "header" ] div [ class "header" ]
[ IT.render titlePattern item |> text [ IT.render titlePattern item |> text
@ -419,7 +418,7 @@ mainTagsAndFields settings item =
(renderFields ++ renderTags) (renderFields ++ renderTags)
previewImage : UiSettings -> Attribute Msg -> Model -> ItemLight -> Html Msg previewImage : UiSettings -> List (Attribute Msg) -> Model -> ItemLight -> Html Msg
previewImage settings cardAction model item = previewImage settings cardAction model item =
let let
mainAttach = mainAttach =
@ -431,10 +430,11 @@ previewImage settings cardAction model item =
|> Maybe.withDefault (Api.itemBasePreviewURL item.id) |> Maybe.withDefault (Api.itemBasePreviewURL item.id)
in in
a a
[ class "image ds-card-image" ([ class "image ds-card-image"
, Data.UiSettings.cardPreviewSize settings , Data.UiSettings.cardPreviewSize settings
, cardAction ]
] ++ cardAction
)
[ img [ img
[ class "preview-image" [ class "preview-image"
, src previewUrl , src previewUrl