From abd277bc02d36570038de4c0646a672f5585fa84 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Tue, 2 Jun 2020 22:34:16 +0200 Subject: stubbing in page editor --- frontend/views/graph/graph.css | 5 ++- frontend/views/graph/graph.reducer.js | 78 +++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 frontend/views/graph/graph.reducer.js (limited to 'frontend/views/graph') diff --git a/frontend/views/graph/graph.css b/frontend/views/graph/graph.css index d24ce97..a2ab8a4 100644 --- a/frontend/views/graph/graph.css +++ b/frontend/views/graph/graph.css @@ -13,6 +13,8 @@ ); } +/* Sidebar boxes */ + .box { width: 15rem; position: absolute; @@ -23,7 +25,6 @@ border: 2px solid #000; box-shadow: 2px 2px 4px rgba(0,0,0,0.5); } - .box h1, .box h2 { font-size: 1rem; @@ -51,6 +52,8 @@ display: none; } +/* Graph handles */ + .handle { position: absolute; border: 2px solid #888; diff --git a/frontend/views/graph/graph.reducer.js b/frontend/views/graph/graph.reducer.js new file mode 100644 index 0000000..9e682e4 --- /dev/null +++ b/frontend/views/graph/graph.reducer.js @@ -0,0 +1,78 @@ +import * as types from '../../types' +// import { session, getDefault, getDefaultInt } from '../../session' + +import { crudState, crudReducer } from '../../api/crud.reducer' + +const initialState = crudState('graph', { + editor: { + addingPage: false, + editingPage: false, + }, + options: { + } +}) + +const reducer = crudReducer('graph') + +export default function graphReducer(state = initialState, action) { + // console.log(action.type, action) + state = reducer(state, action) + switch (action.type) { + case types.graph.update_graph_page: + return { + ...state, + show: { + ...state.show, + res: { + ...state.show.res, + pages: state.show.res.pages.map(page => { + if (page.id === action.page.id) { + return { ...action.page } + } else { + return page + } + }), + } + } + } + + case types.graph.show_add_page_form: + return { + ...state, + editor: { + ...state.editor, + addingPage: true, + } + } + + case types.graph.hide_add_page_form: + return { + ...state, + editor: { + ...state.editor, + addingPage: false, + } + } + + case types.graph.show_edit_page_form: + return { + ...state, + editor: { + ...state.editor, + addingPage: true, + } + } + + case types.graph.hide_edit_page_form: + return { + ...state, + editor: { + ...state.editor, + addingPage: false, + } + } + + default: + return state + } +} -- cgit v1.2.3-70-g09d2