浏览代码

Fixed issues with Jonathan's refactor.

KrisVos130 8 年之前
父节点
当前提交
effdd6e447

+ 2 - 1
backend/logic/actions/queueSongs.js

@@ -60,10 +60,11 @@ module.exports = {
 	update: hooks.adminRequired((session, songId, updatedSong, cb, userId) => {
 		async.waterfall([
 			(next) => {
-				db.models.queueSong.findOne({ songId }, next);
+				db.models.queueSong.findOne({ _id: songId }, next);
 			},
 
 			(song, next) => {
+				if(!song) return next('Song not found');
 				let updated = false;
 				let $set = {};
 				for (let prop in updatedSong) if (updatedSong[prop] !== song[prop]) $set[prop] = updatedSong[prop]; updated = true;

+ 1 - 1
frontend/components/Admin/Songs.vue

@@ -70,7 +70,7 @@
 				this.modals.editSong = !this.modals.editSong;
 			},
 			edit: function (song, index) {
-				this.$broadcast('editSong', song, index, 'queueSongs');
+				this.$broadcast('editSong', song, index, 'songs');
 			},
 			remove: function (id, index) {
 				this.socket.emit('songs.remove', id, res => {

+ 4 - 4
frontend/components/Modals/EditSong.vue

@@ -64,21 +64,21 @@
 						<div>
 							<p class='control has-addons'>
 								<input class='input' id='new-artist' type='text' placeholder='Artist'>
-								<button class='button is-info' @click='$parent.addTag("artists")'>Add Artist</button>
+								<button class='button is-info' @click='addTag("artists")'>Add Artist</button>
 							</p>
 							<span class='tag is-info' v-for='(index, artist) in editing.song.artists' track-by='$index'>
 								{{ artist }}
-								<button class='delete is-info' @click='$parent.$parent.removeTag("artists", index)'></button>
+								<button class='delete is-info' @click='removeTag("artists", index)'></button>
 							</span>
 						</div>
 						<div>
 							<p class='control has-addons'>
 								<input class='input' id='new-genre' type='text' placeholder='Genre'>
-								<button class='button is-info' @click='$parent.addTag("genres")'>Add Genre</button>
+								<button class='button is-info' @click='addTag("genres")'>Add Genre</button>
 							</p>
 							<span class='tag is-info' v-for='(index, genre) in editing.song.genres' track-by='$index'>
 								{{ genre }}
-								<button class='delete is-info' @click='$parent.$parent.removeTag("genres", index)'></button>
+								<button class='delete is-info' @click='removeTag("genres", index)'></button>
 							</span>
 						</div>
 					</div>