Skip to content

Commit

Permalink
ui/fix: link label in tension view.
Browse files Browse the repository at this point in the history
  • Loading branch information
dtrckd committed Jan 12, 2023
1 parent 64f4a76 commit dbcbe47
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 43 deletions.
10 changes: 6 additions & 4 deletions assets/sass/fractal6.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 6 additions & 2 deletions i18n/i18n.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down Expand Up @@ -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"
Expand Down
8 changes: 3 additions & 5 deletions src/Bulk.elm
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
16 changes: 6 additions & 10 deletions src/Bulk/View.elm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 13 additions & 9 deletions src/Components/ContractsPage.elm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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 "" ]
Expand Down Expand Up @@ -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 "" ]
Expand Down Expand Up @@ -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 ]
Expand All @@ -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 ""
Expand Down
43 changes: 31 additions & 12 deletions src/Org/Tension.elm
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import Bulk.Codecs
, nid2rootid
, nodeFromFragment
, tensionAction2NodeType
, toLink
, uriFromNameid
, uriFromUsername
)
Expand Down Expand Up @@ -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 = []
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 "" )

Expand Down Expand Up @@ -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 ""
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand All @@ -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) ]
]
]

Expand Down
5 changes: 4 additions & 1 deletion src/Query/PatchContract.elm
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down

0 comments on commit dbcbe47

Please sign in to comment.