hummingbird-me/kitsu-web

View on GitHub
app/templates/components/users/library/library-list/library-entry.hbs

Summary

Maintainability
Test Coverage
<tr class={{if isChecked "bulk-selected"}}>
  <td class="status status-{{libraryEntry.status}}"></td>

  {{! Checkbox }}
  {{#if (can "edit library-entry" libraryEntry)}}
    <td class="checkbox-cell">
      {{one-way-checkbox isChecked
        update=(action "checkedEntry")
        class="checkbox"
      }}
    </td>
  {{/if}}

  {{! Title }}
  <td class="media-cell">
    <span class="cell-poster">
      <a href={{href-to (concat libraryEntry.media.modelType ".show") libraryEntry.media.slug}}>
        {{lazy-image src=(image libraryEntry.media.posterImage "tiny")}}
      </a>
    </span>
    <span class="cell-title">
      <div class="title-wrapper">
        <a href={{href-to (concat libraryEntry.media.modelType ".show") libraryEntry.media.slug}}>
          {{libraryEntry.media.computedTitle}}
        </a>
      </div>
      <div class="entry-icons">
        {{#if (is-self libraryEntry.user)}}
          <a href="#" {{action (toggle "isReactionModalOpen" this)}}>
            {{#if hasReaction}}
              <span class="reaction-status hint--bottom hint--bounce hint--medium hint--rounded" aria-label={{libraryEntry.mediaReaction.reaction}}>
                {{svg-jar "reaction"}}
              </span>
            {{else}}
              <span class="reaction-status--add hint--bottom hint--bounce hint--rounded" aria-label={{t "users.library.list.add-reaction"}}>
                {{svg-jar "add-reaction"}}
              </span>
            {{/if}}
          </a>
          {{#if isReactionModalOpen}}
            {{to-elsewhere named="modal" send=(component "modals/media-reaction"
              media=libraryEntry.media
              libraryEntry=libraryEntry
              modalId="reaction-modal"
              onClose=(toggle-action "isReactionModalOpen" this)
            )}}
          {{/if}}
        {{else if hasReaction}}
          <a href={{href-to "media-reactions" libraryEntry.mediaReaction.id}}>
            <span class="reaction-status hint--bottom hint--bounce hint--medium hint--rounded" aria-label={{libraryEntry.mediaReaction.reaction}}>
              {{svg-jar "reaction"}}
            </span>
          </a>
        {{/if}}

        {{#if (not (eq libraryEntry.media.status "finished"))}}
          <span class="release-status-cell hint--bottom hint--bounce hint--rounded" aria-label={{t (concat "media-shared.statuses." libraryEntry.media.modelType "." libraryEntry.media.status)}}>
            {{svg-jar libraryEntry.media.status}}
          </span>
        {{/if}}
      </div>
    </span>
  </td>

  {{! Rating }}
  <td class="rating-cell">
    <span class="{{if session.account.isSimpleRating "simple" (if session.hasUser "star" "simple")}}-rating-cell">
      {{#if (gt libraryEntry.rating 0)}}
        <span class="entry-rating entry-rating-{{if session.account.isSimpleRating "simple" (if session.hasUser "star" "simple")}}">
          {{#if (can "edit library-entry" libraryEntry)}}
            {{#library-entry/rating-button
              rating=libraryEntry.rating
              showDropdown=true
              simpleDropdown=true
              onClick=(action "changeRating")
            }}
              {{library-entry/readonly-rating
                rating=libraryEntry.rating
                hideText=true
              }}
            {{/library-entry/rating-button}}
          {{else}}
            {{library-entry/readonly-rating
              rating=libraryEntry.rating
              hideText=true
            }}
          {{/if}}
        </span>
      {{else}}
        <span class="entry-rating entry-rating-empty empty-rating-{{if (or session.account.isSimpleRating (not session.hasUser)) "simple"}}">
          {{#if (can "edit library-entry" libraryEntry)}}
            {{#library-entry/rating-button
              rating=libraryEntry.rating
              canMutate=(can "edit library-entry" libraryEntry)
              onClick=(action "changeRating")
            }}
              <svg class="is-owner" viewBox="0 0 26 26" enable-background="new 0 0 26 26">
                <path d="M13,2c6.065,0,11,4.935,11,11s-4.935,11-11,11S2,19.065,2,13S6.935,2,13,2 M13,0C5.82,0,0,5.82,0,13 s5.82,13,13,13s13-5.82,13-13S20.18,0,13,0L13,0z"></path>
              </svg>
            {{/library-entry/rating-button}}
          {{else}}
            <svg viewBox="0 0 26 26" enable-background="new 0 0 26 26">
              <path d="M13,2c6.065,0,11,4.935,11,11s-4.935,11-11,11S2,19.065,2,13S6.935,2,13,2 M13,0C5.82,0,0,5.82,0,13 s5.82,13,13,13s13-5.82,13-13S20.18,0,13,0L13,0z"></path>
            </svg>
          {{/if}}
        </span>
      {{/if}}
    </span>
  </td>

  {{! Progress }}
  <td class="progress-cell">
    {{users/library/library-list/progress-cell
      progress=libraryEntry.progress
      max=libraryEntry.media.unitCount
      libraryEntry=libraryEntry
      update=(action (mut libraryEntry.progress))
      increment=(action "incrementProgress")
      save=(perform saveTask)
    }}
  </td>

  {{! Volumes (Manga) }}
  {{#if (eq libraryEntry.media.modelType "manga")}}
    <td class="progress-cell">
      {{users/library/library-list/progress-cell
        progress=libraryEntry.volumesOwned
        max=libraryEntry.media.volumeCount
        libraryEntry=libraryEntry
        update=(action (mut libraryEntry.volumesOwned))
        increment=(action "incrementProgress" "volumesOwned")
        save=(perform saveTask)
      }}
    </td>
  {{/if}}

  {{! Edit }}
  <td class="edit-entry">
    {{#if (can "edit library-entry" libraryEntry)}}
      <a href="#" class="edit-entry-button" {{action (toggle "showEditModal" this)}}>
        {{t "users.library.list.list-edit"}}
      </a>
    {{else}}
      <a href="#" class="edit-entry-button" {{action (queue
        (action (mut readOnlyModal) true)
        (toggle-action "showEditModal" this))}}>
        {{t "users.library.list.more"}}
      </a>
    {{/if}}
  </td>
</tr>

{{#if showEditModal}}
  {{to-elsewhere named="modal" send=(component "modals/library-edit"
    libraryEntry=libraryEntry
    saveEntry=(action "saveEntry")
    removeEntry=removeEntry
    isReadOnly=readOnlyModal
    onClose=(queue
      (action (mut readOnlyModal) false)
      (toggle-action "showEditModal" this))
  )}}
{{/if}}