From 752d21ad051900561a13dc6cb6543ea586b90baa Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Mon, 31 Jan 2022 20:25:06 +0000 Subject: Improve the way the field fields work on various pages Remove the brackets from the values since this makes the set of values more consistent, and don't display the no additional fields value on the page. --- guix-data-service/web/compare/html.scm | 3 ++- guix-data-service/web/revision/html.scm | 45 ++++++++++++++++++++------------- 2 files changed, 29 insertions(+), 19 deletions(-) (limited to 'guix-data-service/web') diff --git a/guix-data-service/web/compare/html.scm b/guix-data-service/web/compare/html.scm index 128e3f4..17272e3 100644 --- a/guix-data-service/web/compare/html.scm +++ b/guix-data-service/web/compare/html.scm @@ -680,7 +680,8 @@ (lambda (field) (cons field (hyphenate-words - (string-downcase field)))) + (remove-brackets + (string-downcase field))))) '("(no additional fields)" "Builds"))) (define fields diff --git a/guix-data-service/web/revision/html.scm b/guix-data-service/web/revision/html.scm index eeb2fc8..d8769e6 100644 --- a/guix-data-service/web/revision/html.scm +++ b/guix-data-service/web/revision/html.scm @@ -549,14 +549,18 @@ any-translations-available? #:key path-base header-text header-link) + (define fields + '("Version" "Synopsis" "Description" + "Home page" "Location" "Licenses")) + (define field-options (map (lambda (field) (cons field (hyphenate-words - (string-downcase field)))) - '("Version" "Synopsis" "Description" - "Home page" "Location" "Licenses"))) + (remove-brackets + (string-downcase field))))) + `("(no additional fields)" ,@fields))) (layout #:title @@ -642,12 +646,12 @@ (tr (th (@ (class "col-md-3")) "Name") ,@(filter-map - (match-lambda - ((label . value) - (if (member value (assq-ref query-parameters 'field)) - `(th (@ (class "col-md-3")) ,label) - #f))) - field-options) + (lambda (field) + (if (member (assoc-ref field-options field) + (assq-ref query-parameters 'field)) + `(th (@ (class "col-md-3")) ,field) + #f)) + fields) (th (@ (class "col-md-3")) ""))) (tbody ,@(let ((fields (assq-ref query-parameters 'field))) @@ -1543,7 +1547,8 @@ figure { (lambda (field) (cons field (hyphenate-words - (string-downcase field)))) + (remove-brackets + (string-downcase field))))) '("(no additional fields)" "System" "Target" "Builds"))) (define fields @@ -2210,13 +2215,17 @@ figure { any-translated-lint-warnings? #:key path-base header-text header-link) + (define fields + '("Linter" "Message" "Location")) + (define field-options (map (lambda (field) (cons field (hyphenate-words - (string-downcase field)))) - '("Linter" "Message" "Location"))) + (remove-brackets + (string-downcase field))))) + `("(no additional fields)" ,@fields))) (layout #:title @@ -2300,12 +2309,12 @@ figure { (tr (th (@ (class "col-md-3")) "Package") ,@(filter-map - (match-lambda - ((label . value) - (if (member value (assq-ref query-parameters 'field)) - `(th (@ (class "col-md-3")) ,label) - #f))) - field-options) + (lambda (field) + (if (member (assoc-ref field-options field) + (assq-ref query-parameters 'field)) + `(th (@ (class "col-md-3")) ,field) + #f)) + fields) (th (@ (class "col-md-3")) ""))) (tbody ,@(let ((fields (assq-ref query-parameters 'field))) -- cgit v1.2.3