From dbcbe47c21f0c15fa19346bd36d4704d8da2db90 Mon Sep 17 00:00:00 2001 From: dtrckd Date: Thu, 12 Jan 2023 13:31:41 +0100 Subject: [PATCH] ui/fix: link label in tension view. --- assets/sass/fractal6.scss | 10 +++++--- i18n/i18n.toml | 8 ++++-- src/Bulk.elm | 8 +++--- src/Bulk/View.elm | 16 +++++------- src/Components/ContractsPage.elm | 22 +++++++++------- src/Org/Tension.elm | 43 +++++++++++++++++++++++--------- src/Query/PatchContract.elm | 5 +++- 7 files changed, 69 insertions(+), 43 deletions(-) diff --git a/assets/sass/fractal6.scss b/assets/sass/fractal6.scss index 0466ffda..a996f370 100644 --- a/assets/sass/fractal6.scss +++ b/assets/sass/fractal6.scss @@ -1841,18 +1841,20 @@ tr.mediaBox { } .labelsList { + .tag + .tag { + margin-left: 8px !important; + } + .tag { - margin-right: 8px !important; border: 1px solid transparent; - &:hover { - border-color: var(--link2); - } + &:hover { border-color: var(--link2); } } } .tension-labelsList { margin-top: -8px; .labelsList .tag { margin-top: 8px; + &:hover { border-color: transparent; } } .help { margin-top: 22px !important; diff --git a/i18n/i18n.toml b/i18n/i18n.toml index 141c5f7c..4ceabd73 100644 --- a/i18n/i18n.toml +++ b/i18n/i18n.toml @@ -924,6 +924,10 @@ Vous pouvez [Explorer](/explore) les organisations publiques ou créer votre [Pr - Vous pourrez la rejoindre a nouveau sur invitation seulement. """ +[deleteThisContract] + en="Delete this contract" + fr="Supprimer ce contrat" + [askAnotherQuestion] en="Ask another question." fr="Poser une autre question." @@ -2064,8 +2068,8 @@ Vous pouvez [Explorer](/explore) les organisations publiques ou créer votre [Pr fr="Etiquette retiré" [assigneeAdded_event] - en="Assignee added" - fr="Assigné ajouté" + en="New assignment" + fr="Nouvelle assignation" [assigneeRemoved_event] en="Assignee removed" diff --git a/src/Bulk.elm b/src/Bulk.elm index b2a8b30e..56c22f3a 100644 --- a/src/Bulk.elm +++ b/src/Bulk.elm @@ -174,19 +174,17 @@ type alias UserForm = type alias CommentPatchForm = { id : String -- comment id (for edit/patch) - , pid : String -- parent id (e.g. tid of cid) (for creating) , uctx : UserCtx , post : Post , viewMode : InputViewMode } -initCommentPatchForm : String -> UserState -> CommentPatchForm -initCommentPatchForm reflink user = +initCommentPatchForm : UserState -> List ( String, String ) -> CommentPatchForm +initCommentPatchForm user data = { uctx = uctxFromUser user , id = "" - , pid = "" - , post = Dict.fromList [ ( "reflink", reflink ) ] + , post = Dict.fromList data , viewMode = Write } diff --git a/src/Bulk/View.elm b/src/Bulk/View.elm index 27163060..df67d4f5 100644 --- a/src/Bulk/View.elm +++ b/src/Bulk/View.elm @@ -234,16 +234,12 @@ used to make labels clickable. viewLabels : Maybe String -> List Label -> Html msg viewLabels nid_m labels = let - to_link_m = - case nid_m of - Just nid -> - \l -> - toLink TensionsBaseUri nid [] - ++ ("?l=" ++ l) - |> Just - - Nothing -> - \_ -> Nothing + to_link_m name = + Maybe.map + (\nid -> + toLink TensionsBaseUri nid [] ++ ("?l=" ++ name) + ) + nid_m in span [ class "labelsList" ] (List.map diff --git a/src/Components/ContractsPage.elm b/src/Components/ContractsPage.elm index 59299f36..0ddb7543 100644 --- a/src/Components/ContractsPage.elm +++ b/src/Components/ContractsPage.elm @@ -117,8 +117,8 @@ initModel rootnameid user conf = , form = initContractForm user , voteForm = initVoteForm user , activeView = ContractsView - , comment_form = initCommentPatchForm (toReflink conf.url) user - , comment_patch_form = initCommentPatchForm (toReflink conf.url) user + , comment_form = initCommentPatchForm user [ ( "reflink", toReflink conf.url ) ] + , comment_patch_form = initCommentPatchForm user [ ( "reflink", toReflink conf.url ) ] , comment_result = NotAsked -- Common @@ -557,8 +557,10 @@ update_ apis message model = ( { model | comment_form = { form - | pid = withMaybeDataMap .id model.contract_result |> withDefault "" - , post = Dict.insert "createdAt" (fromTime time) form.post + | post = + form.post + |> Dict.insert "createdAt" (fromTime time) + |> Dict.insert "contractid" (withMaybeDataMap .id model.contract_result |> withDefault "") } , comment_result = LoadingSlowly } @@ -593,7 +595,7 @@ update_ apis message model = other resetForm = - initCommentPatchForm (toReflink model.conf.url) model.user + initCommentPatchForm model.user [ ( "reflink", toReflink model.conf.url ) ] in ( { model | contract_result = contract, comment_form = resetForm, comment_result = result } , out0 [ Ports.bulma_driver "" ] @@ -630,7 +632,7 @@ update_ apis message model = other resetForm = - initCommentPatchForm (toReflink model.conf.url) model.user + initCommentPatchForm model.user [ ( "reflink", toReflink model.conf.url ) ] in ( { model | contract_result = contract, comment_patch_form = resetForm, comment_result = result } , out0 [ Ports.bulma_driver "" ] @@ -878,8 +880,10 @@ viewRow d op model = ] [ td [ onClick (DoClickContract d.id) ] [ a - [ href (Route.Tension_Dynamic_Dynamic_Contract_Dynamic { param1 = model.rootnameid, param2 = model.form.tid, param3 = d.id } |> toHref) ] - [ text (contractEventToText d.event.event_type), Maybe.map (\x -> " | " ++ x) d.event.new |> withDefault "" |> text ] + [ class "discrete-link" + , href (Route.Tension_Dynamic_Dynamic_Contract_Dynamic { param1 = model.rootnameid, param2 = model.form.tid, param3 = d.id } |> toHref) + ] + [ text (contractEventToText d.event.event_type), Maybe.map (\x -> " ・ " ++ x) d.event.new |> withDefault "" |> text ] ] , td [] [ span [] [ text (contractTypeToText d.contract_type) ] ] , td [ class "has-links-discrete" ] [ viewUsernameLink d.createdBy.username ] @@ -897,7 +901,7 @@ viewRow d op model = [ class "button-light" , onClick <| DoModalConfirmOpen (DoDeleteContract d.id) { message = Nothing, txts = [ ( T.confirmDeleteContract, "" ), ( "?", "" ) ] } ] - [ span [ class "tag is-danger is-light is-smaller2" ] [ A.icon "icon-x", loadingSpin deleteLoading ] ] + [ span [ class "tag is-danger is-light is-smaller2 tooltip has-tooltip-arrow", attribute "data-tooltip" T.deleteThisContract ] [ A.icon "icon-x", loadingSpin deleteLoading ] ] else text "" diff --git a/src/Org/Tension.elm b/src/Org/Tension.elm index 5122c77d..0b7cdbac 100644 --- a/src/Org/Tension.elm +++ b/src/Org/Tension.elm @@ -42,6 +42,7 @@ import Bulk.Codecs , nid2rootid , nodeFromFragment , tensionAction2NodeType + , toLink , uriFromNameid , uriFromUsername ) @@ -487,6 +488,14 @@ init global flags = nodeView = Dict.get "v" query |> withDefault [] |> List.head |> withDefault "" |> NodeDoc.nodeViewDecoder + path_data = + ternary fs.orgChange Loading (fromMaybeData global.session.path_data Loading) + + focusid = + withMaybeData path_data + |> Maybe.map (\p -> p.focus.nameid) + |> withDefault newFocus.nameid + model = { node_focus = newFocus , lookup_users = [] @@ -496,7 +505,7 @@ init global flags = , activeTab = tab , nodeView = nodeView , jumpTo = Dict.get "goto" query |> Maybe.map List.head |> withDefault Nothing - , path_data = ternary fs.orgChange Loading (fromMaybeData global.session.path_data Loading) + , path_data = path_data , tension_head = ternary fs.orgChange Loading (fromMaybeData global.session.tension_head Loading) , focusState = fs , tension_comments = Loading @@ -520,7 +529,7 @@ init global flags = , title_result = NotAsked -- Comment Edit - , comment_form = initCommentPatchForm (toReflink conf.url) global.session.user + , comment_form = initCommentPatchForm global.session.user [ ( "reflink", toReflink conf.url ), ( "focusid", focusid ) ] , comment_result = NotAsked -- Blob Edit @@ -1121,8 +1130,11 @@ update global message model = other -> other + focusid = + withMaybeData model.path_data |> Maybe.map (\p -> p.focus.nameid) |> withDefault model.node_focus.nameid + resetForm = - initCommentPatchForm (toReflink model.conf.url) global.session.user + initCommentPatchForm global.session.user [ ( "reflink", toReflink model.conf.url ), ( "focusid", focusid ) ] in ( { model | tension_comments = tension_c, comment_form = resetForm, comment_result = result }, Cmd.none, Ports.bulma_driver "" ) @@ -2072,7 +2084,7 @@ viewComments conf action history_m comments_m comment_form comment_result expand Just _ -> case LE.getAt e.i history of Just event -> - viewEvent conf action event + viewEvent conf (Dict.get "focusid" comment_form.post) action event Nothing -> text "" @@ -2170,8 +2182,8 @@ viewComments conf action history_m comments_m comment_form comment_result expand |> div [] -viewEvent : Conf -> Maybe TensionAction.TensionAction -> Event -> Html Msg -viewEvent conf action event = +viewEvent : Conf -> Maybe String -> Maybe TensionAction.TensionAction -> Event -> Html Msg +viewEvent conf focusid_m action event = let eventView = case event.event_type of @@ -2200,10 +2212,10 @@ viewEvent conf action event = viewEventAssignee conf.lang conf.now event False TensionEvent.LabelAdded -> - viewEventLabel conf.lang conf.now event True + viewEventLabel focusid_m conf.lang conf.now event True TensionEvent.LabelRemoved -> - viewEventLabel conf.lang conf.now event False + viewEventLabel focusid_m conf.lang conf.now event False TensionEvent.BlobPushed -> viewEventPushed conf.lang conf.now event action @@ -2362,8 +2374,8 @@ viewEventAssignee lang now event isNew = ] -viewEventLabel : Lang.Lang -> Time.Posix -> Event -> Bool -> List (Html Msg) -viewEventLabel lang now event isNew = +viewEventLabel : Maybe String -> Lang.Lang -> Time.Posix -> Event -> Bool -> List (Html Msg) +viewEventLabel focusid_m lang now event isNew = let icon = A.icon "icon-tag" @@ -2377,12 +2389,19 @@ viewEventLabel lang now event isNew = label = Label "" (SE.leftOfBack "§" value) (SE.rightOfBack "§" value |> Just) [] + + link = + Maybe.map + (\nid -> + toLink TensionsBaseUri nid [] ++ ("?l=" ++ label.name) + ) + focusid_m in [ div [ class "media-left" ] [ icon ] , div [ class "media-content" ] - [ span [] <| + [ span [ class "labelsList" ] <| List.intersperse (text " ") - [ viewUsernameLink event.createdBy.username, strong [] [ text actionText ], viewLabel "" Nothing label, text (formatDate lang now event.createdAt) ] + [ viewUsernameLink event.createdBy.username, strong [] [ text actionText ], viewLabel "" link label, text (formatDate lang now event.createdAt) ] ] ] diff --git a/src/Query/PatchContract.elm b/src/Query/PatchContract.elm index 5c0259d1..bef2d8b7 100644 --- a/src/Query/PatchContract.elm +++ b/src/Query/PatchContract.elm @@ -189,10 +189,13 @@ commentInputDecoder f = message = Dict.get "message" f.post + contractid = + Dict.get "contractid" f.post |> withDefault "" + inputReq = { filter = Input.buildContractFilter - (\ft -> { ft | id = Present [ encodeId f.pid ] }) + (\ft -> { ft | id = Present [ encodeId contractid ] }) } inputOpt =