From 85ed59d169387991cad0a2fa297ce3a792c158ee Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Sat, 18 Oct 2014 14:21:42 +0200 Subject: [PATCH] Added autocomplete to tag relations --- TODO | 1 - public_html/js/Presenters/TagPresenter.js | 8 ++++++-- public_html/templates/tag.tpl | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/TODO b/TODO index b60c6852..80a76ae4 100644 --- a/TODO +++ b/TODO @@ -10,7 +10,6 @@ first major release. - posts/listing: add buttons for toggling safety - posts: fix empty edit snapshots when changing only thumbnail content - users: add user-configurable "about me" (should support Markdown) -- tags: suggestions and implications should be changed to tag inputs - tags: refresh tags.json when editing post - tags: add tag merging - tags: add tag categories diff --git a/public_html/js/Presenters/TagPresenter.js b/public_html/js/Presenters/TagPresenter.js index 993a7121..e4f8bc26 100644 --- a/public_html/js/Presenters/TagPresenter.js +++ b/public_html/js/Presenters/TagPresenter.js @@ -16,6 +16,8 @@ App.Presenters.TagPresenter = function( var $el = jQuery('#content'); var $messages = $el; var templates = {}; + var implicationsTagInput; + var suggestionsTagInput; var tag; var tagName; @@ -73,6 +75,8 @@ App.Presenters.TagPresenter = function( $el.html(templates.tag({privileges: privileges, tag: tag, tagName: tagName})); $el.find('.post-list').hide(); $el.find('form').submit(editFormSubmitted); + implicationsTagInput = App.Controls.TagInput($el.find('[name=implications]')); + suggestionsTagInput = App.Controls.TagInput($el.find('[name=suggestions]')); } function editFormSubmitted(e) { @@ -89,11 +93,11 @@ App.Presenters.TagPresenter = function( } if (privileges.canChangeImplications) { - formData.implications = $form.find('[name=implications]').val(); + formData.implications = implicationsTagInput.getTags().join(' '); } if (privileges.canChangeSuggestions) { - formData.suggestions = $form.find('[name=suggestions]').val(); + formData.suggestions = suggestionsTagInput.getTags().join(' '); } promise.wait(api.put('/tags/' + tag.name, formData)) diff --git a/public_html/templates/tag.tpl b/public_html/templates/tag.tpl index 8715a31b..97b3cbb4 100644 --- a/public_html/templates/tag.tpl +++ b/public_html/templates/tag.tpl @@ -17,7 +17,7 @@
<% if (privileges.canChangeImplications) { %> - +

Added automatically when tagging with <%= tagName %>.

<% } else { %> <%= _.pluck(tag.implications, 'name').join(' ') || '-' %>

@@ -29,7 +29,7 @@
<% if (privileges.canChangeSuggestions) { %> - +

Suggested when tagging with <%= tagName %>.

<% } else { %> <%= _.pluck(tag.suggestions, 'name').join(' ') || '-' %>