aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
diff options
context:
space:
mode:
authorNathan-SR <144961007+Nathan-SR@users.noreply.github.com>2024-06-12 21:16:17 -0400
committerNathan-SR <144961007+Nathan-SR@users.noreply.github.com>2024-06-12 21:16:17 -0400
commit60a4ccfe2ab6337c064da8a303336f1872f5e9a6 (patch)
treef1c4ce2d69f31ec53e2599771a6e9cf264a68a05 /src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
parent707a1a4cba9f0af9ee07b487eddf0f4ca85c8a78 (diff)
cell value parser for highlighting cells used in equation works; need to implement actual VU
Diffstat (limited to 'src/client/views/collections/collectionSchema/CollectionSchemaView.tsx')
-rw-r--r--src/client/views/collections/collectionSchema/CollectionSchemaView.tsx48
1 files changed, 43 insertions, 5 deletions
diff --git a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
index affa70a62..4d959e42c 100644
--- a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
+++ b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
@@ -39,6 +39,7 @@ import { listSpec } from '../../../../fields/Schema';
import { GetEffectiveAcl } from '../../../../fields/util';
import { ContextMenuProps } from '../../ContextMenuItem';
import { truncate } from 'lodash';
+import { DocumentManager } from '../../../util/DocumentManager';
const { SCHEMA_NEW_NODE_HEIGHT } = require('../../global/globalCssVariables.module.scss'); // prettier-ignore
@@ -481,6 +482,39 @@ export class CollectionSchemaView extends CollectionSubView() {
cellEles.slice(-1)[0].style.borderBottom = edgeStyle;
});
+ getCellElement = (doc: Doc, fieldKey: string) => {
+ const index = this.columnKeys.indexOf(fieldKey);
+ console.log(doc.title)
+ const cell = this._rowEles.get(doc).children[1].children[index];
+ return cell;
+ }
+
+ findCellRefs = (text: string) => {
+ const pattern = /(this|d(\d+))\.(\w+)/g;
+ interface Match { docRef: string; field: string; }
+
+ const matches: Match[] = [];
+ let match: RegExpExecArray | null;
+
+ while ((match = pattern.exec(text)) !== null) {
+ const docRef = match[1] === 'this' ? match[1] : match[2];
+ matches.push({ docRef, field: match[3] });
+ }
+
+ const cells: Array<any> = [];
+ matches.forEach((match: Match) => {
+ const {docRef, field} = match;
+ const doc = DocumentManager.Instance.DocumentViews[Number(docRef)].Document;
+ if (this.columnKeys.includes(field)) {cells.push(this.getCellElement(doc, field))}
+ })
+
+ console.log(cells);
+
+ return cells;
+ }
+
+
+
@action
addRowRef = (doc: Doc, ref: HTMLDivElement) => this._rowEles.set(doc, ref);
@@ -1012,22 +1046,26 @@ export class CollectionSchemaView extends CollectionSubView() {
}
};
- displayedSubCollectionDocs = (doc: Doc) => {
+ subCollectionDocs = (doc: Doc, displayed: boolean) => {
const childDocs = DocListCast(doc[Doc.LayoutFieldKey(doc)]);
- const displayedCollections = childDocs.filter(d => d.type === 'collection' && d._childrenSharedWithSchema);
+ 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];
- displayedCollections.forEach(d => toReturn = toReturn.concat(this.displayedSubCollectionDocs(d)));
+ collections.forEach(d => toReturn = toReturn.concat(this.subCollectionDocs(d, displayed)));
return toReturn;
}
-
+
@computed get docs() {
let docsFromChildren: Doc[] = [];
+
const displayedCollections = this.childDocs.filter(d => d.type === 'collection' && d._childrenSharedWithSchema);
displayedCollections.forEach(d => {
- let docsNotAlreadyDisplayed = this.displayedSubCollectionDocs(d).filter(dc => !this._docs.includes(dc));
+ let docsNotAlreadyDisplayed = this.subCollectionDocs(d, true).filter(dc => !this._docs.includes(dc));
docsFromChildren = docsFromChildren.concat(docsNotAlreadyDisplayed);
});
let docs = this._docs.concat(docsFromChildren);
+
return docs;
}