implemented list/proplist as separate uis. wip reducer for xmldata save lexitem

master
Malar Kannan 2017-07-27 18:47:32 +05:30
parent c715944fa2
commit b7bb5da857
5 changed files with 23 additions and 18 deletions

View File

@ -113,6 +113,6 @@ export class LexEdit extends React.Component<any, any> {
} }
private handleOnSave(event: any) { private handleOnSave(event: any) {
this.props.save(this.state.lexItem); this.props.save(this.state.lexItem, this.props.fieldMetaMap);
} }
} }

View File

@ -234,6 +234,8 @@ export class LexSetup extends React.Component<any, any> {
.then((response) => response.text()) .then((response) => response.text())
.then((xmlString) => { .then((xmlString) => {
XML.parseString(xmlString, (err, xmlData) => { XML.parseString(xmlString, (err, xmlData) => {
let props = this.props;
_.noop(props);
this.props.addXmlData(xmlData); this.props.addXmlData(xmlData);
this.setState({ xmlLoaded: true }); this.setState({ xmlLoaded: true });
}); });

View File

@ -140,7 +140,7 @@ export function componentForType(type: string, params: any) {
return listInput(params); return listInput(params);
} }
default: { default: {
console.log('type discarded :', type); // console.log('type discarded :', type);
// console.log('values discarded :', fieldMeta.get(li)); // console.log('values discarded :', fieldMeta.get(li));
return null; return null;
} }

View File

@ -20,9 +20,10 @@ export function addXmlData(xmlData: any) {
}; };
} }
export function save(lexItem: any) { export function save(lexItem: any, lexSelector: any) {
return { return {
type: 'ACTION_SAVE_LEXITEM', type: 'ACTION_SAVE_LEXITEM',
lexItem, lexItem,
lexSelector
}; };
} }

View File

@ -1,4 +1,5 @@
import { combineReducers } from 'redux'; import { combineReducers } from 'redux';
import * as _ from 'lodash';
function searchValue(state: any = {}, action: any) { function searchValue(state: any = {}, action: any) {
if (action.type === 'ACTION_SEARCH_VALUE_CHANGE') { if (action.type === 'ACTION_SEARCH_VALUE_CHANGE') {
@ -14,28 +15,29 @@ function searchType(state: any = {}, action: any) {
return state; return state;
} }
function save(state: any = {}, action: any) { function updateXMLState(state: any = {}, action: any) {
if (action.type === 'ACTION_XML_DATA') {
return action.xmlData;
}
if (action.type === 'ACTION_SAVE_LEXITEM') { if (action.type === 'ACTION_SAVE_LEXITEM') {
// debugger;
// let guid = action.lexSelector.guid.get(action.lexItem);
// let lang = action.lexSelector.lang.get(action.lexItem);
// // action.lexItem;
// _.findIndex(_.get<any>(state,'document.lexicon[0].item'),(o)=>{
// return _.isEqual(_.get(o,'$.guid'),guid) && _.isEqual(_.get(o,'entry[0].lang'),lang)
// });
_.noop();
return { return {
...state, ...state
lexItem: action.lexItem,
}; };
} }
return state; 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({ const rootReducer = combineReducers({
searchState: searchReducer, searchState: combineReducers({ searchValue, searchType }),
save, xmlData: updateXMLState
xmlData: addXmlData
}); });
export default rootReducer; export default rootReducer;