mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
(core) Fix converting column to ChoiceList when cells contain JSON arrays with non-string values
Summary: title Test Plan: Tested manually, I don't think this needs an automated test. Made a text column with a value `[1, 2]` and converted the column to choice list. Previously this threw a JS error that `tag.trim` wasn't a function. Works now, suggests `1` and `2` as choices in the configuration. Reviewers: georgegevoian Reviewed By: georgegevoian Differential Revision: https://phab.getgrist.com/D3128
This commit is contained in:
parent
822372ed7c
commit
45fc46070d
@ -124,9 +124,9 @@ export async function prepTransformColInfo(docModel: DocModel, origCol: ColumnRe
|
|||||||
for (let value of tableData.getColValues(colId) || []) {
|
for (let value of tableData.getColValues(colId) || []) {
|
||||||
if (value === null) { continue; }
|
if (value === null) { continue; }
|
||||||
value = String(decodeObject(value)).trim();
|
value = String(decodeObject(value)).trim();
|
||||||
const tags: string[] = (value.startsWith('[') && gutil.safeJsonParse(value, null)) || value.split(",");
|
const tags: unknown[] = (value.startsWith('[') && gutil.safeJsonParse(value, null)) || value.split(",");
|
||||||
for (const tag of tags) {
|
for (const tag of tags) {
|
||||||
choices.add(tag.trim());
|
choices.add(String(tag).trim());
|
||||||
if (choices.size > 100) { break; } // Don't suggest excessively many choices.
|
if (choices.size > 100) { break; } // Don't suggest excessively many choices.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user