diff options
Diffstat (limited to 'src/server')
-rw-r--r-- | src/server/authentication/models/current_user_utils.ts | 73 |
1 files changed, 60 insertions, 13 deletions
diff --git a/src/server/authentication/models/current_user_utils.ts b/src/server/authentication/models/current_user_utils.ts index f9e3dc479..e1bb91838 100644 --- a/src/server/authentication/models/current_user_utils.ts +++ b/src/server/authentication/models/current_user_utils.ts @@ -12,6 +12,7 @@ import { listSpec } from "../../../new_fields/Schema"; import { Cast, StrCast, PromiseValue } from "../../../new_fields/Types"; import { Utils } from "../../../Utils"; import { RouteStore } from "../../RouteStore"; +import { ScriptField } from "../../../new_fields/ScriptField"; export class CurrentUserUtils { private static curr_id: string; @@ -97,24 +98,70 @@ export class CurrentUserUtils { curPresentation.boxShadow = "0 0"; doc.curPresentation = curPresentation; } - if (doc.searchBox === undefined) { + + if (doc.Library === undefined) { + let Search = Docs.Create.ButtonDocument({ width: 50, height: 35, title: "Search" }); + let Library = Docs.Create.ButtonDocument({ width: 50, height: 35, title: "Library" }); + let Create = Docs.Create.ButtonDocument({ width: 35, height: 35, title: "Create" }); + if (doc.sidebarContainer === undefined) { + doc.sidebarContainer = new Doc(); + (doc.sidebarContainer as Doc).chromeStatus = "disabled"; + } + + const library = Docs.Create.TreeDocument([doc.workspaces as Doc, doc, doc.recentlyClosed as Doc], { title: "Library" }); + library.forceActive = true; + library.lockedPosition = true; + library.gridGap = 5; + library.xMargin = 5; + library.yMargin = 5; + library.boxShadow = "1 1 3"; + library.workspaceLibrary = true; // flag that this is the document that shows the Notifications button when documents are shared + Library.targetContainer = doc.sidebarContainer; + Library.library = library; + Library.onClick = ScriptField.MakeScript("this.targetContainer.proto = this.library"); + const searchBox = Docs.Create.QueryDocument({ title: "Searching" }); searchBox.boxShadow = "0 0"; searchBox.ignoreClick = true; - doc.searchBox = searchBox; - } + Search.searchBox = searchBox; + Search.targetContainer = doc.sidebarContainer; + Search.onClick = ScriptField.MakeScript("this.targetContainer.proto = this.searchBox"); - if (doc.sidebar === undefined) { - const sidebar = Docs.Create.TreeDocument([doc.workspaces as Doc, doc, doc.recentlyClosed as Doc], { title: "Sidebar" }); - sidebar.forceActive = true; - sidebar.lockedPosition = true; - sidebar.gridGap = 5; - sidebar.xMargin = 5; - sidebar.yMargin = 5; - sidebar.boxShadow = "1 1 3"; - sidebar.workspaceLibrary = true; // flag that this is the document that shows the Notifications button when documents are shared - doc.sidebar = sidebar; + let createCollection = Docs.Create.DragboxDocument({ width: 35, height: 35, title: "Collection", icon: "folder" }); + let createWebPage = Docs.Create.DragboxDocument({ width: 35, height: 35, title: "Web Page", icon: "globe-asia" }); + createWebPage.onDragStart = ScriptField.MakeFunction('Docs.Create.WebDocument("https://en.wikipedia.org/wiki/Hedgehog", { width: 300, height: 300, title: "New Webpage" })'); + let createCatImage = Docs.Create.DragboxDocument({ width: 35, height: 35, title: "Image", icon: "cat" }); + createCatImage.onDragStart = ScriptField.MakeFunction('Docs.Create.ImageDocument(imgurl, { width: 200, title: "an image of a cat" })'); + let createButton = Docs.Create.DragboxDocument({ width: 35, height: 35, title: "Button", icon: "bolt" }); + createButton.onDragStart = ScriptField.MakeFunction('Docs.Create.ButtonDocument({ width: 150, height: 50, title: "Button" })'); + let createPresentation = Docs.Create.DragboxDocument({ width: 35, height: 35, title: "Presentation", icon: "tv" }); + createPresentation.onDragStart = ScriptField.MakeFunction('Doc.UserDoc().curPresentation = Docs.Create.PresDocument(new List<Doc>(), { width: 200, height: 500, title: "a presentation trail" })'); + let createFolderImport = Docs.Create.DragboxDocument({ width: 35, height: 35, title: "Import Folder", icon: "cloud-upload-alt" }); + createFolderImport.onDragStart = ScriptField.MakeFunction('Docs.Create.DirectoryImportDocument({ title: "Directory Import", width: 400, height: 400 })'); + const creators = Docs.Create.MasonryDocument([createCollection, createWebPage, createCatImage, createButton, createPresentation, createFolderImport], { width: 500, height: 50, columnWidth: 35, chromeStatus: "disabled", title: "buttons" }); + Create.targetContainer = doc.sidebarContainer; + Create.creators = creators; + Create.onClick = ScriptField.MakeScript("this.targetContainer.proto = this.creators"); + + const buttons = Docs.Create.StackingDocument([Search, Library, Create], { width: 500, height: 80, chromeStatus: "disabled", title: "buttons" }); + buttons.sectionFilter = "title"; + buttons.boxShadow = "0 0"; + buttons.ignoreClick = true; + buttons.hideHeadings = true; + doc.libraryButtons = buttons; + + doc.Library = Library; + doc.Create = Create; + doc.Search = Search; + (Library.onClick as ScriptField).script.run({ this: Library }); + //(doc.sidebarContainer as Doc).proto = library; } + PromiseValue(Cast(doc.libraryButtons, Doc)).then(libraryButtons => { + if (libraryButtons) { + libraryButtons.backgroundColor = "lightgrey"; + } + }); + PromiseValue(Cast(doc.sidebar, Doc)).then(sidebar => { if (sidebar) { sidebar.backgroundColor = "lightgrey"; |