Merge pull request #799 from rommapp/737-uiux-improve-multi-select-in-gallery

Improved multi-select games
This commit is contained in:
Zurdi
2024-04-08 01:28:34 +02:00
committed by GitHub
6 changed files with 148 additions and 72 deletions

View File

@@ -80,6 +80,7 @@ function toggleEmulation() {
</v-col>
</v-row>
</template>
<style scoped>
.tooltip :deep(.v-overlay__content) {
background: rgba(201, 201, 201, 0.98) !important;

View File

@@ -1,9 +1,9 @@
<script setup lang="ts">
import AdminMenu from "@/components/Gallery/AppBar/AdminMenu.vue";
import FilterBar from "@/components/Gallery/AppBar/FilterBar.vue";
import FilterUnmatchedBtn from "@/components/Gallery/AppBar/FilterUnmatchedBtn.vue";
import FilterBtn from "@/components/Gallery/AppBar/FilterBtn.vue";
import FilterTextField from "@/components/Gallery/AppBar/FilterTextField.vue";
import SelectingBtn from "@/components/Gallery/AppBar/SelectingBtn.vue";
import GalleryViewBtn from "@/components/Gallery/AppBar/GalleryViewBtn.vue";
import SortBar from "@/components/Gallery/AppBar/SortBar.vue";
import SortBtn from "@/components/Gallery/AppBar/SortBtn.vue";
@@ -18,6 +18,7 @@ const auth = storeAuth();
<!-- <sort-btn /> -->
<filter-btn />
<filter-text-field />
<selecting-btn />
<gallery-view-btn />
<template v-if="auth.scopes.includes('roms.write')">
<v-menu location="bottom">

View File

@@ -0,0 +1,31 @@
<script setup lang="ts">
import storeRoms from "@/stores/roms";
// Props
const romsStore = storeRoms();
</script>
<template>
<v-tooltip
location="bottom"
class="tooltip"
transition="fade-transition"
text="Active multi-select"
open-delay="1000"
><template v-slot:activator="{ props }">
<v-btn
@click="romsStore.isSelecting()"
:color="romsStore.selecting ? 'romm-accent-1' : ''"
rounded="0"
variant="text"
v-bind="props"
class="mr-0"
icon="mdi-select-group" /></template
></v-tooltip>
</template>
<style scoped>
.tooltip :deep(.v-overlay__content) {
background: rgba(201, 201, 201, 0.98) !important;
color: rgb(41, 41, 41) !important;
}
</style>

View File

@@ -37,12 +37,12 @@ async function onScan() {
}
function selectAllRoms() {
if (romsStore.filteredRoms.length === romsStore.selectedRoms.length) {
romsStore.resetSelection();
emitter?.emit("openFabMenu", false);
} else {
romsStore.setSelection(romsStore.filteredRoms);
}
romsStore.setSelection(romsStore.filteredRoms);
}
function resetSelection() {
romsStore.resetSelection();
emitter?.emit("openFabMenu", false);
}
function onDownload() {
@@ -53,47 +53,103 @@ function onDownload() {
</script>
<template>
<v-btn
color="terciary"
elevation="8"
:icon="
romsStore.filteredRoms.length === romsStore.selectedRoms.length
? 'mdi-select'
: 'mdi-select-all'
"
class="mb-2 ml-1"
@click.stop="selectAllRoms"
/>
<v-btn
v-if="auth.scopes.includes('roms.write')"
color="terciary"
elevation="8"
icon
class="mb-2 ml-1"
@click="onScan"
<v-tooltip
open-delay="500"
class="tooltip"
text="Reset selection"
location="top"
>
<v-icon>mdi-magnify-scan</v-icon>
</v-btn>
<template v-slot:activator="{ props }">
<v-btn
v-bind="props"
color="terciary"
elevation="8"
icon="mdi-select"
class="mb-2 ml-1"
@click.stop="resetSelection"
/>
</template>
</v-tooltip>
<v-btn
color="terciary"
elevation="8"
icon
class="mb-2 ml-1"
@click="onDownload"
>
<v-icon>mdi-download</v-icon>
</v-btn>
<v-tooltip open-delay="500" class="tooltip" text="Select all" location="top">
<template v-slot:activator="{ props }">
<v-btn
v-bind="props"
color="terciary"
elevation="8"
icon="mdi-select-all"
class="mb-2 ml-1"
@click.stop="selectAllRoms"
/>
</template>
</v-tooltip>
<v-btn
v-if="auth.scopes.includes('roms.write')"
color="terciary"
elevation="8"
icon
class="mb-3 ml-1"
@click="emitter?.emit('showDeleteRomDialog', romsStore.selectedRoms)"
<v-tooltip
open-delay="500"
class="tooltip"
text="Scan selected games"
location="top"
>
<v-icon color="romm-red">mdi-delete</v-icon>
</v-btn>
<template v-slot:activator="{ props }">
<v-btn
v-bind="props"
v-if="auth.scopes.includes('roms.write')"
color="terciary"
elevation="8"
icon
class="mb-2 ml-1"
@click="onScan"
>
<v-icon>mdi-magnify-scan</v-icon>
</v-btn>
</template>
</v-tooltip>
<v-tooltip
open-delay="500"
class="tooltip"
text="Download selected games"
location="top"
>
<template v-slot:activator="{ props }">
<v-btn
v-bind="props"
color="terciary"
elevation="8"
icon
class="mb-2 ml-1"
@click="onDownload"
>
<v-icon>mdi-download</v-icon>
</v-btn>
</template>
</v-tooltip>
<v-tooltip
open-delay="500"
class="tooltip"
text="Delete selected games"
location="top"
>
<template v-slot:activator="{ props }">
<v-btn
v-bind="props"
v-if="auth.scopes.includes('roms.write')"
color="terciary"
elevation="8"
icon
class="mb-3 ml-1"
@click="emitter?.emit('showDeleteRomDialog', romsStore.selectedRoms)"
>
<v-icon color="romm-red">mdi-delete</v-icon>
</v-btn>
</template>
</v-tooltip>
</template>
<style scoped>
.tooltip :deep(.v-overlay__content) {
background: rgba(201, 201, 201, 0.98) !important;
color: rgb(41, 41, 41) !important;
}
</style>

View File

@@ -7,6 +7,7 @@ import { identity, isNull } from "lodash";
import { ref } from "vue";
import { useTheme } from "vuetify";
// Props
defineProps<{
rom: Rom;
isHoveringTop: boolean;
@@ -28,21 +29,15 @@ const showLanguages = isNull(localStorage.getItem("settings.showLanguages"))
const showSiblings = isNull(localStorage.getItem("settings.showSiblings"))
? true
: localStorage.getItem("settings.showSiblings") === "true";
let timeout: ReturnType<typeof setTimeout>;
// Functions
function onSelectRom(event: MouseEvent) {
if (!event.ctrlKey && !event.shiftKey) {
event.preventDefault();
emit("selectRom", event);
}
}
// Functions
function onNavigate(event: MouseEvent) {
if (
event.ctrlKey ||
event.shiftKey ||
(romsStore.touchScreen && romsStore.selectedRoms.length > 0)
romsStore.selecting ||
romsStore.selectedRoms.length > 0
) {
event.preventDefault();
event.stopPropagation();
@@ -54,7 +49,6 @@ function onTouchStart(event: TouchEvent) {
card.value.$el.addEventListener("contextmenu", (event: Event) => {
event.preventDefault();
});
romsStore.isTouchScreen(true);
timeout = setTimeout(() => {
emit("selectRom", event);
}, 500);
@@ -69,7 +63,7 @@ function onTouchEnd() {
<router-link
style="text-decoration: none; color: inherit"
:to="
romsStore.touchScreen && romsStore.selectedRoms.length > 0
romsStore.selecting || romsStore.selectedRoms.length > 0
? {}
: {
name: 'rom',
@@ -125,7 +119,6 @@ function onTouchEnd() {
'text-truncate': galleryViewStore.current == 0 && !isHovering,
}"
>
<v-list-item>{{ rom.name }}</v-list-item>
</div>
</v-expand-transition>
@@ -161,14 +154,6 @@ function onTouchEnd() {
+{{ rom.siblings.length }}
</v-chip>
</v-row>
<v-icon
v-show="isHoveringTop && showSelector"
@click="onSelectRom"
size="small"
class="position-absolute checkbox"
:class="{ 'checkbox-selected': selected }"
>{{ selected ? "mdi-circle-slice-8" : "mdi-circle-outline" }}</v-icon
>
</v-img>
</v-hover>
</router-link>

View File

@@ -23,7 +23,7 @@ export default defineStore("roms", {
lastSelectedIndex: -1,
cursor: "" as string | null,
searchCursor: "" as string | null,
touchScreen: false,
selecting: false,
}),
getters: {
@@ -54,9 +54,11 @@ export default defineStore("roms", {
// Group roms by external id
this._grouped = Object.values(
groupBy(this._all, (game) =>
// If external id is null, generate a random id so that the roms are not grouped
game.igdb_id || game.moby_id || nanoid()
groupBy(
this._all,
(game) =>
// If external id is null, generate a random id so that the roms are not grouped
game.igdb_id || game.moby_id || nanoid()
)
)
.map((games) => ({
@@ -180,8 +182,8 @@ export default defineStore("roms", {
updateLastSelected(index: number) {
this.lastSelectedIndex = index;
},
isTouchScreen(touchScreen: boolean) {
this.touchScreen = touchScreen;
isSelecting() {
this.selecting = !this.selecting;
},
resetSelection() {
this._selectedIDs = [];