aboutsummaryrefslogtreecommitdiff
path: root/src/new_fields/Doc.ts
diff options
context:
space:
mode:
authoryipstanley <stanley_yip@brown.edu>2019-06-20 17:50:46 -0400
committeryipstanley <stanley_yip@brown.edu>2019-06-20 17:50:46 -0400
commit7d0f6c18489f7155818611721985d9610b08d8e7 (patch)
tree3bd9ea75e0513504e359bfab55dd69bfcfcefff3 /src/new_fields/Doc.ts
parentd2dfc0f9d35f0084a7c0dea73215f5d21055f2f3 (diff)
parent46a2a9e1f10b63feeb21a1e186daeaef2ccbcda4 (diff)
Merge branch 'master' of https://github.com/browngraphicslab/Dash-Web
Diffstat (limited to 'src/new_fields/Doc.ts')
-rw-r--r--src/new_fields/Doc.ts10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts
index de4bc4d5d..9bacf49ba 100644
--- a/src/new_fields/Doc.ts
+++ b/src/new_fields/Doc.ts
@@ -222,6 +222,16 @@ export namespace Doc {
return Array.from(results);
}
+ export function AddDocToList(target: Doc, key: string, doc: Doc, relativeTo?: Doc, before?: boolean) {
+ let list = Cast(target[key], listSpec(Doc));
+ if (list) {
+ let ind = relativeTo ? list.indexOf(relativeTo) : -1;
+ if (ind === -1) list.push(doc);
+ else list.splice(before ? ind : ind + 1, 0, doc);
+ }
+ return true;
+ }
+
export function MakeAlias(doc: Doc) {
if (!GetT(doc, "isPrototype", "boolean", true)) {
return Doc.MakeCopy(doc);