{map(perspective_list, ({ treePathList, perspective, textFieldsOptions }, index) => (
// Not so good hack in the name of performance,
- // we just give our state to be modified in the child compoment.
+ // we just give our state to be modified in the child component.
this.setState({ perspectiveSelectionCountMap })}
onModalStateChange={onModalStateChange}
@@ -481,7 +500,8 @@ class MLPerspectiveSelection extends React.Component {
this.state = {
perspectiveSelectionMap: props.perspectiveSelectionMap,
transcriptionFieldIdStrMap: props.transcriptionFieldIdStrMap,
- translationFieldIdStrMap: props.translationFieldIdStrMap
+ translationFieldIdStrMap: props.translationFieldIdStrMap,
+ lexemeFieldIdStrMap: props.lexemeFieldIdStrMap
};
this.onChangeSelect = this.onChangeSelect.bind(this);
@@ -570,6 +590,7 @@ class MLPerspectiveSelection extends React.Component {
perspectiveSelectionMap,
transcriptionFieldIdStrMap,
translationFieldIdStrMap,
+ lexemeFieldIdStrMap,
language_id_str,
onChangeSelectAll
} = this.props;
@@ -630,6 +651,21 @@ class MLPerspectiveSelection extends React.Component {
className="lingvo-dropdown-select lingvo-dropdown-select_cognate"
/>
+
{this.context("Source lexeme field (optional)")}:
+
+
)}
@@ -845,6 +881,7 @@ class MLSelection extends React.Component {
perspectiveSelectionMap,
transcriptionFieldIdStrMap,
translationFieldIdStrMap,
+ lexemeFieldIdStrMap,
perspectiveSelectionCountMap,
language_id_set,
languageSelectionMap,
@@ -941,6 +978,7 @@ class MLSelection extends React.Component {
perspectiveSelectionMap={perspectiveSelectionMap}
transcriptionFieldIdStrMap={transcriptionFieldIdStrMap}
translationFieldIdStrMap={translationFieldIdStrMap}
+ lexemeFieldIdStrMap={lexemeFieldIdStrMap}
perspectiveSelectionCountMap={perspectiveSelectionCountMap}
language_id_str={language_id_str}
onChangeSelectAll={() => this.setState({ perspectiveSelectionCountMap })}
@@ -1240,6 +1278,7 @@ class CognateAnalysisModal extends React.Component {
transcriptionFieldIdStrList: [],
translationFieldIdStrList: [],
+ lexemeFieldIdStrList: [],
perspectiveSelectionList: [],
groupFieldIdStr: "",
@@ -1260,6 +1299,7 @@ class CognateAnalysisModal extends React.Component {
transcriptionFieldIdStrMap: {},
translationFieldIdStrMap: {},
+ lexemeFieldIdStrMap: {},
perspectiveSelectionMap: {},
languageSelectionMap: [],
@@ -1359,11 +1399,12 @@ class CognateAnalysisModal extends React.Component {
* analysis. */
if (this.state.groupFieldIdStr) {
- const { transcriptionFieldIdStrList, translationFieldIdStrList, perspectiveSelectionList } =
+ const { transcriptionFieldIdStrList, translationFieldIdStrList, lexemeFieldIdStrList, perspectiveSelectionList } =
this.initPerspectiveList(this.state.groupFieldIdStr);
this.state.transcriptionFieldIdStrList = transcriptionFieldIdStrList;
this.state.translationFieldIdStrList = translationFieldIdStrList;
+ this.state.lexemeFieldIdStrList = lexemeFieldIdStrList;
this.state.perspectiveSelectionList = perspectiveSelectionList;
}
}
@@ -1491,6 +1532,7 @@ class CognateAnalysisModal extends React.Component {
this.state.transcriptionFieldIdStrMap[p_key] = this.state.transcriptionFieldIdStrList[index];
this.state.translationFieldIdStrMap[p_key] = this.state.translationFieldIdStrList[index];
+ this.state.lexemeFieldIdStrMap[p_key] = this.state.lexemeFieldIdStrList[index];
this.state.perspectiveSelectionMap[p_key] = this.state.perspectiveSelectionList[index];
if (this.state.perspectiveSelectionList[index]) {
@@ -1532,9 +1574,11 @@ class CognateAnalysisModal extends React.Component {
perspectiveSelectionList,
transcriptionFieldIdStrList,
translationFieldIdStrList,
+ lexemeFieldIdStrList,
perspectiveSelectionMap,
transcriptionFieldIdStrMap,
translationFieldIdStrMap,
+ lexemeFieldIdStrMap,
perspectiveSelectionCountMap
} = this.state;
@@ -1554,6 +1598,10 @@ class CognateAnalysisModal extends React.Component {
translationFieldIdStrMap[p_key] = translationFieldIdStrList[index];
}
+ if (!lexemeFieldIdStrMap.hasOwnProperty(p_key)) {
+ lexemeFieldIdStrMap[p_key] = lexemeFieldIdStrList[index];
+ }
+
if (!perspectiveSelectionMap.hasOwnProperty(p_key)) {
perspectiveSelectionMap[p_key] = perspectiveSelectionList[index];
}
@@ -1649,6 +1697,7 @@ class CognateAnalysisModal extends React.Component {
const transcriptionFieldIdStrList = [];
const translationFieldIdStrList = [];
+ const lexemeFieldIdStrList = [];
const perspectiveSelectionList = [];
@@ -1671,10 +1720,11 @@ class CognateAnalysisModal extends React.Component {
textFieldsOptions
});
- /* Selecting text fields with 'transcription' and 'translation' in their names, if we have them. */
+ /* Selecting text fields with 'transcription', 'translation', 'word' in their names, if we have them. */
let transcriptionFieldIdStr = "";
let translationFieldIdStr = "";
+ let lexemeFieldIdStr = "";
for (const field of textFields) {
const check_str = field.english_translation.toLowerCase();
@@ -1686,6 +1736,10 @@ class CognateAnalysisModal extends React.Component {
if (!translationFieldIdStr && (check_str.includes("translation") || check_str.includes("meaning"))) {
translationFieldIdStr = id2str(field.id);
}
+
+ if (!lexemeFieldIdStr && check_str === "word") {
+ lexemeFieldIdStr = id2str(field.id);
+ }
}
/* If we haven't found thus named fields, we try to select the first one. */
@@ -1698,10 +1752,15 @@ class CognateAnalysisModal extends React.Component {
if (!translationFieldIdStr) {
translationFieldIdStr = id2str(textFields[0].id);
}
+
+ if (!lexemeFieldIdStr) {
+ lexemeFieldIdStr = id2str(textFields[0].id);
+ }
}
transcriptionFieldIdStrList.push(transcriptionFieldIdStr);
translationFieldIdStrList.push(translationFieldIdStr);
+ lexemeFieldIdStrList.push(lexemeFieldIdStr);
perspectiveSelectionList.push(true);
}
@@ -1710,12 +1769,14 @@ class CognateAnalysisModal extends React.Component {
this.state.transcriptionFieldIdStrList = transcriptionFieldIdStrList;
this.state.translationFieldIdStrList = translationFieldIdStrList;
+ this.state.lexemeFieldIdStrList = lexemeFieldIdStrList;
this.state.perspectiveSelectionList = perspectiveSelectionList;
return {
transcriptionFieldIdStrList,
translationFieldIdStrList,
+ lexemeFieldIdStrList,
perspectiveSelectionList
};
}
@@ -2056,7 +2117,8 @@ class CognateAnalysisModal extends React.Component {
perspectiveInfoList.push([
perspective.id,
this.fieldDict[this.state.transcriptionFieldIdStrMap[p_key]].id,
- this.fieldDict[this.state.translationFieldIdStrMap[p_key]].id
+ this.fieldDict[this.state.translationFieldIdStrMap[p_key]].id,
+ this.fieldDict[this.state.lexemeFieldIdStrMap[p_key]].id
]);
p_count++;
@@ -2071,7 +2133,8 @@ class CognateAnalysisModal extends React.Component {
.map(({ perspective }, index) => [
perspective.id,
this.fieldDict[this.state.transcriptionFieldIdStrList[index]].id,
- this.fieldDict[this.state.translationFieldIdStrList[index]].id
+ this.fieldDict[this.state.translationFieldIdStrList[index]].id,
+ this.fieldDict[this.state.lexemeFieldIdStrList[index]].id
])
.filter((perspective_info, index) => this.state.perspectiveSelectionList[index]);
@@ -2358,6 +2421,7 @@ class CognateAnalysisModal extends React.Component {
perspectiveSelectionList={this.state.perspectiveSelectionList}
transcriptionFieldIdStrList={this.state.transcriptionFieldIdStrList}
translationFieldIdStrList={this.state.translationFieldIdStrList}
+ lexemeFieldIdStrList={this.state.lexemeFieldIdStrList}
perspectiveSelectionCountMap={this.state.perspectiveSelectionCountMap}
onModalStateChange={() => this.setState({})}
/>
@@ -2403,6 +2467,7 @@ class CognateAnalysisModal extends React.Component {
languageSelectionMap={this.state.languageSelectionMap}
transcriptionFieldIdStrMap={this.state.transcriptionFieldIdStrMap}
translationFieldIdStrMap={this.state.translationFieldIdStrMap}
+ lexemeFieldIdStrMap={this.state.lexemeFieldIdStrMap}
perspectiveSelectionCountMap={this.state.perspectiveSelectionCountMap}
language_id_set={this.state.language_id_set}
available_language_list={this.language_list}