[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
05/09: Make the form-horizontal-control procedure aware of hidden inputs
From: |
Christopher Baines |
Subject: |
05/09: Make the form-horizontal-control procedure aware of hidden inputs |
Date: |
Sun, 7 Jun 2020 16:27:59 -0400 (EDT) |
cbaines pushed a commit to branch master
in repository data-service.
commit 14cd95f2449a8917850be7c0e9e0bb0cc5420a7f
Author: Danjela Lura <danielaluraa@gmail.com>
AuthorDate: Fri May 29 17:27:13 2020 +0200
Make the form-horizontal-control procedure aware of hidden inputs
Signed-off-by: Christopher Baines <mail@cbaines.net>
---
guix-data-service/web/view/html.scm | 240 +++++++++++++++++++-----------------
1 file changed, 125 insertions(+), 115 deletions(-)
diff --git a/guix-data-service/web/view/html.scm
b/guix-data-service/web/view/html.scm
index 39f2101..d734cd0 100644
--- a/guix-data-service/web/view/html.scm
+++ b/guix-data-service/web/view/html.scm
@@ -133,123 +133,133 @@
(invalid-query-parameter? val))))
(show-help-span?
(or help-text has-error? required?)))
- `(div
- (@ (class ,(string-append
- "form-group form-group-lg"
- (if has-error? " has-error" ""))))
- (label (@ (for ,input-id)
- (class "col-sm-2 control-label"))
- ,label)
- (div
- (@ (class "col-sm-9"))
- ,(if options
- `(select (@ (class "form-control")
- (style ,(if font-family
- (string-append
- "font-family: " font-family ";")
- ""))
- ,@(if allow-selecting-multiple-options
- '((multiple #t))
- '())
- (id ,input-id)
- ,@(if show-help-span?
- `((aria-describedby ,help-span-id))
- '())
+ (if (string=? type "hidden")
+ `(input (@ (class "form-control")
+ (id ,input-id)
+ (type ,type)
+ (name ,input-name)
+ ,@(match (assq (string->symbol input-name)
+ query-parameters)
+ (#f '())
+ ((_key . value)
+ `((value ,(value->text value)))))))
+ `(div
+ (@ (class ,(string-append
+ "form-group form-group-lg"
+ (if has-error? " has-error" ""))))
+ (label (@ (for ,input-id)
+ (class "col-sm-2 control-label"))
+ ,label)
+ (div
+ (@ (class "col-sm-9"))
+ ,(if options
+ `(select (@ (class "form-control")
+ (style ,(if font-family
+ (string-append
+ "font-family: " font-family ";")
+ ""))
+ ,@(if allow-selecting-multiple-options
+ '((multiple #t))
+ '())
+ (id ,input-id)
+ ,@(if show-help-span?
+ `((aria-describedby ,help-span-id))
+ '())
- (name ,input-name))
- ,@(let ((selected-options
- (match (assq (string->symbol input-name)
- query-parameters)
- ((_key . value)
- (if (not allow-selecting-multiple-options)
- (list value)
- value))
- (_ '()))))
+ (name ,input-name))
+ ,@(let ((selected-options
+ (match (assq (string->symbol input-name)
+ query-parameters)
+ ((_key . value)
+ (if (not allow-selecting-multiple-options)
+ (list value)
+ value))
+ (_ '()))))
- (map (match-lambda
- ((option-label . option-value)
- `(option
- (@ ,@(if (member (if (and
- (string? option-value)
- (string=? option-value
-
null-string-value))
- ""
- option-value)
- selected-options)
- '((selected ""))
- '())
- (value ,option-value))
- ,(value->text option-label)))
- (option-value
- `(option
- (@ ,@(if (member (if (and
- (string? option-value)
- (string=? option-value
-
null-string-value))
- ""
- option-value)
- selected-options)
- '((selected ""))
- '()))
- ,(value->text option-value))))
- options)))
- `(input (@ (class "form-control")
- (style ,(if font-family
- (string-append
- "font-family: " font-family ";")
- ""))
- (id ,input-id)
- (type ,type)
- ,@(if required?
- '((required #t))
- '())
- ,@(if show-help-span?
- `((aria-describedby ,help-span-id))
- '())
- (name ,input-name)
- ,@(match (assq (string->symbol input-name)
- query-parameters)
- (#f '())
- ((_key . ($ <invalid-query-parameter> value))
- (if (string=? type "checkbox")
- (if value
- '((checked #t))
- '())
- `((value ,(value->text value)))))
- ((_key . value)
- (if (string=? type "checkbox")
- (if value
- '((checked #t))
- '())
- `((value ,(value->text value)))))))))
- ,@(if show-help-span?
- `((span (@ (id ,help-span-id)
- (class "help-block"))
- ,@(if has-error?
- (let* ((val
- (assq-ref query-parameters
- (string->symbol input-name)))
- (messages
- (map invalid-query-parameter-message
- (if (list? val)
- val
- (list val)))))
- `((p
- ,@(if (null? messages)
- '(string "Error: invalid value")
- (map
- (lambda (message)
- `(strong
- (@ (style "display: block;"))
- ,(string-append
- "Error: " message)))
- messages)))))
- '())
- ,@(if required? '((strong "Required. ")) '())
- ,@(if help-text
- (list help-text)
- '())))
- '())))))
+ (map (match-lambda
+ ((option-label . option-value)
+ `(option
+ (@ ,@(if (member (if (and
+ (string? option-value)
+ (string=? option-value
+
null-string-value))
+ ""
+ option-value)
+ selected-options)
+ '((selected ""))
+ '())
+ (value ,option-value))
+ ,(value->text option-label)))
+ (option-value
+ `(option
+ (@ ,@(if (member (if (and
+ (string? option-value)
+ (string=? option-value
+
null-string-value))
+ ""
+ option-value)
+ selected-options)
+ '((selected ""))
+ '()))
+ ,(value->text option-value))))
+ options)))
+ `(input (@ (class "form-control")
+ (style ,(if font-family
+ (string-append
+ "font-family: " font-family ";")
+ ""))
+ (id ,input-id)
+ (type ,type)
+ ,@(if required?
+ '((required #t))
+ '())
+ ,@(if show-help-span?
+ `((aria-describedby ,help-span-id))
+ '())
+ (name ,input-name)
+ ,@(match (assq (string->symbol input-name)
+ query-parameters)
+ (#f '())
+ ((_key . ($ <invalid-query-parameter> value))
+ (if (string=? type "checkbox")
+ (if value
+ '((checked #t))
+ '())
+ `((value ,(value->text value)))))
+ ((_key . value)
+ (if (string=? type "checkbox")
+ (if value
+ '((checked #t))
+ '())
+ `((value ,(value->text value)))))))))
+ ,@(if show-help-span?
+ `((span (@ (id ,help-span-id)
+ (class "help-block"))
+ ,@(if has-error?
+ (let* ((val
+ (assq-ref query-parameters
+ (string->symbol input-name)))
+ (messages
+ (map invalid-query-parameter-message
+ (if (list? val)
+ val
+ (list val)))))
+ `((p
+ ,@(if (null? messages)
+ '(string "Error: invalid value")
+ (map
+ (lambda (message)
+ `(strong
+ (@ (style "display: block;"))
+ ,(string-append
+ "Error: " message)))
+ messages)))))
+ '())
+ ,@(if required? '((strong "Required. ")) '())
+ ,@(if help-text
+ (list help-text)
+ '())))
+ '()))))))
(define (readme contents)
(layout
- branch master updated (ae6541a -> 480d718), Christopher Baines, 2020/06/07
- 01/09: Get the translated lint checker descriptions into the database, Christopher Baines, 2020/06/07
- 02/09: Add checks to guard against null data, Christopher Baines, 2020/06/07
- 05/09: Make the form-horizontal-control procedure aware of hidden inputs,
Christopher Baines <=
- 04/09: Make the query that provides locale options look nicer, Christopher Baines, 2020/06/07
- 07/09: Fall back to en_US.utf8 for the lint warnings page for a revision, Christopher Baines, 2020/06/07
- 09/09: Fix lint checker tests, Christopher Baines, 2020/06/07
- 03/09: Use lint checker related translations on some pages, Christopher Baines, 2020/06/07
- 06/09: Provide the comparison page with translated lint warnings, Christopher Baines, 2020/06/07
- 08/09: Fall back to en_US.utf8 in the package page, Christopher Baines, 2020/06/07