From 61853feccb47157508380706d23a58e0eafeef1c Mon Sep 17 00:00:00 2001 From: David Botton Date: Wed, 24 Feb 2021 16:39:02 -0500 Subject: [PATCH] :checkbox, :email and other text based inputs support for form-dialog --- source/clog-form.lisp | 13 +++++++++++++ source/clog-gui.lisp | 25 ++++++++++++++++++++++--- source/clog.lisp | 1 + tutorial/22-tutorial.lisp | 4 +++- 4 files changed, 39 insertions(+), 4 deletions(-) diff --git a/source/clog-form.lisp b/source/clog-form.lisp index 9df458c..67dade2 100644 --- a/source/clog-form.lisp +++ b/source/clog-form.lisp @@ -382,6 +382,19 @@ group called NAME.")) (cc:query (connection-id obj) (format nil "$('input:radio[name=~A]:checked').val()" name))) + +;;;;;;;;;;;;;;;;;;;; +;; checkbox-value ;; +;;;;;;;;;;;;;;;;;;;; + +(defgeneric checkbox-value (clog-obj name) + (:documentation "Returns t or nil on the selected checkbox button.")) + +(defmethod checkbox-value ((obj clog-obj) name) + (js-on-p (cc:query (connection-id obj) + (format nil "$('input:checkbox[name=~A]:checked').val()" + name)))) + ;;;;;;;;;;;;;;;;;; ;; select-value ;; ;;;;;;;;;;;;;;;;;; diff --git a/source/clog-gui.lisp b/source/clog-gui.lisp index 21e0e86..c69b9de 100644 --- a/source/clog-gui.lisp +++ b/source/clog-gui.lisp @@ -1412,7 +1412,7 @@ with a-list of field name to value if confirmed or nil if canceled." ((eq (third l) :select) (format nil "
~ - " +
" (first l) html-id (second l) (format nil "~{~A~}" (mapcar (lambda (s) @@ -1421,12 +1421,13 @@ with a-list of field name to value if confirmed or nil if canceled." (fourth l))))) ((eq (third l) :radio) (format nil - "
~A" + "
~A
" (first l) (format nil "~{~A~}" (mapcar (lambda (s) (format nil - "
~ + "
~
" html-id (second l) html-id (second l) (second s) @@ -1434,6 +1435,22 @@ with a-list of field name to value if confirmed or nil if canceled." html-id (second l) (second s) (first s))) (fourth l))))) + ((eq (third l) :checkbox) + (format nil + "
~ + ~ +
" + html-id (second l) html-id (second l) + html-id (second l) + (first l))) + ((third l) + (format nil + "
~ +
" + (first l) (third l) + html-id (second l) html-id (second l))) (t (format nil "
~ @@ -1508,6 +1525,8 @@ with a-list of field name to value if confirmed or nil if canceled." (select-value win name)) ((eq (third l) :radio) (radio-value win name)) + ((eq (third l) :checkbox) + (checkbox-value win name)) (t (name-value win name)))))) fields))) diff --git a/source/clog.lisp b/source/clog.lisp index 4bd747e..46aeeea 100644 --- a/source/clog.lisp +++ b/source/clog.lisp @@ -494,6 +494,7 @@ embedded in a native template application.)" (default-value generic-function) (value generic-function) (radio-value generic-function) + (checkbox-value generic-function) (select-value generic-function) (name-value generic-function) (pattern generic-function) diff --git a/tutorial/22-tutorial.lisp b/tutorial/22-tutorial.lisp index 77df9fe..b40c2ce 100644 --- a/tutorial/22-tutorial.lisp +++ b/tutorial/22-tutorial.lisp @@ -82,11 +82,13 @@ ("Brown" "brown") ("Green" "green") ("Other" "other"))) + ("Send Mail" "send-mail" :checkbox) ("Name" "name") ("Address" "address") ("City" "city") ("State" "st") - ("Zip" "zip")) + ("Zip" "zip") + ("E-Mail" "email" :email)) (lambda (results) (alert-dialog obj results)) :height 550))