aboutsummaryrefslogtreecommitdiff
path: root/src/fields/Document.ts
diff options
context:
space:
mode:
authorBob Zeleznik <zzzman@gmail.com>2019-04-29 20:32:39 -0400
committerBob Zeleznik <zzzman@gmail.com>2019-04-29 20:32:39 -0400
commit08849062e84087ac24031944af8697c87d7d183c (patch)
tree4e21bbc4fa144ab5e5a17bdfbeea87b729ff091a /src/fields/Document.ts
parent986595be59e714de4fe6c677dcace3c3f402ac82 (diff)
parent3da71792a339536118b7af7cfe0529201a45c64e (diff)
Merge branch 'master' into presentation_view
Diffstat (limited to 'src/fields/Document.ts')
-rw-r--r--src/fields/Document.ts31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/fields/Document.ts b/src/fields/Document.ts
index 7cf784f0e..2797efc09 100644
--- a/src/fields/Document.ts
+++ b/src/fields/Document.ts
@@ -13,6 +13,7 @@ import { BooleanField } from "./BooleanField";
import { allLimit } from "async";
import { prototype } from "nodemailer/lib/smtp-pool";
import { HistogramField } from "../client/northstar/dash-fields/HistogramField";
+import { Documents } from "../client/documents/Documents";
export class Document extends Field {
//TODO tfs: We should probably store FieldWaiting in fields when we request it from the server so that we don't set up multiple server gets for the same document and field
@@ -371,6 +372,36 @@ export class Document extends Field {
return alias;
}
+ @action
+ CreateLink(dstTarg: Document) {
+ let batch = UndoManager.StartBatch("document view drop");
+ let linkDoc: Document = Documents.TextDocument({ width: 100, height: 25, title: "-link-" });
+ linkDoc.SetText(KeyStore.LinkDescription, "");
+ linkDoc.SetText(KeyStore.LinkTags, "Default");
+
+ let srcTarg = this;
+ linkDoc.Set(KeyStore.LinkedToDocs, dstTarg);
+ linkDoc.Set(KeyStore.LinkedFromDocs, srcTarg);
+ const prom1 = new Promise(resolve => dstTarg.GetOrCreateAsync(
+ KeyStore.LinkedFromDocs,
+ ListField,
+ field => {
+ (field as ListField<Document>).Data.push(linkDoc);
+ resolve();
+ }
+ ));
+ const prom2 = new Promise(resolve => srcTarg.GetOrCreateAsync(
+ KeyStore.LinkedToDocs,
+ ListField,
+ field => {
+ (field as ListField<Document>).Data.push(linkDoc);
+ resolve();
+ }
+ ));
+ Promise.all([prom1, prom2]).finally(() => batch.end());
+ return linkDoc;
+ }
+
MakeDelegate(id?: string): Document {
let delegate = new Document(id);