summaryrefslogtreecommitdiff
path: root/frontend/views/graph
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2020-06-02 22:21:36 +0200
committerJules Laplace <julescarbon@gmail.com>2020-06-02 22:21:36 +0200
commit70a29089cdb05df27cf50b50fcbc2e53d8975571 (patch)
tree052e7b81291d8ac0c5639c32e4a6f98ce593ba38 /frontend/views/graph
parent097e54d4c0646a809eba4ed69929b2a16b682754 (diff)
updating after dragging
Diffstat (limited to 'frontend/views/graph')
-rw-r--r--frontend/views/graph/components/graph.editor.js21
-rw-r--r--frontend/views/graph/graph.actions.js4
2 files changed, 18 insertions, 7 deletions
diff --git a/frontend/views/graph/components/graph.editor.js b/frontend/views/graph/components/graph.editor.js
index d4da2b6..1b2d446 100644
--- a/frontend/views/graph/components/graph.editor.js
+++ b/frontend/views/graph/components/graph.editor.js
@@ -4,6 +4,8 @@ import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import { session } from '../../../session'
+import actions from '../../../actions'
+import * as graphActions from '../graph.actions'
import { Loader } from '../../../common'
import { clamp } from '../../../util'
@@ -114,8 +116,8 @@ class GraphEditor extends Component {
}
handleMouseUp(e) {
- const { actions } = this.props
- const { dragging, draggingBox, bounds, box } = this.state
+ // const { actions } = this.props
+ const { dragging, draggingBox, bounds, box, page } = this.state
if (!dragging && !draggingBox) return
e.preventDefault()
const { x, y, w, h } = box
@@ -127,11 +129,16 @@ class GraphEditor extends Component {
dragging: false,
draggingBox: false,
})
- if (w < 10 / bounds.width || h < 10 / bounds.height) {
- // too small...
- } else {
- // update page, settings.x/y
+ // console.log(page)
+ const updatedPage = {
+ ...page,
+ settings: {
+ ...page.settings,
+ x, y,
+ }
}
+ this.props.graphActions.updateGraphPage(updatedPage)
+ actions.page.update(updatedPage)
}
render(){
@@ -182,7 +189,7 @@ const mapStateToProps = state => ({
})
const mapDispatchToProps = dispatch => ({
- // uploadActions: bindActionCreators({ ...uploadActions }, dispatch),
+ graphActions: bindActionCreators({ ...graphActions }, dispatch),
})
export default connect(mapStateToProps, mapDispatchToProps)(GraphEditor)
diff --git a/frontend/views/graph/graph.actions.js b/frontend/views/graph/graph.actions.js
index 2e6ca54..90d0f96 100644
--- a/frontend/views/graph/graph.actions.js
+++ b/frontend/views/graph/graph.actions.js
@@ -7,3 +7,7 @@ export const showAddPageForm = () => dispatch => {
export const hideAddPageForm = () => dispatch => {
dispatch({ type: types.graph.hide_add_page_form })
}
+
+export const updateGraphPage = page => dispatch => {
+ dispatch({ type: types.graph.update_graph_page, page })
+}