浏览代码

feat(editSong): Confirm song deletion

Owen Diffey 3 年之前
父节点
当前提交
aac6320d85

+ 2 - 2
frontend/src/components/modals/Confirm.vue

@@ -33,10 +33,10 @@ export default {
 	methods: {
 		confirmAction() {
 			this.$emit("confirmed");
-			this.closeModal("confirm");
+			this.closeCurrentModal();
 		},
 		...mapActions("modals/confirm", ["updateConfirmMessage"]),
-		...mapActions("modalVisibility", ["closeModal"])
+		...mapActions("modalVisibility", ["closeCurrentModal"])
 	}
 };
 </script>

+ 29 - 2
frontend/src/components/modals/EditSong/index.vue

@@ -546,11 +546,13 @@
 				><span>Christian rock</span><span>Dubstep</span>
 			</template>
 		</floating-box>
+		<confirm v-if="modals.editSongConfirm" @confirmed="handleConfirmed()" />
 	</div>
 </template>
 
 <script>
 import { mapState, mapGetters, mapActions } from "vuex";
+import { defineAsyncComponent } from "vue";
 import Toast from "toasters";
 
 import aw from "@/aw";
@@ -577,7 +579,10 @@ export default {
 		Discogs,
 		Reports,
 		Youtube,
-		MusareSongs
+		MusareSongs,
+		Confirm: defineAsyncComponent(() =>
+			import("@/components/modals/Confirm.vue")
+		)
 	},
 	props: {
 		youtubeId: { type: String, default: null },
@@ -642,7 +647,12 @@ export default {
 				"Heavy Metal",
 				"Christian rock",
 				"Dubstep"
-			]
+			],
+			confirm: {
+				message: "",
+				action: "",
+				params: null
+			}
 		};
 	},
 	computed: {
@@ -1577,6 +1587,23 @@ export default {
 				new Toast(res.message);
 			});
 		},
+		confirmAction(confirm) {
+			this.confirm = confirm;
+			this.updateConfirmMessage(confirm.message);
+			this.openModal("editSongConfirm");
+		},
+		handleConfirmed() {
+			const { action, params } = this.confirm;
+			if (typeof this[action] === "function") {
+				if (params) this[action](params);
+				else this[action]();
+			}
+			this.confirm = {
+				message: "",
+				action: "",
+				params: null
+			};
+		},
 		...mapActions("modals/importAlbum", [
 			"selectDiscogsAlbum",
 			"updateEditingSongs"

+ 2 - 1
frontend/src/store/modules/modalVisibility.js

@@ -19,7 +19,8 @@ const state = {
 		importAlbum: false,
 		viewReport: false,
 		viewPunishment: false,
-		confirm: false
+		confirm: false,
+		editSongConfirm: false
 	},
 	currentlyActive: []
 };