diff options
author | ljungster <parkerljung@gmail.com> | 2022-08-09 11:52:07 -0500 |
---|---|---|
committer | ljungster <parkerljung@gmail.com> | 2022-08-09 11:52:07 -0500 |
commit | da3cb00f809a482a9fdf732f6a656fbc467cce27 (patch) | |
tree | 9eb1fd278bc71d080d71bbfb7e3aec482d35f439 /src/fields/Types.ts | |
parent | 1638527259a072dfc2ab286bd27bbb1751e8434e (diff) | |
parent | 26670c8b9eb6e2fd981c3a0997bff5556b60504b (diff) |
Merge branch 'parker' of https://github.com/brown-dash/Dash-Web into parker
Diffstat (limited to 'src/fields/Types.ts')
-rw-r--r-- | src/fields/Types.ts | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/fields/Types.ts b/src/fields/Types.ts index c90f3b6b3..bf40a0d7b 100644 --- a/src/fields/Types.ts +++ b/src/fields/Types.ts @@ -4,6 +4,8 @@ import { RefField } from "./RefField"; import { DateField } from "./DateField"; import { ScriptField } from "./ScriptField"; import { URLField, WebField, ImageField } from "./URLField"; +import { TextField } from "@material-ui/core"; +import { RichTextField } from "./RichTextField"; export type ToType<T extends InterfaceValue> = T extends "string" ? string : @@ -74,6 +76,10 @@ export function Cast<T extends CastCtor>(field: FieldResult, ctor: T, defaultVal return defaultVal === null ? undefined : defaultVal; } +export function DocCast(field: FieldResult, defaultVal?: Doc) { + return Cast(field, Doc, null) ?? defaultVal; +} + export function NumCast(field: FieldResult, defaultVal: number | null = 0) { return Cast(field, "number", defaultVal); } @@ -88,6 +94,9 @@ export function BoolCast(field: FieldResult, defaultVal: boolean | null = false) export function DateCast(field: FieldResult) { return Cast(field, DateField, null); } +export function RTFCast(field: FieldResult) { + return Cast(field, RichTextField, null); +} export function ScriptCast(field: FieldResult, defaultVal: ScriptField | null = null) { return Cast(field, ScriptField, defaultVal); |