diff options
| author | Hannah Chow <hannah_chow@brown.edu> | 2019-02-28 22:59:18 -0500 |
|---|---|---|
| committer | Hannah Chow <hannah_chow@brown.edu> | 2019-02-28 22:59:18 -0500 |
| commit | e36ce53aeb15b9d518b007fe34b5053026b43500 (patch) | |
| tree | f6e2fd8dcca6bb89ce46beacad0b95a5121873de /src/client/views/nodes/KeyValuePair.tsx | |
| parent | 75d9e15ab363c196d16a60602ac7f6b0b8bcf6a1 (diff) | |
| parent | 179be4e314409269494da0d5bc52ca05c778d535 (diff) | |
Merge branch 'master' of https://github.com/browngraphicslab/Dash-Web into hannah_linking
Diffstat (limited to 'src/client/views/nodes/KeyValuePair.tsx')
| -rw-r--r-- | src/client/views/nodes/KeyValuePair.tsx | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/client/views/nodes/KeyValuePair.tsx b/src/client/views/nodes/KeyValuePair.tsx new file mode 100644 index 000000000..ecdd47a1e --- /dev/null +++ b/src/client/views/nodes/KeyValuePair.tsx @@ -0,0 +1,55 @@ +import 'react-image-lightbox/style.css'; // This only needs to be imported once in your app +import "./KeyValueBox.scss"; +import React = require("react") +import { FieldViewProps, FieldView } from './FieldView'; +import { Opt, Field } from '../../../fields/Field'; +import { observer } from "mobx-react" +import { observable, action } from 'mobx'; +import { Document } from '../../../fields/Document'; +import { Key } from '../../../fields/Key'; +import { Server } from "../../Server" + +// Represents one row in a key value plane + +export interface KeyValuePairProps { + rowStyle: string; + fieldId: string; + doc: Document; +} +@observer +export class KeyValuePair extends React.Component<KeyValuePairProps> { + + @observable + private key: Opt<Key> + + constructor(props: KeyValuePairProps) { + super(props); + Server.GetField(this.props.fieldId, + action((field: Opt<Field>) => { + if (field) { + this.key = field as Key; + } + })); + + } + + + render() { + if (!this.key) { + return <tr><td>error</td><td></td></tr> + + } + let props: FieldViewProps = { + doc: this.props.doc, + fieldKey: this.key, + isSelected: () => false, + select: () => { }, + isTopMost: false, + bindings: {}, + selectOnLoad: false, + } + return ( + <tr className={this.props.rowStyle}><td>{this.key.Name}</td><td><FieldView {...props} /></td></tr> + ) + } +}
\ No newline at end of file |
