aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormehekj <mehek.jethani@gmail.com>2023-01-28 23:27:17 -0500
committermehekj <mehek.jethani@gmail.com>2023-01-28 23:27:17 -0500
commit6c58ca9d473103624be82c6f2da90f22bafd7b98 (patch)
tree02b1ac45e68f3e61b54f22a1792d7241cb3b4c19 /src
parent9f139c7f0f571bdfea8ce99fc0a507724eb8fd74 (diff)
version without schemarow as documentview
Diffstat (limited to 'src')
-rw-r--r--src/client/documents/DocumentTypes.ts1
-rw-r--r--src/client/documents/Documents.ts11
-rw-r--r--src/client/views/collections/collectionSchema/CollectionSchemaView.scss6
-rw-r--r--src/client/views/collections/collectionSchema/CollectionSchemaView.tsx94
-rw-r--r--src/client/views/collections/collectionSchema/SchemaColumnHeader.tsx2
-rw-r--r--src/client/views/collections/collectionSchema/SchemaRowBox.tsx88
-rw-r--r--src/client/views/nodes/DocumentContentsView.tsx2
7 files changed, 53 insertions, 151 deletions
diff --git a/src/client/documents/DocumentTypes.ts b/src/client/documents/DocumentTypes.ts
index b910b26b0..d99cd2dac 100644
--- a/src/client/documents/DocumentTypes.ts
+++ b/src/client/documents/DocumentTypes.ts
@@ -40,7 +40,6 @@ export enum DocumentType {
SEARCHITEM = 'searchitem',
COMPARISON = 'comparison',
GROUP = 'group',
- SCHEMAROW = 'schemarow',
LINKDB = 'linkdb', // database of links ??? why do we have this
SCRIPTDB = 'scriptdb', // database of scripts
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index f6104d655..7de1221cc 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -26,7 +26,6 @@ import { ScriptingGlobals } from '../util/ScriptingGlobals';
import { undoBatch, UndoManager } from '../util/UndoManager';
import { CollectionDockingView } from '../views/collections/CollectionDockingView';
import { DimUnit } from '../views/collections/collectionMulticolumn/CollectionMulticolumnView';
-import { SchemaRowBox } from '../views/collections/collectionSchema/SchemaRowBox';
import { CollectionView } from '../views/collections/CollectionView';
import { ContextMenu } from '../views/ContextMenu';
import { ContextMenuProps } from '../views/ContextMenuItem';
@@ -651,12 +650,6 @@ export namespace Docs {
},
],
[
- DocumentType.SCHEMAROW,
- {
- layout: { view: SchemaRowBox, dataField: defaultDataKey },
- },
- ],
- [
DocumentType.LOADING,
{
layout: { view: LoadingBox, dataField: '' },
@@ -1148,10 +1141,6 @@ export namespace Docs {
return InstanceFromProto(Prototypes.get(DocumentType.DATAVIZ), new CsvField(url), { title: 'Data Viz', ...options });
}
- export function SchemaRowDocument(options?: DocumentOptions) {
- return InstanceFromProto(Prototypes.get(DocumentType.SCHEMAROW), undefined, { ...(options || {}) });
- }
-
export function DockDocument(documents: Array<Doc>, config: string, options: DocumentOptions, id?: string) {
return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { freezeChildren: 'remove|add', ...options, viewType: CollectionViewType.Docking, _viewType: CollectionViewType.Docking, dockingConfig: config }, id);
}
diff --git a/src/client/views/collections/collectionSchema/CollectionSchemaView.scss b/src/client/views/collections/collectionSchema/CollectionSchemaView.scss
index e0d0101a2..4fa5d80e2 100644
--- a/src/client/views/collections/collectionSchema/CollectionSchemaView.scss
+++ b/src/client/views/collections/collectionSchema/CollectionSchemaView.scss
@@ -126,16 +126,10 @@
}
}
-.schema-row-wrapper {
- max-height: 70px;
- overflow: hidden;
-}
-
.schema-header-row,
.schema-row {
display: flex;
flex-direction: row;
- height: 100%;
max-height: 70px;
overflow: auto;
diff --git a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
index c9f934aec..29b22c0d5 100644
--- a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
+++ b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
@@ -1,29 +1,28 @@
import React = require('react');
-import { action, computed, observable, ObservableMap, ObservableSet, trace, untracked } from 'mobx';
+import { action, computed, observable, ObservableMap, ObservableSet, untracked } from 'mobx';
import { observer } from 'mobx-react';
-import { DataSym, Doc, DocListCast, Opt, StrListCast } from '../../../../fields/Doc';
+import { Doc, DocListCast, Opt } from '../../../../fields/Doc';
import { Id } from '../../../../fields/FieldSymbols';
import { List } from '../../../../fields/List';
import { RichTextField } from '../../../../fields/RichTextField';
import { listSpec } from '../../../../fields/Schema';
import { BoolCast, Cast, StrCast } from '../../../../fields/Types';
import { ImageField } from '../../../../fields/URLField';
-import { emptyFunction, returnEmptyDoclist, returnEmptyFilter, returnEmptyString, returnFalse, returnTrue, setupMoveUpEvents, smoothScroll, Utils } from '../../../../Utils';
+import { emptyFunction, returnEmptyString, setupMoveUpEvents, Utils } from '../../../../Utils';
import { Docs, DocUtils } from '../../../documents/Documents';
import { DragManager } from '../../../util/DragManager';
import { SelectionManager } from '../../../util/SelectionManager';
+import { Transform } from '../../../util/Transform';
import { undoBatch } from '../../../util/UndoManager';
import { ContextMenu } from '../../ContextMenu';
import { ContextMenuProps } from '../../ContextMenuItem';
import { EditableView } from '../../EditableView';
+import { DocumentView } from '../../nodes/DocumentView';
import { FormattedTextBox } from '../../nodes/formattedText/FormattedTextBox';
import { CollectionSubView } from '../CollectionSubView';
import './CollectionSchemaView.scss';
import { SchemaColumnHeader } from './SchemaColumnHeader';
import { SchemaRowBox } from './SchemaRowBox';
-import { DocFocusOptions, DocumentView, ViewAdjustment } from '../../nodes/DocumentView';
-import { DefaultStyleProvider } from '../../StyleProvider';
-import { Transform } from '../../../util/Transform';
export enum ColumnType {
Number,
@@ -33,7 +32,7 @@ export enum ColumnType {
Image,
}
-const defaultColumnKeys: string[] = ['title', 'type', 'author', 'text', 'data', 'tags'];
+const defaultColumnKeys: string[] = ['title', 'type', 'author', 'text', 'data', 'creationDate'];
@observer
export class CollectionSchemaView extends CollectionSubView() {
@@ -399,25 +398,6 @@ export class CollectionSchemaView extends CollectionSubView() {
ContextMenu.Instance.displayMenu(x, y, undefined, true);
};
- focusDocument = (doc: Doc, options: DocFocusOptions) => {
- Doc.BrushDoc(doc);
-
- let focusSpeed = 0;
- const found = this._mainCont && Array.from(this._mainCont.getElementsByClassName('documentView-node')).find((node: any) => node.id === doc[Id]);
- if (found) {
- const top = found.getBoundingClientRect().top;
- const localTop = this.props.ScreenToLocalTransform().transformPoint(0, top);
- if (Math.floor(localTop[1]) !== 0) {
- smoothScroll((focusSpeed = options.zoomTime ?? 500), this._mainCont!, localTop[1] + this._mainCont!.scrollTop, options.easeFunc);
- }
- }
- const endFocus = async (moved: boolean) => options?.afterFocus?.(moved) ?? ViewAdjustment.doNothing;
- this.props.focus(this.rootDoc, {
- ...options,
- afterFocus: (didFocus: boolean) => new Promise<ViewAdjustment>(res => setTimeout(async () => res(await endFocus(didFocus)), focusSpeed)),
- });
- };
-
isChildContentActive = () =>
this.props.isDocumentActive?.() && (this.props.childDocumentsActive?.() || BoolCast(this.rootDoc.childDocumentsActive)) ? true : this.props.childDocumentsActive?.() === false || this.rootDoc.childDocumentsActive === false ? false : undefined;
@@ -465,52 +445,24 @@ export class CollectionSchemaView extends CollectionSubView() {
let dref: Opt<DocumentView>;
return (
- <div className="schema-row-wrapper">
- <DocumentView
- {...this.props}
- ref={r => (dref = r || undefined)}
- LayoutTemplate={this.props.childLayoutTemplate}
- LayoutTemplateString={SchemaRowBox.LayoutString(this.props.fieldKey)}
- renderDepth={this.props.renderDepth + 1}
- Document={doc}
- DataDoc={dataDoc}
- ContainingCollectionView={this.props.CollectionView}
- ContainingCollectionDoc={this.Document}
- PanelWidth={this.props.PanelWidth}
- PanelHeight={() => 70}
- styleProvider={DefaultStyleProvider}
- focus={this.focusDocument}
- docFilters={this.childDocFilters}
- docRangeFilters={this.childDocRangeFilters}
- searchFilterDocs={this.searchFilterDocs}
- rootSelected={this.rootSelected}
- ScreenToLocalTransform={() => this.getDocTransform(doc, dref)}
- bringToFront={emptyFunction}
- isContentActive={this.isChildContentActive}
- hideDecorations={true}
- hideTitle={true}
- hideDocumentButtonBar={true}
- />
- </div>
+ <SchemaRowBox
+ {...this.props}
+ key={index}
+ Document={doc}
+ ContainingCollectionDoc={this.props.CollectionView?.props.Document}
+ ContainingCollectionView={this.props.CollectionView}
+ rowIndex={index}
+ columnKeys={this.columnKeys}
+ columnWidths={this.displayColumnWidths}
+ rowMenuWidth={CollectionSchemaView._rowMenuWidth}
+ selectedDocs={this._selectedDocs}
+ selectRow={this.selectRow}
+ startDrag={this.startDrag}
+ dragging={this._isDragging}
+ dropIndex={this.setDropIndex}
+ addRowRef={this.addRowRef}
+ />
);
-
- // <SchemaRowBox
- // {...this.props}
- // key={index}
- // Document={doc}
- // ContainingCollectionDoc={this.props.CollectionView?.props.Document}
- // ContainingCollectionView={this.props.CollectionView}
- // rowIndex={index}
- // columnKeys={this.columnKeys}
- // columnWidths={this.displayColumnWidths}
- // rowMenuWidth={CollectionSchemaView._rowMenuWidth}
- // selectedDocs={this._selectedDocs}
- // selectRow={this.selectRow}
- // startDrag={this.startDrag}
- // dragging={this._isDragging}
- // dropIndex={this.setDropIndex}
- // addRowRef={this.addRowRef}
- // />
})}
</div>
</div>
diff --git a/src/client/views/collections/collectionSchema/SchemaColumnHeader.tsx b/src/client/views/collections/collectionSchema/SchemaColumnHeader.tsx
index a6a5f66ab..8e6d3d78a 100644
--- a/src/client/views/collections/collectionSchema/SchemaColumnHeader.tsx
+++ b/src/client/views/collections/collectionSchema/SchemaColumnHeader.tsx
@@ -40,7 +40,7 @@ export class SchemaColumnHeader extends React.Component<SchemaColumnHeaderProps>
case ColumnType.Boolean:
return (
<>
- <input type="checkbox" name="" id="" value={this._newFieldDefault ?? false} onPointerDown={e => e.stopPropagation()} onChange={action(e => (this._newFieldDefault = e.target.value))} />
+ <input type="checkbox" name="" id="" value={this._newFieldDefault} onPointerDown={e => e.stopPropagation()} onChange={action(e => (this._newFieldDefault = e.target.checked))} />
{this._newFieldDefault ? 'true' : 'false'}
</>
);
diff --git a/src/client/views/collections/collectionSchema/SchemaRowBox.tsx b/src/client/views/collections/collectionSchema/SchemaRowBox.tsx
index f790e9dbf..2cf0a1b79 100644
--- a/src/client/views/collections/collectionSchema/SchemaRowBox.tsx
+++ b/src/client/views/collections/collectionSchema/SchemaRowBox.tsx
@@ -1,20 +1,17 @@
import React = require('react');
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
-import { action, computed, ObservableMap, ObservableSet } from 'mobx';
+import { action, ObservableSet } from 'mobx';
import { observer } from 'mobx-react';
-import { Doc, StrListCast } from '../../../../fields/Doc';
+import { Doc } from '../../../../fields/Doc';
+import { DragManager } from '../../../util/DragManager';
import { undoBatch } from '../../../util/UndoManager';
import { ViewBoxBaseComponent } from '../../DocComponent';
import { Colors } from '../../global/globalEnums';
-import { FieldView, FieldViewProps } from '../../nodes/FieldView';
+import { OpenWhere } from '../../nodes/DocumentView';
+import { FieldViewProps } from '../../nodes/FieldView';
import './CollectionSchemaView.scss';
import { SchemaTableCell } from './SchemaTableCell';
-import { emptyFunction, setupMoveUpEvents } from '../../../../Utils';
-import { DragManager } from '../../../util/DragManager';
-import { OpenWhere } from '../../nodes/DocumentView';
-import { Cast } from '../../../../fields/Types';
-import { listSpec } from '../../../../fields/Schema';
-import { CollectionSchemaView } from './CollectionSchemaView';
+import { setupMoveUpEvents, emptyFunction } from '../../../../Utils';
export interface SchemaRowBoxProps extends FieldViewProps {
rowIndex: number;
@@ -30,61 +27,37 @@ export interface SchemaRowBoxProps extends FieldViewProps {
}
@observer
-export class SchemaRowBox extends ViewBoxBaseComponent<FieldViewProps>() {
- public static LayoutString(fieldKey: string) {
- return FieldView.LayoutString(SchemaRowBox, fieldKey);
- }
-
+export class SchemaRowBox extends ViewBoxBaseComponent<SchemaRowBoxProps>() {
private _ref: HTMLDivElement | null = null;
bounds = () => this._ref?.getBoundingClientRect();
- @computed get columnKeys() {
- return StrListCast(this.props.ContainingCollectionDoc?.columnKeys);
- }
-
- @computed get storedColumnWidths() {
- let widths = Cast(
- this.props.ContainingCollectionDoc?.columnWidths,
- listSpec('number'),
- this.columnKeys.map(() => (this.props.PanelWidth() - CollectionSchemaView._rowMenuWidth) / this.columnKeys.length)
- );
-
- const totalWidth = widths.reduce((sum, width) => sum + width, 0);
- if (totalWidth !== this.props.PanelWidth() - CollectionSchemaView._rowMenuWidth) {
- widths = widths.map(w => {
- const proportion = w / totalWidth;
- return proportion * (this.props.PanelWidth() - CollectionSchemaView._rowMenuWidth);
- });
- }
-
- return widths;
- }
+ isSelected = () => this.props.selectedDocs.has(this.props.Document);
@action
onRowPointerDown = (e: React.PointerEvent) => {
e.stopPropagation();
- // setupMoveUpEvents(
- // this,
- // e,
- // e => this.props.startDrag(e, this.props.Document, this._ref!, this.props.rowIndex),
- // emptyFunction,
- // e => this.props.selectRow(e, this.props.Document, this._ref!, this.props.rowIndex)
- // );
+ setupMoveUpEvents(
+ this,
+ e,
+ e => this.props.startDrag(e, this.props.Document, this._ref!, this.props.rowIndex),
+ emptyFunction,
+ e => this.props.selectRow(e, this.props.Document, this._ref!, this.props.rowIndex)
+ );
};
onPointerEnter = (e: any) => {
- // if (!this.props.dragging) return;
+ if (!this.props.dragging) return;
document.removeEventListener('pointermove', this.onPointerMove);
document.addEventListener('pointermove', this.onPointerMove);
};
onPointerMove = (e: any) => {
- // if (!this.props.dragging) return;
+ if (!this.props.dragging) return;
let dragIsRow: boolean = true;
DragManager.docsBeingDragged.forEach(doc => {
- // dragIsRow = this.props.selectedDocs.has(doc);
+ dragIsRow = this.props.selectedDocs.has(doc);
});
if (this._ref && dragIsRow) {
const rect = this._ref.getBoundingClientRect();
@@ -94,11 +67,11 @@ export class SchemaRowBox extends ViewBoxBaseComponent<FieldViewProps>() {
if (y <= halfLine) {
this._ref.style.borderTop = `solid 2px ${Colors.MEDIUM_BLUE}`;
this._ref.style.borderBottom = '0px';
- // this.props.dropIndex(this.props.rowIndex);
+ this.props.dropIndex(this.props.rowIndex);
} else if (y > halfLine) {
this._ref.style.borderTop = '0px';
this._ref.style.borderBottom = `solid 2px ${Colors.MEDIUM_BLUE}`;
- // this.props.dropIndex(this.props.rowIndex + 1);
+ this.props.dropIndex(this.props.rowIndex + 1);
}
}
};
@@ -115,22 +88,19 @@ export class SchemaRowBox extends ViewBoxBaseComponent<FieldViewProps>() {
return (
<div
className="schema-row"
- style={this.props.isSelected() ? { backgroundColor: Colors.LIGHT_BLUE } : {}}
- // style={this.isSelected() ? { backgroundColor: Colors.LIGHT_BLUE, opacity: this.props.dragging ? 0.5 : 1 } : {}}
- // onPointerDown={this.onRowPointerDown}
- // onPointerEnter={this.onPointerEnter}
+ style={this.isSelected() ? { backgroundColor: Colors.LIGHT_BLUE, opacity: this.props.dragging ? 0.5 : 1 } : {}}
+ onPointerDown={this.onRowPointerDown}
+ onPointerEnter={this.onPointerEnter}
onPointerLeave={this.onPointerLeave}
ref={(row: HTMLDivElement | null) => {
- // row && this.props.addRowRef(this.props.Document, row);
+ row && this.props.addRowRef(this.props.Document, row);
this._ref = row;
}}>
<div
className="row-menu"
- style={
- {
- /* width: this.props.rowMenuWidth */
- }
- }>
+ style={{
+ width: this.props.rowMenuWidth,
+ }}>
<div
className="schema-row-button"
onPointerDown={undoBatch(e => {
@@ -149,8 +119,8 @@ export class SchemaRowBox extends ViewBoxBaseComponent<FieldViewProps>() {
</div>
</div>
<div className="row-cells">
- {this.columnKeys.map((key, index) => (
- <SchemaTableCell key={key} Document={this.props.Document} fieldKey={key} columnWidth={this.storedColumnWidths[index]} />
+ {this.props.columnKeys.map((key, index) => (
+ <SchemaTableCell key={key} Document={this.props.Document} fieldKey={key} columnWidth={this.props.columnWidths[index]} />
))}
</div>
</div>
diff --git a/src/client/views/nodes/DocumentContentsView.tsx b/src/client/views/nodes/DocumentContentsView.tsx
index 459554ebe..569579996 100644
--- a/src/client/views/nodes/DocumentContentsView.tsx
+++ b/src/client/views/nodes/DocumentContentsView.tsx
@@ -44,7 +44,6 @@ import { WebBox } from './WebBox';
import React = require('react');
import XRegExp = require('xregexp');
import { LoadingBox } from './LoadingBox';
-import { SchemaRowBox } from '../collections/collectionSchema/SchemaRowBox';
const JsxParser = require('react-jsx-parser').default; //TODO Why does this need to be imported like this?
@@ -269,7 +268,6 @@ export class DocumentContentsView extends React.Component<
HTMLtag,
ComparisonBox,
LoadingBox,
- SchemaRowBox,
}}
bindings={bindings}
jsx={layoutFrame}