From f4a0e8d006d773dcf1d897b730e298625197b751 Mon Sep 17 00:00:00 2001 From: Phan An Date: Thu, 4 Jan 2024 11:24:40 +0100 Subject: [PATCH] feat: mark external songs with icon --- app/Http/Resources/SongResource.php | 2 +- .../js/__tests__/factory/songFactory.ts | 1 + .../assets/js/components/song/SongCard.vue | 20 +++++++++++++++--- .../js/components/song/SongListItem.vue | 21 +++++++++++++++++-- resources/assets/js/types.d.ts | 1 + 5 files changed, 39 insertions(+), 6 deletions(-) diff --git a/app/Http/Resources/SongResource.php b/app/Http/Resources/SongResource.php index cfc180a9..4d9476c5 100644 --- a/app/Http/Resources/SongResource.php +++ b/app/Http/Resources/SongResource.php @@ -18,6 +18,7 @@ class SongResource extends JsonResource return [ 'type' => 'songs', 'id' => $this->song->id, + 'owner_id' => $this->song->owner_id, 'title' => $this->song->title, 'lyrics' => $this->song->lyrics, 'album_id' => $this->song->album->id, @@ -35,7 +36,6 @@ class SongResource extends JsonResource 'genre' => $this->song->genre, 'year' => $this->song->year, 'created_at' => $this->song->created_at, - 'owner_id' => $this->song->owner_id, ]; } } diff --git a/resources/assets/js/__tests__/factory/songFactory.ts b/resources/assets/js/__tests__/factory/songFactory.ts index 12e7e899..0a47a134 100644 --- a/resources/assets/js/__tests__/factory/songFactory.ts +++ b/resources/assets/js/__tests__/factory/songFactory.ts @@ -7,6 +7,7 @@ const generate = (partOfCompilation = false): Song => { return { type: 'songs', + owner_id: faker.datatype.number({ min: 1, max: 999 }), artist_id: artistId, album_id: faker.datatype.number({ min: 2 }), // avoid Unknown Album by default artist_name: artistName, diff --git a/resources/assets/js/components/song/SongCard.vue b/resources/assets/js/components/song/SongCard.vue index 7f07d9fe..7114cef1 100644 --- a/resources/assets/js/components/song/SongCard.vue +++ b/resources/assets/js/components/song/SongCard.vue @@ -10,7 +10,12 @@
-

{{ song.title }}

+

+ + + + {{ song.title }} +

{{ song.artist_name }} - {{ pluralize(song.play_count, 'play') }} @@ -22,11 +27,12 @@