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

@ -1,6 +1,6 @@
import * as React from 'react';
import * as _ from 'lodash';
import { componentForType} from './LexSingleInput';
import { componentForType } from './LexSingleInput';
import {
Card,
Button
@ -113,6 +113,6 @@ export class LexEdit extends React.Component<any, 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((xmlString) => {
XML.parseString(xmlString, (err, xmlData) => {
let props = this.props;
_.noop(props);
this.props.addXmlData(xmlData);
this.setState({ xmlLoaded: true });
});

View File

@ -140,7 +140,7 @@ export function componentForType(type: string, params: any) {
return listInput(params);
}
default: {
console.log('type discarded :', type);
// console.log('type discarded :', type);
// console.log('values discarded :', fieldMeta.get(li));
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 {
type: 'ACTION_SAVE_LEXITEM',
lexItem,
lexSelector
};
}

View File

@ -1,4 +1,5 @@
import { combineReducers } from 'redux';
import * as _ from 'lodash';
function searchValue(state: any = {}, action: any) {
if (action.type === 'ACTION_SEARCH_VALUE_CHANGE') {
@ -14,28 +15,29 @@ function searchType(state: any = {}, action: any) {
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') {
// 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 {
...state,
lexItem: action.lexItem,
...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({
searchState: searchReducer,
save,
xmlData: addXmlData
searchState: combineReducers({ searchValue, searchType }),
xmlData: updateXMLState
});
export default rootReducer;