aboutsummaryrefslogtreecommitdiff
path: root/src/fields/Document.ts
diff options
context:
space:
mode:
authoryipstanley <stanley_yip@brown.edu>2019-02-13 20:17:21 -0500
committeryipstanley <stanley_yip@brown.edu>2019-02-13 20:17:21 -0500
commitf3544f004a696e4682fbd8d1f18ac69beec59439 (patch)
tree0839c355fe813ba494c6451b9017c5e325e1cfb8 /src/fields/Document.ts
parent430878f6dd8d36b1322e15d0898ada0d44fecacb (diff)
asdfkj
Diffstat (limited to 'src/fields/Document.ts')
-rw-r--r--src/fields/Document.ts14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/fields/Document.ts b/src/fields/Document.ts
index 56ac3c471..cb4f6f25c 100644
--- a/src/fields/Document.ts
+++ b/src/fields/Document.ts
@@ -8,12 +8,17 @@ import { findDOMNode } from "react-dom";
import { Server } from "../client/Server";
import { Types } from "../server/Message";
import { ObjectID } from "bson";
-import { Utils } from "../Utils";
export class Document extends Field {
public fields: ObservableMap<Key, Opt<Field>> = new ObservableMap();
public _proxies: ObservableMap<string, FIELD_ID> = new ObservableMap();
+ constructor(id?: string) {
+ super(id)
+
+ Server.UpdateField(this)
+ }
+
@computed
public get Title() {
return this.GetText(KeyStore.Title, "<untitled>");
@@ -89,9 +94,11 @@ export class Document extends Field {
Set(key: Key, field: Field | undefined): void {
if (field) {
this.fields.set(key, field);
+ this._proxies.set(key.Id, field.Id)
// Server.AddDocumentField(this, key, field);
} else {
this.fields.delete(key);
+ this._proxies.delete(key.Id)
// Server.DeleteDocumentField(this, key);
}
Server.UpdateField(this);
@@ -159,13 +166,15 @@ export class Document extends Field {
throw new Error("Method not implemented.");
}
- ToJson(): { type: Types, data: [string, string][], _id: ObjectID } {
+ ToJson(): { type: Types, data: [string, string][], _id: string } {
+ console.log(this.fields)
let fields: [string, string][] = []
this._proxies.forEach((field, key) => {
if (field) {
fields.push([key, field as string])
}
});
+ console.log(fields)
return {
type: Types.Document,
@@ -173,5 +182,4 @@ export class Document extends Field {
_id: this.Id
}
}
-
} \ No newline at end of file