aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/views/collections/collectionSchema/CollectionSchemaView.tsx35
-rw-r--r--src/client/views/collections/collectionSchema/SchemaRowBox.tsx6
-rw-r--r--src/client/views/collections/collectionSchema/SchemaTableCell.tsx15
-rw-r--r--src/client/views/nodes/formattedText/DashFieldView.tsx3
4 files changed, 32 insertions, 27 deletions
diff --git a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
index 60b3ae4ab..e722e774d 100644
--- a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
+++ b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
@@ -87,8 +87,9 @@ export class CollectionSchemaView extends CollectionSubView() {
@observable _filterColumnIndex: number | undefined = undefined;
@observable _filterSearchValue: string = '';
//an array of selected docs and the index representing the selected column
- @observable selectedCol: number = 0;
- @observable _selectedCells: [Array<Doc>, number] | undefined;
+ @observable _selectedCol: number = 0;
+ @observable _selectedCells: Array<Doc> | undefined;
+
// target HTMLelement portal for showing a popup menu to edit cell values.
public get MenuTarget() {
@@ -197,7 +198,7 @@ export class CollectionSchemaView extends CollectionSubView() {
} else {
const shift: boolean = e.shiftKey;
- this.selectCell(newDoc, this._selectedCells ? this._selectedCells[1] : 2, shift);
+ this.selectCell(newDoc, this._selectedCol, shift);
this.scrollToDoc(newDoc, {});
}
}
@@ -218,7 +219,7 @@ export class CollectionSchemaView extends CollectionSubView() {
} else {
const shift: boolean = e.shiftKey;
- this.selectCell(newDoc, this._selectedCells ? this._selectedCells[1] : 2, shift);
+ this.selectCell(newDoc, this._selectedCol, shift);
this.scrollToDoc(newDoc, {});
}
}
@@ -228,16 +229,14 @@ export class CollectionSchemaView extends CollectionSubView() {
break;
case 'ArrowRight':
if (this._selectedCells) {
- this.selectCell(this._selectedCells[0][0], this._selectedCells[1] + 1, false);
+ ++this._selectedCol;
} else if (this._selectedDocs.length > 0) {
this.selectCell(this._selectedDocs[0], 0, false);
}
break;
case 'ArrowLeft':
if (this._selectedCells) {
- this._selectedCells = undefined;
- //this._selectedCells = [this._selectedCells[0], 2]
- //this._selectedCells[1] = Math.max(this._selectedCells[1] - 1, 0);
+ --this._selectedCol;
} else if (this._selectedDocs.length > 0) {
this.selectCell(this._selectedDocs[0], 0, false);
}
@@ -448,16 +447,16 @@ export class CollectionSchemaView extends CollectionSubView() {
for (let i = startRow; i <= endRow; i++) {
const currDoc = this.sortedDocs.docs[i];
if (!this._selectedDocs.includes(currDoc)) this.addDocToSelection(currDoc, true, i);
- this._selectedCells && this._selectedCells[0].push(currDoc);
+ this._selectedCells && this._selectedCells.push(currDoc);
}
};
@action
selectCell = (doc: Doc, index: number, shiftKey: boolean) => {
!shiftKey && this.deselectAllCells();
- !this._selectedCells && (this._selectedCells = [[], index]);
- this._selectedCells[0].push(doc);
- this._selectedCells[1] = index;
+ !this._selectedCells && (this._selectedCells = []);
+ this._selectedCells.push(doc);
+ this._selectedCol = index;
if (!this) return;
const lastSelected = Array.from(this._selectedDocs).lastElement();
@@ -466,16 +465,18 @@ export class CollectionSchemaView extends CollectionSubView() {
this.addDocToSelection(doc, false, this.rowIndex(doc));
}
- let selectedIndexes: Array<Number> = this._selectedCells[0].map(doc => this.rowIndex(doc));
+ let selectedIndexes: Array<Number> = this._selectedCells.map(doc => this.rowIndex(doc));
console.log("cells: " + selectedIndexes);
+ console.log("index: " + this._selectedCol);
+
};
@action
deselectCell = (doc: Doc) => {
if (this._selectedCells)
- this._selectedCells[0] = this._selectedCells[0].filter(d => d !== doc);
+ this._selectedCells = this._selectedCells.filter(d => d !== doc);
if (this._selectedCells){
- let selectedIndexes: Array<Number> = this._selectedCells[0].map(doc => this.rowIndex(doc));
+ let selectedIndexes: Array<Number> = this._selectedCells.map(doc => this.rowIndex(doc));
console.log("cells: " + selectedIndexes);
}
};
@@ -607,7 +608,7 @@ export class CollectionSchemaView extends CollectionSubView() {
setColumnValues = (key: string, value: string) => {
this.childDocs.forEach(doc => {
- let docIsSelected = this._selectedCells && !(this._selectedCells[0]?.filter(d => d === doc).length === 0);
+ let docIsSelected = this._selectedCells && !(this._selectedCells?.filter(d => d === doc).length === 0);
console.log(docIsSelected);
if (docIsSelected){
KeyValueBox.SetField(doc, key, value)
@@ -621,7 +622,7 @@ export class CollectionSchemaView extends CollectionSubView() {
setSelectedColumnValues = (key: string, value: string) => {
console.log("called");
this.childDocs.forEach(doc => {
- let docIsSelected = this._selectedCells && !(this._selectedCells[0]?.filter(d => d === doc).length === 0);
+ let docIsSelected = this._selectedCells && !(this._selectedCells?.filter(d => d === doc).length === 0);
if (docIsSelected){
KeyValueBox.SetField(doc, key, value)
}
diff --git a/src/client/views/collections/collectionSchema/SchemaRowBox.tsx b/src/client/views/collections/collectionSchema/SchemaRowBox.tsx
index af502dd03..e3654facb 100644
--- a/src/client/views/collections/collectionSchema/SchemaRowBox.tsx
+++ b/src/client/views/collections/collectionSchema/SchemaRowBox.tsx
@@ -98,10 +98,11 @@ export class SchemaRowBox extends ViewBoxBaseComponent<SchemaRowBoxProps>() {
document.removeEventListener('pointermove', this.onPointerMove);
};
+ selectedCol = () => this.schemaView._selectedCol;
getFinfo = computedFn((fieldKey: string) => this.schemaView?.fieldInfos.get(fieldKey));
selectCell = (doc: Doc, col: number, shift: boolean) => this.schemaView?.selectCell(doc, col, shift);
deselectCell = () => this.schemaView?.deselectAllCells();
- selectedCell = () => this.schemaView?._selectedCells;
+ selectedCells = () => this.schemaView?._selectedCells;
setColumnValues = (field: any, value: any) => this.schemaView?.setColumnValues(field, value) ?? false;
setSelectedColumnValues = (field: any, value: any) => this.schemaView?.setSelectedColumnValues(field, value) ?? false;
columnWidth = computedFn((index: number) => () => this.schemaView?.displayColumnWidths[index] ?? CollectionSchemaView._minColWidth);
@@ -187,7 +188,8 @@ export class SchemaRowBox extends ViewBoxBaseComponent<SchemaRowBoxProps>() {
getFinfo={this.getFinfo}
selectCell={this.selectCell}
deselectCell={this.deselectCell}
- selectedCells={this.selectedCell}
+ selectedCells={this.selectedCells}
+ selectedCol={this.selectedCol}
setColumnValues={this.setColumnValues}
setSelectedColumnValues={this.setSelectedColumnValues}
oneLine={BoolCast(this.schemaDoc?._singleLine)}
diff --git a/src/client/views/collections/collectionSchema/SchemaTableCell.tsx b/src/client/views/collections/collectionSchema/SchemaTableCell.tsx
index cae16be36..52c34e8d6 100644
--- a/src/client/views/collections/collectionSchema/SchemaTableCell.tsx
+++ b/src/client/views/collections/collectionSchema/SchemaTableCell.tsx
@@ -36,7 +36,8 @@ export interface SchemaTableCellProps {
col: number;
deselectCell: () => void;
selectCell: (doc: Doc, col: number, shift: boolean) => void;
- selectedCells: () => [Doc[], number] | undefined;
+ selectedCells: () => Doc[] | undefined;
+ selectedCol: () => number;
fieldKey: string;
maxWidth?: () => number;
columnWidth: () => number;
@@ -108,9 +109,9 @@ export class SchemaTableCell extends ObservableReactComponent<SchemaTableCellPro
}
@computed get selected() {
- const selected: [Doc[], number] | undefined = this._props.selectedCells();
- let istrue = this._props.isRowActive() && (selected && selected[0]?.filter(doc => doc === this._props.Document).length !== 0) && selected[1] === this._props.col;
- //console.log("col: " + this._props.col + "true: " + istrue);
+ const selected: Doc[] | undefined = this._props.selectedCells();
+ let istrue = this._props.isRowActive() && (selected && selected?.filter(doc => doc === this._props.Document).length !== 0) && this._props.selectedCol() === this._props.col;
+ console.log("col: " + this._props.col + " selCol: " + this._props.selectedCol() + " true: " + istrue);
return istrue;
}
@@ -320,7 +321,7 @@ export class SchemaRTFCell extends ObservableReactComponent<SchemaTableCellProps
@computed get selected() {
const selected = this._props.selectedCells();
- return this._props.isRowActive() && (selected && selected[0]?.filter(doc => doc === this._props.Document).length !== 0) && selected[1] === this._props.col;
+ return this._props.isRowActive() && (selected && selected?.filter(doc => doc === this._props.Document).length !== 0) && this._props.selectedCol() === this._props.col;
//return this._props.isRowActive() && selected?.[0] === this._props.Document && selected[1] === this._props.col;
}
selectedFunc = () => this.selected;
@@ -343,7 +344,7 @@ export class SchemaBoolCell extends ObservableReactComponent<SchemaTableCellProp
@computed get selected() {
const selected = this._props.selectedCells();
- return this._props.isRowActive() && (selected && selected[0]?.filter(doc => doc === this._props.Document).length !== 0) && selected[1] === this._props.col;
+ return this._props.isRowActive() && (selected && selected?.filter(doc => doc === this._props.Document).length !== 0) && this._props.selectedCol() === this._props.col;
}
render() {
const { color, textDecoration, fieldProps, cursor, pointerEvents } = SchemaTableCell.renderProps(this._props);
@@ -387,7 +388,7 @@ export class SchemaEnumerationCell extends ObservableReactComponent<SchemaTableC
@computed get selected() {
const selected = this._props.selectedCells();
- return this._props.isRowActive() && (selected && selected[0]?.filter(doc => doc === this._props.Document).length !== 0) && selected[1] === this._props.col;
+ return this._props.isRowActive() && (selected && selected?.filter(doc => doc === this._props.Document).length !== 0) && this._props.selectedCol() === this._props.col;
}
render() {
const { color, textDecoration, fieldProps, cursor, pointerEvents } = SchemaTableCell.renderProps(this._props);
diff --git a/src/client/views/nodes/formattedText/DashFieldView.tsx b/src/client/views/nodes/formattedText/DashFieldView.tsx
index 631de1241..66db06d69 100644
--- a/src/client/views/nodes/formattedText/DashFieldView.tsx
+++ b/src/client/views/nodes/formattedText/DashFieldView.tsx
@@ -140,7 +140,8 @@ export class DashFieldViewInternal extends ObservableReactComponent<IDashFieldVi
selectCell={emptyFunction}
maxWidth={this._props.hideKey ? undefined : this.return100}
columnWidth={this._props.hideKey ? () => this._props.tbox._props.PanelWidth() - 20 : returnZero}
- selectedCells={() => [[this._dashDoc!], 0]}
+ selectedCells={() => [this._dashDoc!]}
+ selectedCol={() => 0} //!!!
fieldKey={this._fieldKey}
rowHeight={returnZero}
isRowActive={() => this._expanded && this._props.editable}