aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/documents/Documents.ts1
-rw-r--r--src/client/util/DocumentManager.ts11
-rw-r--r--src/client/util/Scripting.ts1
-rw-r--r--src/client/views/collections/collectionSchema/CollectionSchemaView.tsx10
-rw-r--r--src/client/views/collections/collectionSchema/SchemaColumnHeader.tsx140
-rw-r--r--src/client/views/nodes/DocumentIcon.tsx2
-rw-r--r--src/client/views/nodes/DocumentView.tsx1
7 files changed, 92 insertions, 74 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index 3cc0d5604..5e1b173dc 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -178,6 +178,7 @@ export class DocumentOptions {
map_pitch?: NUMt = new NumInfo('pitch of a map view', false);
map_bearing?: NUMt = new NumInfo('bearing of a map view', false);
map_style?: STRt = new StrInfo('mapbox style for a map view', false);
+ identifier?: STRt = new StrInfo('documentIcon displayed for each doc as "d[x]"', false);
date_range?: STRt = new StrInfo('date range for calendar', false);
diff --git a/src/client/util/DocumentManager.ts b/src/client/util/DocumentManager.ts
index 97051207b..8dba54541 100644
--- a/src/client/util/DocumentManager.ts
+++ b/src/client/util/DocumentManager.ts
@@ -46,6 +46,7 @@ export class DocumentManager {
DocumentView.addViewRenderedCb = this.AddViewRenderedCb;
DocumentView.getFirstDocumentView = this.getFirstDocumentView;
DocumentView.getDocumentView = this.getDocumentView;
+ DocumentView.getDocViewIndex = this.getDocViewIndex;
DocumentView.getContextPath = DocumentManager.GetContextPath;
DocumentView.getLightboxDocumentView = this.getLightboxDocumentView;
observe(Doc.CurrentlyLoading, change => {
@@ -138,6 +139,16 @@ export class DocumentManager {
);
}
+ public getDocViewIndex(target: Doc): number {
+ const docViewArray = DocumentManager.Instance.DocumentViews;
+ for (let i = 0; i < docViewArray.length; ++i){
+ if (docViewArray[i].Document == target){
+ return i;
+ }
+ }
+ return -1;
+ }
+
public getLightboxDocumentView = (toFind: Doc): DocumentView | undefined => {
const views: DocumentView[] = [];
DocumentManager.Instance.DocumentViews.forEach(view => DocumentView.LightboxContains(view) && Doc.AreProtosEqual(view.Document, toFind) && views.push(view));
diff --git a/src/client/util/Scripting.ts b/src/client/util/Scripting.ts
index 6948469cc..6ef592ef2 100644
--- a/src/client/util/Scripting.ts
+++ b/src/client/util/Scripting.ts
@@ -88,7 +88,6 @@ function Run(script: string | undefined, customParams: string[], diagnostics: an
if (!options.editable) {
batch = Doc.MakeReadOnly();
}
-
const result = compiledFunction.apply(thisParam, params).apply(thisParam, argsArray);
batch?.end();
return { success: true, result };
diff --git a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
index c9d5307c9..deeba3c7a 100644
--- a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
+++ b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
@@ -312,10 +312,10 @@ export class CollectionSchemaView extends CollectionSubView() {
let matches;
let results = new Map<string, string>();
while ((matches = idPattern.exec(field)) !== null) {
- results.set(matches[0], matches[1]);
+ results.set(matches[0], matches[1].replace(/"/g, ''));
}
results.forEach((id, funcId) => {
- modField = modField.replace(funcId, 'd' + (this.rowIndex(IdToDoc(id)) + 1).toString());
+ modField = modField.replace(funcId, 'd' + (DocumentView.getDocViewIndex(IdToDoc(id))).toString());
})
return modField;
}
@@ -549,7 +549,7 @@ export class CollectionSchemaView extends CollectionSubView() {
@action
selectCell = (doc: Doc, col: number, shiftKey: boolean, ctrlKey: boolean) => {
this.populateCellTags();
- console.log(this.getCellTag(doc, col));
+ //docs.findIndex(doc);
if (!shiftKey && !ctrlKey) this.clearSelection();
!this._selectedCells && (this._selectedCells = []);
!shiftKey && this._selectedCells && this._selectedCells.push(doc);
@@ -1211,6 +1211,10 @@ export class CollectionSchemaView extends CollectionSubView() {
{this.columnKeys.map((key, index) => (
<SchemaColumnHeader
// eslint-disable-next-line react/no-array-index-key
+ //cleanupField={this.cleanupComputedField}
+ schemaView={this}
+ columnWidth={() => CollectionSchemaView._minColWidth} //TODO: update
+ Document={this.Document}
key={index}
columnIndex={index}
columnKeys={this.columnKeys}
diff --git a/src/client/views/collections/collectionSchema/SchemaColumnHeader.tsx b/src/client/views/collections/collectionSchema/SchemaColumnHeader.tsx
index dad0c214b..b498a4850 100644
--- a/src/client/views/collections/collectionSchema/SchemaColumnHeader.tsx
+++ b/src/client/views/collections/collectionSchema/SchemaColumnHeader.tsx
@@ -3,15 +3,26 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { action, computed, observable } from 'mobx';
import { observer } from 'mobx-react';
import * as React from 'react';
-import { returnEmptyDoclist, returnEmptyFilter, returnFalse, setupMoveUpEvents } from '../../../../ClientUtils';
+import { returnEmptyDoclist, returnEmptyFilter, returnFalse, returnZero, setupMoveUpEvents } from '../../../../ClientUtils';
import { emptyFunction } from '../../../../Utils';
import { Colors } from '../../global/globalEnums';
import './CollectionSchemaView.scss';
import { EditableView } from '../../EditableView';
import { DefaultStyleProvider, returnEmptyDocViewList } from '../../StyleProvider';
import { FieldViewProps } from '../../nodes/FieldView';
+import { Doc, Field } from '../../../../fields/Doc';
+import { dropActionType } from '../../../util/DropActionTypes';
+import { Transform } from 'prosemirror-transform';
+import { SchemaTableCell } from './SchemaTableCell';
+import { DocCast } from '../../../../fields/Types';
+import { computedFn } from 'mobx-utils';
+import { CollectionSchemaView } from './CollectionSchemaView';
+import { SnappingManager } from '../../../util/SnappingManager';
+import { undoable } from '../../../util/UndoManager';
+import { FInfo } from '../../../documents/Documents';
export interface SchemaColumnHeaderProps {
+ Document: Doc;
autoFocus?: boolean;
oneLine?: boolean; // whether all input should fit on one line vs allowing textare multiline inputs
allowCRs?: boolean; // allow carriage returns in text input (othewrise CR ends the edit)
@@ -20,6 +31,8 @@ export interface SchemaColumnHeaderProps {
columnIndex: number;
sortField: string;
sortDesc: boolean;
+ schemaView: CollectionSchemaView;
+ //cleanupField: (s: string) => string;
isContentActive: (outsideReaction?: boolean | undefined) => boolean | undefined;
setSort: (field: string | undefined, desc?: boolean) => void;
removeColumn: (index: number) => void;
@@ -28,6 +41,10 @@ export interface SchemaColumnHeaderProps {
dragColumn: (e: any, index: number) => boolean;
openContextMenu: (x: number, y: number, index: number) => void;
setColRef: (index: number, ref: HTMLDivElement) => void;
+ rootSelected?: () => boolean;
+ columnWidth: () => number;
+ finishEdit?: () => void; // notify container that edit is over (eg. to hide view in DashFieldView)
+ //transform: () => Transform;
}
@observer
@@ -39,6 +56,9 @@ export class SchemaColumnHeader extends React.Component<SchemaColumnHeaderProps>
return this.props.columnKeys[this.props.columnIndex];
}
+ // getFinfo = computedFn((fieldKey: string) => this.props.schemaView?.fieldInfos.get(fieldKey));
+ // setColumnValues = (field: string, value: string) => this.props.schemaView?.setColumnValues(field, value);
+
@action
sortClicked = (e: React.PointerEvent) => {
e.stopPropagation();
@@ -57,76 +77,58 @@ export class SchemaColumnHeader extends React.Component<SchemaColumnHeaderProps>
this.props.isContentActive(true) && setupMoveUpEvents(this, e, moveEv => this.props.dragColumn(moveEv, this.props.columnIndex), emptyFunction, emptyFunction);
};
- public static renderProps(props: SchemaColumnHeaderProps) {
- const { Document, fieldKey, getFinfo, columnWidth, isContentActive } = props;
- let protoCount = 0;
- let doc: Doc | undefined = Document;
- while (doc) {
- if (Object.keys(doc).includes(fieldKey.replace(/^_/, ''))) {
- break;
- }
- protoCount++;
- doc = DocCast(doc.proto);
- }
- const parenCount = Math.max(0, protoCount - 1);
- const color = protoCount === 0 || (fieldKey.startsWith('_') && Document[fieldKey] === undefined) ? 'black' : 'blue'; // color of text in cells
- const textDecoration = color !== 'black' && parenCount ? 'underline' : '';
- const fieldProps: FieldViewProps = {
- childFilters: returnEmptyFilter,
- childFiltersByRanges: returnEmptyFilter,
- docViewPath: returnEmptyDocViewList,
- searchFilterDocs: returnEmptyDoclist,
- styleProvider: DefaultStyleProvider,
- isSelected: returnFalse,
- setHeight: returnFalse,
- select: emptyFunction,
- dragAction: dropActionType.move,
- renderDepth: 1,
- noSidebar: true,
- isContentActive: returnFalse,
- whenChildContentsActiveChanged: emptyFunction,
- ScreenToLocalTransform: Transform.Identity,
- focus: emptyFunction,
- addDocTab: SchemaTableCell.addFieldDoc,
- pinToPres: returnZero,
- Document: DocCast(Document.rootDocument, Document),
- fieldKey: fieldKey,
- PanelWidth: columnWidth,
- PanelHeight: props.rowHeight,
- rootSelected: props.rootSelected,
- };
- const readOnly = getFinfo(fieldKey)?.readOnly ?? false;
- const cursor = !readOnly ? 'text' : 'default';
- const pointerEvents = 'all';
- return { color, textDecoration, fieldProps, cursor, pointerEvents };
- }
-
- @computed get editableView() {
- const { color, textDecoration, fieldProps, pointerEvents } = SchemaColumnHeader.renderProps(this.props);
-
- return <EditableView
+ // public static renderProps(props: SchemaColumnHeaderProps) {
+ // const { columnKeys, columnWidth, isContentActive, Document } = props;
+ // const fieldKey = columnKeys[props.columnIndex];
+ // const color = 'black'; // color of text in cells
+ // const fieldProps: FieldViewProps = {
+ // childFilters: returnEmptyFilter,
+ // childFiltersByRanges: returnEmptyFilter,
+ // docViewPath: returnEmptyDocViewList,
+ // searchFilterDocs: returnEmptyDoclist,
+ // styleProvider: DefaultStyleProvider,
+ // isSelected: returnFalse,
+ // setHeight: returnFalse,
+ // select: emptyFunction,
+ // dragAction: dropActionType.move,
+ // renderDepth: 1,
+ // noSidebar: true,
+ // isContentActive: returnFalse,
+ // whenChildContentsActiveChanged: emptyFunction,
+ // ScreenToLocalTransform: Transform.Identity,
+ // focus: emptyFunction,
+ // addDocTab: SchemaTableCell.addFieldDoc,
+ // pinToPres: returnZero,
+ // Document: DocCast(Document.rootDocument, Document),
+ // fieldKey: fieldKey,
+ // PanelWidth: columnWidth,
+ // PanelHeight: props.rowHeight,
+ // rootSelected: props.rootSelected,
+ // };
+ // const readOnly = getFinfo(fieldKey)?.readOnly ?? false;
+ // const cursor = !readOnly ? 'text' : 'default';
+ // const pointerEvents = 'all';
+ // return { color, fieldProps, cursor, pointerEvents };
+ // }
+ // @computed get editableView() {
+ // const { color, fieldProps, pointerEvents } = SchemaColumnHeader.renderProps(this.props);
- ref={r => this.props.autoFocus && r?.setIsFocused(true)}
- oneLine={this.props.oneLine}
- allowCRs={this.props.allowCRs}
- contents={undefined}
- fieldContents={fieldProps}
- editing={this._editing ? undefined : false}
- GetValue={() => this._props.cleanupField(Field.toKeyValueString(fieldProps.Document, this._props.fieldKey, SnappingManager.MetaKey)).replace(/[";]/g, '')} //TODO: feed this into parser that handles idToDoc
- SetValue={undoable((value: string, shiftDown?: boolean, enterKey?: boolean) => {
- if (shiftDown && enterKey) {
- this._props.setColumnValues(this._props.fieldKey.replace(/^_/, ''), value);
- this._props.finishEdit?.();
- return true;
- }
- const hasNoLayout = Doc.IsDataProto(fieldProps.Document) ? true : undefined; // the "delegate" is a a data document so never write to it's proto
- const ret = Doc.SetField(fieldProps.Document, this._props.fieldKey.replace(/^_/, ''), value, hasNoLayout);
- this._props.finishEdit?.();
- return ret;
- }, 'edit schema cell')}
- />
- }
+ // return <EditableView
+ // ref={r => this.props.autoFocus && r?.setIsFocused(true)}
+ // oneLine={this.props.oneLine}
+ // allowCRs={this.props.allowCRs}
+ // contents={undefined}
+ // fieldContents={fieldProps}
+ // editing={this._editing ? undefined : false}
+ // GetValue={() => this.props.cleanupField(Field.toKeyValueString(fieldProps.Document, this.fieldKey, SnappingManager.MetaKey)).replace(/[";]/g, '')} //TODO: feed this into parser that handles idToDoc
+ // SetValue={undoable((value: string, enterKey?: boolean) => {
+ // if (enterKey) this.setColumnValues(this.fieldKey.replace(/^_/, ''), value);
+ // this.props.finishEdit?.();
+ // return true;
+ // }, 'edit schema cell')}
+ // />
+ // }
render() {
return (
diff --git a/src/client/views/nodes/DocumentIcon.tsx b/src/client/views/nodes/DocumentIcon.tsx
index 23d934edb..bfca6cad8 100644
--- a/src/client/views/nodes/DocumentIcon.tsx
+++ b/src/client/views/nodes/DocumentIcon.tsx
@@ -47,7 +47,7 @@ export class DocumentIcon extends ObservableReactComponent<DocumentIconProps> {
}
}
-@observer
+@observer
export class DocumentIconContainer extends React.Component {
public static getTransformer(): Transformer {
const usedDocuments = new Set<number>();
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index 8df28a770..32480447d 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -1025,6 +1025,7 @@ export class DocumentView extends DocComponent<DocumentViewProps>() {
public static getViews = (doc?: Doc) => Array.from(doc?.[DocViews] ?? []) as DocumentView[];
public static getFirstDocumentView: (toFind: Doc) => DocumentView | undefined;
public static getDocumentView: (target: Doc | undefined, preferredCollection?: DocumentView) => Opt<DocumentView>;
+ public static getDocViewIndex: (target: Doc) => number;
public static getContextPath: (doc: Opt<Doc>, includeExistingViews?: boolean) => Doc[];
public static getLightboxDocumentView: (toFind: Doc) => Opt<DocumentView>;
public static showDocumentView: (targetDocView: DocumentView, options: FocusViewOptions) => Promise<void>;