From 4ba4951e530cbdfb6fa7bee811456208a83ce1dd Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Mon, 7 Feb 2022 15:17:51 +0100 Subject: In popup, added a predicate to validate the form --- editor/actions/add_page.ml | 3 ++- editor/actions/delete_page.ml | 3 ++- editor/actions/import.ml | 7 ++++++- editor/actions/load_page.ml | 1 - 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/editor/actions/add_page.ml b/editor/actions/add_page.ml index e5e8541..ec9768b 100755 --- a/editor/actions/add_page.ml +++ b/editor/actions/add_page.ml @@ -23,7 +23,8 @@ let create let title = Jstr.v "Nouvelle page" in let ev = Elements.Popup.create ~title - ~form:(Some (Forms.Add_page.create ())) + ~form:(Forms.Add_page.create ()) + () in Note.E.map (fun v -> State.E diff --git a/editor/actions/delete_page.ml b/editor/actions/delete_page.ml index 58c1d32..fbd4fde 100755 --- a/editor/actions/delete_page.ml +++ b/editor/actions/delete_page.ml @@ -22,7 +22,8 @@ let create in let ev = Elements.Popup.create ~title - ~form:(Some (Forms.Validation.create message )) + ~form:(Forms.Validation.create message) + () in Note.E.map (fun v -> State.E diff --git a/editor/actions/import.ml b/editor/actions/import.ml index 4cac76c..13ed938 100755 --- a/editor/actions/import.ml +++ b/editor/actions/import.ml @@ -44,9 +44,14 @@ end let create () = let title = Jstr.v "Importer des notes" in + let form = Forms.Selector.create () in let ev = Elements.Popup.create ~title - ~form:(Some (Forms.Selector.create ())) in + ~form + ~valid_on:(Note.S.map (fun form -> form.Forms.Selector.file != None) (fst form)) + () + in + Note.E.map (fun v -> State.E ( v diff --git a/editor/actions/load_page.ml b/editor/actions/load_page.ml index 349eaad..bcce51c 100755 --- a/editor/actions/load_page.ml +++ b/editor/actions/load_page.ml @@ -8,4 +8,3 @@ module M = struct State.load_page page_id state end - -- cgit v1.2.3