Skip to content

Commit

Permalink
Merge pull request #604 from lihqi/lhq-3.8.3alpha
Browse files Browse the repository at this point in the history
fix(lb-components): The tackID can be modified to 0
  • Loading branch information
Glenfiddish authored Oct 30, 2024
2 parents f8e6a04 + a8e85dc commit 5016c66
Showing 1 changed file with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useContext, useState, useEffect } from 'react';
import React, { useContext, useState, useEffect, useMemo } from 'react';
import { EditFilled } from '@ant-design/icons';
import { ToolIcons } from '../ToolIcons';
import { EToolName } from '@/data/enums/ToolType';
Expand Down Expand Up @@ -42,6 +42,7 @@ import { SetTaskStepList } from '@/store/annotation/actionCreators';
import { usePointCloudViews } from '@/components/pointCloudView/hooks/usePointCloudViews';
import SubAttributeList from '@/components/subAttributeList';
import DynamicResizer from '@/components/DynamicResizer';
import { isNumber } from 'lodash';
interface IProps {
stepInfo: IStepInfo;
toolInstance: ICustomToolInstance; // Created by useCustomToolInstance.
Expand All @@ -61,6 +62,10 @@ const BoxTrackIDInput = () => {

const selectedBoxTrackID = selectedBox?.info.trackID;

const hasSelectedBoxTrackID = useMemo(() => {
return isNumber(selectedBoxTrackID) && selectedBoxTrackID >= 0;
}, [selectedBoxTrackID]);

const hasDuplicateTrackID = (trackID: number) => {
const duplicateBox = pointCloudBoxList.find(
(v) => v.trackID === trackID && v.id !== selectedBox?.info.id,
Expand Down Expand Up @@ -89,7 +94,7 @@ const BoxTrackIDInput = () => {
return;
}

if (!(newTrackID > 0)) {
if (newTrackID < 0) {
message.error(t('PositiveIntegerCheck'));
return;
}
Expand Down Expand Up @@ -120,9 +125,9 @@ const BoxTrackIDInput = () => {
}}
>
<span>{t('CurrentBoxTrackIDs')}</span>
{selectedBoxTrackID && (
{hasSelectedBoxTrackID && (
<BatchUpdateModal
id={selectedBoxTrackID}
id={selectedBoxTrackID as number}
updateCurrentPolygonList={(value) => updateCurrentPolygonList(value)}
/>
)}
Expand All @@ -135,13 +140,13 @@ const BoxTrackIDInput = () => {
lineHeight: '12px',
}}
>
{isEdit && selectedBoxTrackID ? (
{isEdit && hasSelectedBoxTrackID ? (
<Input
defaultValue={selectedBoxTrackID}
onChange={(e) => {
setInputValue(e.target.value);
}}
disabled={!selectedBoxTrackID}
disabled={!hasSelectedBoxTrackID}
size='small'
onBlur={() => {
applyInputValue();
Expand All @@ -160,7 +165,7 @@ const BoxTrackIDInput = () => {
cursor: typeof selectedBoxTrackID !== 'undefined' ? 'pointer' : 'not-allowed',
}}
onClick={() => {
if (selectedBoxTrackID) {
if (hasSelectedBoxTrackID) {
setIsEdit(!isEdit);
}
}}
Expand Down

0 comments on commit 5016c66

Please sign in to comment.