Added siblings to tag edit view

This commit is contained in:
Marcin Kurczewski 2014-10-19 13:36:50 +02:00
parent fb04a13044
commit f7215c42d9
3 changed files with 38 additions and 11 deletions

View file

@ -30,3 +30,14 @@
#tag-view small {
font-size: 12px;
}
#tag-view .siblings ul {
list-style-type: none;
margin: 0;
padding: 0;
}
#tag-view .siblings ul li {
display: inline-block;
margin: 0em 0.5em;
line-height: normal;
}

View file

@ -20,8 +20,8 @@ App.Presenters.TagPresenter = function(
var suggestionsTagInput;
var tag;
var tagName;
var posts;
var siblings;
var privileges = {};
@ -50,15 +50,17 @@ App.Presenters.TagPresenter = function(
}
function reinit(params, loaded) {
tagName = params.tagName;
var tagName = params.tagName;
messagePresenter.hideMessages($messages);
promise.wait(
api.get('tags/' + tagName),
api.get('tags/' + tagName + '/siblings'),
api.get('posts', {query: tagName}))
.then(function(tagResponse, postsResponse) {
.then(function(tagResponse, siblingsResponse, postsResponse) {
tag = tagResponse.json;
siblings = siblingsResponse.json.data;
posts = postsResponse.json.data;
posts = posts.slice(0, 8);
@ -66,8 +68,8 @@ App.Presenters.TagPresenter = function(
loaded();
renderPosts(posts);
}).fail(function(tagResponse, postsResponse) {
messagePresenter.showError($messages, tagResponse.json.error || postsResponse.json.error);
}).fail(function(tagResponse, siblingsResponse, postsResponse) {
messagePresenter.showError($messages, tagResponse.json.error || siblingsResponse.json.error || postsResponse.json.error);
loaded();
});
}
@ -76,7 +78,7 @@ App.Presenters.TagPresenter = function(
$el.html(templates.tag({
privileges: privileges,
tag: tag,
tagName: tagName,
siblings: siblings,
tagCategories: JSON.parse(jQuery('head').attr('data-tag-categories')),
}));
$el.find('.post-list').hide();
@ -126,7 +128,7 @@ App.Presenters.TagPresenter = function(
var $post = jQuery('<li>' + templates.postListItem({
util: util,
post: post,
query: {query: tagName},
query: {query: tag.name},
}) + '</li>');
$target.append($post);
});

View file

@ -1,6 +1,6 @@
<div id="tag-view">
<div class="header">
<h1><%= tagName %></h1>
<h1><%= tag.name %></h1>
</div>
<form class="edit">
@ -18,7 +18,7 @@
<div class="form-input">
<% if (privileges.canChangeImplications) { %>
<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><%= tag.name %></strong>.</small></p>
<% } else { %>
<%= _.pluck(tag.implications, 'name').join(' ') || '-' %></p>
<% } %>
@ -30,7 +30,7 @@
<div class="form-input">
<% if (privileges.canChangeSuggestions) { %>
<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><%= tag.name %></strong>.</small></p>
<% } else { %>
<%= _.pluck(tag.suggestions, 'name').join(' ') || '-' %>
<% } %>
@ -76,12 +76,26 @@
<% } %>
</form>
<div class="siblings">
<h3>Siblings</h3>
<ul>
<% _.each(siblings.slice(0, 50), function(tag) { %>
<li class="tag-category-<%= tag.category %>">
<a href="#/tag/<%= tag.name %>
"><%= tag.name %>
</a>
</li>
<% }) %>
</ul>
</div>
<div class="post-list">
<h3>Example usages</h3>
<ul>
</ul>
<a href="#/posts/query=<%= tagName %>">Search for more</a>
<a href="#/posts/query=<%= tag.name %>">Search for more</a>
</div>
</div>