Refactor Excluded and FolderMappings components to enhance search functionality, improve UI layout, and update tab structure for better navigation.

This commit is contained in:
zurdi
2025-12-29 10:55:07 +00:00
parent d021053530
commit 6a2707cceb
4 changed files with 218 additions and 234 deletions

View File

@@ -112,8 +112,36 @@ function addExclusion(type?: string, icon?: string, title?: string) {
}
</script>
<template>
<RSection icon="mdi-cancel" :title="t('settings.excluded')">
<template #toolbar-title-append>
<v-text-field
v-model="search"
prepend-inner-icon="mdi-magnify"
:label="t('common.search')"
single-line
hide-details
clearable
rounded="0"
density="comfortable"
class="bg-surface"
/>
<div v-if="rows.length === 0" class="text-center py-8">
<v-icon icon="mdi-format-list-bulleted" size="48" class="mb-2 opacity-50" />
<div class="text-body-2 text-romm-gray">
{{ t("settings.exclusions-none") }}
</div>
</div>
<v-data-table-virtual
v-else
:style="{ 'max-height': '100%' }"
:search="search"
:headers="HEADERS"
:items="rows"
:sort-by="[{ key: 'type', order: 'asc' }]"
fixed-header
density="comfortable"
class="rounded bg-background"
hide-default-footer
>
<template #header.actions>
<v-tooltip bottom max-width="400">
<template #activator="{ props }">
<v-btn
@@ -129,90 +157,52 @@ function addExclusion(type?: string, icon?: string, title?: string) {
</p>
</div>
</v-tooltip>
</template>
<template #content>
<v-text-field
v-model="search"
prepend-inner-icon="mdi-magnify"
:label="t('common.search')"
single-line
hide-details
clearable
rounded="0"
density="comfortable"
class="bg-surface"
/>
<div v-if="rows.length === 0" class="text-center py-8">
<v-icon
icon="mdi-format-list-bulleted"
size="48"
class="mb-2 opacity-50"
/>
<div class="text-body-2 text-romm-gray">
{{ t("settings.exclusions-none") }}
</div>
</div>
<v-data-table-virtual
v-else
:style="{ 'max-height': '100%' }"
:search="search"
:headers="HEADERS"
:items="rows"
:sort-by="[{ key: 'type', order: 'asc' }]"
fixed-header
density="comfortable"
class="rounded bg-background"
hide-default-footer
<v-btn
v-if="
authStore.scopes.includes('platforms.write') &&
config.CONFIG_FILE_WRITABLE
"
prepend-icon="mdi-plus"
variant="outlined"
class="text-primary"
@click="addExclusion()"
>
<template #header.actions>
<v-btn
v-if="
authStore.scopes.includes('platforms.write') &&
config.CONFIG_FILE_WRITABLE
"
prepend-icon="mdi-plus"
variant="outlined"
class="text-primary"
@click="addExclusion()"
>
{{ t("common.add") }}
</v-btn>
</template>
<template #item.type="{ item }">
<v-list-item class="pa-0" min-width="240px">
<template #prepend>
<v-icon :icon="item.icon" size="26" class="mr-3" />
</template>
<span class="font-weight-medium">{{ item.title }}</span>
</v-list-item>
</template>
<template #item.value="{ item }">
<v-list-item class="pa-0" min-width="160px">
<span class="font-weight-medium">{{ item.value }}</span>
</v-list-item>
</template>
<template #item.actions="{ item }">
<v-btn-group
v-if="
authStore.scopes.includes('platforms.write') &&
config.CONFIG_FILE_WRITABLE
"
divided
density="compact"
variant="text"
>
<v-btn
class="text-romm-red"
size="small"
:title="t('common.delete')"
@click="removeExclusion(item.value, item.type)"
>
<v-icon>mdi-delete</v-icon>
</v-btn>
</v-btn-group>
</template>
</v-data-table-virtual>
<CreateExclusionDialog />
{{ t("common.add") }}
</v-btn>
</template>
</RSection>
<template #item.type="{ item }">
<v-list-item class="pa-0" min-width="240px">
<template #prepend>
<v-icon :icon="item.icon" size="26" class="mr-3" />
</template>
<span class="font-weight-medium">{{ item.title }}</span>
</v-list-item>
</template>
<template #item.value="{ item }">
<v-list-item class="pa-0" min-width="160px">
<span class="font-weight-medium">{{ item.value }}</span>
</v-list-item>
</template>
<template #item.actions="{ item }">
<v-btn-group
v-if="
authStore.scopes.includes('platforms.write') &&
config.CONFIG_FILE_WRITABLE
"
divided
density="compact"
variant="text"
>
<v-btn
class="text-romm-red"
size="small"
:title="t('common.delete')"
@click="removeExclusion(item.value, item.type)"
>
<v-icon>mdi-delete</v-icon>
</v-btn>
</v-btn-group>
</template>
</v-data-table-virtual>
<CreateExclusionDialog />
</template>

View File

@@ -121,8 +121,29 @@ function deleteMapping(row: Row) {
</script>
<template>
<RSection icon="mdi-folder-cog" :title="t('settings.folder-mappings')">
<template #toolbar-title-append>
<v-text-field
v-model="search"
prepend-inner-icon="mdi-magnify"
:label="t('common.search')"
single-line
hide-details
clearable
rounded="0"
density="comfortable"
class="bg-surface"
/>
<v-data-table-virtual
:style="{ 'max-height': '100%' }"
:search="search"
:headers="HEADERS"
:items="rows"
:sort-by="[{ key: 'fsSlug', order: 'asc' }]"
fixed-header
density="comfortable"
class="rounded bg-background"
hide-default-footer
>
<template #header.actions>
<v-tooltip bottom max-width="500">
<template #activator="{ props }">
<v-btn
@@ -146,143 +167,111 @@ function deleteMapping(row: Row) {
</p>
</div>
</v-tooltip>
</template>
<template #content>
<v-text-field
v-model="search"
prepend-inner-icon="mdi-magnify"
:label="t('common.search')"
single-line
hide-details
clearable
rounded="0"
density="comfortable"
class="bg-surface"
/>
<v-data-table-virtual
:style="{ 'max-height': '100%' }"
:search="search"
:headers="HEADERS"
:items="rows"
:sort-by="[{ key: 'fsSlug', order: 'asc' }]"
fixed-header
density="comfortable"
class="rounded bg-background"
hide-default-footer
<v-btn
v-if="authStore.scopes.includes('platforms.write')"
prepend-icon="mdi-plus"
variant="outlined"
class="text-primary mr-1"
@click="emitter?.emit('showCreateFolderMappingDialog', null)"
>
<template #header.actions>
<v-btn
v-if="authStore.scopes.includes('platforms.write')"
prepend-icon="mdi-plus"
variant="outlined"
class="text-primary"
@click="emitter?.emit('showCreateFolderMappingDialog', null)"
>
{{ t("common.add") }}
</v-btn>
</template>
<template #item.fsSlug="{ item }">
<v-list-item class="pa-0 font-weight-medium" min-width="120px">
{{ item.fsSlug }}
</v-list-item>
</template>
<template #item.slug="{ item }">
<v-list-item class="pa-0" min-width="160px">
<template v-if="item.slug" #prepend>
<PlatformIcon :size="28" :slug="item.slug" class="mr-2" />
</template>
<span v-if="item.slug">{{ item.slug }}</span>
<span v-else class="text-romm-gray">—</span>
</v-list-item>
</template>
<template #item.type="{ item }">
<div class="d-flex align-center justify-center">
<v-chip
v-if="item.type === 'alias'"
color="primary"
size="small"
label
>
{{ t("settings.folder-alias") }}
</v-chip>
<v-chip
v-else-if="item.type === 'variant'"
color="accent"
size="small"
label
>
{{ t("settings.platform-variant") }}
</v-chip>
<v-chip
v-else-if="item.type === 'auto'"
color="success"
variant="tonal"
size="small"
label
>
{{ t("settings.auto-detected") }}
</v-chip>
<span v-else class="text-romm-gray">—</span>
</div>
</template>
<template #item.actions="{ item }">
<v-btn-group divided density="compact" variant="text">
<v-btn
v-if="
authStore.scopes.includes('platforms.write') &&
!item.type &&
config.CONFIG_FILE_WRITABLE
"
size="small"
class="text-primary"
:title="t('settings.add-folder-alias')"
@click="addAlias(item.fsSlug)"
>
<v-icon>mdi-link-variant</v-icon>
</v-btn>
<v-btn
v-if="
authStore.scopes.includes('platforms.write') &&
!item.type &&
config.CONFIG_FILE_WRITABLE
"
size="small"
class="text-accent"
:title="t('settings.add-platform-variant')"
@click="addVariant(item.fsSlug)"
>
<v-icon>mdi-family-tree</v-icon>
</v-btn>
<v-btn
v-if="
authStore.scopes.includes('platforms.write') &&
(item.type === 'alias' || item.type === 'variant') &&
config.CONFIG_FILE_WRITABLE
"
size="small"
:title="t('common.edit')"
@click="editMapping(item)"
>
<v-icon>mdi-pencil</v-icon>
</v-btn>
<v-btn
v-if="
authStore.scopes.includes('platforms.write') &&
(item.type === 'alias' || item.type === 'variant') &&
config.CONFIG_FILE_WRITABLE
"
class="text-romm-red"
size="small"
:title="t('common.delete')"
@click="deleteMapping(item)"
>
<v-icon>mdi-delete</v-icon>
</v-btn>
</v-btn-group>
</template>
</v-data-table-virtual>
<CreateFolderMappingDialog />
<DeleteFolderMappingDialog />
{{ t("common.add") }}
</v-btn>
</template>
</RSection>
<template #item.fsSlug="{ item }">
<v-list-item class="pa-0 font-weight-medium" min-width="120px">
{{ item.fsSlug }}
</v-list-item>
</template>
<template #item.slug="{ item }">
<v-list-item class="pa-0" min-width="160px">
<template v-if="item.slug" #prepend>
<PlatformIcon :size="28" :slug="item.slug" class="mr-2" />
</template>
<span v-if="item.slug">{{ item.slug }}</span>
<span v-else class="text-romm-gray">—</span>
</v-list-item>
</template>
<template #item.type="{ item }">
<div class="d-flex align-center justify-center">
<v-chip v-if="item.type === 'alias'" color="primary" size="small" label>
{{ t("settings.folder-alias") }}
</v-chip>
<v-chip
v-else-if="item.type === 'variant'"
color="accent"
size="small"
label
>
{{ t("settings.platform-variant") }}
</v-chip>
<v-chip
v-else-if="item.type === 'auto'"
color="success"
variant="tonal"
size="small"
label
>
{{ t("settings.auto-detected") }}
</v-chip>
<span v-else class="text-romm-gray">—</span>
</div>
</template>
<template #item.actions="{ item }">
<v-btn-group divided density="compact" variant="text">
<v-btn
v-if="
authStore.scopes.includes('platforms.write') &&
!item.type &&
config.CONFIG_FILE_WRITABLE
"
size="small"
class="text-primary"
:title="t('settings.add-folder-alias')"
@click="addAlias(item.fsSlug)"
>
<v-icon>mdi-link-variant</v-icon>
</v-btn>
<v-btn
v-if="
authStore.scopes.includes('platforms.write') &&
!item.type &&
config.CONFIG_FILE_WRITABLE
"
size="small"
class="text-accent"
:title="t('settings.add-platform-variant')"
@click="addVariant(item.fsSlug)"
>
<v-icon>mdi-family-tree</v-icon>
</v-btn>
<v-btn
v-if="
authStore.scopes.includes('platforms.write') &&
(item.type === 'alias' || item.type === 'variant') &&
config.CONFIG_FILE_WRITABLE
"
size="small"
:title="t('common.edit')"
@click="editMapping(item)"
>
<v-icon>mdi-pencil</v-icon>
</v-btn>
<v-btn
v-if="
authStore.scopes.includes('platforms.write') &&
(item.type === 'alias' || item.type === 'variant') &&
config.CONFIG_FILE_WRITABLE
"
class="text-romm-red"
size="small"
:title="t('common.delete')"
@click="deleteMapping(item)"
>
<v-icon>mdi-delete</v-icon>
</v-btn>
</v-btn-group>
</template>
</v-data-table-virtual>
<CreateFolderMappingDialog />
<DeleteFolderMappingDialog />
</template>

View File

@@ -40,7 +40,7 @@ export type Events = {
slug: string;
type: "alias" | "variant";
};
showCreateExclusionDialog: {
showCreateExclusionDialog: null | {
type: string;
icon: string;
title: string;

View File

@@ -25,13 +25,13 @@ const route = useRoute();
const router = useRouter();
// Valid tab values
const validTabs = ["config", "missing"] as const;
const validTabs = ["mapping", "excluded", "missing"] as const;
// Initialize tab from query parameter or default to "config"
const tab = ref<"config" | "missing">(
const tab = ref<"mapping" | "excluded" | "missing">(
validTabs.includes(route.query.tab as any)
? (route.query.tab as "config" | "missing")
: "config",
? (route.query.tab as "mapping" | "excluded" | "missing")
: "mapping",
);
const configStore = storeConfig();
const { config } = storeToRefs(configStore);
@@ -178,7 +178,7 @@ watch(
() => route.query.tab,
(newTab) => {
if (newTab && validTabs.includes(newTab as any) && tab.value !== newTab) {
tab.value = newTab as "config" | "missing";
tab.value = newTab as "mapping" | "excluded" | "missing";
}
},
{ immediate: true },
@@ -221,8 +221,11 @@ onUnmounted(() => {
slider-color="secondary"
selected-class="bg-toplayer"
>
<v-tab prepend-icon="mdi-cog" class="rounded" value="config">
{{ t("settings.config-tab") }}
<v-tab prepend-icon="mdi-folder-cog" class="rounded" value="mapping">
{{ t("settings.folder-mappings") }}
</v-tab>
<v-tab prepend-icon="mdi-cancel" class="rounded" value="excluded">
{{ t("settings.excluded") }}
</v-tab>
<v-tab
prepend-icon="mdi-folder-question"
@@ -261,8 +264,10 @@ onUnmounted(() => {
</template>
</v-alert>
<v-tabs-window v-model="tab">
<v-tabs-window-item class="h-100" value="config">
<v-tabs-window-item value="mapping">
<FolderMappings class="mt-2" />
</v-tabs-window-item>
<v-tabs-window-item value="excluded">
<Excluded class="mt-4" />
</v-tabs-window-item>
<v-tabs-window-item value="missing">