Skip to content

Commit dbcbe47

Browse files
committed
ui/fix: link label in tension view.
1 parent 64f4a76 commit dbcbe47

File tree

7 files changed

+69
-43
lines changed

7 files changed

+69
-43
lines changed

Diff for: assets/sass/fractal6.scss

+6-4
Original file line numberDiff line numberDiff line change
@@ -1841,18 +1841,20 @@ tr.mediaBox {
18411841
}
18421842

18431843
.labelsList {
1844+
.tag + .tag {
1845+
margin-left: 8px !important;
1846+
}
1847+
18441848
.tag {
1845-
margin-right: 8px !important;
18461849
border: 1px solid transparent;
1847-
&:hover {
1848-
border-color: var(--link2);
1849-
}
1850+
&:hover { border-color: var(--link2); }
18501851
}
18511852
}
18521853
.tension-labelsList {
18531854
margin-top: -8px;
18541855
.labelsList .tag {
18551856
margin-top: 8px;
1857+
&:hover { border-color: transparent; }
18561858
}
18571859
.help {
18581860
margin-top: 22px !important;

Diff for: i18n/i18n.toml

+6-2
Original file line numberDiff line numberDiff line change
@@ -924,6 +924,10 @@ Vous pouvez [Explorer](/explore) les organisations publiques ou créer votre [Pr
924924
- Vous pourrez la rejoindre a nouveau sur invitation seulement.
925925
"""
926926

927+
[deleteThisContract]
928+
en="Delete this contract"
929+
fr="Supprimer ce contrat"
930+
927931
[askAnotherQuestion]
928932
en="Ask another question."
929933
fr="Poser une autre question."
@@ -2064,8 +2068,8 @@ Vous pouvez [Explorer](/explore) les organisations publiques ou créer votre [Pr
20642068
fr="Etiquette retiré"
20652069

20662070
[assigneeAdded_event]
2067-
en="Assignee added"
2068-
fr="Assigné ajouté"
2071+
en="New assignment"
2072+
fr="Nouvelle assignation"
20692073

20702074
[assigneeRemoved_event]
20712075
en="Assignee removed"

Diff for: src/Bulk.elm

+3-5
Original file line numberDiff line numberDiff line change
@@ -174,19 +174,17 @@ type alias UserForm =
174174

175175
type alias CommentPatchForm =
176176
{ id : String -- comment id (for edit/patch)
177-
, pid : String -- parent id (e.g. tid of cid) (for creating)
178177
, uctx : UserCtx
179178
, post : Post
180179
, viewMode : InputViewMode
181180
}
182181

183182

184-
initCommentPatchForm : String -> UserState -> CommentPatchForm
185-
initCommentPatchForm reflink user =
183+
initCommentPatchForm : UserState -> List ( String, String ) -> CommentPatchForm
184+
initCommentPatchForm user data =
186185
{ uctx = uctxFromUser user
187186
, id = ""
188-
, pid = ""
189-
, post = Dict.fromList [ ( "reflink", reflink ) ]
187+
, post = Dict.fromList data
190188
, viewMode = Write
191189
}
192190

Diff for: src/Bulk/View.elm

+6-10
Original file line numberDiff line numberDiff line change
@@ -234,16 +234,12 @@ used to make labels clickable.
234234
viewLabels : Maybe String -> List Label -> Html msg
235235
viewLabels nid_m labels =
236236
let
237-
to_link_m =
238-
case nid_m of
239-
Just nid ->
240-
\l ->
241-
toLink TensionsBaseUri nid []
242-
++ ("?l=" ++ l)
243-
|> Just
244-
245-
Nothing ->
246-
\_ -> Nothing
237+
to_link_m name =
238+
Maybe.map
239+
(\nid ->
240+
toLink TensionsBaseUri nid [] ++ ("?l=" ++ name)
241+
)
242+
nid_m
247243
in
248244
span [ class "labelsList" ]
249245
(List.map

Diff for: src/Components/ContractsPage.elm

+13-9
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ initModel rootnameid user conf =
117117
, form = initContractForm user
118118
, voteForm = initVoteForm user
119119
, activeView = ContractsView
120-
, comment_form = initCommentPatchForm (toReflink conf.url) user
121-
, comment_patch_form = initCommentPatchForm (toReflink conf.url) user
120+
, comment_form = initCommentPatchForm user [ ( "reflink", toReflink conf.url ) ]
121+
, comment_patch_form = initCommentPatchForm user [ ( "reflink", toReflink conf.url ) ]
122122
, comment_result = NotAsked
123123

124124
-- Common
@@ -557,8 +557,10 @@ update_ apis message model =
557557
( { model
558558
| comment_form =
559559
{ form
560-
| pid = withMaybeDataMap .id model.contract_result |> withDefault ""
561-
, post = Dict.insert "createdAt" (fromTime time) form.post
560+
| post =
561+
form.post
562+
|> Dict.insert "createdAt" (fromTime time)
563+
|> Dict.insert "contractid" (withMaybeDataMap .id model.contract_result |> withDefault "")
562564
}
563565
, comment_result = LoadingSlowly
564566
}
@@ -593,7 +595,7 @@ update_ apis message model =
593595
other
594596

595597
resetForm =
596-
initCommentPatchForm (toReflink model.conf.url) model.user
598+
initCommentPatchForm model.user [ ( "reflink", toReflink model.conf.url ) ]
597599
in
598600
( { model | contract_result = contract, comment_form = resetForm, comment_result = result }
599601
, out0 [ Ports.bulma_driver "" ]
@@ -630,7 +632,7 @@ update_ apis message model =
630632
other
631633

632634
resetForm =
633-
initCommentPatchForm (toReflink model.conf.url) model.user
635+
initCommentPatchForm model.user [ ( "reflink", toReflink model.conf.url ) ]
634636
in
635637
( { model | contract_result = contract, comment_patch_form = resetForm, comment_result = result }
636638
, out0 [ Ports.bulma_driver "" ]
@@ -878,8 +880,10 @@ viewRow d op model =
878880
]
879881
[ td [ onClick (DoClickContract d.id) ]
880882
[ a
881-
[ href (Route.Tension_Dynamic_Dynamic_Contract_Dynamic { param1 = model.rootnameid, param2 = model.form.tid, param3 = d.id } |> toHref) ]
882-
[ text (contractEventToText d.event.event_type), Maybe.map (\x -> " | " ++ x) d.event.new |> withDefault "" |> text ]
883+
[ class "discrete-link"
884+
, href (Route.Tension_Dynamic_Dynamic_Contract_Dynamic { param1 = model.rootnameid, param2 = model.form.tid, param3 = d.id } |> toHref)
885+
]
886+
[ text (contractEventToText d.event.event_type), Maybe.map (\x -> "" ++ x) d.event.new |> withDefault "" |> text ]
883887
]
884888
, td [] [ span [] [ text (contractTypeToText d.contract_type) ] ]
885889
, td [ class "has-links-discrete" ] [ viewUsernameLink d.createdBy.username ]
@@ -897,7 +901,7 @@ viewRow d op model =
897901
[ class "button-light"
898902
, onClick <| DoModalConfirmOpen (DoDeleteContract d.id) { message = Nothing, txts = [ ( T.confirmDeleteContract, "" ), ( "?", "" ) ] }
899903
]
900-
[ span [ class "tag is-danger is-light is-smaller2" ] [ A.icon "icon-x", loadingSpin deleteLoading ] ]
904+
[ span [ class "tag is-danger is-light is-smaller2 tooltip has-tooltip-arrow", attribute "data-tooltip" T.deleteThisContract ] [ A.icon "icon-x", loadingSpin deleteLoading ] ]
901905

902906
else
903907
text ""

Diff for: src/Org/Tension.elm

+31-12
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import Bulk.Codecs
4242
, nid2rootid
4343
, nodeFromFragment
4444
, tensionAction2NodeType
45+
, toLink
4546
, uriFromNameid
4647
, uriFromUsername
4748
)
@@ -487,6 +488,14 @@ init global flags =
487488
nodeView =
488489
Dict.get "v" query |> withDefault [] |> List.head |> withDefault "" |> NodeDoc.nodeViewDecoder
489490

491+
path_data =
492+
ternary fs.orgChange Loading (fromMaybeData global.session.path_data Loading)
493+
494+
focusid =
495+
withMaybeData path_data
496+
|> Maybe.map (\p -> p.focus.nameid)
497+
|> withDefault newFocus.nameid
498+
490499
model =
491500
{ node_focus = newFocus
492501
, lookup_users = []
@@ -496,7 +505,7 @@ init global flags =
496505
, activeTab = tab
497506
, nodeView = nodeView
498507
, jumpTo = Dict.get "goto" query |> Maybe.map List.head |> withDefault Nothing
499-
, path_data = ternary fs.orgChange Loading (fromMaybeData global.session.path_data Loading)
508+
, path_data = path_data
500509
, tension_head = ternary fs.orgChange Loading (fromMaybeData global.session.tension_head Loading)
501510
, focusState = fs
502511
, tension_comments = Loading
@@ -520,7 +529,7 @@ init global flags =
520529
, title_result = NotAsked
521530

522531
-- Comment Edit
523-
, comment_form = initCommentPatchForm (toReflink conf.url) global.session.user
532+
, comment_form = initCommentPatchForm global.session.user [ ( "reflink", toReflink conf.url ), ( "focusid", focusid ) ]
524533
, comment_result = NotAsked
525534

526535
-- Blob Edit
@@ -1121,8 +1130,11 @@ update global message model =
11211130
other ->
11221131
other
11231132

1133+
focusid =
1134+
withMaybeData model.path_data |> Maybe.map (\p -> p.focus.nameid) |> withDefault model.node_focus.nameid
1135+
11241136
resetForm =
1125-
initCommentPatchForm (toReflink model.conf.url) global.session.user
1137+
initCommentPatchForm global.session.user [ ( "reflink", toReflink model.conf.url ), ( "focusid", focusid ) ]
11261138
in
11271139
( { model | tension_comments = tension_c, comment_form = resetForm, comment_result = result }, Cmd.none, Ports.bulma_driver "" )
11281140

@@ -2072,7 +2084,7 @@ viewComments conf action history_m comments_m comment_form comment_result expand
20722084
Just _ ->
20732085
case LE.getAt e.i history of
20742086
Just event ->
2075-
viewEvent conf action event
2087+
viewEvent conf (Dict.get "focusid" comment_form.post) action event
20762088

20772089
Nothing ->
20782090
text ""
@@ -2170,8 +2182,8 @@ viewComments conf action history_m comments_m comment_form comment_result expand
21702182
|> div []
21712183

21722184

2173-
viewEvent : Conf -> Maybe TensionAction.TensionAction -> Event -> Html Msg
2174-
viewEvent conf action event =
2185+
viewEvent : Conf -> Maybe String -> Maybe TensionAction.TensionAction -> Event -> Html Msg
2186+
viewEvent conf focusid_m action event =
21752187
let
21762188
eventView =
21772189
case event.event_type of
@@ -2200,10 +2212,10 @@ viewEvent conf action event =
22002212
viewEventAssignee conf.lang conf.now event False
22012213

22022214
TensionEvent.LabelAdded ->
2203-
viewEventLabel conf.lang conf.now event True
2215+
viewEventLabel focusid_m conf.lang conf.now event True
22042216

22052217
TensionEvent.LabelRemoved ->
2206-
viewEventLabel conf.lang conf.now event False
2218+
viewEventLabel focusid_m conf.lang conf.now event False
22072219

22082220
TensionEvent.BlobPushed ->
22092221
viewEventPushed conf.lang conf.now event action
@@ -2362,8 +2374,8 @@ viewEventAssignee lang now event isNew =
23622374
]
23632375

23642376

2365-
viewEventLabel : Lang.Lang -> Time.Posix -> Event -> Bool -> List (Html Msg)
2366-
viewEventLabel lang now event isNew =
2377+
viewEventLabel : Maybe String -> Lang.Lang -> Time.Posix -> Event -> Bool -> List (Html Msg)
2378+
viewEventLabel focusid_m lang now event isNew =
23672379
let
23682380
icon =
23692381
A.icon "icon-tag"
@@ -2377,12 +2389,19 @@ viewEventLabel lang now event isNew =
23772389

23782390
label =
23792391
Label "" (SE.leftOfBack "§" value) (SE.rightOfBack "§" value |> Just) []
2392+
2393+
link =
2394+
Maybe.map
2395+
(\nid ->
2396+
toLink TensionsBaseUri nid [] ++ ("?l=" ++ label.name)
2397+
)
2398+
focusid_m
23802399
in
23812400
[ div [ class "media-left" ] [ icon ]
23822401
, div [ class "media-content" ]
2383-
[ span [] <|
2402+
[ span [ class "labelsList" ] <|
23842403
List.intersperse (text " ")
2385-
[ viewUsernameLink event.createdBy.username, strong [] [ text actionText ], viewLabel "" Nothing label, text (formatDate lang now event.createdAt) ]
2404+
[ viewUsernameLink event.createdBy.username, strong [] [ text actionText ], viewLabel "" link label, text (formatDate lang now event.createdAt) ]
23862405
]
23872406
]
23882407

Diff for: src/Query/PatchContract.elm

+4-1
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,13 @@ commentInputDecoder f =
189189
message =
190190
Dict.get "message" f.post
191191

192+
contractid =
193+
Dict.get "contractid" f.post |> withDefault ""
194+
192195
inputReq =
193196
{ filter =
194197
Input.buildContractFilter
195-
(\ft -> { ft | id = Present [ encodeId f.pid ] })
198+
(\ft -> { ft | id = Present [ encodeId contractid ] })
196199
}
197200

198201
inputOpt =

0 commit comments

Comments
 (0)