Give form-dialog textarea capability

Adds generic function textarea-value in clog-form.lisp

Exports textarea-value in clog.lisp

Adds the option into form-dialog in clog-gui.lisp, with additional key
parameters for size and rows and adds it to the list of special field
types in the doc string.
This commit is contained in:
Sabra Crolleton 2023-10-02 10:32:25 -04:00
parent 6302deb6e6
commit 4a92ce256a
3 changed files with 56 additions and 22 deletions

View file

@ -465,6 +465,18 @@ be unique name on entire document."))
(clog-connection:query (connection-id obj)
(format nil "$('select[name=~A] option:selected').val()" name)))
;;;;;;;;;;;;;;;;
;; textarea-value ;;
;;;;;;;;;;;;;;;;
(defgeneric textarea-value (clog-obj name)
(:documentation "Returns the value of textarea item called NAME and must
be unique name on entire document."))
(defmethod textarea-value ((obj clog-obj) name)
(clog-connection:query (clog::connection-id obj)
(format nil "$('textarea#~A').val()" name)))
;;;;;;;;;;;;;;;;
;; name-value ;;
;;;;;;;;;;;;;;;;

View file

@ -1614,6 +1614,7 @@ Calls on-input with t if confirmed or nil if canceled."
(cancel-text "Cancel")
(left nil) (top nil)
(width 400) (height 500)
(size 40) (rows 4)
(client-movement nil)
(html-id nil))
"Create a form dialog box with CONTENT followed by FIELDS.
@ -1632,10 +1633,13 @@ Special field types
:checkbox t if checked
:radiobox a-list ((label name)) a third value can be added \"checked\"
:select a-list ((label name)) a third value can be added \"selected\"
:textarea value
:text value
(any text input types also work :email, :tel, etc.
see FORM-ELEMENT-TYPE)
The size of any texarea field is controled by the size and rows parameters
Calls on-input after OK or Cancel with an a-list of field name to value
if confirmed or nil if canceled."
(unless html-id
@ -1691,6 +1695,21 @@ if confirmed or nil if canceled."
"")
html-id (second l)
(first l)))
((eq (third l) :textarea)
(format nil
"<div><label class='w3-text-black'><b>~A</b></label>
<textarea
name='~A-~A' id='~A-~A' cols='~A' rows='~A'>~A</textarea></div>"
(first l)
html-id
(second l)
html-id
(second l)
size
rows
(if (fourth l)
(fourth l)
"")))
((third l)
(format nil
"<div><label class='w3-text-black'><b>~A</b></label>~
@ -1710,7 +1729,7 @@ if confirmed or nil if canceled."
(win (create-gui-window obj
:title title
:content (format nil
"<div class='w3-panel'>
"<div class='w3-panel'>
~A
<form class='w3-container' onSubmit='return false;'>
~A
@ -1777,6 +1796,8 @@ if confirmed or nil if canceled."
(radio-value win name))
((eq (third l) :checkbox)
(checkbox-value win name))
((eq (third l) :textarea)
(textarea-value win name))
(t
(name-value win name))))))
fields)))

View file

@ -690,6 +690,7 @@ embedded in a native template application.)"
(radio-value generic-function)
(checkbox-value generic-function)
(select-value generic-function)
(textarea-value generic-function)
(name-value generic-function)
(pattern generic-function)
(minimum generic-function)