wip on react transition 8

This commit is contained in:
Erik Ziegler committed 2018-12-03 18:11:39 +01:00
1 parent 9ae5dd25ce
commit 71b49e6766
35 files changed
+818 -470

No files matched your search

@@ -0,0 +1,9 @@
export const setToolActive = tool => ({
type: 'SET_TOOL_ACTIVE',
tool
});
export const setViewportActive = viewportIndex => ({
type: 'SET_VIEWPORT_ACTIVE',
viewportIndex
});
@@ -0,0 +1,8 @@
import './actions.js';
import combinedReducer from './reducers';
const redux = {
combinedReducer
};
export default redux;
@@ -0,0 +1,10 @@
import { combineReducers } from 'redux';
import tools from './tools.js';
import viewports from './viewports.js';
const combinedReducer = combineReducers({
tools,
viewports
});
export default combinedReducer;
@@ -0,0 +1,101 @@
const defaultButtons = [
{
command: 'Pan',
type: 'tool',
text: 'Pan',
svgUrl: '/icons.svg#icon-tools-pan',
active: false
},
{
command: 'Zoom',
type: 'tool',
text: 'Zoom',
svgUrl: '/icons.svg#icon-tools-zoom',
active: false
},
{
command: 'Bidirectional',
type: 'tool',
text: 'Bidirectional',
svgUrl: '/icons.svg#icon-tools-measure-target',
active: true
},
{
command: 'StackScroll',
type: 'tool',
text: 'Stack Scroll',
svgUrl: '/icons.svg#icon-tools-stack-scroll',
active: false
},
{
command: 'reset',
type: 'command',
text: 'Reset',
svgUrl: '/icons.svg#icon-tools-reset',
active: false
},
{
command: 'Wwwc',
type: 'tool',
text: 'Manual',
svgUrl: '/icons.svg#icon-tools-levels',
active: false
},
{
command: 'setWLPresetSoftTissue',
type: 'command',
text: 'Soft Tissue',
svgUrl: '/icons.svg#icon-wl-soft-tissue',
active: false
},
{
command: 'setWLPresetLung',
type: 'command',
text: 'Lung',
svgUrl: '/icons.svg#icon-wl-lung',
active: false
},
{
command: 'setWLPresetLiver',
type: 'command',
text: 'Liver',
svgUrl: '/icons.svg#icon-wl-liver',
active: false
},
{
command: 'setWLPresetBrain',
type: 'command',
text: 'Brain',
svgUrl: '/icons.svg#icon-wl-brain',
active: false
}
];
const tools = (state = { buttons: defaultButtons }, action) => {
switch (action.type) {
case 'SET_TOOL_ACTIVE':
const item = state.buttons.find(button => button.command === action.tool);
let buttons = [];
if (item.type === 'tool') {
buttons = state.buttons.map(button => {
if (button.command === action.tool) {
button.active = true;
} else if (button.type === 'tool') {
button.active = false;
}
return button;
});
}
return {
buttons
};
default:
return state;
}
};
export default tools;
@@ -0,0 +1,15 @@
const defaultState = {
activeViewport: 0
}
const viewports = (state = defaultState, action) => {
console.warn(action);
switch (action.type) {
case 'SET_VIEWPORT_ACTIVE':
return Object.assign({}, state, { activeViewport: action.viewportIndex });
default:
return state;
}
};
export default viewports;