From 2a16a9d403d294a8cecb2e5201909ba314b896ae Mon Sep 17 00:00:00 2001 From: zurdi Date: Sat, 19 Aug 2023 00:14:44 +0200 Subject: [PATCH 1/2] slash not allowd in file name when editing --- frontend/src/components/Dialog/EditRom.vue | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/frontend/src/components/Dialog/EditRom.vue b/frontend/src/components/Dialog/EditRom.vue index 3317d9e9a..df2c396d8 100644 --- a/frontend/src/components/Dialog/EditRom.vue +++ b/frontend/src/components/Dialog/EditRom.vue @@ -7,6 +7,10 @@ const { xs, mdAndDown, lgAndUp } = useDisplay(); const show = ref(false); const rom = ref(); const renameAsIGDB = ref(false); +const inputRules = { + required: (value) => !!value || "Required.", + newFileName: (value) => !value.includes("/") || "Invalid characters", +}; const emitter = inject("emitter"); emitter.on("showEditDialog", (romToEdit) => { @@ -15,6 +19,16 @@ emitter.on("showEditDialog", (romToEdit) => { }); async function updateRom(updatedData = { ...rom.value }) { + + if (updatedData.file_name.includes("/")) { + emitter.emit("snackbarShow", { + msg: "Couldn't edit rom: invalid file name characters", + icon: "mdi-close-circle", + color: "red", + }); + return; + } + show.value = false; emitter.emit("showLoadingDialog", { loading: true, scrim: true }); @@ -93,6 +107,7 @@ async function updateRom(updatedData = { ...rom.value }) { Cancel - Apply + Apply From 64dbae98284c5304491f0a47e04a9420f19e50d3 Mon Sep 17 00:00:00 2001 From: zurdi Date: Sat, 19 Aug 2023 00:20:23 +0200 Subject: [PATCH 2/2] file name required when editing rom --- frontend/src/components/Dialog/EditRom.vue | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/frontend/src/components/Dialog/EditRom.vue b/frontend/src/components/Dialog/EditRom.vue index df2c396d8..473addd21 100644 --- a/frontend/src/components/Dialog/EditRom.vue +++ b/frontend/src/components/Dialog/EditRom.vue @@ -7,7 +7,7 @@ const { xs, mdAndDown, lgAndUp } = useDisplay(); const show = ref(false); const rom = ref(); const renameAsIGDB = ref(false); -const inputRules = { +const fileNameInputRules = { required: (value) => !!value || "Required.", newFileName: (value) => !value.includes("/") || "Invalid characters", }; @@ -19,16 +19,22 @@ emitter.on("showEditDialog", (romToEdit) => { }); async function updateRom(updatedData = { ...rom.value }) { - if (updatedData.file_name.includes("/")) { emitter.emit("snackbarShow", { msg: "Couldn't edit rom: invalid file name characters", icon: "mdi-close-circle", color: "red", }); - return; + return; + } else if (!updatedData.file_name) { + emitter.emit("snackbarShow", { + msg: "Couldn't edit rom: file name required", + icon: "mdi-close-circle", + color: "red", + }); + return; } - + show.value = false; emitter.emit("showLoadingDialog", { loading: true, scrim: true }); @@ -107,7 +113,10 @@ async function updateRom(updatedData = { ...rom.value }) {