diff options
| author | Tyler Schicke <tyler_schicke@brown.edu> | 2019-04-26 17:08:38 -0400 |
|---|---|---|
| committer | Tyler Schicke <tyler_schicke@brown.edu> | 2019-04-26 17:08:38 -0400 |
| commit | f01b842a5d6ef6b9deb9807fa0c3a8cd2c81a25a (patch) | |
| tree | c9e3b3c18dc35f4a3fa3083b69b985821041c879 /src/new_fields | |
| parent | c318c6cb44b26b780e94e0f0854e5ec4c14634a9 (diff) | |
TreeView and others
Diffstat (limited to 'src/new_fields')
| -rw-r--r-- | src/new_fields/Doc.ts | 2 | ||||
| -rw-r--r-- | src/new_fields/InkField.ts | 7 | ||||
| -rw-r--r-- | src/new_fields/Types.ts | 4 |
3 files changed, 11 insertions, 2 deletions
diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts index 79e5a156d..a5f495477 100644 --- a/src/new_fields/Doc.ts +++ b/src/new_fields/Doc.ts @@ -91,7 +91,7 @@ export namespace Doc { return Cast(Get(doc, key, ignoreProto), ctor) as T | null | undefined; } export async function SetOnPrototype(doc: Doc, key: string, value: Field) { - const proto = await Cast(doc.proto, Doc); + const proto = doc.proto; if (proto) { proto[key] = value; } diff --git a/src/new_fields/InkField.ts b/src/new_fields/InkField.ts index cdb34cedf..49e6bf61e 100644 --- a/src/new_fields/InkField.ts +++ b/src/new_fields/InkField.ts @@ -27,5 +27,10 @@ const strokeDataSchema = createSimpleSchema({ export class InkField extends ObjectField { @serializable(map(object(strokeDataSchema))) - readonly inkData: Map<string, StrokeData> = new Map; + readonly inkData: Map<string, StrokeData>; + + constructor(data?: Map<string, StrokeData>) { + super(); + this.inkData = data || new Map; + } } diff --git a/src/new_fields/Types.ts b/src/new_fields/Types.ts index 079c7b76d..649dfdc3e 100644 --- a/src/new_fields/Types.ts +++ b/src/new_fields/Types.ts @@ -67,6 +67,10 @@ export function StrCast(field: FieldResult, defaultVal: Opt<string> = "") { return Cast(field, "string", defaultVal); } +export function BoolCast(field: FieldResult, defaultVal: Opt<boolean> = undefined) { + return Cast(field, "boolean", defaultVal); +} + type WithoutList<T extends Field> = T extends List<infer R> ? R[] : T; export function FieldValue<T extends Field, U extends WithoutList<T>>(field: Opt<T> | Promise<Opt<T>>, defaultValue: U): WithoutList<T>; |
