aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormehekj <mehek.jethani@gmail.com>2023-03-22 17:42:28 -0400
committermehekj <mehek.jethani@gmail.com>2023-03-22 17:42:28 -0400
commit3fed87fe05a70a5ef63ed7989c7a28faee68bf4b (patch)
treefe4cfa2919ef4b3aa26ad898023d85ada21f6bf2
parent1be46d0193752c4158cf327b8d3f7421b2d1b60f (diff)
shift enter shortcut to fill column
-rw-r--r--src/client/views/collections/collectionSchema/CollectionSchemaView.scss7
-rw-r--r--src/client/views/collections/collectionSchema/CollectionSchemaView.tsx7
-rw-r--r--src/client/views/collections/collectionSchema/SchemaRowBox.tsx9
-rw-r--r--src/client/views/collections/collectionSchema/SchemaTableCell.tsx8
4 files changed, 25 insertions, 6 deletions
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<FieldViewProps>() {
</div>
<div className="row-cells">
{this.schemaView?.columnKeys?.map((key, index) => (
- <SchemaTableCell key={key} Document={this.rootDoc} fieldKey={key} columnWidth={this.schemaView?.displayColumnWidths[index] ?? CollectionSchemaView._minColWidth} isRowActive={this.props.isContentActive} />
+ <SchemaTableCell
+ key={key}
+ Document={this.rootDoc}
+ fieldKey={key}
+ columnWidth={this.schemaView?.displayColumnWidths[index] ?? CollectionSchemaView._minColWidth}
+ isRowActive={this.props.isContentActive}
+ setColumnValues={(field, value) => this.schemaView?.setColumnValues(field, value) ?? false}
+ />
))}
</div>
</div>
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<SchemaTableCellProps> {
<EditableView
contents={<FieldView {...props} />}
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}
/>
</div>