From f7215c42d98642e5fc9d2a72bc471d8f3e0788ae Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Sun, 19 Oct 2014 13:36:50 +0200 Subject: [PATCH] Added siblings to tag edit view --- public_html/css/tags.css | 11 +++++++++++ public_html/js/Presenters/TagPresenter.js | 16 +++++++++------- public_html/templates/tag.tpl | 22 ++++++++++++++++++---- 3 files changed, 38 insertions(+), 11 deletions(-) diff --git a/public_html/css/tags.css b/public_html/css/tags.css index a2b65b00..4ba4c87a 100644 --- a/public_html/css/tags.css +++ b/public_html/css/tags.css @@ -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; +} diff --git a/public_html/js/Presenters/TagPresenter.js b/public_html/js/Presenters/TagPresenter.js index c5983015..a3029cfb 100644 --- a/public_html/js/Presenters/TagPresenter.js +++ b/public_html/js/Presenters/TagPresenter.js @@ -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('
  • ' + templates.postListItem({ util: util, post: post, - query: {query: tagName}, + query: {query: tag.name}, }) + '
  • '); $target.append($post); }); diff --git a/public_html/templates/tag.tpl b/public_html/templates/tag.tpl index 4d9e6e54..87e2e2a7 100644 --- a/public_html/templates/tag.tpl +++ b/public_html/templates/tag.tpl @@ -1,6 +1,6 @@
    -

    <%= tagName %>

    +

    <%= tag.name %>

    @@ -18,7 +18,7 @@
    <% if (privileges.canChangeImplications) { %> -

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

    +

    Added automatically when tagging with <%= tag.name %>.

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

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

    Suggested when tagging with <%= tagName %>.

    +

    Suggested when tagging with <%= tag.name %>.

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

    Siblings

    + +
      + <% _.each(siblings.slice(0, 50), function(tag) { %> +
    • + <%= tag.name %> + +
    • + <% }) %> +
    +
    +

    Example usages

    - Search for more + Search for more