Skip to content

Commit 47c9295

Browse files
committed
Impl clickable parameter chips
1 parent afacdc4 commit 47c9295

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/ui/panel/ParameterView.re

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ open Lwt
22
open Cohttp
33
open Cohttp_lwt
44

5+
module Js = Js_of_ocaml.Js
56
module Client = Cohttp_lwt_jsoo.Client
67
module ReactDOM = React.Dom
78

@@ -75,6 +76,18 @@ let make = (~goblint_path, ~inputValue, ~setInputValue,~disableRun, ~setDisableR
7576
setSortDesc(_ => !sortDesc);
7677
}
7778

79+
let on_add_parameter = (ev) => {
80+
let target = React.Event.Mouse.target(ev) |> ReactDOM.domElement_of_js;
81+
let unresolved_parameter = target##.textContent |> Js.Opt.to_option;
82+
83+
let parameter = switch unresolved_parameter {
84+
| Some(p) => Js.to_string(p) ++ " "
85+
| None => ""
86+
};
87+
88+
setInputValue(inputVal => String.cat(parameter, inputVal));
89+
}
90+
7891
let is_input_invalid = (parameter_list: list((string, string)), is_malformed, input_val): inputState => {
7992
if (String.length(input_val) == 0) {
8093
Empty
@@ -156,6 +169,9 @@ let make = (~goblint_path, ~inputValue, ~setInputValue,~disableRun, ~setDisableR
156169
Client.post(config_uri, ~body=config_body, ~headers=headers) >>=
157170
((res, body)) => {
158171
let code = res |> Response.status |> Code.code_of_status;
172+
/*let msg_from_body = Cohttp_lwt.Body.to_string(body) >|= (body) => {
173+
Lwt.return(body)
174+
}*/
159175
let _ = Body.drain_body(body);
160176

161177
if (code < 200 || code >= 400) {
@@ -271,7 +287,9 @@ let make = (~goblint_path, ~inputValue, ~setInputValue,~disableRun, ~setDisableR
271287
</div>
272288
<div className="col">
273289
{parameter_grouping |> List.mapi((j,e) => {
274-
<span key={"pill_" ++ string_of_int(j)} className="m-1 badge rounded-pill bg-secondary text">{e |> React.string}</span>
290+
<span key={"pill_" ++ string_of_int(j)} className="m-1 badge rounded-pill bg-secondary text" style={ReactDOM.Style.make(~cursor="pointer", ())} onClick=on_add_parameter>
291+
{e |> React.string}
292+
</span>
275293
}) |> React.list}
276294
</div>
277295
</div>

0 commit comments

Comments
 (0)