diff options
author | Sébastien Dailly <sebastien@dailly.me> | 2022-02-07 16:21:26 +0100 |
---|---|---|
committer | Sébastien Dailly <sebastien@dailly.me> | 2022-02-07 16:43:33 +0100 |
commit | fe2cced55e1b44dbae57e55fe0f459c85e7369cb (patch) | |
tree | e7ca5f015da050b37aa759a277198512236c97f5 /editor/actions/actions.ml | |
parent | 1eeaf137bd30aff1bef34d05eeec686f6da8959d (diff) |
Application unification
Diffstat (limited to 'editor/actions/actions.ml')
-rwxr-xr-x | editor/actions/actions.ml | 47 |
1 files changed, 27 insertions, 20 deletions
diff --git a/editor/actions/actions.ml b/editor/actions/actions.ml index e8b4d71..b150279 100755 --- a/editor/actions/actions.ml +++ b/editor/actions/actions.ml @@ -7,16 +7,17 @@ module Event = Event type button_actions = { delete : Event.t Note.event - ; redirect : Jstr.t option Note.event + ; redirect : Event.t Note.event ; add: Event.t Note.event } let populate_menu - : Forms.Events.event option Note.E.send -> button_actions option - = fun sender -> + : unit -> button_actions option + = fun () -> match Blog.Sidebar.get () with | None -> None | Some element -> + let () = Blog.Sidebar.clean element in let delete_button = El.button @@ -39,24 +40,27 @@ let populate_menu ~at:At.[ class' (Jstr.v "fa") ; class' (Jstr.v "fa-2x") ; class' (Jstr.v "fa-plus") ] ] - in + (* We are waiting for event inside another event ( form validation inside + popup creation. + + Note.E.join is used here in order to get only te popup validation. *) let delete_event = - Evr.on_el - Ev.click - (fun _ -> Event.E - ( sender - , (module Delete_page: Event.Handler with type t = Delete_page.t)) ) - delete_button + Note.E.join ( + Evr.on_el + Ev.click + (fun _ -> Delete_page.create ()) + delete_button) + (* Event on popup creation *) and add_event = - Evr.on_el - Ev.click - (fun _ -> Event.E - ( sender - , (module Add_page: Event.Handler with type t = Add_page.t)) ) - add_button in + Note.E.join ( + Evr.on_el + Ev.click + (fun _ -> Add_page.create ()) + add_button) in + let stored_pages = State.Storage.get_ids () in let pages = @@ -73,8 +77,7 @@ let populate_menu El.li [ El.a ~at:[At.href target] - [ El.txt name ] ] - ) in + [ El.txt name ] ]) in (* Wait for a click on an existing page in order to sent the associated event. @@ -82,17 +85,21 @@ let populate_menu We compose the resulting event with both : - the home button - the list for all the pages presents in the sidebar *) + + let redirect_handler = + (module Load_page.M : Event.Handler with type t = Load_page.M.t ) in + let redirect_event = Note.E.select (( Evr.on_el Ev.click - (fun _ -> None) + (fun _ -> Event.E (None, redirect_handler)) home_button ) :: ( List.map2 stored_pages pages ~f:(fun name el -> Evr.on_el Ev.click - (fun _ -> Some name) + (fun _ -> Event.E ((Some name), redirect_handler)) el ))) in let childs = |