mirror of
https://github.com/rommapp/romm.git
synced 2026-11-30 10:32:57 +01:00
added multi rom selection with ctrl key
This commit is contained in:
@@ -84,18 +84,19 @@ async function deleteRoms() {
|
||||
<v-divider class="border-opacity-25" :thickness="1" />
|
||||
<v-card-text>
|
||||
<v-row class="justify-center pa-2" no-gutters>
|
||||
<span>Deleting the following</span><span class="text-romm-accent-2 mx-1">{{ roms.length }}</span><span>games. Do you confirm?</span>
|
||||
<span>Deleting the following</span>
|
||||
<span class="text-romm-accent-2 mx-1">{{ roms.length }}</span>
|
||||
<span>games. Do you confirm?</span>
|
||||
</v-row>
|
||||
</v-card-text>
|
||||
<v-card-text class="scroll bg-terciary py-0">
|
||||
<v-row class="justify-center pa-2" no-gutters>
|
||||
<v-list class="bg-terciary py-0">
|
||||
<v-list-item
|
||||
v-for="rom in roms"
|
||||
class="justify-center bg-terciary"
|
||||
>{{ rom.r_name }} - [
|
||||
<span class="text-romm-accent-1">{{ rom.file_name }}</span>
|
||||
]</v-list-item
|
||||
<v-list-item v-for="rom in roms" class="justify-center bg-terciary"
|
||||
>{{ rom.r_name }} - [<span class="text-romm-accent-1">{{
|
||||
rom.file_name
|
||||
}}</span
|
||||
>]</v-list-item
|
||||
>
|
||||
</v-list>
|
||||
</v-row>
|
||||
|
||||
@@ -1,21 +1,39 @@
|
||||
<script setup>
|
||||
import storeDownload from "@/stores/download";
|
||||
import storeRoms from "@/stores/roms";
|
||||
|
||||
const downloadStore = storeDownload();
|
||||
const romsStore = storeRoms();
|
||||
|
||||
// Props
|
||||
const props = defineProps(["rom", "isHoveringTop", "size", "selected"]);
|
||||
|
||||
const emit = defineEmits(["selectRom"]);
|
||||
const selectRom = () => {
|
||||
emit("selectRom");
|
||||
};
|
||||
function selectRom(event) {
|
||||
if (!event.ctrlKey) {
|
||||
event.preventDefault();
|
||||
emit("selectRom");
|
||||
}
|
||||
}
|
||||
|
||||
function onNavigate(event) {
|
||||
if (event.ctrlKey) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
emit("selectRom");
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<router-link
|
||||
style="text-decoration: none; color: inherit"
|
||||
:to="`/platform/${$route.params.platform}/${rom.id}`"
|
||||
:to="
|
||||
romsStore.length > 0
|
||||
? `#`
|
||||
: `/platform/${$route.params.platform}/${rom.id}`
|
||||
"
|
||||
@click="onNavigate"
|
||||
>
|
||||
<v-progress-linear
|
||||
color="romm-accent-1"
|
||||
@@ -60,7 +78,7 @@ const selectRom = () => {
|
||||
</v-chip-group>
|
||||
<v-icon
|
||||
v-show="isHoveringTop"
|
||||
@click.prevent="selectRom"
|
||||
@click="selectRom"
|
||||
size="small"
|
||||
class="position-absolute checkbox"
|
||||
:class="{ 'checkbox-selected': selected }"
|
||||
|
||||
@@ -155,6 +155,37 @@ function toTop() {
|
||||
});
|
||||
}
|
||||
|
||||
function toggleRomSelected(event, rom) {
|
||||
const isSelected = selectedRoms.value.includes(rom);
|
||||
|
||||
if (event.shiftKey && lastSelectedRom.value) {
|
||||
const [startIndex, endIndex] = [
|
||||
filteredRoms.value.indexOf(lastSelectedRom.value),
|
||||
filteredRoms.value.indexOf(rom),
|
||||
].sort((a, b) => a - b);
|
||||
|
||||
for (let i = startIndex; i <= endIndex; i++) {
|
||||
const currentRom = filteredRoms.value[i];
|
||||
if (!selectedRoms.value.includes(currentRom)) {
|
||||
selectedRoms.value.push(currentRom);
|
||||
} else if (isSelected) {
|
||||
selectedRoms.value.splice(selectedRoms.value.indexOf(currentRom), 1);
|
||||
}
|
||||
|
||||
if (i === endIndex) {
|
||||
lastSelectedRom.value = currentRom;
|
||||
}
|
||||
}
|
||||
} else if (!isSelected) {
|
||||
selectedRoms.value.push(rom);
|
||||
|
||||
// Allows to select multiple roms with shift key
|
||||
lastSelectedRom.value = rom;
|
||||
} else {
|
||||
selectedRoms.value.splice(selectedRoms.value.indexOf(rom), 1);
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
fetchRoms(route.params.platform);
|
||||
});
|
||||
@@ -163,6 +194,7 @@ onBeforeUnmount(() => {
|
||||
socket.off("scan:scanning_rom");
|
||||
socket.off("scan:done");
|
||||
socket.off("scan:done_ko");
|
||||
romsStore.updateSelectedRoms([]);
|
||||
});
|
||||
|
||||
onBeforeRouteUpdate(async (to, _) => {
|
||||
@@ -171,6 +203,7 @@ onBeforeRouteUpdate(async (to, _) => {
|
||||
roms.value = [];
|
||||
searchRoms.value = [];
|
||||
filteredRoms.value = [];
|
||||
romsStore.updateSelectedRoms([]);
|
||||
fetchRoms(to.params.platform);
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user