summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRicardo Wurmus <rekado@elephly.net>2019-10-30 09:20:51 +0100
committerRicardo Wurmus <rekado@elephly.net>2019-10-30 09:20:51 +0100
commit53fe4996be9ceaa11cae6295af3195e66f9711a5 (patch)
tree8b3f1d6f7d7b089be9b8b9179695325a7d31160e
parent8a618322b12436dac6034817c596aa9fd433dd8d (diff)
downloadcuirass-53fe4996be9ceaa11cae6295af3195e66f9711a5.tar
cuirass-53fe4996be9ceaa11cae6295af3195e66f9711a5.tar.gz
templates: specifications-table: Add admin features.
* src/cuirass/templates.scm (specifications-table): Handle optional ADMIN? argument.
-rw-r--r--src/cuirass/templates.scm46
1 files changed, 42 insertions, 4 deletions
diff --git a/src/cuirass/templates.scm b/src/cuirass/templates.scm
index 059493c..7477191 100644
--- a/src/cuirass/templates.scm
+++ b/src/cuirass/templates.scm
@@ -125,7 +125,7 @@
((= (build-status canceled) status) "Canceled")
(else "Invalid status")))
-(define (specifications-table specs)
+(define* (specifications-table specs #:optional admin?)
"Return HTML for the SPECS table."
`((p (@ (class "lead")) "Specifications")
(table
@@ -133,7 +133,10 @@
,@(if (null? specs)
`((th (@ (scope "col")) "No elements here."))
`((thead (tr (th (@ (scope "col")) Name)
- (th (@ (scope "col")) Inputs)))
+ (th (@ (scope "col")) Inputs)
+ ,@(if admin?
+ '((th (@ (scope "col")) Action))
+ '())))
(tbody
,@(map
(lambda (spec)
@@ -144,8 +147,43 @@
(format #f "~a (on ~a)"
(assq-ref input #:name)
(assq-ref input #:branch)))
- (assq-ref spec #:inputs)) ", "))))
- specs)))))))
+ (assq-ref spec #:inputs)) ", "))
+ ,@(if admin?
+ `((form (@ (class "form")
+ (action ,(string-append "/admin/specifications/delete/"
+ (assq-ref spec #:name)))
+ (method "POST")
+ (onsubmit
+ ,(string-append "return confirm('Please confirm deletion of specification "
+ (assq-ref spec #:name)
+ ".');")))
+ `((div
+ (@ (class "input-group"))
+ (span (@ (class "input-group-append"))
+ (button
+ (@ (type "submit")
+ (class "btn"))
+ "Remove"))))))
+ '())))
+ specs))))
+ ,@(if admin?
+ `((form (@ (id "add-specification")
+ (class "form")
+ (action "/admin/specifications/add/")
+ (method "POST"))
+ (div
+ (@ (class "input-group"))
+ (input (@ (type "text")
+ (class "form-control")
+ (id "spec-name")
+ (name "spec-name")
+ (placeholder "specification / branch name")))
+ (span (@ (class "input-group-append"))
+ (button
+ (@ (type "submit")
+ (class "btn btn-primary"))
+ "Add")))))
+ '()))))
(define (build-details build)
"Return HTML showing details for the BUILD."