diff options
author | bob <bcz@cs.brown.edu> | 2019-07-05 14:45:15 -0400 |
---|---|---|
committer | bob <bcz@cs.brown.edu> | 2019-07-05 14:45:15 -0400 |
commit | 8b9fa667816378cc6cae2977f1c2d80c204b28d0 (patch) | |
tree | 4e22f3c293bf10269c284662451a3d77411da2ca /src/new_fields/Doc.ts | |
parent | 336266551d363df8c4958d485170846b478f1787 (diff) |
added more options to sidebar
Diffstat (limited to 'src/new_fields/Doc.ts')
-rw-r--r-- | src/new_fields/Doc.ts | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts index c361e3032..092205f52 100644 --- a/src/new_fields/Doc.ts +++ b/src/new_fields/Doc.ts @@ -241,12 +241,15 @@ export namespace Doc { return Array.from(results); } - export function AddDocToList(target: Doc, key: string, doc: Doc, relativeTo?: Doc, before?: boolean) { + export function AddDocToList(target: Doc, key: string, doc: Doc, relativeTo?: Doc, before?: boolean, first?: 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); + if (first) list.splice(0, 0, doc); + else { + let ind = relativeTo ? list.indexOf(relativeTo) : -1; + if (ind === -1) list.push(doc); + else list.splice(before ? ind : ind + 1, 0, doc); + } } return true; } |