FEAT: Implement deceased/givenaway enclosure visibility rules, preserve external clan name, and hide receiver fields for deceased gerbils
This commit is contained in:
@@ -45,12 +45,20 @@ function matchesFilter(row: Row, filter: string | null): boolean {
|
||||
|
||||
function applyOrderBy(rows: Row[], orderBy: string | null): Row[] {
|
||||
if (!orderBy) return rows
|
||||
const [field, dir] = orderBy.split(/\s+/)
|
||||
const sign = dir?.toLowerCase() === 'desc' ? -1 : 1
|
||||
// Mirror Gridify's comma-separated multi-key ordering (e.g. "name,id"): each key
|
||||
// is "<field> [desc]"; later keys act as tiebreakers.
|
||||
const keys = orderBy.split(',').map((part) => {
|
||||
const [field, dir] = part.trim().split(/\s+/)
|
||||
return { field, sign: dir?.toLowerCase() === 'desc' ? -1 : 1 }
|
||||
})
|
||||
return [...rows].sort((a, b) => {
|
||||
const av = String(a[field] ?? '')
|
||||
const bv = String(b[field] ?? '')
|
||||
return av < bv ? -sign : av > bv ? sign : 0
|
||||
for (const { field, sign } of keys) {
|
||||
const av = String(a[field] ?? '')
|
||||
const bv = String(b[field] ?? '')
|
||||
if (av < bv) return -sign
|
||||
if (av > bv) return sign
|
||||
}
|
||||
return 0
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user