aboutsummaryrefslogtreecommitdiff
path: root/src/client/documents
diff options
context:
space:
mode:
authorbob <bcz@cs.brown.edu>2019-09-13 09:18:12 -0400
committerbob <bcz@cs.brown.edu>2019-09-13 09:18:12 -0400
commit32861c7cfcac8c03be5692fb98b5a7dc7786be83 (patch)
tree3cb09464277cc020fc1ab772381cc4cbd828b091 /src/client/documents
parentb3d9c4e3d8c7c425df41b2d8555a7d242771a823 (diff)
parente241e61d6521ff5d63de1292f2b4269493f5d7cc (diff)
Merge branch 'master' of https://github.com/browngraphicslab/Dash-Web
Diffstat (limited to 'src/client/documents')
-rw-r--r--src/client/documents/Documents.ts28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index 602a7f9ad..28e5e5f40 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -20,7 +20,7 @@ import { AttributeTransformationModel } from "../northstar/core/attribute/Attrib
import { AggregateFunction } from "../northstar/model/idea/idea";
import { MINIMIZED_ICON_SIZE } from "../views/globalCssVariables.scss";
import { IconBox } from "../views/nodes/IconBox";
-import { Field, Doc, Opt } from "../../new_fields/Doc";
+import { Field, Doc, Opt, DocListCastAsync } from "../../new_fields/Doc";
import { OmitKeys, JSONUtils } from "../../Utils";
import { ImageField, VideoField, AudioField, PdfField, WebField, YoutubeField } from "../../new_fields/URLField";
import { HtmlField } from "../../new_fields/HtmlField";
@@ -607,6 +607,32 @@ export namespace Docs {
export namespace DocUtils {
+ export function Publish(promoteDoc: Doc, targetID: string, addDoc: any, remDoc: any) {
+ if (targetID.startsWith("-")) {
+ targetID = targetID.substr(1, targetID.length - 1);
+ Doc.GetProto(promoteDoc).title = targetID;
+ }
+ DocServer.GetRefField(targetID).then(doc => {
+ let copy = doc instanceof Doc ? doc : Doc.MakeCopy(promoteDoc, true, targetID);
+ !doc && (Doc.GetProto(copy).title = targetID);
+ addDoc && addDoc(copy);
+ !doc && remDoc && remDoc(promoteDoc);
+ if (!doc) {
+ DocListCastAsync(promoteDoc.links).then(links => {
+ links && links.map(async link => {
+ if (link) {
+ let a1 = await Cast(link.anchor1, Doc);
+ if (a1 && Doc.AreProtosEqual(a1, promoteDoc)) link.anchor1 = copy;
+ let a2 = await Cast(link.anchor2, Doc);
+ if (a2 && Doc.AreProtosEqual(a2, promoteDoc)) link.anchor2 = copy;
+ LinkManager.Instance.deleteLink(link);
+ LinkManager.Instance.addLink(link);
+ }
+ })
+ })
+ }
+ });
+ }
export function MakeLink(source: Doc, target: Doc, targetContext?: Doc, title: string = "", description: string = "", sourceContext?: Doc, id?: string) {
if (LinkManager.Instance.doesLinkExist(source, target)) return undefined;
let sv = DocumentManager.Instance.getDocumentView(source);