Make tag completions be all searchable tags, not just formal tags

This commit is contained in:
Tony Garnock-Jones 2014-11-09 17:21:01 -05:00
parent e4398eef54
commit 17886b24d1
3 changed files with 9 additions and 6 deletions

View File

@ -108,7 +108,9 @@
[all-tags
(for/fold ((ts (set)))
((pkg (in-hash-values (package-manager-state-local-packages state))))
(set-union ts (list->set (or (@ pkg tags) '()))))]))
(set-union ts (list->set
(map symbol->string
(hash-keys (or (@ pkg search-terms) (hash)))))))]))
(define (replace-package old-pkg new-pkg state)
(define local-packages (package-manager-state-local-packages state))

View File

@ -53,7 +53,7 @@
[("create") edit-package-page]
[("logout") logout-page]
[("json" "search-completions") json-search-completions]
[("json" "all-tags") json-all-tags]
[("json" "tag-completions") json-tag-completions]
))
(define (on-continuation-expiry request)
@ -1098,7 +1098,7 @@
(lambda (response-port)
(write-json (set->list completions) response-port))))
(define (json-all-tags request)
(define (json-tag-completions request)
(response/output #:mime-type #"application/json"
(lambda (response-port)
(write-json (set->list (all-tags)) response-port))))

View File

@ -35,9 +35,10 @@ $(document).ready(function () {
$("table.sortable").tablesorter();
if ($("#tags").length) {
$.getJSON("/json/all-tags", function (allTags) {
allTags.sort();
PkgSite.multiTermComplete(PkgSite.preventTabMovingDuringSelection($("#tags")), allTags);
$.getJSON("/json/tag-completions", function (tagCompletions) {
tagCompletions.sort();
PkgSite.multiTermComplete(PkgSite.preventTabMovingDuringSelection($("#tags")),
tagCompletions);
});
}
});