diff options
| author | Nathan-SR <144961007+Nathan-SR@users.noreply.github.com> | 2024-06-10 12:56:51 -0400 |
|---|---|---|
| committer | Nathan-SR <144961007+Nathan-SR@users.noreply.github.com> | 2024-06-10 12:56:51 -0400 |
| commit | 4b604b5118a1aac89d977c832c81495ec2c9aa19 (patch) | |
| tree | 73128d91c92b706365137eb7f18b00e686442e04 /src/client/views/collections/collectionSchema/SchemaTableCell.tsx | |
| parent | ecea2cb94fa0ea3f9959b3a8f5f43ae7e98aa552 (diff) | |
lock row editing
Diffstat (limited to 'src/client/views/collections/collectionSchema/SchemaTableCell.tsx')
| -rw-r--r-- | src/client/views/collections/collectionSchema/SchemaTableCell.tsx | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/src/client/views/collections/collectionSchema/SchemaTableCell.tsx b/src/client/views/collections/collectionSchema/SchemaTableCell.tsx index dc060218c..49ec70b74 100644 --- a/src/client/views/collections/collectionSchema/SchemaTableCell.tsx +++ b/src/client/views/collections/collectionSchema/SchemaTableCell.tsx @@ -76,8 +76,20 @@ export class SchemaTableCell extends ObservableReactComponent<SchemaTableCellPro makeObservable(this); } - get defaultKey(){ - return SchemaColumnHeader.isDefaultField(this._props.fieldKey) + get isDefault(){ + return SchemaColumnHeader.isDefaultField(this._props.fieldKey); + } + + get lockedInteraction(){ + return (this.isDefault || this._props.Document._lockedSchemaEditing); + } + + get backgroundColor(){ + if (this.lockedInteraction){ + if (this._props.rowSelected()) return '#B0D1E7' + else return '#F5F5F5' + } + return '' } static addFieldDoc = (docs: Doc | Doc[] /* , where: OpenWhere */) => { @@ -89,9 +101,7 @@ export class SchemaTableCell extends ObservableReactComponent<SchemaTableCellPro let protoCount = 0; let doc: Doc | undefined = Document; while (doc) { - if (Object.keys(doc).includes(fieldKey.replace(/^_/, ''))) { - break; - } + if (Object.keys(doc).includes(fieldKey.replace(/^_/, ''))) break; protoCount++; doc = DocCast(doc.proto); } @@ -130,6 +140,7 @@ export class SchemaTableCell extends ObservableReactComponent<SchemaTableCellPro @computed get defaultCellContent() { const { color, textDecoration, fieldProps, pointerEvents } = SchemaTableCell.renderProps(this._props); + return ( <div className="schemacell-edit-wrapper" @@ -137,7 +148,7 @@ export class SchemaTableCell extends ObservableReactComponent<SchemaTableCellPro color, textDecoration, width: '100%', - pointerEvents, + pointerEvents: this.lockedInteraction ? 'none' : pointerEvents, }}> <EditableView ref={r => selectedCell(this._props) && this._props.autoFocus && r?.setIsFocused(true)} @@ -190,14 +201,6 @@ export class SchemaTableCell extends ObservableReactComponent<SchemaTableCellPro } } - get backgroundColor(){ - if (this.defaultKey){ - if (this._props.rowSelected()) return '#B0D1E7' - else return '#F5F5F5' - } - return '' - } - render() { return ( <div @@ -218,7 +221,7 @@ export class SchemaTableCell extends ObservableReactComponent<SchemaTableCellPro width: this._props.columnWidth() || undefined, border: selectedCell(this._props) ? `solid 2px ${Colors.MEDIUM_BLUE}` : undefined, backgroundColor: this.backgroundColor}}> - {this.defaultKey ? '' : this.content} + {this.isDefault ? '' : this.content} </div> ); } |
