Row.vue 3.05 KB
Newer Older
1
2
3
<template>
  <tr>
    <td>
4
      <play-button class="basic icon" :discrete="true" :is-playable="playable" :track="track"></play-button>
5
6
    </td>
    <td>
7
      <img class="ui mini image" v-if="track.album.cover.original" v-lazy="$store.getters['instance/absoluteUrl'](track.album.cover.small_square_crop)">
8
      <img class="ui mini image" v-else src="../../../assets/audio/default-cover.png">
9
10
    </td>
    <td colspan="6">
11
      <router-link class="track" :title="track.title" :to="{name: 'library.tracks.detail', params: {id: track.id }}">
12
13
14
15
16
17
        <template v-if="displayPosition && track.position">
          {{ track.position }}.
        </template>
        {{ track.title }}
      </router-link>
    </td>
Renon's avatar
Renon committed
18
    <td colspan="4">
19
      <router-link v-if="track.artist.id === albumArtist.id" :title="track.artist.name" class="artist discrete link" :to="{name: 'library.artists.detail', params: {id: track.artist.id }}">
20
21
        {{ track.artist.name }}
      </router-link>
22
      <template v-else>
23
        <router-link class="artist discrete link" :title="albumArtist.name" :to="{name: 'library.artists.detail', params: {id: albumArtist.id }}">
24
25
26
          {{ albumArtist.name }}
        </router-link>
         /
27
         <router-link class="artist discrete link" :title="track.artist.name" :to="{name: 'library.artists.detail', params: {id: track.artist.id }}">
28
29
30
          {{ track.artist.name }}
        </router-link>
      </template>
31
    </td>
Renon's avatar
Renon committed
32
    <td colspan="4">
33
      <router-link class="album discrete link" :title="track.album.title" :to="{name: 'library.albums.detail', params: {id: track.album.id }}">
34
35
36
        {{ track.album.title }}
      </router-link>
    </td>
37
38
    <td colspan="4" v-if="track.uploads && track.uploads.length > 0">
      {{ time.parse(track.uploads[0].duration) }}
Renon's avatar
Renon committed
39
40
41
42
    </td>
    <td colspan="4" v-else>
      <translate>N/A</translate>
    </td>
43
    <td colspan="2">
44
45
46
47
48
49
50
51
52
      <track-favorite-icon class="favorite-icon" :track="track"></track-favorite-icon>
      <track-playlist-icon
        v-if="$store.state.auth.authenticated"
        :track="track"></track-playlist-icon>
    </td>
  </tr>
</template>

<script>
Renon's avatar
Renon committed
53
54

import time from '@/utils/time'
55
56
57
58
59
60
61
import TrackFavoriteIcon from '@/components/favorites/TrackFavoriteIcon'
import TrackPlaylistIcon from '@/components/playlists/TrackPlaylistIcon'
import PlayButton from '@/components/audio/PlayButton'

export default {
  props: {
    track: {type: Object, required: true},
62
    artist: {type: Object, required: false},
63
64
    displayPosition: {type: Boolean, default: false},
    playable: {type: Boolean, required: false, default: false},
65
66
67
68
69
70
  },
  components: {
    TrackFavoriteIcon,
    TrackPlaylistIcon,
    PlayButton
  },
Renon's avatar
Renon committed
71
72
73
74
75
  data () {
    return {
      time
    }
  },
76
77
78
79
80
81
82
  computed: {
    albumArtist () {
      if (this.artist) {
        return this.artist
      } else {
        return this.track.album.artist
      }
83
84
85
86
87
88
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
Eliot Berriot's avatar
Eliot Berriot committed
89
90
<style lang="scss" scoped>
tr:not(:hover) {
91
92
  .favorite-icon:not(.favorited),
  .playlist-icon {
93
    visibility: hidden;
Eliot Berriot's avatar
Eliot Berriot committed
94
  }
95
96
}
</style>