Compare commits
2 commits
main
...
feat/story
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
99949b5311 | ||
|
|
f9606472fe |
1 changed files with 14 additions and 7 deletions
|
|
@ -203,6 +203,7 @@ export function PbiList({ productId, isDemo }: PbiListProps) {
|
||||||
const [filterPriority, setFilterPriority] = useState<number | 'all'>('all')
|
const [filterPriority, setFilterPriority] = useState<number | 'all'>('all')
|
||||||
const [filterStatus, setFilterStatus] = useState<PbiStatusApi | 'all'>('all')
|
const [filterStatus, setFilterStatus] = useState<PbiStatusApi | 'all'>('all')
|
||||||
const [sortMode, setSortMode] = useState<SortMode>('priority')
|
const [sortMode, setSortMode] = useState<SortMode>('priority')
|
||||||
|
const [sortDir, setSortDir] = useState<'asc' | 'desc'>('asc')
|
||||||
const [prefsLoaded, setPrefsLoaded] = useState(false)
|
const [prefsLoaded, setPrefsLoaded] = useState(false)
|
||||||
const [dialogState, setDialogState] = useState<PbiDialogState | null>(null)
|
const [dialogState, setDialogState] = useState<PbiDialogState | null>(null)
|
||||||
const [activeDragId, setActiveDragId] = useState<string | null>(null)
|
const [activeDragId, setActiveDragId] = useState<string | null>(null)
|
||||||
|
|
@ -225,6 +226,8 @@ export function PbiList({ productId, isDemo }: PbiListProps) {
|
||||||
if (savedStatus === 'ready' || savedStatus === 'blocked' || savedStatus === 'done') {
|
if (savedStatus === 'ready' || savedStatus === 'blocked' || savedStatus === 'done') {
|
||||||
setFilterStatus(savedStatus)
|
setFilterStatus(savedStatus)
|
||||||
}
|
}
|
||||||
|
const savedDir = localStorage.getItem('scrum4me:pbi_sort_dir')
|
||||||
|
if (savedDir === 'asc' || savedDir === 'desc') setSortDir(savedDir)
|
||||||
setPrefsLoaded(true)
|
setPrefsLoaded(true)
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
|
@ -232,6 +235,7 @@ export function PbiList({ productId, isDemo }: PbiListProps) {
|
||||||
useEffect(() => { if (prefsLoaded) localStorage.setItem('scrum4me:pbi_sort', sortMode) }, [sortMode, prefsLoaded])
|
useEffect(() => { if (prefsLoaded) localStorage.setItem('scrum4me:pbi_sort', sortMode) }, [sortMode, prefsLoaded])
|
||||||
useEffect(() => { if (prefsLoaded) localStorage.setItem('scrum4me:pbi_filter_priority', String(filterPriority)) }, [filterPriority, prefsLoaded])
|
useEffect(() => { if (prefsLoaded) localStorage.setItem('scrum4me:pbi_filter_priority', String(filterPriority)) }, [filterPriority, prefsLoaded])
|
||||||
useEffect(() => { if (prefsLoaded) localStorage.setItem('scrum4me:pbi_filter_status', filterStatus) }, [filterStatus, prefsLoaded])
|
useEffect(() => { if (prefsLoaded) localStorage.setItem('scrum4me:pbi_filter_status', filterStatus) }, [filterStatus, prefsLoaded])
|
||||||
|
useEffect(() => { if (prefsLoaded) localStorage.setItem('scrum4me:pbi_sort_dir', sortDir) }, [sortDir, prefsLoaded])
|
||||||
|
|
||||||
// Sync server data into store — use stable string dep to avoid infinite loop
|
// Sync server data into store — use stable string dep to avoid infinite loop
|
||||||
const pbiIdKey = pbis.map(p => p.id).join(',')
|
const pbiIdKey = pbis.map(p => p.id).join(',')
|
||||||
|
|
@ -259,17 +263,19 @@ export function PbiList({ productId, isDemo }: PbiListProps) {
|
||||||
const activeFilterCount =
|
const activeFilterCount =
|
||||||
(filterPriority !== 'all' ? 1 : 0) +
|
(filterPriority !== 'all' ? 1 : 0) +
|
||||||
(filterStatus !== 'all' ? 1 : 0) +
|
(filterStatus !== 'all' ? 1 : 0) +
|
||||||
(sortMode !== 'priority' ? 1 : 0)
|
(sortMode !== 'priority' ? 1 : 0) +
|
||||||
|
(sortDir !== 'asc' ? 1 : 0)
|
||||||
|
|
||||||
const filtered = [...base].sort((a, b) => {
|
const filtered = [...base].sort((a, b) => {
|
||||||
|
let cmp = 0
|
||||||
if (sortMode === 'code') {
|
if (sortMode === 'code') {
|
||||||
return (a.code ?? '').localeCompare(b.code ?? '', 'nl', { numeric: true })
|
cmp = (a.code ?? '').localeCompare(b.code ?? '', 'nl', { numeric: true })
|
||||||
|
} else if (sortMode === 'date') {
|
||||||
|
cmp = new Date(a.created_at).getTime() - new Date(b.created_at).getTime()
|
||||||
|
} else {
|
||||||
|
cmp = a.priority !== b.priority ? a.priority - b.priority : 0
|
||||||
}
|
}
|
||||||
if (sortMode === 'date') {
|
return sortDir === 'asc' ? cmp : -cmp
|
||||||
return new Date(b.created_at).getTime() - new Date(a.created_at).getTime()
|
|
||||||
}
|
|
||||||
// priority: sort by priority asc, then drag-and-drop sort_order within group
|
|
||||||
return a.priority !== b.priority ? a.priority - b.priority : 0
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const sensors = useSensors(
|
const sensors = useSensors(
|
||||||
|
|
@ -392,6 +398,7 @@ export function PbiList({ productId, isDemo }: PbiListProps) {
|
||||||
setFilterPriority('all')
|
setFilterPriority('all')
|
||||||
setFilterStatus('all')
|
setFilterStatus('all')
|
||||||
setSortMode('priority')
|
setSortMode('priority')
|
||||||
|
setSortDir('asc')
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Wis filters
|
Wis filters
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue