From 335b8a94c4f82a9da6d8b50481d21dae4c5cbfd8 Mon Sep 17 00:00:00 2001 From: Jessica Stokes Date: Sun, 3 Apr 2022 14:58:36 -0700 Subject: [PATCH 1/2] Allow autocomplete for tagging in addition to tag searching --- ext/autocomplete/script.js | 28 ++++++++++++++++++++++++++++ ext/tag_edit/theme.php | 4 +++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/ext/autocomplete/script.js b/ext/autocomplete/script.js index 3180d673..6dd2d883 100644 --- a/ext/autocomplete/script.js +++ b/ext/autocomplete/script.js @@ -59,6 +59,34 @@ document.addEventListener('DOMContentLoaded', () => { }) }); + $('#tag_editor').tagit({ + singleFieldDelimiter: ' ', + autocomplete : ({ + source: function (request, response) { + $.ajax({ + url: base_href + '/api/internal/autocomplete', + data: {'s': request.term}, + dataType : 'json', + type : 'GET', + success : function (data) { + response( + $.map(data, function (count, item) { + return { + label : item + ' ('+count+')', + value : item + }; + }) + ); + }, + error : function (request, status, error) { + console.log(error); + } + }); + }, + minLength: 1 + }) + }); + $('.ui-autocomplete-input').keydown(function(e) { var keyCode = e.keyCode || e.which; diff --git a/ext/tag_edit/theme.php b/ext/tag_edit/theme.php index 2baf5fff..e1cd84af 100644 --- a/ext/tag_edit/theme.php +++ b/ext/tag_edit/theme.php @@ -55,7 +55,9 @@ class TagEditTheme extends Themelet ".($user->can(Permissions::EDIT_IMAGE_TAG) ? " $h_tag_links - +
+ +
" : " $h_tag_links ")." From d4c45112ee1d20c260a619784f3f1adb34b58425 Mon Sep 17 00:00:00 2001 From: Jessica Stokes Date: Sun, 3 Apr 2022 21:01:25 -0700 Subject: [PATCH 2/2] Autocomplete in bulk tag editor, too --- ext/autocomplete/script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/autocomplete/script.js b/ext/autocomplete/script.js index 6dd2d883..2f024825 100644 --- a/ext/autocomplete/script.js +++ b/ext/autocomplete/script.js @@ -59,7 +59,7 @@ document.addEventListener('DOMContentLoaded', () => { }) }); - $('#tag_editor').tagit({ + $('#tag_editor,[name="bulk_tags"]').tagit({ singleFieldDelimiter: ' ', autocomplete : ({ source: function (request, response) {