Added autocomplete to tag relations

This commit is contained in:
Marcin Kurczewski 2014-10-18 14:21:42 +02:00
parent 9c29f6173d
commit 85ed59d169
3 changed files with 8 additions and 5 deletions

1
TODO
View file

@ -10,7 +10,6 @@ first major release.
- posts/listing: add buttons for toggling safety - posts/listing: add buttons for toggling safety
- posts: fix empty edit snapshots when changing only thumbnail content - posts: fix empty edit snapshots when changing only thumbnail content
- users: add user-configurable "about me" (should support Markdown) - 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: refresh tags.json when editing post
- tags: add tag merging - tags: add tag merging
- tags: add tag categories - tags: add tag categories

View file

@ -16,6 +16,8 @@ App.Presenters.TagPresenter = function(
var $el = jQuery('#content'); var $el = jQuery('#content');
var $messages = $el; var $messages = $el;
var templates = {}; var templates = {};
var implicationsTagInput;
var suggestionsTagInput;
var tag; var tag;
var tagName; var tagName;
@ -73,6 +75,8 @@ App.Presenters.TagPresenter = function(
$el.html(templates.tag({privileges: privileges, tag: tag, tagName: tagName})); $el.html(templates.tag({privileges: privileges, tag: tag, tagName: tagName}));
$el.find('.post-list').hide(); $el.find('.post-list').hide();
$el.find('form').submit(editFormSubmitted); $el.find('form').submit(editFormSubmitted);
implicationsTagInput = App.Controls.TagInput($el.find('[name=implications]'));
suggestionsTagInput = App.Controls.TagInput($el.find('[name=suggestions]'));
} }
function editFormSubmitted(e) { function editFormSubmitted(e) {
@ -89,11 +93,11 @@ App.Presenters.TagPresenter = function(
} }
if (privileges.canChangeImplications) { if (privileges.canChangeImplications) {
formData.implications = $form.find('[name=implications]').val(); formData.implications = implicationsTagInput.getTags().join(' ');
} }
if (privileges.canChangeSuggestions) { if (privileges.canChangeSuggestions) {
formData.suggestions = $form.find('[name=suggestions]').val(); formData.suggestions = suggestionsTagInput.getTags().join(' ');
} }
promise.wait(api.put('/tags/' + tag.name, formData)) promise.wait(api.put('/tags/' + tag.name, formData))

View file

@ -17,7 +17,7 @@
<label class="form-label" for="tag-implications">Implications:</label> <label class="form-label" for="tag-implications">Implications:</label>
<div class="form-input"> <div class="form-input">
<% if (privileges.canChangeImplications) { %> <% if (privileges.canChangeImplications) { %>
<input maxlength="200" type="text" name="implications" id="tag-implications" placeholder="tag1, tag2&hellip;" value="<%= _.pluck(tag.implications, 'name').join(' ') %>"/> <input maxlength="200" type="text" name="implications" id="tag-implications" placeholder="some tag&hellip;" value="<%= _.pluck(tag.implications, 'name').join(' ') %>"/>
<p><small>Added automatically when tagging with <strong><%= tagName %></strong>.</small></p> <p><small>Added automatically when tagging with <strong><%= tagName %></strong>.</small></p>
<% } else { %> <% } else { %>
<%= _.pluck(tag.implications, 'name').join(' ') || '-' %></p> <%= _.pluck(tag.implications, 'name').join(' ') || '-' %></p>
@ -29,7 +29,7 @@
<label class="form-label" for="tag-suggestions">Suggestions:</label> <label class="form-label" for="tag-suggestions">Suggestions:</label>
<div class="form-input"> <div class="form-input">
<% if (privileges.canChangeSuggestions) { %> <% if (privileges.canChangeSuggestions) { %>
<input maxlength="200" type="text" name="suggestions" id="tag-suggestions" placeholder="tag1, tag2&hellip;" value="<%= _.pluck(tag.suggestions, 'name').join(' ') %>"/> <input maxlength="200" type="text" name="suggestions" id="tag-suggestions" placeholder="some tag&hellip;" value="<%= _.pluck(tag.suggestions, 'name').join(' ') %>"/>
<p><small>Suggested when tagging with <strong><%= tagName %></strong>.</small></p> <p><small>Suggested when tagging with <strong><%= tagName %></strong>.</small></p>
<% } else { %> <% } else { %>
<%= _.pluck(tag.suggestions, 'name').join(' ') || '-' %> <%= _.pluck(tag.suggestions, 'name').join(' ') || '-' %>