mirror of
https://github.com/PerpetualSoftware/pad.git
synced 2026-09-25 03:42:06 +00:00
fix: dashboard "New Idea" button now targets first collection (#95)
The dashboard had two buttons that both called requestQuickAdd() with no argument, so both created tasks. Now: - "New Task" explicitly targets the tasks collection - The second button dynamically targets the first non-system, non-task collection by sort order (showing its icon and name) - requestQuickAdd() accepts an optional collection slug, which the sidebar respects when choosing the target collection Fixes BUG-498.
This commit is contained in:
@@ -108,8 +108,10 @@
|
||||
// Watch for Cmd-N quick-add requests from the layout
|
||||
$effect(() => {
|
||||
if (uiStore.quickAddRequested) {
|
||||
const targetSlug = uiStore.quickAddTargetSlug;
|
||||
uiStore.clearQuickAddRequest();
|
||||
const target = activeColl
|
||||
const target = (targetSlug ? regularCollections.find(c => c.slug === targetSlug) : null)
|
||||
?? activeColl
|
||||
?? regularCollections.find(c => c.slug === 'tasks')
|
||||
?? regularCollections[0];
|
||||
if (target) startQuickAdd(target);
|
||||
|
||||
@@ -8,6 +8,7 @@ let isTouch = $state(browser ? 'ontouchstart' in window : false);
|
||||
let detailPanelOpen = $state(browser ? localStorage.getItem('pad-detail-panel') !== 'closed' && window.innerWidth > 768 : false);
|
||||
let createWorkspaceOpen = $state(false);
|
||||
let quickAddRequested = $state(false);
|
||||
let quickAddTargetSlug = $state<string | null>(null);
|
||||
|
||||
if (browser) {
|
||||
window.addEventListener('resize', () => {
|
||||
@@ -71,8 +72,9 @@ export const uiStore = {
|
||||
|
||||
// Quick-add item trigger — sidebar watches this
|
||||
get quickAddRequested() { return quickAddRequested; },
|
||||
requestQuickAdd() { quickAddRequested = true; },
|
||||
clearQuickAddRequest() { quickAddRequested = false; },
|
||||
get quickAddTargetSlug() { return quickAddTargetSlug; },
|
||||
requestQuickAdd(collectionSlug?: string) { quickAddTargetSlug = collectionSlug ?? null; quickAddRequested = true; },
|
||||
clearQuickAddRequest() { quickAddRequested = false; quickAddTargetSlug = null; },
|
||||
|
||||
/** Close sidebar on mobile after navigation */
|
||||
onNavigate() {
|
||||
|
||||
@@ -78,6 +78,7 @@
|
||||
}
|
||||
|
||||
let totalItems = $derived(dashboard?.summary.total_items ?? 0);
|
||||
let firstCollection = $derived(collections.filter(c => !c.is_system && c.slug !== 'tasks').sort((a, b) => a.sort_order - b.sort_order)[0]);
|
||||
|
||||
function statusColor(status: string): string {
|
||||
const s = status.toLowerCase().replace(/-/g, '_');
|
||||
@@ -176,8 +177,10 @@
|
||||
<span class="item-count">{totalItems} item{totalItems !== 1 ? 's' : ''}</span>
|
||||
</div>
|
||||
<div class="dash-header-actions">
|
||||
<button class="btn btn-secondary" onclick={() => uiStore.requestQuickAdd()}>💡 New Idea</button>
|
||||
<button class="btn btn-primary" onclick={() => uiStore.requestQuickAdd()}>+ New Task</button>
|
||||
{#if firstCollection}
|
||||
<button class="btn btn-secondary" onclick={() => uiStore.requestQuickAdd(firstCollection.slug)}>{firstCollection.icon} New {firstCollection.name.replace(/s$/, '')}</button>
|
||||
{/if}
|
||||
<button class="btn btn-primary" onclick={() => uiStore.requestQuickAdd('tasks')}>+ New Task</button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user