From 7035e2e6bdcb3efbfa3a4eca887b41eba87e6d6e Mon Sep 17 00:00:00 2001 From: bobzel Date: Tue, 23 Feb 2021 01:53:52 -0500 Subject: fixed backspace to delete text items in treeViews. simplified UndoRunInTempBatch. fixed clicking on sort line for treeView to only recognize actual clicks. fixed stayInCollection with DocDecorations to not create a giant gray square. prevent server crash when db has bad data somehow. --- src/client/util/CurrentUserUtils.ts | 2 +- src/client/util/DragManager.ts | 2 +- src/client/util/UndoManager.ts | 11 +++++++---- 3 files changed, 9 insertions(+), 6 deletions(-) (limited to 'src/client/util') diff --git a/src/client/util/CurrentUserUtils.ts b/src/client/util/CurrentUserUtils.ts index 288f75592..beced8c3c 100644 --- a/src/client/util/CurrentUserUtils.ts +++ b/src/client/util/CurrentUserUtils.ts @@ -558,7 +558,7 @@ export class CurrentUserUtils { _width: 60, _height: 60, watchedDocuments, - onClick: ScriptField.MakeScript(click, { scriptContext: "any" }), system: true + onClick: ScriptField.MakeScript(click, { scriptContext: "any" }) })); const userDoc = menuBtns[menuBtns.length - 1]; userDoc.userDoc = doc; diff --git a/src/client/util/DragManager.ts b/src/client/util/DragManager.ts index 7b4d43793..19f1f8d15 100644 --- a/src/client/util/DragManager.ts +++ b/src/client/util/DragManager.ts @@ -13,7 +13,7 @@ import * as globalCssVariables from "../views/globalCssVariables.scss"; import { UndoManager } from "./UndoManager"; import { SnappingManager } from "./SnappingManager"; -export type dropActionType = "alias" | "copy" | "move" | "same" | "none" | undefined; // undefined = move +export type dropActionType = "alias" | "copy" | "move" | "same" | "none" | undefined; // undefined = move, "same" = move but don't call removeDropProperties export function SetupDrag( _reference: React.RefObject, docFunc: () => Doc | Promise | undefined, diff --git a/src/client/util/UndoManager.ts b/src/client/util/UndoManager.ts index 569ad8ab4..05fb9f378 100644 --- a/src/client/util/UndoManager.ts +++ b/src/client/util/UndoManager.ts @@ -148,12 +148,15 @@ export namespace UndoManager { } }); - export function ClearTempBatch() { - tempEvents = undefined; - } export function RunInTempBatch(fn: () => T) { tempEvents = []; - return runInAction(fn); + try { + const success = runInAction(fn); + if (!success) UndoManager.UndoTempBatch(); + return success; + } finally { + tempEvents = undefined; + } } //TODO Make this return the return value export function RunInBatch(fn: () => T, batchName: string) { -- cgit v1.2.3-70-g09d2 From 17ee7f6f1f61a079ec79b71aebc65abfd72ec32a Mon Sep 17 00:00:00 2001 From: bobzel Date: Thu, 25 Feb 2021 13:38:31 -0500 Subject: added an aliases toggle to file system --- src/client/util/DocumentManager.ts | 12 +++++++++++- src/client/views/collections/TreeView.tsx | 11 ++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) (limited to 'src/client/util') diff --git a/src/client/util/DocumentManager.ts b/src/client/util/DocumentManager.ts index 67e05f8d0..637e219d5 100644 --- a/src/client/util/DocumentManager.ts +++ b/src/client/util/DocumentManager.ts @@ -10,6 +10,8 @@ import { LightboxView } from '../views/LightboxView'; import { DocumentView, ViewAdjustment } from '../views/nodes/DocumentView'; import { Scripting } from './Scripting'; import { CurrentUserUtils } from './CurrentUserUtils'; +import { TabDocView } from '../views/collections/TabDocView'; +import { UndoManager } from './UndoManager'; export class DocumentManager { @@ -219,4 +221,12 @@ export class DocumentManager { } } -Scripting.addGlobal(function DocFocus(doc: any) { DocumentManager.Instance.getDocumentViews(Doc.GetProto(doc)).map(view => view.props.focus(doc, { willZoom: true })); }); \ No newline at end of file +Scripting.addGlobal(function DocFocus(doc: any) { + const dv = DocumentManager.Instance.getDocumentView(doc); + if (dv && dv?.props.Document === doc) dv.props.focus(doc, { willZoom: true }); + else { + const context = Cast(doc.context, Doc, null); + CollectionDockingView.AddSplit(context || doc, "right") && context && + setTimeout(() => DocumentManager.Instance.getDocumentView(Doc.GetProto(doc))?.focus(doc)); + } +}); \ No newline at end of file diff --git a/src/client/views/collections/TreeView.tsx b/src/client/views/collections/TreeView.tsx index dbd05f37a..ac19a3591 100644 --- a/src/client/views/collections/TreeView.tsx +++ b/src/client/views/collections/TreeView.tsx @@ -115,11 +115,11 @@ export class TreeView extends React.Component { @computed get fieldKey() { TraceMobx(); const splits = StrCast(Doc.LayoutField(this.doc)).split("fieldKey={\'"); return splits.length > 1 ? splits[1].split("\'")[0] : "data"; } @computed get childDocs() { TraceMobx(); return this.childDocList(this.fieldKey); } @computed get childLinks() { return this.childDocList("links"); } + @computed get childAliases() { return this.childDocList("aliases"); } @computed get childAnnos() { return this.childDocList(this.fieldKey + "-annotations"); } @computed get selected() { return SelectionManager.Views().length && SelectionManager.Views()[0].props.Document === this.props.document; } childDocList(field: string) { - if (this.fileSysMode && !this.doc.isFolder) return [] as Doc[]; const layout = Doc.LayoutField(this.doc) instanceof Doc ? Doc.LayoutField(this.doc) as Doc : undefined; return ((this.props.dataDoc ? DocListCastOrNull(this.props.dataDoc[field]) : undefined) || // if there's a data doc for an expanded template, use it's data field (layout ? DocListCastOrNull(layout[field]) : undefined) || // else if there's a layout doc, display it's fields @@ -376,7 +376,7 @@ export class TreeView extends React.Component { @computed get renderContent() { TraceMobx(); const expandKey = this.treeViewExpandedView; - if (["links", "annotations", this.fieldKey].includes(expandKey)) { + if (["links", "annotations", "aliases", this.fieldKey].includes(expandKey)) { const key = expandKey === "annotations" ? this.fieldKey + "-annotations" : expandKey; const remDoc = (doc: Doc | Doc[]) => this.remove(doc, key); const localAdd = (doc: Doc, addBefore?: Doc, before?: boolean) => { @@ -395,7 +395,7 @@ export class TreeView extends React.Component { return added; }; const addDoc = (doc: Doc | Doc[], addBefore?: Doc, before?: boolean) => (doc instanceof Doc ? [doc] : doc).reduce((flg, doc) => flg && localAdd(doc, addBefore, before), true); - const docs = expandKey === "links" ? this.childLinks : expandKey === "annotations" ? this.childAnnos : this.childDocs; + const docs = expandKey === "aliases" ? this.childAliases : expandKey === "links" ? this.childLinks : expandKey === "annotations" ? this.childAnnos : this.childDocs; const sortKey = `${this.fieldKey}-sortCriteria`; let downX = 0, downY = 0; const sortings = ["up", "down", "Z", undefined]; @@ -422,7 +422,7 @@ export class TreeView extends React.Component { ; } - return
    {this.renderEmbeddedDocument(false)}
; + return
    {this.renderEmbeddedDocument(false)}
; // "layout" } get onCheckedClick() { return this.doc.type === DocumentType.COL ? undefined : this.props.onCheckedClick?.() ?? ScriptCast(this.doc.onCheckedClick); } @@ -477,7 +477,8 @@ export class TreeView extends React.Component { { if (this.fileSysMode) { - this.doc.treeViewExpandedView = this.doc.isFolder ? this.fieldKey : this.treeViewExpandedView === "layout" ? "fields" : "layout"; + this.doc.treeViewExpandedView = this.doc.isFolder ? this.fieldKey : this.treeViewExpandedView === "layout" ? "fields" : + this.treeViewExpandedView === "fields" ? "aliases" : "layout"; } else if (this.treeViewOpen) { this.doc.treeViewExpandedView = this.treeViewLockExpandedView ? this.doc.treeViewExpandedView : this.treeViewExpandedView === this.fieldKey ? (Doc.UserDoc().noviceMode || this.outlineMode ? "layout" : "fields") : -- cgit v1.2.3-70-g09d2