From 3fed87fe05a70a5ef63ed7989c7a28faee68bf4b Mon Sep 17 00:00:00 2001 From: mehekj Date: Wed, 22 Mar 2023 17:42:28 -0400 Subject: shift enter shortcut to fill column --- .../views/collections/collectionSchema/CollectionSchemaView.scss | 7 +++---- .../views/collections/collectionSchema/CollectionSchemaView.tsx | 7 +++++++ src/client/views/collections/collectionSchema/SchemaRowBox.tsx | 9 ++++++++- .../views/collections/collectionSchema/SchemaTableCell.tsx | 8 +++++++- 4 files changed, 25 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/client/views/collections/collectionSchema/CollectionSchemaView.scss b/src/client/views/collections/collectionSchema/CollectionSchemaView.scss index 1853fb589..287e2b01b 100644 --- a/src/client/views/collections/collectionSchema/CollectionSchemaView.scss +++ b/src/client/views/collections/collectionSchema/CollectionSchemaView.scss @@ -109,6 +109,8 @@ align-items: center; padding: 0; z-index: 1; + border: 1px solid $medium-gray; + overflow: hidden; .schema-column-title { flex-grow: 2; @@ -146,7 +148,6 @@ } .schema-row-wrapper { - // max-height: 70px; overflow: hidden; } @@ -159,16 +160,14 @@ display: flex; flex-direction: row; height: 100%; - // max-height: 70px; overflow: auto; } -.schema-column-header, .schema-table-cell, .row-menu { border: 1px solid $medium-gray; - padding: 5px; overflow: hidden; + padding: 5px; } .schema-row { diff --git a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx index 4498a2258..48db1467c 100644 --- a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx +++ b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx @@ -28,6 +28,7 @@ import { DocumentManager } from '../../../util/DocumentManager'; import { ScriptField } from '../../../../fields/ScriptField'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { IconButton } from 'browndash-components'; +import { KeyValueBox } from '../../nodes/KeyValueBox'; export enum ColumnType { Number, @@ -607,6 +608,12 @@ export class CollectionSchemaView extends CollectionSubView() { this.closeColumnMenu(); }; + setColumnValues = (key: string, value: string) => { + let success: boolean = true; + this.childDocs.forEach(doc => success && KeyValueBox.SetField(doc, key, value)); + return success; + }; + @action openColumnMenu = (index: number, newCol: boolean) => { this._makeNewColumn = false; diff --git a/src/client/views/collections/collectionSchema/SchemaRowBox.tsx b/src/client/views/collections/collectionSchema/SchemaRowBox.tsx index 05197d05f..37999484d 100644 --- a/src/client/views/collections/collectionSchema/SchemaRowBox.tsx +++ b/src/client/views/collections/collectionSchema/SchemaRowBox.tsx @@ -120,7 +120,14 @@ export class SchemaRowBox extends ViewBoxBaseComponent() {
{this.schemaView?.columnKeys?.map((key, index) => ( - + this.schemaView?.setColumnValues(field, value) ?? false} + /> ))}
diff --git a/src/client/views/collections/collectionSchema/SchemaTableCell.tsx b/src/client/views/collections/collectionSchema/SchemaTableCell.tsx index d475c3b6f..13e45963e 100644 --- a/src/client/views/collections/collectionSchema/SchemaTableCell.tsx +++ b/src/client/views/collections/collectionSchema/SchemaTableCell.tsx @@ -15,6 +15,7 @@ export interface SchemaTableCellProps { fieldKey: string; columnWidth: number; isRowActive: () => boolean | undefined; + setColumnValues: (field: string, value: string) => boolean; } @observer @@ -53,7 +54,12 @@ export class SchemaTableCell extends React.Component { } GetValue={() => Field.toKeyValueString(this.props.Document, this.props.fieldKey)} - SetValue={(value: string) => KeyValueBox.SetField(this.props.Document, this.props.fieldKey, value)} + SetValue={(value: string, shiftDown?: boolean, enterKey?: boolean) => { + if (shiftDown && enterKey) { + this.props.setColumnValues(this.props.fieldKey, value); + } + return KeyValueBox.SetField(this.props.Document, this.props.fieldKey, value); + }} editing={this.props.isRowActive() ? undefined : false} /> -- cgit v1.2.3-70-g09d2