aboutsummaryrefslogtreecommitdiff
path: root/src/views/EditableView.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/views/EditableView.tsx')
-rw-r--r--src/views/EditableView.tsx39
1 files changed, 0 insertions, 39 deletions
diff --git a/src/views/EditableView.tsx b/src/views/EditableView.tsx
deleted file mode 100644
index 2e784d3f9..000000000
--- a/src/views/EditableView.tsx
+++ /dev/null
@@ -1,39 +0,0 @@
-import React = require('react')
-import { observer } from 'mobx-react';
-import { observable, action } from 'mobx';
-
-export interface EditableProps {
- GetValue(): string;
- SetValue(value: string): boolean;
- contents: any;
-}
-
-@observer
-export class EditableView extends React.Component<EditableProps> {
- @observable
- editing: boolean = false;
-
- @action
- onKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
- if (e.key == "Enter" && !e.ctrlKey) {
- this.props.SetValue(e.currentTarget.value);
- this.editing = false;
- } else if (e.key == "Escape") {
- this.editing = false;
- }
- }
-
- render() {
- if (this.editing) {
- return <input defaultValue={this.props.GetValue()} onKeyDown={this.onKeyDown} autoFocus onBlur={action(() => this.editing = false)}
- style={{ width: "100%" }}></input>
- } else {
- return (
- <div>
- {this.props.contents}
- <button onClick={action(() => this.editing = true)}>Edit</button>
- </div>
- )
- }
- }
-} \ No newline at end of file