feat(playlists): add folder selector to playlist modal and simplify folder UI
- Add folder selector dropdown to PlaylistModal for create/edit modes - Pass currentFolderId prop to PlaylistModal in detail and manager views - Remove custom folder colors from Sidebar (consistent styling) - Simplify folder creation - name only, no color picker - Remove unused color-picker CSS from PlaylistManagerView Phase 5 of playlist folders feature.
This commit is contained in:
1 parent
df53c962f1
commit
664cf8d3f0
4 files changed
+67
-53
No files matched your search
@@ -1,9 +1,15 @@
|
||||
<script lang="ts">
|
||||
import { invoke } from '@tauri-apps/api/core';
|
||||
import { X, Trash2, EyeOff, Eye } from 'lucide-svelte';
|
||||
import { X, Trash2, EyeOff, Eye, Folder } from 'lucide-svelte';
|
||||
import { logPlaylistAdd } from '$lib/services/recoService';
|
||||
import { subscribe as subscribeOffline, getStatus, createPendingPlaylist } from '$lib/stores/offlineStore';
|
||||
import { showToast } from '$lib/stores/toastStore';
|
||||
import {
|
||||
subscribe as subscribeFolders,
|
||||
getVisibleFolders,
|
||||
movePlaylistToFolder,
|
||||
type PlaylistFolder
|
||||
} from '$lib/stores/playlistFoldersStore';
|
||||
|
||||
interface Playlist {
|
||||
id: number;
|
||||
@@ -22,6 +28,7 @@
|
||||
onDelete?: (playlistId: number) => void;
|
||||
isHidden?: boolean;
|
||||
isLocalTracks?: boolean;
|
||||
currentFolderId?: string | null;
|
||||
}
|
||||
|
||||
let {
|
||||
@@ -34,7 +41,8 @@
|
||||
onSuccess,
|
||||
onDelete,
|
||||
isHidden = false,
|
||||
isLocalTracks = false
|
||||
isLocalTracks = false,
|
||||
currentFolderId = null
|
||||
}: Props = $props();
|
||||
|
||||
// Form state
|
||||
@@ -42,10 +50,14 @@
|
||||
let description = $state('');
|
||||
let isPublic = $state(false);
|
||||
let hidden = $state(false);
|
||||
let folderId = $state<string | null>(null);
|
||||
let selectedPlaylistId = $state<number | null>(null);
|
||||
let loading = $state(false);
|
||||
let error = $state<string | null>(null);
|
||||
|
||||
// Folders state
|
||||
let folders = $state<PlaylistFolder[]>([]);
|
||||
|
||||
// Offline state (reactive)
|
||||
let offlineMode = $state(false);
|
||||
|
||||
@@ -85,6 +97,16 @@
|
||||
return unsubscribe;
|
||||
});
|
||||
|
||||
// Subscribe to folders state changes
|
||||
$effect(() => {
|
||||
const unsubscribe = subscribeFolders(() => {
|
||||
folders = getVisibleFolders();
|
||||
});
|
||||
// Initialize folders
|
||||
folders = getVisibleFolders();
|
||||
return unsubscribe;
|
||||
});
|
||||
|
||||
// Reset form when modal opens
|
||||
$effect(() => {
|
||||
if (isOpen) {
|
||||
@@ -96,13 +118,16 @@
|
||||
description = '';
|
||||
isPublic = false;
|
||||
hidden = isHidden;
|
||||
folderId = currentFolderId;
|
||||
} else if (mode === 'create') {
|
||||
name = '';
|
||||
description = '';
|
||||
isPublic = false;
|
||||
hidden = false;
|
||||
folderId = null;
|
||||
} else if (mode === 'addTrack') {
|
||||
selectedPlaylistId = null;
|
||||
folderId = null;
|
||||
loadLocalTrackCounts();
|
||||
}
|
||||
}
|
||||
@@ -143,6 +168,12 @@
|
||||
description: description.trim() || null,
|
||||
isPublic
|
||||
});
|
||||
|
||||
// Assign to folder if selected
|
||||
if (folderId) {
|
||||
await movePlaylistToFolder(newPlaylist.id, folderId);
|
||||
}
|
||||
|
||||
onSuccess?.(newPlaylist);
|
||||
onClose();
|
||||
}
|
||||
@@ -179,6 +210,11 @@
|
||||
hidden
|
||||
});
|
||||
|
||||
// Update folder assignment if changed
|
||||
if (folderId !== currentFolderId) {
|
||||
await movePlaylistToFolder(playlist.id, folderId);
|
||||
}
|
||||
|
||||
onSuccess?.(updatedPlaylist);
|
||||
onClose();
|
||||
} catch (err) {
|
||||
@@ -474,6 +510,25 @@
|
||||
</label>
|
||||
</div>
|
||||
|
||||
{#if folders.length > 0}
|
||||
<div class="form-group">
|
||||
<label for="folder-select">
|
||||
<Folder size={14} style="display: inline; vertical-align: middle; margin-right: 4px;" />
|
||||
Folder (optional)
|
||||
</label>
|
||||
<select
|
||||
id="folder-select"
|
||||
bind:value={folderId}
|
||||
disabled={loading}
|
||||
>
|
||||
<option value={null}>No folder</option>
|
||||
{#each folders as folder (folder.id)}
|
||||
<option value={folder.id}>{folder.name}</option>
|
||||
{/each}
|
||||
</select>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if mode === 'edit'}
|
||||
<div class="form-group checkbox">
|
||||
<label>
|
||||
|
||||
@@ -783,7 +783,7 @@
|
||||
<span class="folder-chevron" class:expanded={isExpanded_}>
|
||||
<ChevronRight size={12} />
|
||||
</span>
|
||||
<Folder size={14} style="color: {folder.icon_color}" />
|
||||
<Folder size={14} />
|
||||
<span class="folder-name">{folder.name}</span>
|
||||
<span class="folder-count">{folderPlaylists.length}</span>
|
||||
</button>
|
||||
@@ -812,7 +812,7 @@
|
||||
onclick={() => handleToggleFolder(folder.id)}
|
||||
title="{folder.name} ({folderPlaylists.length})"
|
||||
>
|
||||
<Folder size={14} style="color: {folder.icon_color}" />
|
||||
<Folder size={14} />
|
||||
</button>
|
||||
{/if}
|
||||
{/each}
|
||||
|
||||
@@ -1166,6 +1166,7 @@
|
||||
mode="edit"
|
||||
playlist={{ id: playlist.id, name: playlist.name, tracks_count: playlist.tracks_count }}
|
||||
isHidden={playlistSettings?.hidden ?? false}
|
||||
currentFolderId={playlistSettings?.folder_id ?? null}
|
||||
onClose={() => editModalOpen = false}
|
||||
onSuccess={handleEditSuccess}
|
||||
onDelete={handleDelete}
|
||||
|
||||
@@ -109,7 +109,6 @@
|
||||
let showFolderModal = $state(false);
|
||||
let editingFolder = $state<PlaylistFolder | null>(null);
|
||||
let folderName = $state('');
|
||||
let folderColor = $state('#6366f1');
|
||||
|
||||
// Persist preferences
|
||||
$effect(() => { localStorage.setItem('qbz-pm-filter', filter); });
|
||||
@@ -539,14 +538,12 @@
|
||||
function openCreateFolderModal() {
|
||||
editingFolder = null;
|
||||
folderName = '';
|
||||
folderColor = '#6366f1';
|
||||
showFolderModal = true;
|
||||
}
|
||||
|
||||
function openEditFolderModal(folder: PlaylistFolder) {
|
||||
editingFolder = folder;
|
||||
folderName = folder.name;
|
||||
folderColor = folder.icon_color;
|
||||
showFolderModal = true;
|
||||
}
|
||||
|
||||
@@ -560,14 +557,13 @@
|
||||
if (!folderName.trim()) return;
|
||||
|
||||
if (editingFolder) {
|
||||
// Update existing folder
|
||||
// Update existing folder (name only for now)
|
||||
await updateFolder(editingFolder.id, {
|
||||
name: folderName.trim(),
|
||||
iconColor: folderColor
|
||||
name: folderName.trim()
|
||||
});
|
||||
} else {
|
||||
// Create new folder
|
||||
await createFolder(folderName.trim(), 'preset', 'folder', folderColor);
|
||||
// Create new folder (simple, name only)
|
||||
await createFolder(folderName.trim());
|
||||
}
|
||||
|
||||
folders = getVisibleFolders();
|
||||
@@ -774,7 +770,7 @@
|
||||
onclick={() => navigateToFolder(folder.id)}
|
||||
onkeydown={(e) => e.key === 'Enter' && navigateToFolder(folder.id)}
|
||||
>
|
||||
<div class="folder-icon" style="color: {folder.icon_color}">
|
||||
<div class="folder-icon">
|
||||
<Folder size={32} />
|
||||
</div>
|
||||
<span class="folder-name">{folder.name}</span>
|
||||
@@ -1018,19 +1014,7 @@
|
||||
onkeydown={(e) => e.key === 'Enter' && handleSaveFolder()}
|
||||
/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="folder-color-input">Color</label>
|
||||
<div class="color-picker">
|
||||
<input
|
||||
id="folder-color-input"
|
||||
type="color"
|
||||
bind:value={folderColor}
|
||||
/>
|
||||
<span class="color-preview" style="background: {folderColor}"></span>
|
||||
<span class="color-value">{folderColor}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-actions">
|
||||
<div class="modal-actions">
|
||||
{#if editingFolder}
|
||||
<button class="btn-danger" onclick={handleDeleteFolder}>
|
||||
<Trash2 size={14} />
|
||||
@@ -1061,6 +1045,7 @@
|
||||
mode="edit"
|
||||
playlist={{ id: editingPlaylist.id, name: editingPlaylist.name, tracks_count: editingPlaylist.tracks_count }}
|
||||
isHidden={playlistSettings.get(editingPlaylist.id)?.hidden ?? false}
|
||||
currentFolderId={playlistSettings.get(editingPlaylist.id)?.folder_id ?? null}
|
||||
onClose={() => { editModalOpen = false; editingPlaylist = null; }}
|
||||
onSuccess={handleEditSuccess}
|
||||
onDelete={handleDelete}
|
||||
@@ -1329,33 +1314,6 @@
|
||||
border-color: var(--accent-primary);
|
||||
}
|
||||
|
||||
.color-picker {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.color-picker input[type="color"] {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.color-preview {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.color-value {
|
||||
font-size: 13px;
|
||||
color: var(--text-muted);
|
||||
font-family: var(--font-mono);
|
||||
}
|
||||
|
||||
.modal-actions {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
|
||||
Reference in new issue
Block a user