diff options
| author | mehekj <mehek.jethani@gmail.com> | 2022-08-10 19:33:19 -0400 |
|---|---|---|
| committer | mehekj <mehek.jethani@gmail.com> | 2022-08-10 19:33:19 -0400 |
| commit | 9f39b14b2e321e09d071ad1c5bf8e3978ff7f181 (patch) | |
| tree | b9c9f27b365de2ca889b6635d3f2a470829f8412 /src/client/views/collections/collectionSchema/SchemaRowBox.tsx | |
| parent | 19aa61f593c896f4d3bd0ffae6dbe306c2a9546d (diff) | |
basic selection complete
Diffstat (limited to 'src/client/views/collections/collectionSchema/SchemaRowBox.tsx')
| -rw-r--r-- | src/client/views/collections/collectionSchema/SchemaRowBox.tsx | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/src/client/views/collections/collectionSchema/SchemaRowBox.tsx b/src/client/views/collections/collectionSchema/SchemaRowBox.tsx index 50e2502dc..33f4e0bfc 100644 --- a/src/client/views/collections/collectionSchema/SchemaRowBox.tsx +++ b/src/client/views/collections/collectionSchema/SchemaRowBox.tsx @@ -1,25 +1,42 @@ import React = require('react'); +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import { action, ObservableMap, ObservableSet } from 'mobx'; import { observer } from 'mobx-react'; -import './CollectionSchemaView.scss'; -import { ViewBoxAnnotatableComponent, ViewBoxBaseComponent } from '../../DocComponent'; +import { Doc } from '../../../../fields/Doc'; +import { undoBatch } from '../../../util/UndoManager'; +import { ViewBoxBaseComponent } from '../../DocComponent'; +import { Colors } from '../../global/globalEnums'; import { FieldViewProps } from '../../nodes/FieldView'; +import './CollectionSchemaView.scss'; import { SchemaTableCell } from './SchemaTableCell'; -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; -import { undoBatch } from '../../../util/UndoManager'; export interface SchemaRowBoxProps extends FieldViewProps { columnKeys: string[]; columnWidths: number[]; + rowMenuWidth: number; + selectedRows: ObservableSet<Doc>; + selectRow: (doc: Doc, cmd?: boolean, shift?: boolean) => void; } @observer -export class SchemaRowBox extends ViewBoxAnnotatableComponent<SchemaRowBoxProps>() { +export class SchemaRowBox extends ViewBoxBaseComponent<SchemaRowBoxProps>() { + isSelected = () => this.props.selectedRows.has(this.props.Document); + + @action + onRowPointerDown = (e: React.PointerEvent) => { + e.stopPropagation(); + this.props.selectRow(this.props.Document, e.ctrlKey || e.metaKey, e.shiftKey); + } + render() { return ( - <div className="schema-row" /*style={this.props.isSelected() ? { backgroundColor: 'grey' } : {}}*/> - <div className="row-menu"> - <div className="row-button" onPointerDown={undoBatch(() => this.props.removeDocument?.(this.props.Document))}> - <FontAwesomeIcon icon={'times'} /> + <div className="schema-row" style={this.isSelected() ? { backgroundColor: Colors.LIGHT_BLUE } : {}} onPointerDown={this.onRowPointerDown}> + <div className="row-menu" style={{width: this.props.rowMenuWidth}}> + <div className="row-button" onPointerDown={undoBatch((e) => {e.stopPropagation(); this.props.removeDocument?.(this.props.Document)})}> + <FontAwesomeIcon icon="times" /> + </div> + <div className="row-button" onPointerDown={(e) => {e.stopPropagation(); this.props.addDocTab(this.props.Document, 'add:right')}}> + <FontAwesomeIcon icon="external-link-alt" /> </div> </div> <div className="row-cells"> |
