summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--frontend/api/crud.reducer.js7
-rw-r--r--frontend/views/graph/components/graph.editor.js5
-rw-r--r--frontend/views/graph/components/page.handle.js5
-rw-r--r--frontend/views/graph/graph.actions.js8
-rw-r--r--frontend/views/graph/graph.container.js1
-rw-r--r--frontend/views/graph/graph.css4
6 files changed, 28 insertions, 2 deletions
diff --git a/frontend/api/crud.reducer.js b/frontend/api/crud.reducer.js
index 04ade91..baf2536 100644
--- a/frontend/api/crud.reducer.js
+++ b/frontend/api/crud.reducer.js
@@ -114,6 +114,13 @@ export const crudReducer = (type) => {
return {
...state,
update: action.data,
+ index: addToIndex(state.index, action.data.res, state.options.sort),
+ show: {
+ res: (state.show.res.id === action.data.res.id ? {
+ ...state.show.res,
+ ...action.data.res,
+ } : state.show.res),
+ }
}
case crud_type.index_error:
return {
diff --git a/frontend/views/graph/components/graph.editor.js b/frontend/views/graph/components/graph.editor.js
index 3be0063..99c5665 100644
--- a/frontend/views/graph/components/graph.editor.js
+++ b/frontend/views/graph/components/graph.editor.js
@@ -82,6 +82,11 @@ class GraphEditor extends Component {
}
handleMouseDown(e, page) {
+ if (e.shiftKey) {
+ e.preventDefault()
+ this.props.graphActions.setHomePageId(this.props.graph.show.res, page)
+ return
+ }
const bounds = this.getBoundingClientRect()
const mouseX = e.pageX
const mouseY = e.pageY
diff --git a/frontend/views/graph/components/page.handle.js b/frontend/views/graph/components/page.handle.js
index 13eee45..be05a1a 100644
--- a/frontend/views/graph/components/page.handle.js
+++ b/frontend/views/graph/components/page.handle.js
@@ -36,11 +36,14 @@ export default class PageHandle extends Component {
left: (bounds.width) * Math.min(page.settings.x, 0.95),
}
}
+ const className = (graph.home_page_id === page.id)
+ ? 'handle homepage'
+ : 'handle'
const url = '/' + graph.path + '/' + page.path
// console.log(style)
return (
<div
- className='handle'
+ className={className}
ref={this.ref}
onMouseDown={onMouseDown}
onDoubleClick={() => history.push(url)}
diff --git a/frontend/views/graph/graph.actions.js b/frontend/views/graph/graph.actions.js
index 03ea217..bf6b643 100644
--- a/frontend/views/graph/graph.actions.js
+++ b/frontend/views/graph/graph.actions.js
@@ -1,4 +1,5 @@
import * as types from '../../types'
+import actions from '../../actions'
export const showAddPageForm = () => dispatch => {
dispatch({ type: types.graph.show_add_page_form })
@@ -27,3 +28,10 @@ export const toggleEditPageForm = () => dispatch => {
export const updateGraphPage = page => dispatch => {
dispatch({ type: types.graph.update_graph_page, page })
}
+
+export const setHomePageId = (graph, page) => dispatch => {
+ let updated_graph = { ...graph }
+ delete updated_graph.pages
+ updated_graph.home_page_id = page.id
+ actions.graph.update(updated_graph)
+} \ No newline at end of file
diff --git a/frontend/views/graph/graph.container.js b/frontend/views/graph/graph.container.js
index 5c6e3b5..7f53d64 100644
--- a/frontend/views/graph/graph.container.js
+++ b/frontend/views/graph/graph.container.js
@@ -25,7 +25,6 @@ class GraphContainer extends Component {
}
shouldShowGraph() {
const { graph_name, page_name } = this.props.match.params
- // console.log(graph_name, page_name)
return (graph_name && !page_name && graph_name !== 'index')
}
shouldLoadGraph(prevProps) {
diff --git a/frontend/views/graph/graph.css b/frontend/views/graph/graph.css
index d59e649..389a55d 100644
--- a/frontend/views/graph/graph.css
+++ b/frontend/views/graph/graph.css
@@ -160,6 +160,10 @@
user-select: none;
cursor: arrow;
}
+.handle.homepage {
+ background: #533854;
+ border-color: #edc40e;
+}
.handle a {
margin-left: 0.25rem;
color: #fff;