hummingbird-me/hummingbird

View on GitHub
frontend/app/templates/components/favorite-container.hbs

Summary

Maintainability
Test Coverage
{{#if showAnimeFavorites}}
  <div class="favorite-anime">
    <div class="panel-heading">
      <h3 class="panel-title">
        {{#if isAnimeContainer}}Favorite Anime{{else}}Favorite Manga{{/if}}
      </h3>
      {{#if viewingSelf}}
        <span class="edit-panel">
          {{#unless isEditing}}
            <a {{action "editFavorites"}}><i class="fa fa-pencil"></i></a>
          {{else}}
            <a class="btn btn-xs btn-default" {{action "saveFavoritePositions"}}> Save</a>
          {{/unless}}
        </span>
      {{/if}}
    </div>
    <div class="panel-body">
      <ul class="media-grid media-grid-dragsort">
        {{#if favoriteListCapped}}
          {{#each favoriteListCapped as |favorite|}}
            {{#if isEditing}}
              <li class="grid-list grid-draggable clearfix" {{bind-attr data-id=favorite.id}}>
                {{!-- <span class="grid-position">{{favorite.favRank}}</span> --}}
                <img class="grid-list-thumb" {{bind-attr src=favorite.item.posterImageThumb}} />
                <span class="grid-list-title">{{favorite.item.displayTitle}}</span>
                <span class="grid-position" {{action 'deleteFavorite' favorite}}><i class="fa fa-times-circle"></i></span>
              </li>
            {{else}}
              <li class="grid-thumb" {{bind-attr data-id=favorite.id}}>
                {{#if isAnimeContainer}}
                  {{#link-to 'anime' favorite.item.id}}
                    <div class="thumbnail">
                      <img {{bind-attr src=favorite.item.posterImage}} />
                    </div>
                  {{/link-to}}
                {{else}}
                  {{#link-to 'manga' favorite.item.id}}
                    <div class="thumbnail">
                      <img {{bind-attr src=favorite.item.posterImage}} />
                    </div>
                  {{/link-to}}
                {{/if}}
              </li>
            {{/if}}
          {{/each}}
          {{#if isEditing}}
            <div class="grid-list fav-search clearfix">
              {{favorite-search action="pushFavorite" favorites=favoriteList type=containerType currentUser=currentUser}}
            </div>
          {{/if}}
        {{else}}
          {{#if isEditing}}
            <div class="grid-list fav-search clearfix">
              {{favorite-search action="pushFavorite" favorites=favoriteList type=containerType currentUser=currentUser}}
            </div>
          {{else}}
            <div class="no-favorites text-center">
              {{#if viewingSelf}}
                <h3>You have no favorites.</h3>
                <a href="https://forums.hummingbird.me/t/how-to-adding-an-anime-to-your-favorites">How to add Favorites</a>
              {{else}}
                <h3>{{user.username}} has no favorites.</h3>
                <p>Clearly they're an individual of fine, discerning tastes.</p>
              {{/if}}
            </div>
          {{/if}}
        {{/if}}
      </ul>
      {{#if canLoadMoreFavorites}}
        <div class="more-wrapper">
          <a class="view-more-button" {{action "loadMoreFavorites"}}> View More</a>
        </div>
      {{/if}}
    </div>
  </div>
{{/if}}