mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
20 lines
895 B
TypeScript
20 lines
895 B
TypeScript
|
import {DataRowModel} from 'app/client/models/DataRowModel';
|
||
|
|
||
|
import {ViewFieldRec} from 'app/client/models/entities/ViewFieldRec';
|
||
|
import {getObjCode} from 'app/common/gristTypes';
|
||
|
import {formatUnknown} from 'app/common/ValueFormatter';
|
||
|
import {dom} from 'grainjs';
|
||
|
|
||
|
export function buildErrorDom(row: DataRowModel, field: ViewFieldRec) {
|
||
|
const value = row.cells[field.colId.peek()];
|
||
|
const options = field.widgetOptionsJson;
|
||
|
// The "invalid" class sets the pink background, as long as the error text is non-empty.
|
||
|
return dom('div.field_clip.invalid',
|
||
|
// Sets CSS class field-error-P, field-error-U, etc.
|
||
|
dom.clsPrefix('field-error-', (use) => getObjCode(use(value)) || ''),
|
||
|
dom.style('text-align', options.prop('alignment')),
|
||
|
dom.cls('text_wrapping', (use) => Boolean(use(options.prop('wrap')))),
|
||
|
dom.text((use) => formatUnknown(value ? use(value) : '???'))
|
||
|
);
|
||
|
}
|