master
Malar Kannan 2017-08-01 11:24:34 +05:30
parent fcdc0841b0
commit a4db9e12ea
6 changed files with 6 additions and 19 deletions

View File

@ -34,11 +34,6 @@ function simpleAttrAccessor(attrPred: any) {
return !pred(m);
});
_.set(lexItem, lens, _.concat(keepProps, [def(value)]));
// if (prop.length > 0) {
// _.set(prop, '[0]._', value);
// } else {
//
// }
} else {
_.set(lexItem, lens, [def(value)]);
}
@ -217,7 +212,7 @@ function getSelectOptions(field: string, entries: any) {
}
}
export const xmlToEntries = (xmlData: any) => {
export const xmlToLexData = (xmlData: any) => {
let allEntries = _.chain(xmlData)
.get<any>('document.lexicon[0].item')
.flatMap((o: any) => _.chain(o)
@ -242,11 +237,6 @@ export const xmlToEntries = (xmlData: any) => {
return _.includes(selectableFields, fieldMetaMap[s].type);
}).map((s) => {
let entries = _.get<any>(langEntries, lang, 'en');
// let allOpts = entries.map((q: any) => {
// return fieldMetaMap[s].get(q);
// });
// let select = _.isEqual(fieldMetaMap[s].type, 'select');
// let selectOptions = select ? _.uniq(allOpts) : _.uniq(_.flatten(allOpts));
return [s, getSelectOptions(s, entries)];
}));
return [lang, langOpts];

View File

@ -86,7 +86,6 @@ export class LexEdit extends React.Component<any, any> {
}
private handleOnLoad(event: any) {
// this.props.load(this.state.lexItem)
let li = this.state.lexItem;
let word = this.props.fieldMetaMap.label.get(li);
let pos = this.props.fieldMetaMap.pos.get(li);

View File

@ -9,7 +9,6 @@ import {
} from 'semantic-ui-react';
const { Flex } = require('reflexbox');
// container component
export class LexEditor extends React.Component<any, any> {
public render() {
let searchMeta = this.props.fieldMetaMap[this.props.searchState.searchType];
@ -109,8 +108,6 @@ function LexMatches(params: any) {
return editEntries;
}
};
// const debouncedSelect = _.throttle(selectMode,10000,{leading:true});
return (
<Flex wrap={true}>
{selectMode(params)}

View File

@ -3,7 +3,7 @@ import {
Dimmer, Loader, Header, Icon, Segment, Button, Dropdown
} from 'semantic-ui-react';
import * as XML from 'xml2js';
import { xmlToEntries } from './LexAccessors';
import { xmlToLexData } from './LexAccessors';
import { LexEditor } from './LexEditor';
export class LexXMLSelect extends React.Component<any, any> {
@ -86,7 +86,7 @@ export class LexSetup extends React.Component<any, any> {
Load
</Button>
);
let xmlEntries = xmlToEntries(this.props.xmlData);
let lexData = xmlToLexData(this.props.xmlData);
let dimmer = (
<Dimmer active={true} inverted={true}>
<Loader inverted={true}>Loading</Loader>
@ -112,7 +112,7 @@ export class LexSetup extends React.Component<any, any> {
</Header>
</Segment>
<LexEditor
{...xmlEntries}
{...lexData}
{...this.props}
markDirty={() => {
this.setState({ dirty: true });

View File

@ -4,7 +4,6 @@ import registerServiceWorker from './registerServiceWorker';
import './index.css';
import { bindActionCreators } from 'redux';
import { Provider, connect } from 'react-redux';
// import { LexEditor } from './LexComponents';
import { LexSetup } from './LexSetup';
import * as actionCreators from './actionCreators';
import { walleStore } from './WallEStore';

View File

@ -27,7 +27,9 @@ function updateXMLState(state: any = {}, action: any) {
let entGuid = _.find(entries, (o) => _.isEqual(_.get<any>(o, '$.guid'), guid));
let entLang = _.get<any>(entGuid, 'entry', []);
// TODO handle new entries
debugger;
let entlang = _.find(entLang, (o) => _.isEqual(_.get<any>(o, 'lang[0].$.id'), lang));
console.log('guid, lang : ', guid, lang);
_.set(entlang, 'lang[0]', action.lexItem);
return newState;
}