Design change: transformer of non-multi input-fields get two
arguments: the input-field *and* the binding value (not only the binding value) Rational: (a) transformers of non-multi input-fields can now access the attribute field of the input-field record, (b) there is no real reason why to treat multi and non-multi input-fields differently in respect to their transformer arguments (keep design simple). Updates of current surflets only necessary if they create their own non-multi input-fields (with make-input-field). Example surlfets calculate.scm and calculate-cb.scm updated as well as standard HTML input-fields provided by the SUrflets.
This commit is contained in:
parent
299a4ef815
commit
15f07f8d4a
|
@ -124,7 +124,8 @@
|
||||||
((real-input-field-transformer real-input-field) input-field bindings))
|
((real-input-field-transformer real-input-field) input-field bindings))
|
||||||
((real-input-field-binding real-input-field bindings) =>
|
((real-input-field-binding real-input-field bindings) =>
|
||||||
(lambda (binding)
|
(lambda (binding)
|
||||||
((real-input-field-transformer real-input-field) (cdr binding))))
|
((real-input-field-transformer real-input-field)
|
||||||
|
input-field (cdr binding))))
|
||||||
(else
|
(else
|
||||||
(error "no such input-field" input-field bindings)))))
|
(error "no such input-field" input-field bindings)))))
|
||||||
|
|
||||||
|
|
|
@ -56,10 +56,12 @@
|
||||||
(define set-simple-field-default!
|
(define set-simple-field-default!
|
||||||
(make-simple-default-setter simple-default?))
|
(make-simple-default-setter simple-default?))
|
||||||
|
|
||||||
|
(define (second-arg first second) second)
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;
|
||||||
;;; Text input field
|
;;; Text input field
|
||||||
(define make-text-field
|
(define make-text-field
|
||||||
(simple-field-maker "text" "text" simple-default? identity))
|
(simple-field-maker "text" "text" simple-default? second-arg))
|
||||||
(define set-text-field-value! set-simple-field-default!)
|
(define set-text-field-value! set-simple-field-default!)
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
@ -67,7 +69,7 @@
|
||||||
(define (number-field-default? value)
|
(define (number-field-default? value)
|
||||||
(or (number? value)
|
(or (number? value)
|
||||||
(simple-default? value)))
|
(simple-default? value)))
|
||||||
(define (number-field-transformer string)
|
(define (number-field-transformer input-field string)
|
||||||
(or (string->number string)
|
(or (string->number string)
|
||||||
(error "wrong type")))
|
(error "wrong type")))
|
||||||
(define make-number-field
|
(define make-number-field
|
||||||
|
@ -82,14 +84,14 @@
|
||||||
;; as it is hidden.
|
;; as it is hidden.
|
||||||
(define make-hidden-field
|
(define make-hidden-field
|
||||||
(simple-field-maker "hidden" "hidden"
|
(simple-field-maker "hidden" "hidden"
|
||||||
simple-default? identity))
|
simple-default? second-arg))
|
||||||
(define set-hidden-field-value! set-simple-field-default!)
|
(define set-hidden-field-value! set-simple-field-default!)
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;;; Password input field
|
;;; Password input field
|
||||||
(define make-password-field
|
(define make-password-field
|
||||||
(simple-field-maker "password" "password"
|
(simple-field-maker "password" "password"
|
||||||
simple-default? identity))
|
simple-default? second-arg))
|
||||||
(define set-password-field-value! set-simple-field-default!)
|
(define set-password-field-value! set-simple-field-default!)
|
||||||
|
|
||||||
;;; That's it for simple input fields.
|
;;; That's it for simple input fields.
|
||||||
|
@ -110,7 +112,7 @@
|
||||||
,@(sxml-attribute-attributes attributes))))
|
,@(sxml-attribute-attributes attributes))))
|
||||||
(make-input-field
|
(make-input-field
|
||||||
name "textarea"
|
name "textarea"
|
||||||
identity
|
second-arg
|
||||||
(make-field-attributes (and default-text)
|
(make-field-attributes (and default-text)
|
||||||
all-attributes)
|
all-attributes)
|
||||||
make-textarea-html-tree))))
|
make-textarea-html-tree))))
|
||||||
|
@ -282,7 +284,7 @@
|
||||||
;; internal
|
;; internal
|
||||||
(define (make-single-select name select-options attributes)
|
(define (make-single-select name select-options attributes)
|
||||||
(make-input-field name "select"
|
(make-input-field name "select"
|
||||||
(lambda (tag)
|
(lambda (input-field tag)
|
||||||
(cond ((find-select-option-value tag select-options)
|
(cond ((find-select-option-value tag select-options)
|
||||||
=> identity)
|
=> identity)
|
||||||
(else (error "no such option." tag))))
|
(else (error "no such option." tag))))
|
||||||
|
@ -330,7 +332,7 @@
|
||||||
((checked? #f boolean?)
|
((checked? #f boolean?)
|
||||||
(attributes '() sxml-attribute?))
|
(attributes '() sxml-attribute?))
|
||||||
(make-input-field name "radio"
|
(make-input-field name "radio"
|
||||||
identity
|
second-arg
|
||||||
(make-field-attributes
|
(make-field-attributes
|
||||||
(and checked? '(checked))
|
(and checked? '(checked))
|
||||||
`((value ,value-string)
|
`((value ,value-string)
|
||||||
|
@ -367,7 +369,7 @@
|
||||||
|
|
||||||
|
|
||||||
(define (make-radio-transformer value-table)
|
(define (make-radio-transformer value-table)
|
||||||
(lambda (tag)
|
(lambda (input-field tag)
|
||||||
(cond
|
(cond
|
||||||
((string->number tag) =>
|
((string->number tag) =>
|
||||||
(lambda (number)
|
(lambda (number)
|
||||||
|
@ -420,7 +422,7 @@
|
||||||
checkbox-html-tree-maker))))
|
checkbox-html-tree-maker))))
|
||||||
|
|
||||||
(define (make-checkbox-transformer value)
|
(define (make-checkbox-transformer value)
|
||||||
(lambda (tag)
|
(lambda (input-field tag)
|
||||||
(if (string=? tag "on")
|
(if (string=? tag "on")
|
||||||
value
|
value
|
||||||
#f)))
|
#f)))
|
||||||
|
@ -443,7 +445,7 @@
|
||||||
;; button input-fields
|
;; button input-fields
|
||||||
(define (make-button type name button-caption attributes)
|
(define (make-button type name button-caption attributes)
|
||||||
(make-input-field name type
|
(make-input-field name type
|
||||||
identity
|
second-arg
|
||||||
(make-field-attributes
|
(make-field-attributes
|
||||||
(and button-caption `(value ,button-caption))
|
(and button-caption `(value ,button-caption))
|
||||||
(sxml-attribute-attributes attributes))
|
(sxml-attribute-attributes attributes))
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
(let ((name (generate-input-field-name "operator")))
|
(let ((name (generate-input-field-name "operator")))
|
||||||
(make-input-field
|
(make-input-field
|
||||||
name
|
name
|
||||||
(lambda (operator-string)
|
(lambda (input-field operator-string)
|
||||||
(cond
|
(cond
|
||||||
((assoc operator-string *operator-alist*) =>
|
((assoc operator-string *operator-alist*) =>
|
||||||
(lambda (a) a))
|
(lambda (a) a))
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
(let ((name (generate-input-field-name "operator")))
|
(let ((name (generate-input-field-name "operator")))
|
||||||
(make-input-field
|
(make-input-field
|
||||||
name "operator"
|
name "operator"
|
||||||
(lambda (operator-string)
|
(lambda (input-field operator-string)
|
||||||
(let ((operator (assoc operator-string *operator-alist*)))
|
(let ((operator (assoc operator-string *operator-alist*)))
|
||||||
(if operator
|
(if operator
|
||||||
operator
|
operator
|
||||||
|
|
Loading…
Reference in New Issue