diff --git a/src/App.tsx b/src/App.tsx index a8a9982..7b7db8d 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -8,7 +8,7 @@ import { walleStore } from './WallEStore'; import { Header, Icon, Segment } from 'semantic-ui-react'; function mapStateToProps(state: any) { - return {...state}; + return state; } function mapDispachToProps(dispatch: any) { diff --git a/src/LexComponents.tsx b/src/LexComponents.tsx index 51c6127..fc8eac8 100644 --- a/src/LexComponents.tsx +++ b/src/LexComponents.tsx @@ -16,14 +16,14 @@ export class LexEditor extends React.Component { .filter((q: any) => _.get(q, searchLens, '') === searchText) .take(10) .value(); + let { fieldMetaMap: fieldMetaMap, save: save } = this.props; return (
{ let lens = this.props.fieldMetaMap[type].lens; let { lexItem: lexItem } = this.state; _.set(lexItem, lens, value); - console.log('setting event :', lexItem); this.setState(lexItem); } private handleOnSave(event: any) { + this.props.save(this.state.lexItem); console.log('saving object :', this.state.lexItem); } } diff --git a/src/LexSetup.tsx b/src/LexSetup.tsx index 37e9413..e1cdbad 100644 --- a/src/LexSetup.tsx +++ b/src/LexSetup.tsx @@ -59,8 +59,9 @@ export class LexSetup extends React.Component { })); return [lang, langOpts]; })); + this.props.addXmlData(lexData); this.setState({ - lexData, allEntries, selectFields, fieldMetaMap + allEntries, selectFields, fieldMetaMap }); }); }) diff --git a/src/WallEStore.tsx b/src/WallEStore.tsx index 3e4f310..becee06 100644 --- a/src/WallEStore.tsx +++ b/src/WallEStore.tsx @@ -2,7 +2,8 @@ import { createStore } from 'redux'; import rootReducer from './reducers'; const defaultState = { - searchState: { searchValue: 'just', searchType: 'label' } + searchState: { searchValue: 'just', searchType: 'label' }, + xmlData: [] }; const devToolsKey = '__REDUX_DEVTOOLS_EXTENSION__'; diff --git a/src/actionCreators.tsx b/src/actionCreators.tsx index 0912628..b75c9ec 100644 --- a/src/actionCreators.tsx +++ b/src/actionCreators.tsx @@ -13,6 +13,13 @@ export function searchForValue(searchValue: any) { }; } +export function addXmlData(xmlData: any) { + return { + type: 'ACTION_XML_DATA', + xmlData + }; +} + export function save(lexItem: any) { return { type: 'ACTION_SAVE_LEXITEM', diff --git a/src/reducers.tsx b/src/reducers.tsx index dd1767f..60e7d24 100644 --- a/src/reducers.tsx +++ b/src/reducers.tsx @@ -24,7 +24,18 @@ function save(state: any = {}, action: any) { return state; } +function addXmlData(state: any = {}, action: any) { + if (action.type === 'ACTION_XML_DATA') { + return action.xmlData; + } + return state; +} + const searchReducer = combineReducers({ searchValue, searchType }); -const rootReducer = combineReducers({ searchState: searchReducer, save }); +const rootReducer = combineReducers({ + searchState: searchReducer, + save, + xmlData: addXmlData +}); export default rootReducer;