diff options
author | Bob Zeleznik <zzzman@gmail.com> | 2019-06-25 22:16:07 -0400 |
---|---|---|
committer | Bob Zeleznik <zzzman@gmail.com> | 2019-06-25 22:16:07 -0400 |
commit | 5f3ba2363b74dc493b96ef2253560a48d3a7c711 (patch) | |
tree | 092d4ca8d0fb1dec7b008b8c98a2a4ea23b34c7e /src/new_fields/Doc.ts | |
parent | 24d835913f919d99df56303982c38a441ac57e59 (diff) |
final cleanup for now
Diffstat (limited to 'src/new_fields/Doc.ts')
-rw-r--r-- | src/new_fields/Doc.ts | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts index 675278ed5..8825bc13a 100644 --- a/src/new_fields/Doc.ts +++ b/src/new_fields/Doc.ts @@ -249,22 +249,27 @@ export namespace Doc { return true; } - export function extDoc(doc: Doc, fieldKey: string, fieldExt: string) { - return doc && fieldExt && doc[fieldKey + "_ext"] instanceof Doc ? doc[fieldKey + "_ext"] as Doc : doc; + // + // Resolves a reference to a field by returning 'doc' if o field extension is specified, + // otherwise, it returns the extension document stored in doc.<fieldKey>_ext. + // This mechanism allows any fields to be extended with an extension document that can + // be used to capture field-specific metadata. For example, an image field can be extended + // to store annotations, ink, and other data. + // + export function resolvedFieldDataDoc(doc: Doc, fieldKey: string, fieldExt: string) { + return fieldExt && doc[fieldKey + "_ext"] instanceof Doc ? doc[fieldKey + "_ext"] as Doc : doc; } - export function extField(doc: Doc, fieldKey: string, fieldExt: string) { - return doc && fieldExt && doc[fieldKey + "_ext"] instanceof Doc ? fieldExt : fieldKey; - } - export function UpdateFieldExtension(doc: Doc, fieldKey: string) { - if (doc && doc[fieldKey + "_ext"] === undefined) { + + export function UpdateDocumentExtensionForField(doc: Doc, fieldKey: string) { + if (doc[fieldKey + "_ext"] === undefined) { setTimeout(() => { - let fieldExtension = new Doc(doc[Id] + fieldKey, true); - fieldExtension.title = "Extension of " + doc.title + "'s field:" + fieldKey; + let docExtensionForField = new Doc(doc[Id] + fieldKey, true); + docExtensionForField.title = "Extension of " + doc.title + "'s field:" + fieldKey; let proto: Doc | undefined = doc; while (proto && !Doc.IsPrototype(proto)) { proto = proto.proto; } - (proto ? proto : doc)[fieldKey + "_ext"] = fieldExtension; + (proto ? proto : doc)[fieldKey + "_ext"] = docExtensionForField; }, 0); } } |