mirror of
https://github.com/rommapp/romm.git
synced 2026-11-30 02:22:44 +01:00
feat: add exclusion option for deleting ROMs and platforms
This commit is contained in:
@@ -240,7 +240,8 @@ class Rom(BaseModel):
|
||||
|
||||
@cached_property
|
||||
def multi(self) -> bool:
|
||||
return len(self.files) > 1
|
||||
# Temporal fix to check if multi. TODO: Improve multi game detection
|
||||
return len(self.files) > 1 or len(self.files[0].full_path.split("/")) > 3
|
||||
|
||||
@cached_property
|
||||
def fs_size_bytes(self) -> int:
|
||||
|
||||
@@ -3,14 +3,18 @@ import RomListItem from "@/components/common/Game/ListItem.vue";
|
||||
import RDialog from "@/components/common/RDialog.vue";
|
||||
import romApi from "@/services/api/rom";
|
||||
import storeRoms, { type SimpleRom } from "@/stores/roms";
|
||||
import configApi from "@/services/api/config";
|
||||
import type { Events } from "@/types/emitter";
|
||||
import storeConfig from "@/stores/config";
|
||||
import { ROUTES } from "@/plugins/router";
|
||||
import type { Emitter } from "mitt";
|
||||
import { inject, ref } from "vue";
|
||||
import { useRouter, useRoute } from "vue-router";
|
||||
import { useDisplay } from "vuetify";
|
||||
import { useI18n } from "vue-i18n";
|
||||
|
||||
// Props
|
||||
const { t } = useI18n();
|
||||
const { mdAndUp } = useDisplay();
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
@@ -18,8 +22,10 @@ const show = ref(false);
|
||||
const romsStore = storeRoms();
|
||||
const roms = ref<SimpleRom[]>([]);
|
||||
const romsToDeleteFromFs = ref<number[]>([]);
|
||||
const excludeOnDelete = ref(false);
|
||||
const platformId = ref<number>(0);
|
||||
const emitter = inject<Emitter<Events>>("emitter");
|
||||
const configStore = storeConfig();
|
||||
emitter?.on("showDeleteRomDialog", (romsToDelete) => {
|
||||
roms.value = romsToDelete;
|
||||
platformId.value = roms.value[0].platform_id;
|
||||
@@ -43,6 +49,23 @@ async function deleteRoms() {
|
||||
icon: "mdi-check-bold",
|
||||
color: "green",
|
||||
});
|
||||
if (excludeOnDelete.value) {
|
||||
for (const rom of roms.value) {
|
||||
if (!rom.multi) {
|
||||
configApi.addExclusion({
|
||||
exclusionValue: rom.fs_name,
|
||||
exclusionType: "EXCLUDED_SINGLE_FILES",
|
||||
});
|
||||
configStore.addExclusion("EXCLUDED_SINGLE_FILES", rom.fs_name);
|
||||
} else {
|
||||
configApi.addExclusion({
|
||||
exclusionValue: rom.fs_name,
|
||||
exclusionType: "EXCLUDED_MULTI_FILES",
|
||||
});
|
||||
configStore.addExclusion("EXCLUDED_MULTI_FILES", rom.fs_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
romsStore.resetSelection();
|
||||
romsStore.remove(roms.value);
|
||||
emitter?.emit("refreshDrawer", null);
|
||||
@@ -120,6 +143,18 @@ function closeDialog() {
|
||||
</v-data-table-virtual>
|
||||
</template>
|
||||
<template #append>
|
||||
<v-row class="justify-center text-center pa-2" no-gutters>
|
||||
<v-col>
|
||||
<v-chip @click="excludeOnDelete = !excludeOnDelete" variant="text"
|
||||
><v-icon :color="excludeOnDelete ? 'accent' : ''" class="mr-1">{{
|
||||
excludeOnDelete
|
||||
? "mdi-checkbox-outline"
|
||||
: "mdi-checkbox-blank-outline"
|
||||
}}</v-icon>
|
||||
{{ t("common.exclude-on-delete") }}
|
||||
</v-chip>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row v-if="romsToDeleteFromFs.length > 0" no-gutters>
|
||||
<v-col>
|
||||
<v-list-item class="text-center mt-2">
|
||||
|
||||
@@ -66,10 +66,6 @@ async function deletePlatform() {
|
||||
closeDialog();
|
||||
}
|
||||
|
||||
function toggleExcludeOnDelete() {
|
||||
excludeOnDelete.value = !excludeOnDelete.value;
|
||||
}
|
||||
|
||||
function closeDialog() {
|
||||
show.value = false;
|
||||
excludeOnDelete.value = false;
|
||||
@@ -103,7 +99,7 @@ function closeDialog() {
|
||||
<template #append>
|
||||
<v-row class="justify-center text-center pa-2" no-gutters>
|
||||
<v-col>
|
||||
<v-chip @click="toggleExcludeOnDelete" variant="text"
|
||||
<v-chip @click="excludeOnDelete = !excludeOnDelete" variant="text"
|
||||
><v-icon :color="excludeOnDelete ? 'accent' : ''" class="mr-1">{{
|
||||
excludeOnDelete
|
||||
? "mdi-checkbox-outline"
|
||||
|
||||
Reference in New Issue
Block a user