Added siblings to tag edit view
This commit is contained in:
parent
fb04a13044
commit
f7215c42d9
3 changed files with 38 additions and 11 deletions
|
@ -30,3 +30,14 @@
|
||||||
#tag-view small {
|
#tag-view small {
|
||||||
font-size: 12px;
|
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;
|
||||||
|
}
|
||||||
|
|
|
@ -20,8 +20,8 @@ App.Presenters.TagPresenter = function(
|
||||||
var suggestionsTagInput;
|
var suggestionsTagInput;
|
||||||
|
|
||||||
var tag;
|
var tag;
|
||||||
var tagName;
|
|
||||||
var posts;
|
var posts;
|
||||||
|
var siblings;
|
||||||
|
|
||||||
var privileges = {};
|
var privileges = {};
|
||||||
|
|
||||||
|
@ -50,15 +50,17 @@ App.Presenters.TagPresenter = function(
|
||||||
}
|
}
|
||||||
|
|
||||||
function reinit(params, loaded) {
|
function reinit(params, loaded) {
|
||||||
tagName = params.tagName;
|
var tagName = params.tagName;
|
||||||
|
|
||||||
messagePresenter.hideMessages($messages);
|
messagePresenter.hideMessages($messages);
|
||||||
|
|
||||||
promise.wait(
|
promise.wait(
|
||||||
api.get('tags/' + tagName),
|
api.get('tags/' + tagName),
|
||||||
|
api.get('tags/' + tagName + '/siblings'),
|
||||||
api.get('posts', {query: tagName}))
|
api.get('posts', {query: tagName}))
|
||||||
.then(function(tagResponse, postsResponse) {
|
.then(function(tagResponse, siblingsResponse, postsResponse) {
|
||||||
tag = tagResponse.json;
|
tag = tagResponse.json;
|
||||||
|
siblings = siblingsResponse.json.data;
|
||||||
posts = postsResponse.json.data;
|
posts = postsResponse.json.data;
|
||||||
posts = posts.slice(0, 8);
|
posts = posts.slice(0, 8);
|
||||||
|
|
||||||
|
@ -66,8 +68,8 @@ App.Presenters.TagPresenter = function(
|
||||||
loaded();
|
loaded();
|
||||||
|
|
||||||
renderPosts(posts);
|
renderPosts(posts);
|
||||||
}).fail(function(tagResponse, postsResponse) {
|
}).fail(function(tagResponse, siblingsResponse, postsResponse) {
|
||||||
messagePresenter.showError($messages, tagResponse.json.error || postsResponse.json.error);
|
messagePresenter.showError($messages, tagResponse.json.error || siblingsResponse.json.error || postsResponse.json.error);
|
||||||
loaded();
|
loaded();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -76,7 +78,7 @@ App.Presenters.TagPresenter = function(
|
||||||
$el.html(templates.tag({
|
$el.html(templates.tag({
|
||||||
privileges: privileges,
|
privileges: privileges,
|
||||||
tag: tag,
|
tag: tag,
|
||||||
tagName: tagName,
|
siblings: siblings,
|
||||||
tagCategories: JSON.parse(jQuery('head').attr('data-tag-categories')),
|
tagCategories: JSON.parse(jQuery('head').attr('data-tag-categories')),
|
||||||
}));
|
}));
|
||||||
$el.find('.post-list').hide();
|
$el.find('.post-list').hide();
|
||||||
|
@ -126,7 +128,7 @@ App.Presenters.TagPresenter = function(
|
||||||
var $post = jQuery('<li>' + templates.postListItem({
|
var $post = jQuery('<li>' + templates.postListItem({
|
||||||
util: util,
|
util: util,
|
||||||
post: post,
|
post: post,
|
||||||
query: {query: tagName},
|
query: {query: tag.name},
|
||||||
}) + '</li>');
|
}) + '</li>');
|
||||||
$target.append($post);
|
$target.append($post);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<div id="tag-view">
|
<div id="tag-view">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<h1><%= tagName %></h1>
|
<h1><%= tag.name %></h1>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form class="edit">
|
<form class="edit">
|
||||||
|
@ -18,7 +18,7 @@
|
||||||
<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="some tag…" value="<%= _.pluck(tag.implications, 'name').join(' ') %>"/>
|
<input maxlength="200" type="text" name="implications" id="tag-implications" placeholder="some tag…" 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 { %>
|
<% } else { %>
|
||||||
<%= _.pluck(tag.implications, 'name').join(' ') || '-' %></p>
|
<%= _.pluck(tag.implications, 'name').join(' ') || '-' %></p>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
<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="some tag…" value="<%= _.pluck(tag.suggestions, 'name').join(' ') %>"/>
|
<input maxlength="200" type="text" name="suggestions" id="tag-suggestions" placeholder="some tag…" 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 { %>
|
<% } else { %>
|
||||||
<%= _.pluck(tag.suggestions, 'name').join(' ') || '-' %>
|
<%= _.pluck(tag.suggestions, 'name').join(' ') || '-' %>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
@ -76,12 +76,26 @@
|
||||||
<% } %>
|
<% } %>
|
||||||
</form>
|
</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">
|
<div class="post-list">
|
||||||
<h3>Example usages</h3>
|
<h3>Example usages</h3>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<a href="#/posts/query=<%= tagName %>">Search for more</a>
|
<a href="#/posts/query=<%= tag.name %>">Search for more</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue