Skip to content

Commit

Permalink
Some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
vmonakhov committed Sep 29, 2023
1 parent 7a234ba commit b414ecb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
11 changes: 8 additions & 3 deletions src/pages/CorpImport/ColumnMapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function valueColor(value) {
}

if (value === "secondary") {
return "purple";
return "yellow";
}

return null;
Expand Down Expand Up @@ -83,9 +83,11 @@ const ColumnWithData = compose(
)(Column);

function Columns({ blob, index, fieldOptions, columnTypes, onSetColumnType }) {
const getTranslation = useContext(TranslationContext);
const blobId = blob.get("id");
const values = blob.get("values");
const columnIdStr = `${index}:sentence`;
const column = index ? "sentence" : "base sentence";
const columnIdStr = `${index}:${column}`;
const value = values.get(columnIdStr);

return (
Expand All @@ -95,7 +97,7 @@ function Columns({ blob, index, fieldOptions, columnTypes, onSetColumnType }) {
{ value != null && (
<ColumnWithData
key={columnIdStr}
name={columnIdStr.slice(columnIdStr.indexOf(":") + 1)}
name={getTranslation(column)}
value={value}
type={columnTypes.getIn([blobId, columnIdStr])}
onSetColumnType={onSetColumnType(columnIdStr)}
Expand Down Expand Up @@ -128,13 +130,16 @@ function ColumnMapper({ state, types, columnTypes, onSetColumnType }) {
fieldOptions[idStr] = id;
}

let i = 0;

return (
<div className="column-mapper">
{state
.map((v, id) => (
<Columns
key={id.join("/")}
blob={v}
index={i++}
fieldOptions={fieldOptions}
columnTypes={columnTypes}
onSetColumnType={onSetColumnType(id)}
Expand Down
14 changes: 8 additions & 6 deletions src/pages/CorpImport/Linker.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useContext } from "react";
import React, { useContext, useEffect } from "react";
import { Button, Checkbox, Dropdown, Grid, Icon, Popup } from "semantic-ui-react";
import { pure } from "recompose";

Expand All @@ -11,19 +11,21 @@ function valueColor(value) {
return "yellow";
}

function Columns({ blob, value, onUpdateColumn, onToggleColumn, onDelete }) {
function Columns({ blob, index, onUpdateColumn, onToggleColumn, onDelete }) {
const getTranslation = useContext(TranslationContext);
const name = (value === "base") ? getTranslation("base sentence") : getTranslation("sentence");
const value = index ? "secondary" : "base";
const column = index ? "sentence" : "base sentence";
const idStr = `${index}:${column}`;

onUpdateColumn("sentence", value, null);
useEffect(() => { onUpdateColumn(idStr, value, null); }, []);

return (
<div className="blob">
<Button negative icon="trash" size="tiny" onClick={() => onDelete(blob.get("id"))} />
<b className="blob-name">{blob.get("name")}</b>
<div className="blob-columns">
<Button size="tiny" className="column-button" color={valueColor(value)}>
{name}
{getTranslation(column)}
</Button>
</div>
<Checkbox className="blob-checkbox" onClick={onToggleColumn} checked={blob.get("add")} />
Expand Down Expand Up @@ -71,7 +73,7 @@ function Linker({ blobs, state, onSelect, onDelete, onUpdateColumn, onToggleColu
<Columns
key={id.join("/")}
blob={v}
value={ (i++) ? "secondary" : "base" }
index={i++}
onUpdateColumn={onUpdateColumn(id)}
onToggleColumn={onToggleColumn(id)}
onDelete={onDelete}
Expand Down

0 comments on commit b414ecb

Please sign in to comment.