aboutsummaryrefslogtreecommitdiff
path: root/src/fields/Key.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/fields/Key.ts')
-rw-r--r--src/fields/Key.ts12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/fields/Key.ts b/src/fields/Key.ts
index 7120c6e3e..51d8e093c 100644
--- a/src/fields/Key.ts
+++ b/src/fields/Key.ts
@@ -3,6 +3,7 @@ import { Utils } from "../Utils";
import { observable } from "mobx";
import { Types } from "../server/Message";
import { ObjectID } from "bson";
+import { Server } from "../client/Server";
export class Key extends Field {
private name: string;
@@ -11,10 +12,17 @@ export class Key extends Field {
return this.name;
}
- constructor(name: string, id?: string) {
+ constructor(name: string, id?: string, save: boolean = true) {
super(id || Utils.GenerateDeterministicGuid(name));
this.name = name;
+ if (save) {
+ Server.UpdateField(this)
+ }
+ }
+
+ UpdateFromServer(data: string) {
+ this.name = data;
}
TrySetValue(value: any): boolean {
@@ -33,7 +41,7 @@ export class Key extends Field {
return name;
}
- ToJson(): { type: Types, data: string, _id: String } {
+ ToJson(): { type: Types, data: string, _id: string } {
return {
type: Types.Key,
data: this.name,