aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/KeyValuePair.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/nodes/KeyValuePair.tsx')
-rw-r--r--src/client/views/nodes/KeyValuePair.tsx47
1 files changed, 20 insertions, 27 deletions
diff --git a/src/client/views/nodes/KeyValuePair.tsx b/src/client/views/nodes/KeyValuePair.tsx
index 3e0b61c3d..5d69f23b2 100644
--- a/src/client/views/nodes/KeyValuePair.tsx
+++ b/src/client/views/nodes/KeyValuePair.tsx
@@ -1,18 +1,18 @@
-import 'react-image-lightbox/style.css'; // This only needs to be imported once in your app
-import "./KeyValueBox.scss";
-import "./KeyValuePair.scss";
-import React = require("react");
-import { FieldViewProps, FieldView } from './FieldView';
-import { Opt, Field } from '../../../fields/Field';
+import { action, observable } from 'mobx';
import { observer } from "mobx-react";
-import { observable, action } from 'mobx';
+import 'react-image-lightbox/style.css'; // This only needs to be imported once in your app
import { Document } from '../../../fields/Document';
+import { Field, Opt } from '../../../fields/Field';
import { Key } from '../../../fields/Key';
+import { emptyDocFunction, emptyFunction, returnFalse } from '../../../Utils';
import { Server } from "../../Server";
-import { EditableView } from "../EditableView";
import { CompileScript, ToField } from "../../util/Scripting";
import { Transform } from '../../util/Transform';
-import { returnFalse, emptyFunction, emptyDocFunction } from '../../../Utils';
+import { EditableView } from "../EditableView";
+import { FieldView, FieldViewProps } from './FieldView';
+import "./KeyValueBox.scss";
+import "./KeyValuePair.scss";
+import React = require("react");
// Represents one row in a key value plane
@@ -25,28 +25,23 @@ export interface KeyValuePairProps {
@observer
export class KeyValuePair extends React.Component<KeyValuePairProps> {
- @observable
- private key: Opt<Key>;
+ @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;
- }
- }));
+ action((field: Opt<Field>) => field instanceof Key && (this.key = field)));
}
render() {
if (!this.key) {
- return <tr><td>error</td><td></td></tr>;
-
+ return <tr><td>error</td><td /></tr>;
}
let props: FieldViewProps = {
Document: this.props.doc,
+ ContainingCollectionView: undefined,
fieldKey: this.key,
isSelected: returnFalse,
select: emptyFunction,
@@ -57,19 +52,17 @@ export class KeyValuePair extends React.Component<KeyValuePairProps> {
ScreenToLocalTransform: Transform.Identity,
focus: emptyDocFunction,
};
- let contents = (
- <FieldView {...props} />
- );
+ let contents = <FieldView {...props} />;
return (
<tr className={this.props.rowStyle}>
<td className="keyValuePair-td-key" style={{ width: `${this.props.keyWidth}%` }}>
- <div className="container">
- <button className="delete" onClick={() => {
+ <div className="keyValuePair-td-key-container">
+ <button className="keyValuePair-td-key-delete" onClick={() => {
let field = props.Document.Get(props.fieldKey);
- if (field && field instanceof Field) {
- props.Document.Set(props.fieldKey, undefined);
- }
- }}>X</button>
+ field && field instanceof Field && props.Document.Set(props.fieldKey, undefined);
+ }}>
+ X
+ </button>
<div className="keyValuePair-keyField">{this.key.Name}</div>
</div>
</td>