Exclude system tags when editing a package

This commit is contained in:
Tony Garnock-Jones 2014-11-09 17:39:26 -05:00
parent c08d89b66f
commit a791c435c1
2 changed files with 18 additions and 7 deletions

View File

@ -53,7 +53,8 @@
[("create") edit-package-page] [("create") edit-package-page]
[("logout") logout-page] [("logout") logout-page]
[("json" "search-completions") json-search-completions] [("json" "search-completions") json-search-completions]
[("json" "tag-completions") json-tag-completions] [("json" "tag-search-completions") json-tag-search-completions]
[("json" "formal-tags") json-formal-tags]
)) ))
(define (on-continuation-expiry request) (define (on-continuation-expiry request)
@ -787,6 +788,7 @@
(bootstrap-response (if has-old-name? (bootstrap-response (if has-old-name?
(format "Edit package ~a" old-name) (format "Edit package ~a" old-name)
"Create a new package") "Create a new package")
#:body-class "package-form"
(if error-message (if error-message
`(div ((class "alert alert-danger")) `(div ((class "alert alert-danger"))
,(glyphicon 'exclamation-sign) " " ,error-message) ,(glyphicon 'exclamation-sign) " " ,error-message)
@ -1070,6 +1072,7 @@
[(pregexp #px"!(.*)" (list _ tag)) (list (string->symbol tag) #f)] [(pregexp #px"!(.*)" (list _ tag)) (list (string->symbol tag) #f)]
[tag (list (string->symbol tag) #t)]))) [tag (list (string->symbol tag) #t)])))
(bootstrap-response "Search Package Index" (bootstrap-response "Search Package Index"
#:body-class "search-page"
`(form ((class "form-horizontal") `(form ((class "form-horizontal")
(role "form")) (role "form"))
,(form-group 0 2 (label "q" "Search terms") ,(form-group 0 2 (label "q" "Search terms")
@ -1098,7 +1101,12 @@
(lambda (response-port) (lambda (response-port)
(write-json (set->list completions) response-port)))) (write-json (set->list completions) response-port))))
(define (json-tag-completions request) (define (json-tag-search-completions request)
(response/output #:mime-type #"application/json" (response/output #:mime-type #"application/json"
(lambda (response-port) (lambda (response-port)
(write-json (set->list (all-tags)) response-port)))) (write-json (set->list (all-tags)) response-port))))
(define (json-formal-tags request)
(response/output #:mime-type #"application/json"
(lambda (response-port)
(write-json (set->list (all-formal-tags)) response-port))))

View File

@ -35,10 +35,13 @@ $(document).ready(function () {
$("table.sortable").tablesorter(); $("table.sortable").tablesorter();
if ($("#tags").length) { if ($("#tags").length) {
$.getJSON("/json/tag-completions", function (tagCompletions) { $.getJSON((document.body.className === "package-form")
tagCompletions.sort(); ? "/json/formal-tags"
PkgSite.multiTermComplete(PkgSite.preventTabMovingDuringSelection($("#tags")), : "/json/tag-search-completions",
tagCompletions); function (completions) {
}); completions.sort();
PkgSite.multiTermComplete(PkgSite.preventTabMovingDuringSelection($("#tags")),
completions);
});
} }
}); });