summaryrefslogtreecommitdiff
path: root/frontend/views/graph
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/views/graph')
-rw-r--r--frontend/views/graph/components/page.form.js51
-rw-r--r--frontend/views/graph/components/page.handle.js4
-rw-r--r--frontend/views/graph/graph.reducer.js2
3 files changed, 48 insertions, 9 deletions
diff --git a/frontend/views/graph/components/page.form.js b/frontend/views/graph/components/page.form.js
index 26e30c9..38fee18 100644
--- a/frontend/views/graph/components/page.form.js
+++ b/frontend/views/graph/components/page.form.js
@@ -3,7 +3,7 @@ import { Link } from 'react-router-dom'
import { session } from '../../../session'
-import { TextInput, LabelDescription, TextArea, Checkbox, SubmitButton, Loader } from '../../../common'
+import { TextInput, ColorInput, LabelDescription, TextArea, Checkbox, SubmitButton, Loader } from '../../../common'
const newPage = (data) => ({
path: '',
@@ -11,7 +11,9 @@ const newPage = (data) => ({
username: session('username'),
description: '',
settings: {
- x: 0.05, y: 0.05,
+ x: 0.05,
+ y: 0.05,
+ background_color: '#000000',
},
...data,
})
@@ -72,6 +74,19 @@ export default class PageForm extends Component {
})
}
+ handleSettingsChange(e) {
+ const { name, value } = e.target
+ this.setState({
+ data: {
+ ...this.state.data,
+ settings: {
+ ...this.state.data.settings,
+ [name]: value,
+ }
+ }
+ })
+ }
+
handleSubmit(e) {
e.preventDefault()
const { isNew, onSubmit } = this.props
@@ -95,6 +110,14 @@ export default class PageForm extends Component {
}
}
+ handleDelete() {
+ const { data } = this.state
+ console.log(data)
+ if (confirm('Really delete this page?')) {
+ actions.page.delete(page_id)
+ }
+ }
+
render() {
const { graph, isNew } = this.props
const { title, submitTitle, errorFields, data } = this.state
@@ -123,16 +146,32 @@ export default class PageForm extends Component {
onChange={this.handleChange.bind(this)}
autoComplete="off"
/>
+ <ColorInput
+ title='BG'
+ name='background_color'
+ data={data.settings}
+ onChange={this.handleSettingsChange.bind(this)}
+ autoComplete="off"
+ />
<TextArea
title="Description"
name="description"
data={data}
onChange={this.handleChange.bind(this)}
/>
- <SubmitButton
- title={submitTitle}
- onClick={this.handleSubmit.bind(this)}
- />
+ <div className='row buttons'>
+ <SubmitButton
+ title={submitTitle}
+ onClick={this.handleSubmit.bind(this)}
+ />
+ {!isNew &&
+ <SubmitButton
+ title={'Delete'}
+ className='destroy'
+ onClick={this.handleDelete.bind(this)}
+ />
+ }
+ </div>
{!!errorFields.size &&
<label>
<span></span>
diff --git a/frontend/views/graph/components/page.handle.js b/frontend/views/graph/components/page.handle.js
index 06acc63..13eee45 100644
--- a/frontend/views/graph/components/page.handle.js
+++ b/frontend/views/graph/components/page.handle.js
@@ -19,7 +19,7 @@ export default class PageHandle extends Component {
measure() {
const { offsetWidth: width, offsetHeight: height } = this.ref.current
const { id } = this.props.page
- console.log(id, width, height)
+ // console.log(id, width, height)
this.props.onMeasure({ id, width, height })
}
render() {
@@ -46,7 +46,7 @@ export default class PageHandle extends Component {
onDoubleClick={() => history.push(url)}
style={style}
>
- {page.title}
+ {page.path}
<Link to={url}>{'>'}</Link>
</div>
)
diff --git a/frontend/views/graph/graph.reducer.js b/frontend/views/graph/graph.reducer.js
index 60f52ee..37798b3 100644
--- a/frontend/views/graph/graph.reducer.js
+++ b/frontend/views/graph/graph.reducer.js
@@ -90,7 +90,7 @@ export default function graphReducer(state = initialState, action) {
editor: {
...state.editor,
addingPage: false,
- editingPage: true,
+ editingPage: !state.editor.editingPage,
}
}