diff options
| author | bobzel <zzzman@gmail.com> | 2021-03-30 09:37:56 -0400 |
|---|---|---|
| committer | bobzel <zzzman@gmail.com> | 2021-03-30 09:37:56 -0400 |
| commit | 6c689a999e22fc414386e39007ca0929057ff1d8 (patch) | |
| tree | d84b2f85c45895385d6d7a23d3c3ab5bcc903191 /src/client/views/collections | |
| parent | 3aa6f1676a3fd366aade7c468ad495ade1314577 (diff) | |
fixed a bunch of compile errors. activated Clear button for recently closed tree views.
Diffstat (limited to 'src/client/views/collections')
5 files changed, 24 insertions, 26 deletions
diff --git a/src/client/views/collections/CollectionLinearView.tsx b/src/client/views/collections/CollectionLinearView.tsx index 5c12bd126..07cab829d 100644 --- a/src/client/views/collections/CollectionLinearView.tsx +++ b/src/client/views/collections/CollectionLinearView.tsx @@ -7,7 +7,7 @@ import { documentSchema } from '../../../fields/documentSchemas'; import { Id } from '../../../fields/FieldSymbols'; import { makeInterface } from '../../../fields/Schema'; import { BoolCast, NumCast, ScriptCast, StrCast } from '../../../fields/Types'; -import { emptyFunction, returnTrue, Utils, emptyPath, returnEmptyDoclist } from '../../../Utils'; +import { emptyFunction, returnTrue, Utils, emptyPath, returnEmptyDoclist, returnFalse } from '../../../Utils'; import { DragManager } from '../../util/DragManager'; import { Transform } from '../../util/Transform'; import { DocumentLinksButton } from '../nodes/DocumentLinksButton'; @@ -140,6 +140,8 @@ export class CollectionLinearView extends CollectionSubView(LinearDocument) { <DocumentView Document={pair.layout} DataDoc={pair.data} + isContentActive={returnFalse} + isDocumentActive={returnTrue} addDocument={this.props.addDocument} moveDocument={this.props.moveDocument} addDocTab={this.props.addDocTab} diff --git a/src/client/views/collections/CollectionSchemaView.tsx b/src/client/views/collections/CollectionSchemaView.tsx index d49403d8e..b33c437a9 100644 --- a/src/client/views/collections/CollectionSchemaView.tsx +++ b/src/client/views/collections/CollectionSchemaView.tsx @@ -410,6 +410,8 @@ export class CollectionSchemaView extends CollectionSubView(doc => doc) { rootSelected={this.rootSelected} PanelWidth={this.previewWidth} PanelHeight={this.previewHeight} + isContentActive={returnTrue} + isDocumentActive={returnFalse} ScreenToLocalTransform={this.getPreviewTransform} docFilters={this.docFilters} docRangeFilters={this.docRangeFilters} diff --git a/src/client/views/collections/CollectionTreeView.tsx b/src/client/views/collections/CollectionTreeView.tsx index d80534ef9..7177edfc4 100644 --- a/src/client/views/collections/CollectionTreeView.tsx +++ b/src/client/views/collections/CollectionTreeView.tsx @@ -84,19 +84,15 @@ export class CollectionTreeView extends CollectionSubView<Document, Partial<coll return false; }); @action - addDoc = (doc: Doc | Doc[], relativeTo: Opt<Doc>, before?: boolean): boolean => { + addDoc = (docs: Doc | Doc[], relativeTo: Opt<Doc>, before?: boolean): boolean => { const doAddDoc = (doc: Doc | Doc[]) => - (doc instanceof Doc ? [doc] : doc).reduce((flg, doc) => - flg && Doc.AddDocToList(this.doc[DataSym], this.props.fieldKey, doc, relativeTo, before, false, false, false), true); - if (this.doc.resolvedDataDoc instanceof Promise) { - this.doc.resolvedDataDoc.then((resolved: any) => doAddDoc(doc)); - } else if (relativeTo === undefined) { - this.props.addDocument?.(doc); - } else { - doAddDoc(doc); - (doc instanceof Doc ? [doc] : doc).forEach(d => d.context = this.props.Document); - } - return true; + (doc instanceof Doc ? [doc] : doc).reduce((flg, doc) => { + const res = flg && Doc.AddDocToList(this.doc[DataSym], this.props.fieldKey, doc, relativeTo, before); + res && (doc.context = this.props.Document); + return res; + }, true); + if (this.doc.resolvedDataDoc instanceof Promise) return false; + return relativeTo === undefined ? this.props.addDocument?.(docs) || false : doAddDoc(docs); } onContextMenu = (e: React.MouseEvent): void => { // need to test if propagation has stopped because GoldenLayout forces a parallel react hierarchy to be created for its top-level layout @@ -116,7 +112,7 @@ export class CollectionTreeView extends CollectionSubView<Document, Partial<coll onTreeDrop = (e: React.DragEvent) => this.onExternalDrop(e, {}); @computed get renderClearButton() { - return !this.doc.allowClear ? (null) : <div key="toolbar"> + return !this.doc.treeViewShowClearButton ? (null) : <div key="toolbar"> <button className="toolbar-button round-button" title="Empty" onClick={undoBatch(action(() => Doc.GetProto(this.doc)[this.props.fieldKey] = undefined))}> <FontAwesomeIcon icon={"trash"} size="sm" /> </button> @@ -193,17 +189,14 @@ export class CollectionTreeView extends CollectionSubView<Document, Partial<coll </div>; } @computed get treeViewtruncateTitleWidth() { return NumCast(this.doc.treeViewTruncateTitleWidth, this.panelWidth()); } - truncateTitleWidth = () => this.treeViewtruncateTitleWidth; + @computed get treeChildren() { return this.props.childDocuments || this.childDocs; } @computed get outlineMode() { return this.doc.treeViewType === "outline"; } @computed get fileSysMode() { return this.doc.treeViewType === "fileSystem"; } + truncateTitleWidth = () => this.treeViewtruncateTitleWidth; onChildClick = () => this.props.onChildClick?.() || ScriptCast(this.doc.onChildClick); whenChildContentsActiveChanged = (isActive: boolean) => { this.props.whenChildContentsActiveChanged(this._isChildActive = isActive); }; active = (outsideReaction: boolean | undefined) => this.props.isContentActive(outsideReaction) || this._isChildActive; panelWidth = () => this.props.PanelWidth() - 20; // bcz: 20 is the 10 + 10 for the left and right padding. - @computed get treeChildren() { - TraceMobx(); - return this.props.childDocuments || this.childDocs; - } @computed get treeViewElements() { TraceMobx(); const dropAction = StrCast(this.doc.childDropAction) as dropActionType; diff --git a/src/client/views/collections/SchemaTable.tsx b/src/client/views/collections/SchemaTable.tsx index c91942c05..0c69ee030 100644 --- a/src/client/views/collections/SchemaTable.tsx +++ b/src/client/views/collections/SchemaTable.tsx @@ -15,7 +15,7 @@ import { ComputedField } from "../../../fields/ScriptField"; import { Cast, FieldValue, NumCast, StrCast } from "../../../fields/Types"; import { ImageField } from "../../../fields/URLField"; import { GetEffectiveAcl } from "../../../fields/util"; -import { emptyFunction, emptyPath, returnEmptyDoclist, returnEmptyFilter, returnFalse } from "../../../Utils"; +import { emptyFunction, emptyPath, returnEmptyDoclist, returnEmptyFilter, returnFalse, returnTrue } from "../../../Utils"; import { Docs, DocumentOptions, DocUtils } from "../../documents/Documents"; import { DocumentType } from "../../documents/DocumentTypes"; import { CompileScript, Transformer, ts } from "../../util/Scripting"; @@ -559,15 +559,15 @@ export class SchemaTable extends React.Component<SchemaTableProps> { onPointerDown={this.props.onPointerDown} onClick={this.props.onClick} onWheel={e => this.props.active(true) && e.stopPropagation()} onDrop={e => this.props.onDrop(e, {})} onContextMenu={this.onContextMenu} > {this.reactTable} - {this.props.Document._chromeHidden ? undefined : <div className="collectionSchemaView-addRow" onClick={() => this.createRow()}>+ new</div>} + {this.props.Document._chromeHidden ? undefined : <div className="collectionSchemaView-addRow" onClick={this.createRow}>+ new</div>} {!this._showDoc ? (null) : - <div className="collectionSchemaView-documentPreview" + <div className="collectionSchemaView-documentPreview" ref="overlay" style={{ position: "absolute", width: 150, height: 150, background: "dimGray", display: "block", top: 0, left: 0, transform: `translate(${this._showDocPos[0]}px, ${this._showDocPos[1] - 180}px)` - }} - ref="overlay"><DocumentView + }} > + <DocumentView Document={this._showDoc} DataDoc={this._showDataDoc} styleProvider={DefaultStyleProvider} @@ -576,7 +576,9 @@ export class SchemaTable extends React.Component<SchemaTableProps> { freezeDimensions={true} focus={DocUtils.DefaultFocus} renderDepth={this.props.renderDepth} - rootSelected={() => false} + rootSelected={returnFalse} + isContentActive={returnTrue} + isDocumentActive={returnFalse} PanelWidth={() => 150} PanelHeight={() => 150} ScreenToLocalTransform={this.getPreviewTransform} diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx index 950fc4a25..512ec81f8 100644 --- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx +++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx @@ -36,7 +36,6 @@ import { ActiveArrowEnd, ActiveArrowStart, ActiveDash, ActiveFillColor, ActiveIn import { LightboxView } from "../../LightboxView"; import { CollectionFreeFormDocumentView } from "../../nodes/CollectionFreeFormDocumentView"; import { DocFocusOptions, DocumentView, DocumentViewProps, ViewAdjustment, ViewSpecPrefix } from "../../nodes/DocumentView"; -import { FieldViewProps } from "../../nodes/FieldView"; import { FormattedTextBox } from "../../nodes/formattedText/FormattedTextBox"; import { pageSchema } from "../../nodes/ImageBox"; import { PresBox } from "../../nodes/PresBox"; |
