diff options
author | Nathan-SR <144961007+Nathan-SR@users.noreply.github.com> | 2024-05-05 18:28:35 -0400 |
---|---|---|
committer | Nathan-SR <144961007+Nathan-SR@users.noreply.github.com> | 2024-05-05 18:28:35 -0400 |
commit | 86f55d8aa12268fe847eaa344e8efbab5d293f34 (patch) | |
tree | 6bbc5c6fb6825ef969ed0342e4851667b81577cc /src/fields/ObjectField.ts | |
parent | 2a9db784a6e3492a8f7d8ce9a745b4f1a0494241 (diff) | |
parent | 139600ab7e8a82a31744cd3798247236cd5616fc (diff) |
Merge branch 'nathan-starter' of https://github.com/brown-dash/Dash-Web into nathan-starter
Diffstat (limited to 'src/fields/ObjectField.ts')
-rw-r--r-- | src/fields/ObjectField.ts | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/src/fields/ObjectField.ts b/src/fields/ObjectField.ts index e1b5b036c..231086262 100644 --- a/src/fields/ObjectField.ts +++ b/src/fields/ObjectField.ts @@ -1,26 +1,36 @@ -import { RefField } from './RefField'; -import { FieldChanged, Parent, Copy, ToScriptString, ToString, ToJavascriptString } from './FieldSymbols'; import { ScriptingGlobals } from '../client/util/ScriptingGlobals'; -import { Field } from './Doc'; +import { Copy, FieldChanged, Parent, ToJavascriptString, ToScriptString, ToString } from './FieldSymbols'; +import { RefField } from './RefField'; export abstract class ObjectField { // prettier-ignore public [FieldChanged]?: (diff?: { op: '$addToSet' | '$remFromSet' | '$set'; - items: Field[] | undefined; + // eslint-disable-next-line no-use-before-define + items: FieldType[] | undefined; length: number | undefined; hint?: any }, serverOp?: any) => void; + // eslint-disable-next-line no-use-before-define public [Parent]?: RefField | ObjectField; abstract [Copy](): ObjectField; abstract [ToJavascriptString](): string; abstract [ToScriptString](): string; abstract [ToString](): string; -} - -export namespace ObjectField { - export function MakeCopy<T extends ObjectField>(field: T) { + static MakeCopy<T extends ObjectField>(field: T) { return field?.[Copy](); } } +export type FieldType = number | string | boolean | ObjectField | RefField; // bcz: hack for now .. must match the type definition in Doc.ts .. put here to avoid import cycles +// eslint-disable-next-line import/no-mutable-exports +export let ObjGetRefField: (id: string, force?: boolean) => Promise<RefField | undefined>; +// eslint-disable-next-line import/no-mutable-exports +export let ObjGetRefFields: (ids: string[]) => Promise<{ [id: string]: RefField | undefined }>; + +export function SetObjGetRefField(func: (id: string, force?: boolean) => Promise<RefField | undefined>) { + ObjGetRefField = func; +} +export function SetObjGetRefFields(func: (ids: string[]) => Promise<{ [id: string]: RefField | undefined }>) { + ObjGetRefFields = func; +} ScriptingGlobals.add(ObjectField); |