hummingbird-me/hummingbird

View on GitHub
frontend/app/templates/anime/quotes.hbs

Summary

Maintainability
Test Coverage
<div class="container">
  <div class="back-to-anime">
    <span>
      {{#link-to 'anime.index' anime}}
        <i class="fa fa-caret-left"></i> Back to anime page
      {{/link-to}}
    </span>
  </div>

  <div class="row row-centered">
    <div class="col-xs-6 col-md-offset-3">

      {{#each model as |quote|}}
        <div class="rounded-block col-sm-12 clearfix quote-container">
          <p><strong>{{quote.characterName}}:</strong> {{quote.content}}</p>
          <span class="favorited-by">
            <span class="favorite-count">Favorited by {{pluralize quote.favoriteCount "user" "users"}} - </span>
            <a {{action "toggleQuoteFavorite" quote}}>
              {{#if quote.isFavorite}}
                Unfavorite this quote
              {{else}}
                Favorite this quote
              {{/if}}
            </a>
          </span>
        </div>
      {{else}}
        <div class="rounded-block col-sm-12 clearfix quote-container">
          <p>No quotes listed yet, be the first one to submit a quote.</p>
        </div>
      {{/each}}

      <div class="quote-spacer">&nbsp;</div>

      {{#if showCreate}}
        <div class="rounded-block col-sm-12 clearfix quote-container">
          <div class="row quote-input">
            <div class="col-md-4 col-xs-4">Quote</div>
            <div class="col-md-8 col-xs-8">
              {{textarea value=quoteText class="form-control"}}
              {{#unless textCorrectLength}}
                <small class="text-danger">Quote must be atleast 10 characters.</small>
              {{/unless}}
            </div>
          </div>
          <div class="row quote-input">
            <div class="col-md-4 col-xs-4">
              Character
            </div>
            <div class="col-md-8 col-xs-8">
              {{input type="text" value=quoteChar class="form-control"}}
              {{#unless charCorrectLength}}
                <small class="text-danger">Character name must be atleast 3 characters.</small>
              {{/unless}}
            </div>
          </div>
          <button class="btn status-button pull-right disabled"
                  {{bind-attr class="isFormCorrect:enabled:disabled"}} {{action 'submitQuote'}}>Submit</button>
        </div>
      {{else}}
        <button class="btn status-button pull-right" {{action 'toggleQuoteCreate'}}>Submit new quote</button>
      {{/if}}

    </div>
  </div>
</div>