diff options
Diffstat (limited to 'src/client/views')
| -rw-r--r-- | src/client/views/DashboardView.tsx | 41 | ||||
| -rw-r--r-- | src/client/views/MainView.tsx | 12 | ||||
| -rw-r--r-- | src/client/views/collections/TabDocView.tsx | 11 |
3 files changed, 55 insertions, 9 deletions
diff --git a/src/client/views/DashboardView.tsx b/src/client/views/DashboardView.tsx index 526a32f5a..982640266 100644 --- a/src/client/views/DashboardView.tsx +++ b/src/client/views/DashboardView.tsx @@ -5,9 +5,11 @@ import * as React from 'react'; import { DataSym, Doc, DocListCast, DocListCastAsync } from '../../fields/Doc'; import { Id } from '../../fields/FieldSymbols'; import { List } from '../../fields/List'; -import { Cast, ImageCast, StrCast } from '../../fields/Types'; +import { listSpec } from '../../fields/Schema'; +import { ScriptField } from '../../fields/ScriptField'; +import { Cast, DocCast, ImageCast, StrCast } from '../../fields/Types'; import { DocServer } from '../DocServer'; -import { Docs, DocumentOptions } from '../documents/Documents'; +import { Docs, DocumentOptions, DocUtils } from '../documents/Documents'; import { CollectionViewType } from '../documents/DocumentTypes'; import { HistoryUtil } from '../util/History'; import { ScriptingGlobals } from '../util/ScriptingGlobals'; @@ -18,6 +20,7 @@ import { CollectionView } from './collections/CollectionView'; import { ContextMenu } from './ContextMenu'; import './DashboardView.scss'; import { MainViewModal } from './MainViewModal'; +import { ButtonType } from './nodes/button/FontIconBox'; enum DashboardGroup { MyDashboards, @@ -255,7 +258,7 @@ export class DashboardView extends React.Component { }; public static createNewDashboard = (id?: string, name?: string) => { - const presentation = Doc.MakeCopy(Doc.UserDoc().emptyPresentation as Doc, true); + // const presentation = Doc.MakeCopy(Doc.UserDoc().emptyPresentation as Doc, true); const dashboards = Doc.MyDashboards; const dashboardCount = DocListCast(dashboards.data).length + 1; const freeformOptions: DocumentOptions = { @@ -277,12 +280,40 @@ export class DashboardView extends React.Component { dashboardDoc.data = new List<Doc>(dashboardTabs); dashboardDoc['pane-count'] = 1; - Doc.ActivePresentation = presentation; - Doc.AddDocToList(dashboards, 'data', dashboardDoc); // open this new dashboard Doc.ActiveDashboard = dashboardDoc; Doc.ActivePage = 'dashboard'; + + + // this section is creating the button document itself === myTrails = new Button + const reqdBtnOpts:DocumentOptions = { _forceActive: true, _width: 30, _height: 30, _stayInCollection: true, _hideContextMenu: true, + title: "New trail", toolTip: "Create new trail", btnType: ButtonType.ClickButton, buttonText: "New trail", icon: "plus", system: true }; + const reqdBtnScript = {onClick: `createNewPresentation()`}; + const myTrailsBtn = DocUtils.AssignScripts(Docs.Create.FontIconDocument(reqdBtnOpts), reqdBtnScript); + + // createa a list of presentations (as a tree view collection) and store i on the new dashboard + // instead of assigninbg Doc.UserDoc().myrails we want to assign Doc.AxtiveDashboard.myTrails + // but we don't wanbt to create the list of trails here-- but rather in createDashbarod + // myTrail + const reqdOpts:DocumentOptions = { + title: "My Trails", _showTitle: "title", _height: 100, + treeViewHideTitle: true, _fitWidth: true, _gridGap: 5, _forceActive: true, childDropAction: "alias", + treeViewTruncateTitleWidth: 150, ignoreClick: true, buttonMenu: true, buttonMenuDoc: myTrailsBtn, + contextMenuIcons: new List<string>(["plus"]), + contextMenuLabels: new List<string>(["Create New Trail"]), + _lockedPosition: true, boxShadow: "0 0", childDontRegisterViews: true, targetDropAction: "same", system: true, + explainer: "All of the trails that you have created will appear here." + }; + const myTrails = Docs.Create.TreeDocument([], reqdOpts); + + dashboardDoc.myTrails = myTrails; + console.log(myTrails) + const contextMenuScripts = [reqdBtnScript.onClick]; + if (Cast(myTrails.contextMenuScripts, listSpec(ScriptField), null)?.length !== contextMenuScripts.length) { + myTrails.contextMenuScripts = new List<ScriptField>(contextMenuScripts.map(script => ScriptField.MakeFunction(script)!)); + } + }; } diff --git a/src/client/views/MainView.tsx b/src/client/views/MainView.tsx index b61cd3409..437a97d0b 100644 --- a/src/client/views/MainView.tsx +++ b/src/client/views/MainView.tsx @@ -8,6 +8,7 @@ import { observer } from 'mobx-react'; import * as React from 'react'; import * as ReactDOM from 'react-dom'; import { Doc, DocListCast, Opt } from '../../fields/Doc'; +import { List } from '../../fields/List'; import { ScriptField } from '../../fields/ScriptField'; import { StrCast } from '../../fields/Types'; import { emptyFunction, returnEmptyDoclist, returnEmptyFilter, returnFalse, returnTrue, returnZero, setupMoveUpEvents, simulateMouseClick, Utils } from '../../Utils'; @@ -502,8 +503,15 @@ export class MainView extends React.Component { createNewPresentation = async () => { const pres = Docs.Create.PresDocument({ title: 'Untitled Trail', _viewType: CollectionViewType.Stacking, _fitWidth: true, _width: 400, _height: 500, targetDropAction: 'alias', _chromeHidden: true, boxShadow: '0 0' }); CollectionDockingView.AddSplit(pres, 'left'); - Doc.ActivePresentation = pres; - Doc.AddDocToList(Doc.MyTrails, 'data', pres); + + // add the presentation documents to dashboard doc + // const myTrails = new Doc; + // Doc.ActiveDashboard!.myTrails = myTrails; + // myTrails.trails = new List<Doc>([]) // todo: move to dashboard creation + // Doc.ActiveDashboard!.myTrails!.trails = new List<Doc>([]) + console.log(Doc.ActiveDashboard!.myTrails) + // Doc.AddDocToList(myTrails, "trails", pres) + // Doc.ActivePresentation = pres }; @action diff --git a/src/client/views/collections/TabDocView.tsx b/src/client/views/collections/TabDocView.tsx index b8aaea622..7614154c0 100644 --- a/src/client/views/collections/TabDocView.tsx +++ b/src/client/views/collections/TabDocView.tsx @@ -214,8 +214,15 @@ export class TabDocView extends React.Component<TabDocViewProps> { const docList = docs instanceof Doc ? [docs] : docs; const batch = UndoManager.StartBatch('pinning doc'); - // all docs will be added to the ActivePresentation as stored on CurrentUserUtils - const curPres = Doc.ActivePresentation; + let curPres = Doc.ActivePresentation + console.log(curPres) + // let curPres = Doc.ActiveDashboard!['presentation'] + if (!curPres) { + curPres = Doc.MakeCopy(Doc.UserDoc().emptyPresentation as Doc, true); + Doc.ActivePresentation = curPres + // Doc.ActiveDashboard!['presentation'] = curPres + } + curPres && docList.forEach(doc => { // Edge Case 1: Cannot pin document to itself |
