slash not allowd in file name when editing

This commit is contained in:
zurdi
2023-08-19 00:14:44 +02:00
parent 06ce61339a
commit 2a16a9d403

View File

@@ -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 }) {
<v-text-field
@keyup.enter="updateRom()"
v-model="rom.file_name"
:rules="[inputRules.newFileName, inputRules.required]"
label="File name"
variant="outlined"
required
@@ -122,11 +137,7 @@ async function updateRom(updatedData = { ...rom.value }) {
</v-row>
<v-row class="justify-center pa-2" no-gutters>
<v-btn @click="show = false">Cancel</v-btn>
<v-btn
@click="updateRom()"
class="text-rommGreen ml-5"
>Apply</v-btn
>
<v-btn @click="updateRom()" class="text-rommGreen ml-5">Apply</v-btn>
</v-row>
</v-card-text>
</v-card>