summaryrefslogtreecommitdiff
path: root/editor/actions/actions.ml
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@chimrod.com>2021-06-01 13:11:58 +0200
committerSébastien Dailly <sebastien@dailly.me>2022-02-07 16:43:33 +0100
commit72e3b16bbd258e63f047392c973ba5e8f0a823c8 (patch)
tree67f75383a9d20590587c648ecb5e3c78f6bd0044 /editor/actions/actions.ml
parent54f6e68c051afec0d20c349352feee5356e11b35 (diff)
Added export button in editor
Diffstat (limited to 'editor/actions/actions.ml')
-rwxr-xr-xeditor/actions/actions.ml133
1 files changed, 0 insertions, 133 deletions
diff --git a/editor/actions/actions.ml b/editor/actions/actions.ml
deleted file mode 100755
index f35beef..0000000
--- a/editor/actions/actions.ml
+++ /dev/null
@@ -1,133 +0,0 @@
-open StdLabels
-open Js_of_ocaml
-open Brr
-open Brr_note
-
-type button_actions =
- { delete : State.event Note.event
- ; redirect : State.event Note.event
- ; add: State.event Note.event
- }
-
-let populate_menu
- : 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
- ~at:At.[ class' (Jstr.v "action-button") ]
- [ El.i []
- ~at:At.[ class' (Jstr.v "fa")
- ; class' (Jstr.v "fa-2x")
- ; class' (Jstr.v "fa-trash") ] ]
-
- and home_button = El.button
- ~at:At.[ class' (Jstr.v "action-button") ]
- [ El.i []
- ~at:At.[ class' (Jstr.v "fa")
- ; class' (Jstr.v "fa-2x")
- ; class' (Jstr.v "fa-home") ] ]
-
- and add_button = El.button
- ~at:At.[ class' (Jstr.v "action-button") ]
- [ El.i []
- ~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 =
- Note.E.join (
- Evr.on_el
- Ev.click
- (fun _ -> Delete_page.create ())
- delete_button)
-
- (* Event on popup creation *)
- and add_event =
- 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 =
- List.map
- stored_pages
- ~f:(fun id ->
-
- let name_opt = (State.Storage.load (Some id))##.title in
- let name = Js.Opt.get
- name_opt
- (fun () -> id) in
-
- let target = Jstr.v "#" in
- El.li
- [ El.a
- ~at:[At.href target]
- [ El.txt name ] ]) in
-
- (* Wait for a click on an existing page in order to sent the associated
- event.
-
- 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 : State.Event with type t = Load_page.M.t ) in
-
- let redirect_event = Note.E.select
- (( Evr.on_el
- Ev.click
- (fun _ -> State.E (None, redirect_handler))
- home_button
- ) :: (
- List.map2 stored_pages pages
- ~f:(fun name el ->
- Evr.on_el
- Ev.click
- (fun _ -> State.E ((Some name), redirect_handler))
- el ))) in
-
- let childs =
- [ home_button
- ; add_button
- ; El.button
- ~at:At.[class' (Jstr.v "action-button")]
- [ El.i
- []
- ~at:At.[ class' (Jstr.v "fa")
- ; class' (Jstr.v "fa-2x")
- ; class' (Jstr.v "fa-download") ]
- ]
- ; delete_button
- ; El.button
- ~at:At.[class' (Jstr.v "action-button")]
- [ El.i
- []
- ~at:At.[ class' (Jstr.v "fa")
- ; class' (Jstr.v "fa-2x")
- ; class' (Jstr.v "fa-cog") ]
- ]
- ; El.hr ()
- ; El.ul
- pages
- ] in
-
- let () = El.append_children element childs in
- Some
- { delete = delete_event
- ; redirect = redirect_event
- ; add = add_event
- }