aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/views/collections/collectionSchema/CollectionSchemaView.tsx12
-rw-r--r--src/client/views/collections/collectionSchema/SchemaTableCell.tsx28
2 files changed, 19 insertions, 21 deletions
diff --git a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
index ac9b57414..d75f076d2 100644
--- a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
+++ b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
@@ -523,16 +523,13 @@ export class CollectionSchemaView extends CollectionSubView() {
this.removeCellHighlights();
const randomRGBColor = (): string[] => {
- let r; let g; let b;
const brightness = 450;
- r = Math.floor(Math.random() * 256);
- g = Math.floor(Math.random() * Math.min(256, brightness - r));
- b = Math.floor(brightness - r - g);
+ const r = Math.floor(Math.random() * 256);
+ const g = Math.floor(Math.random() * Math.min(256, brightness - r));
+ const b = Math.floor(brightness - r - g);
const lightenedRGB = ClientUtils.lightenRGB(r, g, b, 65);
- const rL = lightenedRGB[0];
- const gL = lightenedRGB[1];
- const bL = lightenedRGB[2];
+ const rL = lightenedRGB[0]; const gL = lightenedRGB[1]; const bL = lightenedRGB[2]; // prettier-ignore
const bgdRGB = {rL, gL, bL};
return new Array<string>(`rgb(${r}, ${g}, ${b})`, `rgb(${bgdRGB.rL}, ${bgdRGB.gL}, ${bgdRGB.bL})`);
@@ -542,7 +539,6 @@ export class CollectionSchemaView extends CollectionSubView() {
this._highlightedCells = [...cellsToHighlight];
this._highlightedCells.forEach(cell => {
const color = randomRGBColor();
- console.log('border: ' + color[0] + ' background: ' + color[1])
if (!this._cellHighlightColors.has(cell)) {this._cellHighlightColors.set(cell, new Array<string>(`solid 2px ${color[0]}`, color[1]))}
cell.style.border = this._cellHighlightColors.get(cell)[0];
cell.style.backgroundColor = this._cellHighlightColors.get(cell)[1];
diff --git a/src/client/views/collections/collectionSchema/SchemaTableCell.tsx b/src/client/views/collections/collectionSchema/SchemaTableCell.tsx
index 26dc9c3c2..69880b280 100644
--- a/src/client/views/collections/collectionSchema/SchemaTableCell.tsx
+++ b/src/client/views/collections/collectionSchema/SchemaTableCell.tsx
@@ -81,13 +81,11 @@ export class SchemaTableCell extends ObservableReactComponent<SchemaTableCellPro
makeObservable(this);
}
- get isDefault(){
- return SchemaColumnHeader.isDefaultField(this._props.fieldKey);
- }
+ get docIndex(){return DocumentView.getDocViewIndex(this._props.Document);} // prettier-ignore
- get lockedInteraction(){
- return (this.isDefault || this._props.Document._lockedSchemaEditing);
- }
+ get isDefault(){return SchemaColumnHeader.isDefaultField(this._props.fieldKey);} // prettier-ignore
+
+ get lockedInteraction(){return (this.isDefault || this._props.Document._lockedSchemaEditing);} // prettier-ignore
get backgroundColor(){
if (this.lockedInteraction){
@@ -141,13 +139,12 @@ export class SchemaTableCell extends ObservableReactComponent<SchemaTableCellPro
const pointerEvents: 'all' | 'none' = !readOnly && isRowActive() ? 'all' : 'none';
return { color, textDecoration, fieldProps, cursor, pointerEvents };
}
-
- // openContextMenu = () => {
- // const cm = ContextMenu.Instance;
- // cm.clearItems();
-
- // }
+ adjustedHighlight = (field: string) => {
+ const pattern = /\bthis.\b/g;
+ const modField = field.replace(pattern, `d${this.docIndex}.`);
+ this._props.highlightCells(modField);
+ }
// parses a field from the "idToDoc(####)" format to DocumentId (d#) format for readability
cleanupField = (field: string) => {
@@ -158,6 +155,11 @@ export class SchemaTableCell extends ObservableReactComponent<SchemaTableCellPro
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());})
if (modField.charAt(modField.length - 1) === ';') modField = modField.substring(0, modField.length - 1);
+
+ const selfRefPattern = `d${this.docIndex}.${this._props.fieldKey}`
+ const selfRefRegX = RegExp(selfRefPattern, 'g');
+ if (selfRefRegX.exec(modField) !== null) { return 'Invalid'}
+
return modField;
}
@@ -175,7 +177,7 @@ export class SchemaTableCell extends ObservableReactComponent<SchemaTableCellPro
pointerEvents: this.lockedInteraction ? 'none' : pointerEvents,
}}>
<EditableView
- highlightCells={this._props.highlightCells}
+ highlightCells={this.adjustedHighlight}
ref={r => selectedCell(this._props) && this._props.autoFocus && r?.setIsFocused(true)}
oneLine={this._props.oneLine}
allowCRs={this._props.allowCRs}