Summarise a plain-value array row by its value
A task script is a list of strings, and every row read back as "Item 1", "Item 2": the summary only knew how to read object rows, so the very text being configured was hidden behind its position. A string, number or boolean row now reads as itself, and falls back to the position only when it is blank. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
974589aeee
commit
44be453cbb
|
|
@ -1372,4 +1372,15 @@ describe('GenericNodeComponent', () => {
|
|||
expect(summary(definition, { source: 'INPUT', name: 'planDoc', multiple: true }, 0))
|
||||
.toBe('INPUT · planDoc');
|
||||
});
|
||||
|
||||
it('reads back a plain-value row as its value, not as its position', () => {
|
||||
// A task script is a list of strings: "Item 1 / Item 2" hid the very text being configured.
|
||||
const definition = { path: 'taskScript', label: 'Steps', itemSchema: { type: 'string' }, uniqueBy: null } as any;
|
||||
const summary = (component as any).toArrayItemSummary.bind(component);
|
||||
|
||||
expect(summary(definition, 'Sign in with the test account', 0)).toBe('Sign in with the test account');
|
||||
expect(summary(definition, ' Create an order ', 1)).toBe('Create an order');
|
||||
// An empty string identifies nothing, so the position is all that is left to say.
|
||||
expect(summary(definition, ' ', 2)).toBe('Item 3');
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1956,6 +1956,11 @@ export class GenericNodeComponent implements OnDestroy {
|
|||
}
|
||||
|
||||
private toArrayItemSummary(definition: ArrayFieldDefinition, item: unknown, index: number) {
|
||||
// An array of plain values - a task script, a list of names - is its own summary. Reading back
|
||||
// "Item 1 / Item 2" where the row holds "Sign in" tells the reader nothing they can act on.
|
||||
if (typeof item === 'string') return item.trim() || `Item ${index + 1}`;
|
||||
if (typeof item === 'number' || typeof item === 'boolean') return String(item);
|
||||
|
||||
if (!item || typeof item !== 'object' || Array.isArray(item)) {
|
||||
return `Item ${index + 1}`;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue