From efea3cda2f31b4676c5e6069527db69dffcb8f87 Mon Sep 17 00:00:00 2001 From: Peter Deltchev Date: Sun, 7 Aug 2016 16:31:09 -0700 Subject: [PATCH] Fixes #102: Tagging tracks with multiple show songs works again. This was broken during the MySQL -> PostgreSQL migration. --- app/Commands/EditTrackCommand.php | 6 +++--- resources/assets/scripts/app/directives/track-editor.coffee | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Commands/EditTrackCommand.php b/app/Commands/EditTrackCommand.php index 542d21da..796cc444 100644 --- a/app/Commands/EditTrackCommand.php +++ b/app/Commands/EditTrackCommand.php @@ -73,14 +73,14 @@ class EditTrackCommand extends CommandBase 'genre_id' => 'required|exists:genres,id', 'cover' => 'image|mimes:png,jpeg|min_width:350|min_height:350', 'track_type_id' => 'required|exists:track_types,id|not_in:'.TrackType::UNCLASSIFIED_TRACK, - 'songs' => 'required_when:track_type,2|exists:songs,id', 'cover_id' => 'exists:images,id', 'album_id' => 'exists:albums,id', 'username' => 'exists:users,username' ]; - if (isset($this->_input['track_type_id']) && $this->_input['track_type_id'] == 2) { + if (isset($this->_input['track_type_id']) && $this->_input['track_type_id'] == TrackType::OFFICIAL_TRACK_REMIX) { $rules['show_song_ids'] = 'required|exists:show_songs,id'; + $this->_input['show_song_ids'] = json_decode($this->_input['show_song_ids']); } $validator = \Validator::make($this->_input, $rules); @@ -126,7 +126,7 @@ class EditTrackCommand extends CommandBase } if ($track->track_type_id == TrackType::OFFICIAL_TRACK_REMIX) { - $track->showSongs()->sync(explode(',', $this->_input['show_song_ids'])); + $track->showSongs()->sync($this->_input['show_song_ids']); } else { $track->showSongs()->sync([]); } diff --git a/resources/assets/scripts/app/directives/track-editor.coffee b/resources/assets/scripts/app/directives/track-editor.coffee index a7ff7a78..5a681191 100644 --- a/resources/assets/scripts/app/directives/track-editor.coffee +++ b/resources/assets/scripts/app/directives/track-editor.coffee @@ -108,7 +108,7 @@ module.exports = angular.module('ponyfm').directive 'pfmTrackEditor', () -> formData.append name, value if parseInt($scope.track.track_type_id) == 2 - formData.append 'show_song_ids', _.map(_.values($scope.selectedSongs), (s) -> s.id).join() + formData.append 'show_song_ids', JSON.stringify(_.map(_.values($scope.selectedSongs), (s) -> s.id)) xhr.open 'POST', '/api/web/tracks/edit/' + $scope.track.id, true xhr.setRequestHeader 'X-XSRF-TOKEN', $.cookie('XSRF-TOKEN')