Skip to content

Commit

Permalink
Merge pull request #1116 from SaraVieira/feat/open-links-new-tab
Browse files Browse the repository at this point in the history
feat(UX) - Allow links to open in a new tab
  • Loading branch information
gantoine authored Aug 27, 2024
2 parents bff90fe + 1c704dd commit ee93deb
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 28 deletions.
34 changes: 17 additions & 17 deletions frontend/src/components/common/Game/Card/Base.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const props = withDefaults(
withBorder: false,
withBorderRommAccent: false,
src: "",
}
},
);
const romsStore = storeRoms();
const emit = defineEmits(["click", "touchstart", "touchend"]);
Expand Down Expand Up @@ -99,29 +99,29 @@ onMounted(() => {
src
? src
: romsStore.isSimpleRom(rom)
? !rom.igdb_id && !rom.moby_id && !rom.has_cover
? `/assets/default/cover/big_${theme.global.name.value}_unmatched.png`
: (rom.igdb_id || rom.moby_id) && !rom.has_cover
? `/assets/default/cover/big_${theme.global.name.value}_missing_cover.png`
: `/assets/romm/resources/${rom.path_cover_l}?ts=${rom.updated_at}`
: !rom.igdb_url_cover && !rom.moby_url_cover
? `/assets/default/cover/big_${theme.global.name.value}_missing_cover.png`
: rom.igdb_url_cover
? rom.igdb_url_cover
: rom.moby_url_cover
? !rom.igdb_id && !rom.moby_id && !rom.has_cover
? `/assets/default/cover/big_${theme.global.name.value}_unmatched.png`
: (rom.igdb_id || rom.moby_id) && !rom.has_cover
? `/assets/default/cover/big_${theme.global.name.value}_missing_cover.png`
: `/assets/romm/resources/${rom.path_cover_l}?ts=${rom.updated_at}`
: !rom.igdb_url_cover && !rom.moby_url_cover
? `/assets/default/cover/big_${theme.global.name.value}_missing_cover.png`
: rom.igdb_url_cover
? rom.igdb_url_cover
: rom.moby_url_cover
"
:lazy-src="
romsStore.isSimpleRom(rom)
? !rom.igdb_id && !rom.moby_id && !rom.has_cover
? `/assets/default/cover/big_${theme.global.name.value}_unmatched.png`
: (rom.igdb_id || rom.moby_id) && !rom.has_cover
? `/assets/default/cover/big_${theme.global.name.value}_missing_cover.png`
: `/assets/romm/resources/${rom.path_cover_s}?ts=${rom.updated_at}`
? `/assets/default/cover/big_${theme.global.name.value}_missing_cover.png`
: `/assets/romm/resources/${rom.path_cover_s}?ts=${rom.updated_at}`
: !rom.igdb_url_cover && !rom.moby_url_cover
? `/assets/default/cover/big_${theme.global.name.value}_missing_cover.png`
: rom.igdb_url_cover
? rom.igdb_url_cover
: rom.moby_url_cover
? `/assets/default/cover/big_${theme.global.name.value}_missing_cover.png`
: rom.igdb_url_cover
? rom.igdb_url_cover
: rom.moby_url_cover
"
:aspect-ratio="2 / 3"
>
Expand Down
12 changes: 10 additions & 2 deletions frontend/src/layouts/Dashboard/Recent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,20 @@ import { useRouter } from "vue-router";
// Props
const romsStore = storeRoms();
const { recentRoms } = storeToRefs(romsStore)
const { recentRoms } = storeToRefs(romsStore);
const router = useRouter();
// Functions
function onGameClick(emitData: { rom: SimpleRom; event: MouseEvent }) {
router.push({ name: "rom", params: { rom: emitData.rom.id } });
if (emitData.event.metaKey || emitData.event.ctrlKey) {
const link = router.resolve({
name: "rom",
params: { rom: emitData.rom.id },
});
window.open(link.href, "_blank");
} else {
router.push({ name: "rom", params: { rom: emitData.rom.id } });
}
}
</script>
<template>
Expand Down
10 changes: 9 additions & 1 deletion frontend/src/views/Gallery/Collection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,15 @@ function onGameClick(emitData: { rom: SimpleRom; event: MouseEvent }) {
romsStore.updateLastSelected(index);
}
} else {
router.push({ name: "rom", params: { rom: emitData.rom.id } });
if (emitData.event.metaKey || emitData.event.ctrlKey) {
const link = router.resolve({
name: "rom",
params: { rom: emitData.rom.id },
});
window.open(link.href, "_blank");
} else {
router.push({ name: "rom", params: { rom: emitData.rom.id } });
}
}
}
Expand Down
24 changes: 16 additions & 8 deletions frontend/src/views/Gallery/Platform.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ async function fetchRoms() {
timeout: 4000,
});
console.error(
`Couldn't fetch roms for platform ID ${currentPlatform.value?.id}: ${error}`
`Couldn't fetch roms for platform ID ${currentPlatform.value?.id}: ${error}`,
);
noPlatformError.value = true;
})
Expand All @@ -87,28 +87,28 @@ function setFilters() {
...new Set(
romsStore.filteredRoms
.flatMap((rom) => rom.genres.map((genre) => genre))
.sort()
.sort(),
),
]);
galleryFilterStore.setFilterFranchises([
...new Set(
romsStore.filteredRoms
.flatMap((rom) => rom.franchises.map((franchise) => franchise))
.sort()
.sort(),
),
]);
galleryFilterStore.setFilterCompanies([
...new Set(
romsStore.filteredRoms
.flatMap((rom) => rom.companies.map((company) => company))
.sort()
.sort(),
),
]);
galleryFilterStore.setFilterCollections([
...new Set(
romsStore.filteredRoms
.flatMap((rom) => rom.collections.map((collection) => collection))
.sort()
.sort(),
),
]);
}
Expand All @@ -135,7 +135,7 @@ function onGameClick(emitData: { rom: SimpleRom; event: MouseEvent }) {
}
if (emitData.event.shiftKey) {
const [start, end] = [romsStore.lastSelectedIndex, index].sort(
(a, b) => a - b
(a, b) => a - b,
);
if (romsStore.selectedRoms.includes(emitData.rom)) {
for (let i = start + 1; i < end; i++) {
Expand All @@ -147,13 +147,21 @@ function onGameClick(emitData: { rom: SimpleRom; event: MouseEvent }) {
}
}
romsStore.updateLastSelected(
romsStore.selectedRoms.includes(emitData.rom) ? index : index - 1
romsStore.selectedRoms.includes(emitData.rom) ? index : index - 1,
);
} else {
romsStore.updateLastSelected(index);
}
} else {
router.push({ name: "rom", params: { rom: emitData.rom.id } });
if (emitData.event.metaKey || emitData.event.ctrlKey) {
const link = router.resolve({
name: "rom",
params: { rom: emitData.rom.id },
});
window.open(link.href, "_blank");
} else {
router.push({ name: "rom", params: { rom: emitData.rom.id } });
}
}
}
Expand Down

0 comments on commit ee93deb

Please sign in to comment.