Fix cleanLayout stripping expression columns from pivot layout save/restore
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
99b7b7d721
commit
7a7fd01285
@ -173,11 +173,13 @@ export default function Pivot({ source }) {
|
||||
function cleanLayout(cfg) {
|
||||
if (!cfg) return cfg
|
||||
const clean = { ...cfg }
|
||||
if (clean.columns) clean.columns = clean.columns.filter(c => c == null || validCols.has(c))
|
||||
if (clean.group_by) clean.group_by = clean.group_by.filter(c => validCols.has(c))
|
||||
if (clean.split_by) clean.split_by = clean.split_by.filter(c => validCols.has(c))
|
||||
if (clean.sort) clean.sort = clean.sort.filter(([c]) => validCols.has(c))
|
||||
if (clean.filter) clean.filter = clean.filter.filter(([c]) => validCols.has(c))
|
||||
const exprNames = new Set(Object.keys(clean.expressions || {}))
|
||||
const valid = (c) => validCols.has(c) || exprNames.has(c)
|
||||
if (clean.columns) clean.columns = clean.columns.filter(c => c == null || valid(c))
|
||||
if (clean.group_by) clean.group_by = clean.group_by.filter(valid)
|
||||
if (clean.split_by) clean.split_by = clean.split_by.filter(valid)
|
||||
if (clean.sort) clean.sort = clean.sort.filter(([c]) => valid(c))
|
||||
if (clean.filter) clean.filter = clean.filter.filter(([c]) => valid(c))
|
||||
return clean
|
||||
}
|
||||
|
||||
@ -257,11 +259,13 @@ export default function Pivot({ source }) {
|
||||
function cleanLayout(cfg) {
|
||||
if (!cfg) return cfg
|
||||
const clean = { ...cfg }
|
||||
if (clean.columns) clean.columns = clean.columns.filter(c => c == null || validCols.has(c))
|
||||
if (clean.group_by) clean.group_by = clean.group_by.filter(c => validCols.has(c))
|
||||
if (clean.split_by) clean.split_by = clean.split_by.filter(c => validCols.has(c))
|
||||
if (clean.sort) clean.sort = clean.sort.filter(([c]) => validCols.has(c))
|
||||
if (clean.filter) clean.filter = clean.filter.filter(([c]) => validCols.has(c))
|
||||
const exprNames = new Set(Object.keys(clean.expressions || {}))
|
||||
const valid = (c) => validCols.has(c) || exprNames.has(c)
|
||||
if (clean.columns) clean.columns = clean.columns.filter(c => c == null || valid(c))
|
||||
if (clean.group_by) clean.group_by = clean.group_by.filter(valid)
|
||||
if (clean.split_by) clean.split_by = clean.split_by.filter(valid)
|
||||
if (clean.sort) clean.sort = clean.sort.filter(([c]) => valid(c))
|
||||
if (clean.filter) clean.filter = clean.filter.filter(([c]) => valid(c))
|
||||
return clean
|
||||
}
|
||||
const cleaned = cleanLayout(layout.config)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user