diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/client/views/Main.scss | 1 | ||||
-rw-r--r-- | src/client/views/Main.tsx | 16 | ||||
-rw-r--r-- | src/client/views/PresentationView.tsx | 62 | ||||
-rw-r--r-- | src/client/views/collections/CollectionBaseView.tsx | 4 | ||||
-rw-r--r-- | src/client/views/collections/CollectionDockingView.tsx | 30 | ||||
-rw-r--r-- | src/client/views/collections/CollectionSchemaView.tsx | 1 | ||||
-rw-r--r-- | src/client/views/collections/CollectionTreeView.scss | 17 | ||||
-rw-r--r-- | src/client/views/collections/CollectionTreeView.tsx | 37 | ||||
-rw-r--r-- | src/client/views/nodes/DocumentView.tsx | 2 | ||||
-rw-r--r-- | src/client/views/nodes/KeyValuePair.tsx | 4 | ||||
-rw-r--r-- | src/client/views/nodes/LinkEditor.tsx | 5 | ||||
-rw-r--r-- | src/new_fields/Doc.ts | 2 |
12 files changed, 112 insertions, 69 deletions
diff --git a/src/client/views/Main.scss b/src/client/views/Main.scss index cbf920793..5c5c252e9 100644 --- a/src/client/views/Main.scss +++ b/src/client/views/Main.scss @@ -182,6 +182,7 @@ button:hover { top: 0; left: 0; overflow: scroll; + z-index: 1; } #mainContent-div { width: 100%; diff --git a/src/client/views/Main.tsx b/src/client/views/Main.tsx index c3b48d20f..617580332 100644 --- a/src/client/views/Main.tsx +++ b/src/client/views/Main.tsx @@ -51,9 +51,6 @@ export class Main extends React.Component { } private set mainContainer(doc: Opt<Doc>) { if (doc) { - if (!("presentationView" in doc)) { - doc.presentationView = new Doc(); - } CurrentUserUtils.UserDocument.activeWorkspace = doc; } } @@ -177,23 +174,12 @@ export class Main extends React.Component { } }, 100); } - - @computed - get presentationView() { - if (this.mainContainer) { - let presentation = FieldValue(Cast(this.mainContainer.presentationView, Doc)); - return presentation ? <PresentationView Document={presentation} key="presentation" /> : (null); - } - return (null); - } - @computed get mainContent() { let pwidthFunc = () => this.pwidth; let pheightFunc = () => this.pheight; let noScaling = () => 1; let mainCont = this.mainContainer; - let pcontent = this.presentationView; return <Measure onResize={action((r: any) => { this.pwidth = r.entry.width; this.pheight = r.entry.height; })}> {({ measureRef }) => <div ref={measureRef} id="mainContent-div"> @@ -213,7 +199,7 @@ export class Main extends React.Component { whenActiveChanged={emptyFunction} bringToFront={emptyFunction} ContainingCollectionView={undefined} />} - {pcontent} + <PresentationView key="presentation" /> </div> } </Measure>; diff --git a/src/client/views/PresentationView.tsx b/src/client/views/PresentationView.tsx index b4c12d057..f2d685443 100644 --- a/src/client/views/PresentationView.tsx +++ b/src/client/views/PresentationView.tsx @@ -1,18 +1,19 @@ import { observer } from "mobx-react"; import React = require("react") -import { observable, action } from "mobx"; +import { observable, action, runInAction, reaction } from "mobx"; import "./PresentationView.scss" import "./Main.tsx"; import { DocumentManager } from "../util/DocumentManager"; import { Utils } from "../../Utils"; import { Doc } from "../../new_fields/Doc"; import { listSpec } from "../../new_fields/Schema"; -import { Cast, NumCast, FieldValue } from "../../new_fields/Types"; +import { Cast, NumCast, FieldValue, PromiseValue } from "../../new_fields/Types"; import { Id } from "../../new_fields/RefField"; import { List } from "../../new_fields/List"; +import { CurrentUserUtils } from "../../server/authentication/models/current_user_utils"; export interface PresViewProps { - Document: Doc; + //Document: Doc; } @@ -22,6 +23,11 @@ export interface PresViewProps { */ class PresentationViewItem extends React.Component<PresViewProps> { + @observable Document?: Doc; + constructor(props: PresViewProps) { + super(props); + this.Document = FieldValue(Cast(FieldValue(Cast(CurrentUserUtils.UserDocument.activeWorkspace, Doc))!.presentationView, Doc))!; + } //look at CollectionFreeformView.focusDocument(d) @action openDoc = (doc: Doc) => { @@ -36,7 +42,7 @@ class PresentationViewItem extends React.Component<PresViewProps> { **/ @action public RemoveDoc(doc: Doc) { - const value = Cast(this.props.Document.data, listSpec(Doc), []); + const value = Cast(this.Document!.data, listSpec(Doc), []); let index = -1; for (let i = 0; i < value.length; i++) { if (value[i][Id] === doc[Id]) { @@ -57,10 +63,10 @@ class PresentationViewItem extends React.Component<PresViewProps> { let title = document.title; //to get currently selected presentation doc - let selected = NumCast(this.props.Document.selectedDoc, 0); + let selected = NumCast(this.Document!.selectedDoc, 0); // finally, if it's a normal document, then render it as such. - const children = Cast(this.props.Document.data, listSpec(Doc)); + const children = Cast(this.Document!.data, listSpec(Doc)); const styles: any = {}; if (children && children[selected] === document) { //this doc is selected @@ -76,7 +82,7 @@ class PresentationViewItem extends React.Component<PresViewProps> { } render() { - const children = Cast(this.props.Document.data, listSpec(Doc), []); + const children = Cast(this.Document!.data, listSpec(Doc), []); return ( <div> @@ -94,13 +100,13 @@ export class PresentationView extends React.Component<PresViewProps> { //observable means render is re-called every time variable is changed @observable collapsed: boolean = false; - closePresentation = action(() => this.props.Document.width = 0); + closePresentation = action(() => this.Document!.width = 0); next = () => { - const current = NumCast(this.props.Document.selectedDoc); - const allDocs = FieldValue(Cast(this.props.Document.data, listSpec(Doc))); + const current = NumCast(this.Document!.selectedDoc); + const allDocs = FieldValue(Cast(this.Document!.data, listSpec(Doc))); if (allDocs && current < allDocs.length + 1) { //can move forwards - this.props.Document.selectedDoc = current + 1; + this.Document!.selectedDoc = current + 1; const doc = allDocs[current + 1]; let docView = DocumentManager.Instance.getDocumentView(doc); if (docView) { @@ -110,11 +116,11 @@ export class PresentationView extends React.Component<PresViewProps> { } back = () => { - const current = NumCast(this.props.Document.selectedDoc); - const allDocs = FieldValue(Cast(this.props.Document.data, listSpec(Doc))); + const current = NumCast(this.Document!.selectedDoc); + const allDocs = FieldValue(Cast(this.Document!.data, listSpec(Doc))); if (allDocs && current - 1 >= 0) { //can move forwards - this.props.Document.selectedDoc = current - 1; + this.Document!.selectedDoc = current - 1; const doc = allDocs[current - 1]; let docView = DocumentManager.Instance.getDocumentView(doc); if (docView) { @@ -125,9 +131,21 @@ export class PresentationView extends React.Component<PresViewProps> { private ref = React.createRef<HTMLDivElement>(); + @observable Document?: Doc; //initilize class variables constructor(props: PresViewProps) { super(props); + let self = this; + reaction(() => + CurrentUserUtils.UserDocument.activeWorkspace, + (activeW) => { + if (activeW && activeW instanceof Doc) { + PromiseValue(Cast(activeW.presentationView, Doc)). + then(pv => runInAction(() => + self.Document = pv ? pv : (activeW.presentationView = new Doc()))) + } + }, + { fireImmediately: true }); PresentationView.Instance = this; } @@ -137,19 +155,21 @@ export class PresentationView extends React.Component<PresViewProps> { @action public PinDoc(doc: Doc) { //add this new doc to props.Document - const data = Cast(this.props.Document.data, listSpec(Doc)); + const data = Cast(this.Document!.data, listSpec(Doc)); if (data) { data.push(doc); } else { - this.props.Document.data = new List([doc]); + this.Document!.data = new List([doc]); } - this.props.Document.width = 300; + this.Document!.width = 300; } render() { - let titleStr = this.props.Document.Title; - let width = NumCast(this.props.Document.width); + if (!this.Document) + return (null); + let titleStr = this.Document.Title; + let width = NumCast(this.Document.width); //TODO: next and back should be icons return ( @@ -163,9 +183,7 @@ export class PresentationView extends React.Component<PresViewProps> { </div> <ul> - <PresentationViewItem - Document={this.props.Document} - /> + <PresentationViewItem /> </ul> </div> ); diff --git a/src/client/views/collections/CollectionBaseView.tsx b/src/client/views/collections/CollectionBaseView.tsx index 76adfcdcd..cbb568c07 100644 --- a/src/client/views/collections/CollectionBaseView.tsx +++ b/src/client/views/collections/CollectionBaseView.tsx @@ -100,12 +100,12 @@ export class CollectionBaseView extends React.Component<CollectionViewProps> { value.push(doc); } } else { - this.props.Document[this.props.fieldKey] = new List([doc]); + Doc.SetOnPrototype(this.props.Document, this.props.fieldKey, new List([doc])); } // set the ZoomBasis only if hasn't already been set -- bcz: maybe set/resetting the ZoomBasis should be a parameter to addDocument? if (this.collectionViewType === CollectionViewType.Freeform || this.collectionViewType === CollectionViewType.Invalid) { let zoom = NumCast(this.props.Document.scale, 1); - doc.zoomBasis = zoom; + Doc.SetOnPrototype(doc, "zoomBasis", zoom); } } return true; diff --git a/src/client/views/collections/CollectionDockingView.tsx b/src/client/views/collections/CollectionDockingView.tsx index cfb1aef7d..278065479 100644 --- a/src/client/views/collections/CollectionDockingView.tsx +++ b/src/client/views/collections/CollectionDockingView.tsx @@ -231,6 +231,11 @@ export class CollectionDockingView extends React.Component<SubCollectionViewProp @undoBatch stateChanged = () => { + let docs = Cast(CollectionDockingView.Instance.props.Document.data, listSpec(Doc)); + CollectionDockingView.Instance._removedDocs.map(theDoc => + docs && docs.indexOf(theDoc) !== -1 && + docs.splice(docs.indexOf(theDoc), 1)); + CollectionDockingView.Instance._removedDocs.length = 0; var json = JSON.stringify(this._goldenLayout.toConfig()); this.props.Document.dockingConfig = json; if (this.undohack && !this.hack) { @@ -275,19 +280,19 @@ export class CollectionDockingView extends React.Component<SubCollectionViewProp }); } tab.closeElement.off('click') //unbind the current click handler - .click(function () { + .click(async function () { if (tab.reactionDisposer) { tab.reactionDisposer(); } - DocServer.GetRefField(tab.contentItem.config.props.documentId).then(async f => runInAction(() => { - if (f instanceof Doc) { - let docs = Cast(CollectionDockingView.Instance.props.Document.data, listSpec(Doc)); - docs && docs.indexOf(f) !== -1 && docs.splice(docs.indexOf(f), 1); - } - })); + let doc = await DocServer.GetRefField(tab.contentItem.config.props.documentId); + if (doc instanceof Doc) { + let theDoc = doc; + CollectionDockingView.Instance._removedDocs.push(theDoc); + } tab.contentItem.remove(); }); } + _removedDocs: Doc[] = []; stackCreated = (stack: any) => { //stack.header.controlsContainer.find('.lm_popout').hide(); @@ -304,6 +309,16 @@ export class CollectionDockingView extends React.Component<SubCollectionViewProp var url = DocServer.prepend("/doc/" + stack.contentItems[0].tab.contentItem.config.props.documentId); let win = window.open(url, stack.contentItems[0].tab.title, "width=300,height=400"); })); + stack.header.controlsContainer.find('.lm_close') //unbind the current click handler + .click(async function () { + stack.contentItems.map(async (contentItem: any) => { + let doc = await DocServer.GetRefField(contentItem.config.props.documentId); + if (doc instanceof Doc) { + let theDoc = doc; + CollectionDockingView.Instance._removedDocs.push(theDoc); + } + }); + }); } render() { @@ -368,6 +383,7 @@ export class DockedFrameRenderer extends React.Component<DockedFrameProps> { parentActive={returnTrue} whenActiveChanged={emptyFunction} focus={emptyFunction} + bringToFront={emptyFunction} ContainingCollectionView={undefined} /> </div >); } diff --git a/src/client/views/collections/CollectionSchemaView.tsx b/src/client/views/collections/CollectionSchemaView.tsx index 67784fa81..4fee9db85 100644 --- a/src/client/views/collections/CollectionSchemaView.tsx +++ b/src/client/views/collections/CollectionSchemaView.tsx @@ -268,6 +268,7 @@ export class CollectionSchemaView extends CollectionSubView(doc => doc) { focus={emptyFunction} parentActive={this.props.active} whenActiveChanged={this.props.whenActiveChanged} + bringToFront={emptyFunction} /> </div> <input className="collectionSchemaView-input" value={this.previewScript} onChange={this.onPreviewScriptChange} diff --git a/src/client/views/collections/CollectionTreeView.scss b/src/client/views/collections/CollectionTreeView.scss index 19d4abc05..6ce13cf56 100644 --- a/src/client/views/collections/CollectionTreeView.scss +++ b/src/client/views/collections/CollectionTreeView.scss @@ -33,9 +33,10 @@ } .bullet { - position: absolute; - width: 1.5em; - display: inline-block; + float:left; + position: relative; + width: 15px; + display: block; color: $intermediate-color; margin-top: 3px; transform: scale(1.3,1.3); @@ -50,7 +51,7 @@ .docContainer { margin-left: 10px; display: block; - width: max-content; + width:100%;//width: max-content; } .docContainer:hover { @@ -59,6 +60,9 @@ // width: auto; } } + .editableView-container { + font-weight: bold; + } .delete-button { color: $intermediate-color; @@ -67,4 +71,9 @@ // margin-top: 3px; display: inline; } + + .collectionTreeView-keyHeader { + font-style: italic; + font-size: 8pt; + } }
\ No newline at end of file diff --git a/src/client/views/collections/CollectionTreeView.tsx b/src/client/views/collections/CollectionTreeView.tsx index b67d6f965..17109508d 100644 --- a/src/client/views/collections/CollectionTreeView.tsx +++ b/src/client/views/collections/CollectionTreeView.tsx @@ -18,6 +18,8 @@ import { Main } from '../Main'; import { CurrentUserUtils } from '../../../server/authentication/models/current_user_utils'; import { CollectionDockingView } from './CollectionDockingView'; import { DocumentManager } from '../../util/DocumentManager'; +import { Utils } from '../../../Utils'; +import { List } from '../../../new_fields/List'; export interface TreeViewProps { @@ -122,17 +124,25 @@ class TreeView extends React.Component<TreeViewProps> { render() { let bulletType = BulletType.List; - let contentElement: JSX.Element | null = (null); - var children = Cast(this.props.document.data, listSpec(Doc)); - if (children) { // add children for a collection - if (!this._collapsed) { - bulletType = BulletType.Collapsible; - contentElement = <ul> - {TreeView.GetChildElements(children, this.remove, this.move, this.props.dropAction)} - </ul >; - } - else bulletType = BulletType.Collapsed; + let contentElement: (JSX.Element | null)[] = []; + let keys = Array.from(Object.keys(this.props.document)); + if (this.props.document.proto instanceof Doc) { + keys.push(...Array.from(Object.keys(this.props.document.proto))); } + keys.map(key => { + let docList = Cast(this.props.document[key], listSpec(Doc)); + if (docList instanceof List && docList.length && docList[0] instanceof Doc) { + if (!this._collapsed) { + bulletType = BulletType.Collapsible; + contentElement.push(<ul key={key + "more"}> + {(key === "data") ? (null) : + <span className="collectionTreeView-keyHeader" key={key}>{key}</span>} + {TreeView.GetChildElements(docList, key !== "data", this.remove, this.move, this.props.dropAction)} + </ul >); + } else + bulletType = BulletType.Collapsed; + } + }); return <div className="treeViewItem-container" style={{ background: BoolCast(this.props.document.libraryBrush, false) ? "#06121212" : "0" }} onContextMenu={this.onWorkspaceContextMenu} @@ -144,8 +154,8 @@ class TreeView extends React.Component<TreeViewProps> { </li> </div>; } - public static GetChildElements(docs: Doc[], remove: ((doc: Doc) => void), move: DragManager.MoveFunction, dropAction: dropActionType) { - return docs.filter(child => !child.excludeFromLibrary).filter(doc => FieldValue(doc)).map(child => + public static GetChildElements(docs: Doc[], allowMinimized: boolean, remove: ((doc: Doc) => void), move: DragManager.MoveFunction, dropAction: dropActionType) { + return docs.filter(child => !child.excludeFromLibrary && (allowMinimized || !child.isMinimized)).filter(doc => FieldValue(doc)).map(child => <TreeView document={child} key={child[Id]} deleteDoc={remove} moveDocument={move} dropAction={dropAction} />); } } @@ -168,13 +178,12 @@ export class CollectionTreeView extends CollectionSubView(Document) { } } render() { - trace(); const children = this.children; let dropAction = StrCast(this.props.Document.dropAction, "alias") as dropActionType; if (!children) { return (null); } - let childElements = TreeView.GetChildElements(children, this.remove, this.props.moveDocument, dropAction); + let childElements = TreeView.GetChildElements(children, false, this.remove, this.props.moveDocument, dropAction); return ( <div id="body" className="collectionTreeView-dropTarget" diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx index fd012e7ea..096a02d9b 100644 --- a/src/client/views/nodes/DocumentView.tsx +++ b/src/client/views/nodes/DocumentView.tsx @@ -198,7 +198,7 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu this.props.removeDocument && this.props.removeDocument(this.props.Document); } fieldsClicked = (e: React.MouseEvent): void => { - let kvp = Docs.KVPDocument(this.props.Document, { width: 300, height: 300 }); + let kvp = Docs.KVPDocument(this.props.Document, { title: this.props.Document.title + ".kvp", width: 300, height: 300 }); CollectionDockingView.Instance.AddRightSplit(kvp); } makeButton = (e: React.MouseEvent): void => { diff --git a/src/client/views/nodes/KeyValuePair.tsx b/src/client/views/nodes/KeyValuePair.tsx index 235792cbe..203fb5625 100644 --- a/src/client/views/nodes/KeyValuePair.tsx +++ b/src/client/views/nodes/KeyValuePair.tsx @@ -40,6 +40,7 @@ export class KeyValuePair extends React.Component<KeyValuePairProps> { PanelHeight: returnZero, }; let contents = <FieldView {...props} />; + let fieldKey = Object.keys(props.Document).indexOf(props.fieldKey) !== -1 ? props.fieldKey : "(" + props.fieldKey + ")"; return ( <tr className={this.props.rowStyle}> <td className="keyValuePair-td-key" style={{ width: `${this.props.keyWidth}%` }}> @@ -50,11 +51,12 @@ export class KeyValuePair extends React.Component<KeyValuePairProps> { }}> X </button> - <div className="keyValuePair-keyField">{this.props.keyName}</div> + <div className="keyValuePair-keyField">{fieldKey}</div> </div> </td> <td className="keyValuePair-td-value" style={{ width: `${100 - this.props.keyWidth}%` }}> <EditableView contents={contents} height={36} GetValue={() => { + let field = FieldValue(props.Document[props.fieldKey]); if (field) { //TODO Types diff --git a/src/client/views/nodes/LinkEditor.tsx b/src/client/views/nodes/LinkEditor.tsx index f82c6e9cb..71a423338 100644 --- a/src/client/views/nodes/LinkEditor.tsx +++ b/src/client/views/nodes/LinkEditor.tsx @@ -24,8 +24,9 @@ export class LinkEditor extends React.Component<Props> { onSaveButtonPressed = (e: React.PointerEvent): void => { e.stopPropagation(); - this.props.linkDoc.title = this._nameInput; - this.props.linkDoc.linkDescription = this._descriptionInput; + let linkDoc = this.props.linkDoc.proto ? this.props.linkDoc.proto : this.props.linkDoc; + linkDoc.title = this._nameInput; + linkDoc.linkDescription = this._descriptionInput; this.props.showLinks(); } diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts index 3055af1bf..b2863c632 100644 --- a/src/new_fields/Doc.ts +++ b/src/new_fields/Doc.ts @@ -186,7 +186,7 @@ export namespace Doc { UndoManager.RunInBatch(() => { let linkDoc = Docs.TextDocument({ width: 100, height: 30, borderRounding: -1 }); //let linkDoc = new Doc; - linkDoc.title = "-link name-"; + linkDoc.proto!.title = "-link name-"; linkDoc.linkDescription = ""; linkDoc.linkTags = "Default"; |