summaryrefslogtreecommitdiff
path: root/editor/actions
diff options
context:
space:
mode:
Diffstat (limited to 'editor/actions')
-rwxr-xr-xeditor/actions/add_page.ml9
-rwxr-xr-xeditor/actions/editor_actions.ml37
-rwxr-xr-xeditor/actions/editor_actions.mli10
3 files changed, 28 insertions, 28 deletions
diff --git a/editor/actions/add_page.ml b/editor/actions/add_page.ml
index ec9768b..fcad87f 100755
--- a/editor/actions/add_page.ml
+++ b/editor/actions/add_page.ml
@@ -21,9 +21,16 @@ let create
: unit -> State.event Note.event
= fun () ->
let title = Jstr.v "Nouvelle page" in
+ let form = Forms.Add_page.create () in
+
+ let valid_on = Note.S.map
+ (fun Forms.Add_page.{title} -> not @@ Jstr.equal Jstr.empty title)
+ (fst form)
+ in
let ev = Elements.Popup.create
~title
- ~form:(Forms.Add_page.create ())
+ ~form
+ ~valid_on
()
in
Note.E.map
diff --git a/editor/actions/editor_actions.ml b/editor/actions/editor_actions.ml
index 5b2a3d3..91d2a24 100755
--- a/editor/actions/editor_actions.ml
+++ b/editor/actions/editor_actions.ml
@@ -4,7 +4,7 @@ open Brr_note
module Js = Js_of_ocaml.Js
-(** This is the attribute attached to each link in which containing the node id
+(** This is the attribute attached to each link and containing the node id
pointed by the link. *)
let note_id_attribute = Jstr.v "data-note-id"
@@ -47,8 +47,7 @@ let build
[]
~at:At.[ class' (Jstr.v "fa")
; class' (Jstr.v "fa-2x")
- ; class' (Jstr.v "fa-download") ]
- ]
+ ; class' (Jstr.v "fa-download") ] ]
and load_button = El.button
~at:At.[class' (Jstr.v "action-button")]
@@ -56,8 +55,7 @@ let build
[]
~at:At.[ class' (Jstr.v "fa")
; class' (Jstr.v "fa-2x")
- ; class' (Jstr.v "fa-upload") ]
- ]
+ ; class' (Jstr.v "fa-upload") ] ]
in
(* We are waiting for event inside another event ( form validation inside
@@ -139,8 +137,7 @@ let build
; class' (Jstr.v "fa-cog") ]
]
; El.hr ()
- ; ul
- ] in
+ ; ul ] in
let result_event =
Note.E.select
@@ -148,15 +145,13 @@ let build
; redirect_event
; add_event
; export_event
- ; import_event
- ] in
+ ; import_event ] in
{ ev = result_event
; childs
; ul
; delete_button
- ; completed = false
- }
+ ; completed = false }
let get_event
: t -> State.event Note.event
@@ -178,19 +173,19 @@ let get_notes _ =
let complete
: t -> State.t Note.signal -> El.t list
- = fun ({ childs; ul ; completed ; delete_button ; _ } as t) change ->
+ = fun t change ->
+ (* As we register some events, we have to prevent many execution of this
+ function *)
let () =
- if completed then
+ if t.completed then
raise (Failure "The action panel is already registered") in
-
- let note_list =
- Note.S.map get_notes
- change
- in
t.completed <- true;
- Elr.def_children ul note_list;
+ Elr.def_children
+ t.ul
+ (Note.S.map get_notes change);
+
Elr.def_at
(Jstr.v "disabled")
(Note.S.map
@@ -199,6 +194,6 @@ let complete
| None -> Some Jstr.empty
| Some _ -> None)
change)
- delete_button;
+ t.delete_button;
- childs
+ t.childs
diff --git a/editor/actions/editor_actions.mli b/editor/actions/editor_actions.mli
index 27b09d7..0e9997b 100755
--- a/editor/actions/editor_actions.mli
+++ b/editor/actions/editor_actions.mli
@@ -1,17 +1,15 @@
type t
-(** Create the elements to be declareds inside the panel *)
+(** Create the elements to be declared inside the panel *)
val build
: unit -> t
-(* Get the events triggered by the actions buttons *)
+(** Get the events triggered by the actions buttons *)
val get_event
: t -> State.event Note.event
-(* Finalize the creation, register the handler to state update, and return the dom elements.
+(** Finalize the creation, register the handler to state update, and return the dom elements.
- Raise an error if already completed.
-
-*)
+ Raise an error if already completed. *)
val complete
: t -> State.t Note.signal -> Brr.El.t list