diff options
author | yipstanley <stanley_yip@brown.edu> | 2019-07-12 22:34:09 -0400 |
---|---|---|
committer | yipstanley <stanley_yip@brown.edu> | 2019-07-12 22:34:09 -0400 |
commit | 3daca894b6eaf1eb8590f54b1a5bf5feca663a08 (patch) | |
tree | c11a4cdb53574f8fb551cebb39b1cdfdb016c806 /src | |
parent | 59d32987f4f220c97a3b3cd4886ba47f3e8c4341 (diff) |
links now go between users
Diffstat (limited to 'src')
-rw-r--r-- | src/client/documents/Documents.ts | 18 | ||||
-rw-r--r-- | src/client/util/LinkManager.ts | 5 | ||||
-rw-r--r-- | src/client/views/Main.tsx | 23 |
3 files changed, 44 insertions, 2 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts index 2a3827782..638ba287f 100644 --- a/src/client/documents/Documents.ts +++ b/src/client/documents/Documents.ts @@ -54,7 +54,8 @@ export enum DocumentType { PDF = "pdf", ICON = "icon", IMPORT = "import", - LINK = "link" + LINK = "link", + LINKDOC = "linkdoc" } export interface DocumentOptions { @@ -85,6 +86,12 @@ export interface DocumentOptions { // [key: string]: Opt<Field>; } +class EmptyBox { + public static LayoutString() { + return ""; + } +} + export namespace Docs { export namespace Prototypes { @@ -148,6 +155,11 @@ export namespace Docs { [DocumentType.IMPORT, { layout: { view: DirectoryImportBox }, options: { height: 150 } + }], + [DocumentType.LINKDOC, { + data: new List<Doc>(), + layout: { view: EmptyBox }, + options: {} }] ]); @@ -195,6 +207,10 @@ export namespace Docs { return PrototypeMap.get(type)!; } + export function MainLinkDocument() { + return Prototypes.get(DocumentType.LINKDOC); + } + /** * This is a convenience method that is used to initialize * prototype documents for the first time. diff --git a/src/client/util/LinkManager.ts b/src/client/util/LinkManager.ts index 1ed040aa4..a647f22c1 100644 --- a/src/client/util/LinkManager.ts +++ b/src/client/util/LinkManager.ts @@ -5,6 +5,7 @@ import { listSpec } from "../../new_fields/Schema"; import { List } from "../../new_fields/List"; import { Id } from "../../new_fields/FieldSymbols"; import { CurrentUserUtils } from "../../server/authentication/models/current_user_utils"; +import { Docs } from "../documents/Documents"; /* @@ -35,7 +36,9 @@ export class LinkManager { // the linkmanagerdoc stores a list of docs representing all linkdocs in 'allLinks' and a list of strings representing all group types in 'allGroupTypes' // lists of strings representing the metadata keys for each group type is stored under a key that is the same as the group type public get LinkManagerDoc(): Doc | undefined { - return FieldValue(Cast(CurrentUserUtils.UserDocument.linkManagerDoc, Doc)); + // return FieldValue(Cast(CurrentUserUtils.UserDocument.linkManagerDoc, Doc)); + + return Docs.Prototypes.MainLinkDocument(); } public getAllLinks(): Doc[] { diff --git a/src/client/views/Main.tsx b/src/client/views/Main.tsx index 932a6375f..1b9a45f0b 100644 --- a/src/client/views/Main.tsx +++ b/src/client/views/Main.tsx @@ -3,9 +3,32 @@ import { Docs } from "../documents/Documents"; import { CurrentUserUtils } from "../../server/authentication/models/current_user_utils"; import * as ReactDOM from 'react-dom'; import * as React from 'react'; +import { Cast } from "../../new_fields/Types"; +import { Doc, DocListCastAsync } from "../../new_fields/Doc"; +import { List } from "../../new_fields/List"; + +let swapDocs = async () => { + let oldDoc = await Cast(CurrentUserUtils.UserDocument.linkManagerDoc, Doc); + Docs.Prototypes.MainLinkDocument().allLinks = new List<Doc>(); + if (oldDoc) { + let links = await DocListCastAsync(oldDoc.allLinks); + // if (links && DocListCast(links)) { + if (links && links.length) { + let data = await DocListCastAsync(Docs.Prototypes.MainLinkDocument().allLinks); + if (data) { + data.push(...links); + } + else { + Docs.Prototypes.MainLinkDocument().allLinks = new List<Doc>(links); + } + } + CurrentUserUtils.UserDocument.LinkManagerDoc = undefined; + } +} (async () => { await Docs.Prototypes.initialize(); await CurrentUserUtils.loadCurrentUser(); + await swapDocs(); ReactDOM.render(<MainView />, document.getElementById('root')); })();
\ No newline at end of file |