fixed new entry addition

master
Malar Kannan 2017-08-01 12:07:33 +05:30
parent a4db9e12ea
commit 6c669d39cc
2 changed files with 8 additions and 4 deletions

View File

@ -224,6 +224,8 @@ export const xmlToLexData = (xmlData: any) => {
.value() .value()
) )
.value(); .value();
let allGuids = _.map(allEntries, _.flow(fieldMetaMap.guid.get, _.toInteger));
let newGuid = (): number => _.toInteger(_.max(allGuids));
let langReducer = ((result: any, q: any) => { let langReducer = ((result: any, q: any) => {
let lang = fieldMetaMap.lang.get(q); let lang = fieldMetaMap.lang.get(q);
(result[lang] || (result[lang] = [])).push(q); (result[lang] || (result[lang] = [])).push(q);
@ -242,6 +244,6 @@ export const xmlToLexData = (xmlData: any) => {
return [lang, langOpts]; return [lang, langOpts];
})); }));
return ({ return ({
allEntries, selectFields, fieldMetaMap allEntries, newGuid, selectFields, fieldMetaMap
}); });
}; };

View File

@ -17,14 +17,14 @@ export class LexEditor extends React.Component<any, any> {
.filter((q: any) => searchMeta.get(q) === searchText) .filter((q: any) => searchMeta.get(q) === searchText)
.take(10) .take(10)
.value(); .value();
let { fieldMetaMap, save, markDirty } = this.props; let { fieldMetaMap, save, markDirty, newGuid } = this.props;
return ( return (
<div> <div>
<LexSearch <LexSearch
{...this.props} {...this.props}
/> />
<LexMatches <LexMatches
{...{ fieldMetaMap, save, markDirty }} {...{ fieldMetaMap, save, markDirty, newGuid }}
matchedEntries={matchedEntries} matchedEntries={matchedEntries}
selectionMeta={this.props.selectFields} selectionMeta={this.props.selectFields}
searchText={searchText} searchText={searchText}
@ -94,7 +94,9 @@ function LexMatches(params: any) {
/> />
); );
}); });
let addProps = props.searchMeta.set({}, props.searchText); let sf = props.searchMeta.set({}, props.searchText);
let gf = fm.guid.set(sf, props.newGuid());
let addProps = fm.lang.set(gf, 'en');
let addEntry = ( let addEntry = (
<LexEdit <LexEdit
{...props} {...props}