diff options
6 files changed, 44 insertions, 63 deletions
diff --git a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx index 11a4e88f9..51b3e1532 100644 --- a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx +++ b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx @@ -7,16 +7,15 @@ import * as React from 'react'; import { ClientUtils, returnEmptyDoclist, returnEmptyString, returnFalse, returnIgnore, returnNever, returnTrue, setupMoveUpEvents, smoothScroll } from '../../../../ClientUtils'; import { emptyFunction } from '../../../../Utils'; import { Doc, DocListCast, Field, FieldType, IdToDoc, NumListCast, Opt, StrListCast } from '../../../../fields/Doc'; -import { AclPrivate, DocData } from '../../../../fields/DocSymbols'; +import { DocData } from '../../../../fields/DocSymbols'; import { Id } from '../../../../fields/FieldSymbols'; import { List } from '../../../../fields/List'; import { ColumnType } from '../../../../fields/SchemaHeaderField'; -import { BoolCast, Cast, NumCast, StrCast } from '../../../../fields/Types'; +import { BoolCast, NumCast, StrCast } from '../../../../fields/Types'; import { DocUtils } from '../../../documents/DocUtils'; import { Docs, DocumentOptions, FInfo } from '../../../documents/Documents'; import { DragManager } from '../../../util/DragManager'; import { dropActionType } from '../../../util/DropActionTypes'; -import { SettingsManager } from '../../../util/SettingsManager'; import { undoBatch, undoable } from '../../../util/UndoManager'; import { ContextMenu } from '../../ContextMenu'; import { EditableView } from '../../EditableView'; @@ -31,20 +30,9 @@ import { CollectionSubView } from '../CollectionSubView'; import './CollectionSchemaView.scss'; import { SchemaColumnHeader } from './SchemaColumnHeader'; import { SchemaRowBox } from './SchemaRowBox'; -import { ActionButton } from '@adobe/react-spectrum'; -import { CollectionMasonryViewFieldRow } from '../CollectionMasonryViewFieldRow'; -import { Func } from 'mocha'; -import { CollectionView } from '../CollectionView'; -import { listSpec } from '../../../../fields/Schema'; -import { GetEffectiveAcl } from '../../../../fields/util'; import { ContextMenuProps } from '../../ContextMenuItem'; -import { truncate } from 'lodash'; import { DocumentManager } from '../../../util/DocumentManager'; -import { TbHemispherePlus } from 'react-icons/tb'; -import { docs_v1 } from 'googleapis'; import { SchemaCellField } from './SchemaCellField'; -import { threadId } from 'worker_threads'; -import { FontIconBox } from '../../nodes/FontIconBox/FontIconBox'; import { SnappingManager } from '../../../util/SnappingManager'; /** @@ -458,7 +446,7 @@ export class CollectionSchemaView extends CollectionSubView() { * @returns column index */ findColDropIndex = (mouseX: number) => { - let xOffset: number = this._props.ScreenToLocalTransform().inverse().transformPoint(0,0)[0] + CollectionSchemaView._rowMenuWidth; + const xOffset: number = this._props.ScreenToLocalTransform().inverse().transformPoint(0,0)[0] + CollectionSchemaView._rowMenuWidth; let index: number | undefined; this.displayColumnWidths.reduce((total, curr, i) => { if (total <= mouseX && total + curr >= mouseX) { @@ -562,7 +550,7 @@ export class CollectionSchemaView extends CollectionSubView() { */ highlightSortedColumn = (field?: string, descending?: boolean) => { let index = -1; - let highlightColors: string[] = []; + const highlightColors: string[] = []; const rowCount: number = this._containedDocs.length + 1; if (field || this.sortField){ index = this.columnKeys.indexOf(field || this.sortField); @@ -1169,20 +1157,20 @@ export class CollectionSchemaView extends CollectionSubView() { }; /** - * Gets docs contained by collections within the schema + * Gets docs contained by collections within the schema. Currently defunct. * @param doc * @param displayed * @returns */ - subCollectionDocs = (doc: Doc, displayed: boolean) => { - const childDocs = DocListCast(doc[Doc.LayoutFieldKey(doc)]); - let collections: Array<Doc> = []; - if (displayed) collections = childDocs.filter(d => d.type === 'collection' && d._childrenSharedWithSchema); - else collections = childDocs.filter(d => d.type === 'collection' && !d._childrenSharedWithSchema); - let toReturn: Doc[] = [...childDocs]; - collections.forEach(d => toReturn = toReturn.concat(this.subCollectionDocs(d, displayed))); - return toReturn; - } + // subCollectionDocs = (doc: Doc, displayed: boolean) => { + // const childDocs = DocListCast(doc[Doc.LayoutFieldKey(doc)]); + // let collections: Array<Doc> = []; + // if (displayed) collections = childDocs.filter(d => d.type === 'collection' && d._childrenSharedWithSchema); + // else collections = childDocs.filter(d => d.type === 'collection' && !d._childrenSharedWithSchema); + // let toReturn: Doc[] = [...childDocs]; + // collections.forEach(d => toReturn = toReturn.concat(this.subCollectionDocs(d, displayed))); + // return toReturn; + // } /** * Applies any filters active on the schema to filter out docs that don't match. @@ -1234,16 +1222,16 @@ export class CollectionSchemaView extends CollectionSubView() { * Returns all child docs of the schema and child docs of contained collections that satisfy applied filters. */ @computed get docs() { - let docsFromChildren: Doc[] = []; + //let docsFromChildren: Doc[] = []; - const displayedCollections = this.childDocs.filter(d => d.type === 'collection' && d._childrenSharedWithSchema); - displayedCollections.forEach(d => { - let docsNotAlreadyDisplayed = this.subCollectionDocs(d, true).filter(dc => !this._containedDocs.includes(dc)); - docsFromChildren = docsFromChildren.concat(docsNotAlreadyDisplayed); - }); - let docs = this.filteredDocs; + // Functionality for adding child docs + //const displayedCollections = this.childDocs.filter(d => d.type === 'collection' && d._childrenSharedWithSchema); + // displayedCollections.forEach(d => { + // let docsNotAlreadyDisplayed = this.subCollectionDocs(d, true).filter(dc => !this._containedDocs.includes(dc)); + // docsFromChildren = docsFromChildren.concat(docsNotAlreadyDisplayed); + // }); - return docs; + return this.filteredDocs;; } /** diff --git a/src/client/views/collections/collectionSchema/SchemaCellField.tsx b/src/client/views/collections/collectionSchema/SchemaCellField.tsx index 72dcc00e6..065544ac9 100644 --- a/src/client/views/collections/collectionSchema/SchemaCellField.tsx +++ b/src/client/views/collections/collectionSchema/SchemaCellField.tsx @@ -148,10 +148,8 @@ export class SchemaCellField extends ObservableReactComponent<SchemaCellFieldPro } } - let matchNum = 0; matches.forEach((match: string) => { chunkedText = chunkedText.replace(match, this.generateSpan(match, cells.get(match))); - ++matchNum; }) return chunkedText; @@ -365,7 +363,7 @@ export class SchemaCellField extends ObservableReactComponent<SchemaCellFieldPro className='schemaField-editing' ref={r => { this._inputref = r; }} style={{ cursor: 'text', outline: 'none', overflow: 'auto', minHeight: `min(100%, ${(this._props.GetValue()?.split('\n').length || 1) * 15})`, minWidth: 20, }} - onBlur={e => {this._props.refSelectModeInfo.enabled ? setTimeout(() => {this.setIsFocused(true)}, 1000) : this.finalizeEdit(false, true, false)}} + onBlur={() => {this._props.refSelectModeInfo.enabled ? setTimeout(() => {this.setIsFocused(true)}, 1000) : this.finalizeEdit(false, true, false)}} autoFocus onInput={this.onChange} onKeyDown={this.onKeyDown} diff --git a/src/client/views/collections/collectionSchema/SchemaColumnHeader.tsx b/src/client/views/collections/collectionSchema/SchemaColumnHeader.tsx index 3495c5ab4..cf4fe4ef4 100644 --- a/src/client/views/collections/collectionSchema/SchemaColumnHeader.tsx +++ b/src/client/views/collections/collectionSchema/SchemaColumnHeader.tsx @@ -147,7 +147,7 @@ export class SchemaColumnHeader extends ObservableReactComponent<SchemaColumnHea this._altTitle = undefined; this._props.finishEdit?.(); return true; - } else if (enterKey) this.updateAlt(value); + } this._props.finishEdit?.(); return true; }, 'edit column header')} @@ -157,7 +157,7 @@ export class SchemaColumnHeader extends ObservableReactComponent<SchemaColumnHea public static isDefaultField = (key: string) => { const defaultPattern = /EmptyColumnKey/; - let isDefault: boolean = (defaultPattern.exec(key) != null); + const isDefault: boolean = (defaultPattern.exec(key) != null); return isDefault; } @@ -220,7 +220,7 @@ export class SchemaColumnHeader extends ObservableReactComponent<SchemaColumnHea setupMoveUpEvents( this, e, - e => {return this._inputRef?.setIsEditing(false) ?? false}, + () => {return this._inputRef?.setIsEditing(false) ?? false}, emptyFunction, emptyFunction, ); diff --git a/src/client/views/collections/collectionSchema/SchemaRowBox.tsx b/src/client/views/collections/collectionSchema/SchemaRowBox.tsx index b928a5c67..a8a4ef2c2 100644 --- a/src/client/views/collections/collectionSchema/SchemaRowBox.tsx +++ b/src/client/views/collections/collectionSchema/SchemaRowBox.tsx @@ -3,27 +3,21 @@ import { computed, makeObservable, observable } from 'mobx'; import { observer } from 'mobx-react'; import { computedFn } from 'mobx-utils'; import * as React from 'react'; -import { CgClose, CgLock, CgLockUnlock, CgMenu } from 'react-icons/cg'; -import { FaExternalLinkAlt } from 'react-icons/fa'; import { returnFalse, setupMoveUpEvents } from '../../../../ClientUtils'; import { emptyFunction } from '../../../../Utils'; -import { Doc, DocListCast, FieldResult } from '../../../../fields/Doc'; +import { Doc } from '../../../../fields/Doc'; import { BoolCast } from '../../../../fields/Types'; import { Transform } from '../../../util/Transform'; import { undoable } from '../../../util/UndoManager'; import { ViewBoxBaseComponent } from '../../DocComponent'; -import { Colors } from '../../global/globalEnums'; import { FieldView, FieldViewProps } from '../../nodes/FieldView'; import { OpenWhere } from '../../nodes/OpenWhere'; import { CollectionSchemaView } from './CollectionSchemaView'; import './CollectionSchemaView.scss'; import { SchemaTableCell } from './SchemaTableCell'; import { ContextMenu } from '../../ContextMenu'; -import { CollectionFreeFormView } from '../collectionFreeForm'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { IconProp } from '@fortawesome/fontawesome-svg-core'; -import { infoState } from '../collectionFreeForm/CollectionFreeFormInfoState'; -import { TbShieldX } from 'react-icons/tb'; /** * The SchemaRowBox renders a doc as a row of cells, with each cell representing @@ -78,16 +72,17 @@ export class SchemaRowBox extends ViewBoxBaseComponent<SchemaRowBoxProps>() { event: () => this.schemaView.removeDoc(this.Document), icon: 'minus', }); - const childDocs = DocListCast(this.Document[Doc.LayoutFieldKey(this.Document)]) - if (this.Document.type === 'collection' && childDocs.length) { - ContextMenu.Instance.addItem({ - description: this.Document._childrenSharedWithSchema ? 'Remove children from schema' : 'Add children to schema', - event: () => { - this.Document._childrenSharedWithSchema = !this.Document._childrenSharedWithSchema; - }, - icon: this.Document._childrenSharedWithSchema ? 'minus' : 'plus', - }); - } + // Defunct option to add child docs of collections to the main schema + // const childDocs = DocListCast(this.Document[Doc.LayoutFieldKey(this.Document)]) + // if (this.Document.type === 'collection' && childDocs.length) { + // ContextMenu.Instance.addItem({ + // description: this.Document._childrenSharedWithSchema ? 'Remove children from schema' : 'Add children to schema', + // event: () => { + // this.Document._childrenSharedWithSchema = !this.Document._childrenSharedWithSchema; + // }, + // icon: this.Document._childrenSharedWithSchema ? 'minus' : 'plus', + // }); + // } ContextMenu.Instance.displayMenu(x, y, undefined, false); } diff --git a/src/client/views/collections/collectionSchema/SchemaTableCell.tsx b/src/client/views/collections/collectionSchema/SchemaTableCell.tsx index 1bca3c84d..247739fd2 100644 --- a/src/client/views/collections/collectionSchema/SchemaTableCell.tsx +++ b/src/client/views/collections/collectionSchema/SchemaTableCell.tsx @@ -3,7 +3,7 @@ /* eslint-disable no-use-before-define */ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { Popup, Size, Type } from 'browndash-components'; -import { ObservableMap, action, computed, makeObservable, observable } from 'mobx'; +import { action, computed, makeObservable, observable } from 'mobx'; import { observer } from 'mobx-react'; import { extname } from 'path'; import * as React from 'react'; @@ -161,14 +161,10 @@ export class SchemaTableCell extends ObservableReactComponent<SchemaTableCellPro const idPattern = /idToDoc\((.*?)\)/g; let matches; - let results = new Array<[id: string, func: string]>(); + const results = new Array<[id: string, func: string]>(); while ((matches = idPattern.exec(field)) !== null) {results.push([matches[0], matches[1].replace(/"/g, '')]); } results.forEach((idFuncPair) => {modField = modField.replace(idFuncPair[0], 'd' + (DocumentView.getDocViewIndex(IdToDoc(idFuncPair[1]))).toString());}) - for (let i = 0; i < modField.length; ++i){ - - } - if (modField.endsWith(';')) modField = modField.substring(0, modField.length - 1); const inQuotes = (field: string) => {return ((field.startsWith('`') && field.endsWith('`')) || (field.startsWith("'") && field.endsWith("'")) || (field.startsWith('"') && field.endsWith('"')))} diff --git a/src/client/views/nodes/DataVizBox/DocCreatorMenu.tsx b/src/client/views/nodes/DataVizBox/DocCreatorMenu.tsx index bb9ea7e17..5d5c35dce 100644 --- a/src/client/views/nodes/DataVizBox/DocCreatorMenu.tsx +++ b/src/client/views/nodes/DataVizBox/DocCreatorMenu.tsx @@ -2181,4 +2181,8 @@ export class TemplateLayouts { // }] // }; +} + +export class ContentField extends Field { + }
\ No newline at end of file |