Skip to content

Commit

Permalink
Renamed values
Browse files Browse the repository at this point in the history
  • Loading branch information
ActiveChooN committed May 17, 2021
1 parent bde6e5b commit 46860c9
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions cvat-ui/src/components/move-task-modal/move-task-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default function MoveTaskModal(): JSX.Element {

const [projectId, setProjectId] = useState<number | null>(null);
const [project, setProject] = useState<any>(null);
const [values, setValues] = useState<{ [key: string]: LabelMapperItemValue }>({});
const [labelMap, setLabelMap] = useState<{ [key: string]: LabelMapperItemValue }>({});

const initValues = (): void => {
if (task) {
Expand All @@ -43,7 +43,7 @@ export default function MoveTaskModal(): JSX.Element {
clearAtrributes: true,
};
});
setValues(labelValues);
setLabelMap(labelValues);
}
};

Expand All @@ -61,7 +61,7 @@ export default function MoveTaskModal(): JSX.Element {
});
return;
}
if (!Object.values(values).every((_value) => _value.newLabelName !== null)) {
if (!Object.values(labelMap).every((map) => map.newLabelName !== null)) {
notification.error({
message: 'Not all labels mapped',
description: 'Please choose any action to not mapped labels first',
Expand All @@ -72,10 +72,10 @@ export default function MoveTaskModal(): JSX.Element {
moveTaskToProjectAsync(
task,
projectId,
Object.values(values).map((value) => ({
label_id: value.labelId,
new_label_name: value.newLabelName,
clear_attributes: value.clearAtrributes,
Object.values(labelMap).map((map) => ({
label_id: map.labelId,
new_label_name: map.newLabelName,
clear_attributes: map.clearAtrributes,
})),
),
);
Expand All @@ -89,7 +89,7 @@ export default function MoveTaskModal(): JSX.Element {
setProject(_project[0]);
const { labels } = _project[0];
const labelValues: { [key: string]: LabelMapperItemValue } = {};
Object.entries(values).forEach(([id, label]) => {
Object.entries(labelMap).forEach(([id, label]) => {
const taskLabelName = task.labels.filter(
(_label: any) => (_label.id === label.labelId),
)[0].name;
Expand All @@ -102,7 +102,7 @@ export default function MoveTaskModal(): JSX.Element {
clearAtrributes: true,
};
});
setValues(labelValues);
setLabelMap(labelValues);
}
});
} else {
Expand Down Expand Up @@ -142,17 +142,17 @@ export default function MoveTaskModal(): JSX.Element {
</Col>
</Row>
<Divider orientation='left'>Label mapping</Divider>
{!!Object.keys(values).length && !taskUpdating &&
{!!Object.keys(labelMap).length && !taskUpdating &&
task?.labels.map((label: any) => (
<LabelMapperItem
label={label}
key={label.id}
projectLabels={project?.labels}
value={values[label.id]}
labelMappers={Object.values(values)}
value={labelMap[label.id]}
labelMappers={Object.values(labelMap)}
onChange={(value) => {
setValues({
...values,
setLabelMap({
...labelMap,
[value.labelId]: value,
});
}}
Expand Down

0 comments on commit 46860c9

Please sign in to comment.