aboutsummaryrefslogtreecommitdiff
path: root/src/fields/Document.ts
diff options
context:
space:
mode:
authorAndrew Kim <andrewdkim@users.noreply.github.com>2019-04-20 18:42:01 -0400
committerAndrew Kim <andrewdkim@users.noreply.github.com>2019-04-20 18:42:01 -0400
commit840de58f003d0962ef7d3a0ad6ea284d1f4870db (patch)
tree32377ecaedceb24e54b6645ae76f3a5e0171fd54 /src/fields/Document.ts
parent604d20941837fa90c06a7da7e77a27c262cd4648 (diff)
parente47656cdc18aa1fd801a3853fa0f819140a68646 (diff)
update
Diffstat (limited to 'src/fields/Document.ts')
-rw-r--r--src/fields/Document.ts21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/fields/Document.ts b/src/fields/Document.ts
index 60eaf5b51..7cf784f0e 100644
--- a/src/fields/Document.ts
+++ b/src/fields/Document.ts
@@ -26,6 +26,12 @@ export class Document extends Field {
Server.UpdateField(this);
}
}
+ static FromJson(data: any, id: string, save: boolean): Document {
+ let doc = new Document(id, save);
+ let fields = data as [string, string][];
+ fields.forEach(pair => doc._proxies.set(pair[0], pair[1]));
+ return doc;
+ }
UpdateFromServer(data: [string, string][]) {
for (const key in data) {
@@ -41,14 +47,14 @@ export class Document extends Field {
@computed
public get Title(): string {
let title = this.Get(KeyStore.Title, true);
- if (title) {
+ if (title || title === FieldWaiting) {
if (title !== FieldWaiting && title instanceof TextField) {
return title.Data;
}
else return "-waiting-";
}
let parTitle = this.GetT(KeyStore.Title, TextField);
- if (parTitle) {
+ if (parTitle || parTitle === FieldWaiting) {
if (parTitle !== FieldWaiting) return parTitle.Data + ".alias";
else return "-waiting-.alias";
}
@@ -410,18 +416,15 @@ export class Document extends Field {
return copy;
}
- ToJson(): { type: Types; data: [string, string][]; _id: string } {
+ ToJson() {
let fields: [string, string][] = [];
- this._proxies.forEach((field, key) => {
- if (field) {
- fields.push([key, field]);
- }
- });
+ this._proxies.forEach((field, key) =>
+ field && fields.push([key, field]));
return {
type: Types.Document,
data: fields,
- _id: this.Id
+ id: this.Id
};
}
}