aboutsummaryrefslogtreecommitdiff
path: root/src/fields
diff options
context:
space:
mode:
authormadelinegr <mgriswold99@gmail.com>2019-02-12 19:25:28 -0500
committermadelinegr <mgriswold99@gmail.com>2019-02-12 19:25:28 -0500
commit837509322d7e556830c57653828e223b06eb38a6 (patch)
tree0af1076c9535ba6cd912d331ec61bcef951563bb /src/fields
parent1d667d19f5402dc9f9069e0a57008dac96f6de2a (diff)
fixed bugs with launching
Diffstat (limited to 'src/fields')
-rw-r--r--src/fields/Document 2.ts93
-rw-r--r--src/fields/DocumentReference 2.ts46
-rw-r--r--src/fields/Field 2.ts54
-rw-r--r--src/fields/FieldUpdatedArgs 2.ts27
-rw-r--r--src/fields/Key 2.ts45
-rw-r--r--src/fields/ListField 2.ts21
-rw-r--r--src/fields/NumberField 2.ts13
-rw-r--r--src/fields/TextField 2.ts13
8 files changed, 0 insertions, 312 deletions
diff --git a/src/fields/Document 2.ts b/src/fields/Document 2.ts
deleted file mode 100644
index 0bba9c21e..000000000
--- a/src/fields/Document 2.ts
+++ /dev/null
@@ -1,93 +0,0 @@
-import { Field, Cast, Opt } from "./Field"
-import { Key, KeyStore } from "./Key"
-import { ObservableMap } from "mobx";
-
-export class Document extends Field {
- private fields: ObservableMap<Key, Field> = new ObservableMap();
-
- GetField(key: Key, ignoreProto: boolean = false): Opt<Field> {
- let field: Opt<Field>;
- if (ignoreProto) {
- if (this.fields.has(key)) {
- field = this.fields.get(key);
- }
- } else {
- let doc: Opt<Document> = this;
- while (doc && !(doc.fields.has(key))) {
- doc = doc.GetPrototype();
- }
-
- if (doc) {
- field = doc.fields.get(key);
- }
- }
-
- return field;
- }
-
- GetFieldT<T extends Field = Field>(key: Key, ctor: { new(): T }, ignoreProto?: boolean): Opt<T> {
- return Cast(this.GetField(key, ignoreProto), ctor);
- }
-
- GetFieldValue<T, U extends { Data: T }>(key: Key, ctor: { new(): U }, defaultVal: T): T {
- let val = this.GetField(key);
- return (val && val instanceof ctor) ? val.Data : defaultVal;
- }
-
- SetField(key: Key, field: Opt<Field>): void {
- if (field) {
- this.fields.set(key, field);
- } else {
- this.fields.delete(key);
- }
- }
-
- SetFieldValue<T extends Field>(key: Key, value: any, ctor: { new(): T }): boolean {
- let field = this.GetField(key, true);
- if (field != null) {
- return field.TrySetValue(value);
- } else {
- field = new ctor();
- if (field.TrySetValue(value)) {
- this.SetField(key, field);
- return true;
- } else {
- return false;
- }
- }
- }
-
- GetPrototype(): Opt<Document> {
- return this.GetFieldT(KeyStore.Prototype, Document, true);
- }
-
- GetAllPrototypes(): Document[] {
- let protos: Document[] = [];
- let doc: Opt<Document> = this;
- while (doc != null) {
- protos.push(doc);
- doc = doc.GetPrototype();
- }
- return protos;
- }
-
- MakeDelegate(): Document {
- let delegate = new Document();
-
- delegate.SetField(KeyStore.Prototype, this);
-
- return delegate;
- }
-
- TrySetValue(value: any): boolean {
- throw new Error("Method not implemented.");
- }
- GetValue() {
- throw new Error("Method not implemented.");
- }
- Copy(): Field {
- throw new Error("Method not implemented.");
- }
-
-
-} \ No newline at end of file
diff --git a/src/fields/DocumentReference 2.ts b/src/fields/DocumentReference 2.ts
deleted file mode 100644
index 936067bd2..000000000
--- a/src/fields/DocumentReference 2.ts
+++ /dev/null
@@ -1,46 +0,0 @@
-import { Field, Opt } from "./Field";
-import { Document } from "./Document";
-import { Key } from "./Key";
-import { DocumentUpdatedArgs } from "./FieldUpdatedArgs";
-
-export class DocumentReference extends Field {
- get Key(): Key{
- return this.key;
- }
-
- get Document(): Document {
- return this.document;
- }
-
- constructor(private document: Document, private key: Key) {
- super();
- }
-
- private DocFieldUpdated(args: DocumentUpdatedArgs):void{
- // this.FieldUpdated.emit(args.fieldArgs);
- }
-
- Dereference() : Opt<Field> {
- return this.document.GetField(this.key);
- }
-
- DereferenceToRoot(): Opt<Field> {
- let field: Opt<Field> = this;
- while (field instanceof DocumentReference) {
- field = field.Dereference();
- }
- return field;
- }
-
- TrySetValue(value: any): boolean {
- throw new Error("Method not implemented.");
- }
- GetValue() {
- throw new Error("Method not implemented.");
- }
- Copy(): Field {
- throw new Error("Method not implemented.");
- }
-
-
-} \ No newline at end of file
diff --git a/src/fields/Field 2.ts b/src/fields/Field 2.ts
deleted file mode 100644
index 46f92f203..000000000
--- a/src/fields/Field 2.ts
+++ /dev/null
@@ -1,54 +0,0 @@
-import { TypedEvent } from "../util/TypedEvent";
-import { FieldUpdatedArgs } from "./FieldUpdatedArgs";
-import { DocumentReference } from "./DocumentReference";
-import { Utils } from "../Utils";
-
-export function Cast<T extends Field>(field: Opt<Field>, ctor: { new(): T }): Opt<T> {
- if (field) {
- if (ctor && field instanceof ctor) {
- return field;
- }
- }
- return undefined;
-}
-
-export type Opt<T> = T | undefined;
-
-export abstract class Field {
- //FieldUpdated: TypedEvent<Opt<FieldUpdatedArgs>> = new TypedEvent<Opt<FieldUpdatedArgs>>();
-
- private id: string;
- get Id(): string {
- return this.id;
- }
-
- constructor(id: Opt<string> = undefined) {
- this.id = id || Utils.GenerateGuid();
- }
-
- Dereference(): Opt<Field> {
- return this;
- }
- DereferenceToRoot(): Opt<Field> {
- return this;
- }
-
- DereferenceT<T extends Field = Field>(ctor: { new(): T }): Opt<T> {
- return Cast(this.Dereference(), ctor);
- }
-
- DereferenceToRootT<T extends Field = Field>(ctor: { new(): T }): Opt<T> {
- return Cast(this.DereferenceToRoot(), ctor);
- }
-
- Equals(other: Field): boolean {
- return this.id === other.id;
- }
-
- abstract TrySetValue(value: any): boolean;
-
- abstract GetValue(): any;
-
- abstract Copy(): Field;
-
-} \ No newline at end of file
diff --git a/src/fields/FieldUpdatedArgs 2.ts b/src/fields/FieldUpdatedArgs 2.ts
deleted file mode 100644
index 23ccf2a5a..000000000
--- a/src/fields/FieldUpdatedArgs 2.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-import { Field, Opt } from "./Field";
-import { Document } from "./Document";
-import { Key } from "./Key";
-
-export enum FieldUpdatedAction {
- Add,
- Remove,
- Replace,
- Update
-}
-
-export interface FieldUpdatedArgs {
- field: Field;
- action: FieldUpdatedAction;
-}
-
-export interface DocumentUpdatedArgs {
- field: Document;
- key: Key;
-
- oldValue: Opt<Field>;
- newValue: Opt<Field>;
-
- fieldArgs?: FieldUpdatedArgs;
-
- action: FieldUpdatedAction;
-}
diff --git a/src/fields/Key 2.ts b/src/fields/Key 2.ts
deleted file mode 100644
index db30f545d..000000000
--- a/src/fields/Key 2.ts
+++ /dev/null
@@ -1,45 +0,0 @@
-import { Field } from "./Field"
-import { Utils } from "../Utils";
-import { observable } from "mobx";
-
-export class Key extends Field {
- private name:string;
-
- get Name():string {
- return this.name;
- }
-
- constructor(name:string){
- super(Utils.GenerateDeterministicGuid(name));
-
- this.name = name;
- }
-
- TrySetValue(value: any): boolean {
- throw new Error("Method not implemented.");
- }
-
- GetValue() {
- return this.Name;
- }
-
- Copy(): Field {
- return this;
- }
-
-
-}
-
-export namespace KeyStore {
- export let Prototype = new Key("Prototype");
- export let X = new Key("X");
- export let Y = new Key("Y");
- export let PanX = new Key("PanX");
- export let PanY = new Key("PanY");
- export let Width = new Key("Width");
- export let Height = new Key("Height");
- export let Data = new Key("Data");
- export let Layout = new Key("Layout");
- export let LayoutKeys = new Key("LayoutKeys");
- export let LayoutFields = new Key("LayoutFields");
-} \ No newline at end of file
diff --git a/src/fields/ListField 2.ts b/src/fields/ListField 2.ts
deleted file mode 100644
index dd96ea8c8..000000000
--- a/src/fields/ListField 2.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-import { Field } from "./Field";
-import { BasicField } from "./BasicField";
-
-export class ListField<T extends Field> extends BasicField<T[]> {
- constructor(data: T[] = []) {
- super(data.slice());
- }
-
- Get(index:number) : T{
- return this.Data[index];
- }
-
- Set(index:number, value:T):void {
- this.Data[index] = value;
- }
-
- Copy(): Field {
- return new ListField<T>(this.Data);
- }
-
-} \ No newline at end of file
diff --git a/src/fields/NumberField 2.ts b/src/fields/NumberField 2.ts
deleted file mode 100644
index cbe15f987..000000000
--- a/src/fields/NumberField 2.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import { BasicField } from "./BasicField"
-
-export class NumberField extends BasicField<number> {
- constructor(data: number = 0) {
- super(data);
- }
-
- Copy() {
- return new NumberField(this.Data);
- }
-
-
-} \ No newline at end of file
diff --git a/src/fields/TextField 2.ts b/src/fields/TextField 2.ts
deleted file mode 100644
index a7c221788..000000000
--- a/src/fields/TextField 2.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import { BasicField } from "./BasicField"
-
-export class TextField extends BasicField<string> {
- constructor(data: string = "") {
- super(data);
- }
-
- Copy() {
- return new TextField(this.Data);
- }
-
-
-}