From 38e42723a916b7d5c2a15e514b3f3e6dcab398dd Mon Sep 17 00:00:00 2001 From: Joris Date: Sat, 8 Aug 2020 21:04:28 +0200 Subject: Propose already defined colors in the form --- src/View/Map/Marker.ml | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src/View/Map/Marker.ml') diff --git a/src/View/Map/Marker.ml b/src/View/Map/Marker.ml index e793742..80072af 100644 --- a/src/View/Map/Marker.ml +++ b/src/View/Map/Marker.ml @@ -1,4 +1,4 @@ -let form on_validate init_name init_color init_icon = +let form on_validate colors init_name init_color init_icon = let name = ref init_name in let color = ref init_color in let icon = ref init_icon in @@ -19,7 +19,7 @@ let form on_validate init_name init_color init_icon = [| Layout.section [| |] [| Form.input "g-MarkerForm__Name" "Name" init_name (fun newName -> name := newName) - ; Form.color_input "g-MarkerForm__Color" "Color" init_color (fun newColor -> color := newColor) + ; Form.color_input colors "g-MarkerForm__Color" "Color" init_color (fun newColor -> color := newColor) ; H.div [| HA.class_ "g-Form__Field" |] [| H.div @@ -59,7 +59,7 @@ let form on_validate init_name init_color init_icon = |] -let create on_remove on_update pos init_name init_color init_icon = +let create on_remove on_update colors pos init_name init_color init_icon = let marker = Leaflet.marker pos { title = init_name @@ -72,8 +72,13 @@ let create on_remove on_update pos init_name init_color init_icon = let () = Leaflet.on marker "contextmenu" (fun event -> ContextMenu.show (Leaflet.original_event event) - [| { label = "Modify"; action = fun _ -> Modal.show (form (on_update pos pos) init_name init_color init_icon) } - ; { label = "Remove"; action = fun _ -> on_remove pos } + [| { label = "Modify" + ; action = fun _ -> + Modal.show (form (on_update pos pos) colors init_name init_color init_icon) + } + ; { label = "Remove" + ; action = fun _ -> on_remove pos + } |]) in @@ -83,6 +88,6 @@ let create on_remove on_update pos init_name init_color init_icon = on_update pos newPos init_name init_color init_icon) in let () = Leaflet.on marker "dblclick" (fun _ -> - Modal.show (form (on_update pos pos) init_name init_color init_icon)) in + Modal.show (form (on_update pos pos) colors init_name init_color init_icon)) in marker -- cgit v1.2.3