Add action, reducer and selector for blocks
[MAILPOET-2451]
This commit is contained in:
committed by
Jack Kitterhing
parent
d9295569a2
commit
3efc103625
@ -6,6 +6,13 @@ export function toggleSidebar(toggleTo) {
|
||||
};
|
||||
}
|
||||
|
||||
export function changeFormBlocks(blocks) {
|
||||
return {
|
||||
type: 'CHANGE_FORM_BLOCKS',
|
||||
blocks,
|
||||
};
|
||||
}
|
||||
|
||||
export function changeFormName(name) {
|
||||
return {
|
||||
type: 'CHANGE_FORM_NAME',
|
||||
|
@ -8,9 +8,11 @@ import saveFormStarted from './reducers/save_form_started.jsx';
|
||||
import switchSidebarTab from './reducers/switch_sidebar_tab.jsx';
|
||||
import toggleSidebar from './reducers/toggle_sidebar.jsx';
|
||||
import toggleSidebarPanel from './reducers/toggle_sidebar_panel.jsx';
|
||||
import changeFormBlocks from './reducers/change_form_blocks.jsx';
|
||||
|
||||
export default (defaultState) => (state = defaultState, action) => {
|
||||
switch (action.type) {
|
||||
case 'CHANGE_FORM_BLOCKS': return changeFormBlocks(state, action);
|
||||
case 'CHANGE_FORM_NAME': return changeFormName(state, action);
|
||||
case 'CHANGE_FORM_SETTINGS': return changeFormSettings(state, action);
|
||||
case 'CHANGE_FORM_STYLES': return changeFormStyles(state, action);
|
||||
|
@ -0,0 +1,12 @@
|
||||
import validateForm from '../form_validator.jsx';
|
||||
|
||||
export default (state, action) => {
|
||||
const newState = {
|
||||
...state,
|
||||
formBlocks: action.blocks,
|
||||
};
|
||||
return {
|
||||
...newState,
|
||||
formErrors: validateForm(newState.formData, newState.formBlocks),
|
||||
};
|
||||
};
|
@ -44,4 +44,7 @@ export default {
|
||||
getSidebarOpenedPanels(state) {
|
||||
return state.sidebar.openedPanels;
|
||||
},
|
||||
getFormBlocks(state) {
|
||||
return state.formBlocks;
|
||||
},
|
||||
};
|
||||
|
Reference in New Issue
Block a user