Browse Source

Added quick song-delete confirmation, and made songs focus after modal closes with shortcut

Kristian Vos 4 years ago
parent
commit
c71c8bf043

+ 4 - 0
frontend/src/components/modals/EditSong.vue

@@ -560,6 +560,7 @@ export default {
 	components: { Modal },
 	data() {
 		return {
+			focusedElementBefore: null,
 			discogsQuery: "",
 			youtubeVideoDuration: 0.0,
 			youtubeVideoCurrentTime: 0.0,
@@ -1386,6 +1387,9 @@ export default {
 					sector: "admin",
 					modal: "editSong"
 				});
+				setTimeout(() => {
+					window.focusedElementBefore.focus();
+				}, 500);
 			}
 		});
 

+ 1 - 0
frontend/src/main.js

@@ -44,6 +44,7 @@ Vue.directive("scroll", {
 
 Vue.directive("focus", {
 	inserted(el) {
+		window.focusedElementBefore = document.activeElement;
 		el.focus();
 	}
 });

+ 5 - 0
frontend/src/pages/Admin/tabs/QueueSongs.vue

@@ -165,6 +165,11 @@ export default {
 			});
 		},
 		remove(id) {
+			// eslint-disable-next-line
+			const dialogResult = window.confirm(
+				"Are you sure you want to delete this song?"
+			);
+			if (dialogResult !== true) return;
 			this.socket.emit("queueSongs.remove", id, res => {
 				if (res.status === "success")
 					new Toast({ content: res.message, timeout: 2000 });

+ 5 - 0
frontend/src/pages/Admin/tabs/Songs.vue

@@ -151,6 +151,11 @@ export default {
 			this.openModal({ sector: "admin", modal: "editSong" });
 		},
 		remove(id) {
+			// eslint-disable-next-line
+			const dialogResult = window.confirm(
+				"Are you sure you want to delete this song?"
+			);
+			if (dialogResult !== true) return;
 			this.socket.emit("songs.remove", id, res => {
 				if (res.status === "success")
 					new Toast({ content: res.message, timeout: 4000 });