feat(tool): hide all object
This commit is contained in:
@@ -355,13 +355,10 @@ const RightObjectTools: React.FC<RightObjectToolsComponentProps> = (props) => {
|
|||||||
if (operationMap) {
|
if (operationMap) {
|
||||||
const objList = operationMap.get(operationId)
|
const objList = operationMap.get(operationId)
|
||||||
if (objList && objList.length) {
|
if (objList && objList.length) {
|
||||||
let hideFlag = true
|
const hideFlag = objList.every(([id]) => {
|
||||||
objList.forEach(([id]) => {
|
return useObjectStore.getState().pathStatus[`${imgId}${id}`]?.["HIDE"]
|
||||||
const objStatus =
|
? true
|
||||||
useObjectStore.getState().pathStatus[`${imgId}${id}`]
|
: false
|
||||||
if (objStatus && !objStatus["HIDE"]) {
|
|
||||||
hideFlag = false
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
updateOperationStatus(imgId + operationId, "HIDE", hideFlag)
|
updateOperationStatus(imgId + operationId, "HIDE", hideFlag)
|
||||||
}
|
}
|
||||||
@@ -401,6 +398,39 @@ const RightObjectTools: React.FC<RightObjectToolsComponentProps> = (props) => {
|
|||||||
[activeImage]
|
[activeImage]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const activeImageOperations = labelState.get(activeImage) || []
|
||||||
|
|
||||||
|
const isObjectHidden = (imageId: string, objectId: number) => {
|
||||||
|
return pathStatus[imageId + objectId]?.["HIDE"] ?? false
|
||||||
|
}
|
||||||
|
|
||||||
|
const isOperationHidden = (imageId: string, operationId: string) => {
|
||||||
|
const operationChildren = storeLabel.get(imageId)?.get(operationId) || []
|
||||||
|
return (
|
||||||
|
operationChildren.length > 0 &&
|
||||||
|
operationChildren.every(([objectId]) => isObjectHidden(imageId, objectId))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const totalObjectCount = activeImageOperations.reduce(
|
||||||
|
(count, operationId) => {
|
||||||
|
return (
|
||||||
|
count + (storeLabel.get(activeImage)?.get(operationId)?.length || 0)
|
||||||
|
)
|
||||||
|
},
|
||||||
|
0
|
||||||
|
)
|
||||||
|
|
||||||
|
const areAllObjectsHidden =
|
||||||
|
totalObjectCount > 0 &&
|
||||||
|
activeImageOperations.every((operationId) => {
|
||||||
|
const operationChildren =
|
||||||
|
storeLabel.get(activeImage)?.get(operationId) || []
|
||||||
|
return operationChildren.every(([objectId]) =>
|
||||||
|
isObjectHidden(activeImage, objectId)
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
// const renderObjectName = useCallback((name: string, input: string) => {
|
// const renderObjectName = useCallback((name: string, input: string) => {
|
||||||
// const index = name?.indexOf(input);
|
// const index = name?.indexOf(input);
|
||||||
// const beforeStr = name?.substring(0, index);
|
// const beforeStr = name?.substring(0, index);
|
||||||
@@ -509,9 +539,22 @@ const RightObjectTools: React.FC<RightObjectToolsComponentProps> = (props) => {
|
|||||||
<Box h="100%" w="100%">
|
<Box h="100%" w="100%">
|
||||||
<Flex direction="column" h="100%" gap="xs">
|
<Flex direction="column" h="100%" gap="xs">
|
||||||
<Flex justify="space-between" align="center" px="md" py="xs">
|
<Flex justify="space-between" align="center" px="md" py="xs">
|
||||||
|
<Group gap="xs">
|
||||||
|
<ActionIcon
|
||||||
|
variant="subtle"
|
||||||
|
aria-label={areAllObjectsHidden ? "显示全部对象" : "隐藏全部对象"}
|
||||||
|
onClick={() => {
|
||||||
|
if (!totalObjectCount) return
|
||||||
|
activeImageOperations.forEach((operationId) => {
|
||||||
|
operationHide(operationId, !areAllObjectsHidden)
|
||||||
|
})
|
||||||
|
}}>
|
||||||
|
{areAllObjectsHidden ? <EyeOff size={16} /> : <Eye size={16} />}
|
||||||
|
</ActionIcon>
|
||||||
<Title order={4} size="h4">
|
<Title order={4} size="h4">
|
||||||
对象列表
|
对象列表
|
||||||
</Title>
|
</Title>
|
||||||
|
</Group>
|
||||||
<Group gap="xs">
|
<Group gap="xs">
|
||||||
<TextInput
|
<TextInput
|
||||||
w={96}
|
w={96}
|
||||||
@@ -566,13 +609,11 @@ const RightObjectTools: React.FC<RightObjectToolsComponentProps> = (props) => {
|
|||||||
}}>
|
}}>
|
||||||
<ScrollArea style={{ flex: 1 }} px="md">
|
<ScrollArea style={{ flex: 1 }} px="md">
|
||||||
<Stack gap="xs" pb="md">
|
<Stack gap="xs" pb="md">
|
||||||
{labelState.get(activeImage) &&
|
{activeImageOperations.map((operationId) => {
|
||||||
labelState.get(activeImage)?.map((operationId) => {
|
|
||||||
const operationSchema = getOperationSchema(operationId)
|
const operationSchema = getOperationSchema(operationId)
|
||||||
const isCollapsed =
|
const isCollapsed =
|
||||||
operationStatus[activeImage + operationId]?.["COLLAPSE"]
|
operationStatus[activeImage + operationId]?.["COLLAPSE"]
|
||||||
const isHide =
|
const isHide = isOperationHidden(activeImage, operationId)
|
||||||
operationStatus[activeImage + operationId]?.HIDE
|
|
||||||
const hasSubAttrError = getOperationSubAttrStatus(operationId)
|
const hasSubAttrError = getOperationSubAttrStatus(operationId)
|
||||||
const operationLabel = operationSchema?.label_class
|
const operationLabel = operationSchema?.label_class
|
||||||
const operationChildren =
|
const operationChildren =
|
||||||
@@ -613,14 +654,8 @@ const RightObjectTools: React.FC<RightObjectToolsComponentProps> = (props) => {
|
|||||||
<ActionIcon
|
<ActionIcon
|
||||||
variant="subtle"
|
variant="subtle"
|
||||||
size="sm"
|
size="sm"
|
||||||
onClick={() =>
|
onClick={() => operationHide(operationId, !isHide)}>
|
||||||
operationHide(operationId, !isHide)
|
{!isHide ? <Eye size={16} /> : <EyeOff size={16} />}
|
||||||
}>
|
|
||||||
{!isHide ? (
|
|
||||||
<Eye size={16} />
|
|
||||||
) : (
|
|
||||||
<EyeOff size={16} />
|
|
||||||
)}
|
|
||||||
</ActionIcon>
|
</ActionIcon>
|
||||||
<Group
|
<Group
|
||||||
gap={8}
|
gap={8}
|
||||||
@@ -851,8 +886,7 @@ const RightObjectTools: React.FC<RightObjectToolsComponentProps> = (props) => {
|
|||||||
{
|
{
|
||||||
userOpts.find(
|
userOpts.find(
|
||||||
(item) =>
|
(item) =>
|
||||||
item.value ===
|
item.value === child[2]?.uid
|
||||||
child[2]?.uid
|
|
||||||
)?.label
|
)?.label
|
||||||
}
|
}
|
||||||
</Text>
|
</Text>
|
||||||
@@ -865,9 +899,7 @@ const RightObjectTools: React.FC<RightObjectToolsComponentProps> = (props) => {
|
|||||||
</Group>
|
</Group>
|
||||||
{child[2]?.first_modified_uid && (
|
{child[2]?.first_modified_uid && (
|
||||||
<Group gap={4}>
|
<Group gap={4}>
|
||||||
<Text size="xs">
|
<Text size="xs">首次修改:</Text>
|
||||||
首次修改:
|
|
||||||
</Text>
|
|
||||||
<Text size="xs">
|
<Text size="xs">
|
||||||
{
|
{
|
||||||
userOpts.find(
|
userOpts.find(
|
||||||
@@ -883,17 +915,13 @@ const RightObjectTools: React.FC<RightObjectToolsComponentProps> = (props) => {
|
|||||||
(child[2]
|
(child[2]
|
||||||
?.first_modified_timestamp ||
|
?.first_modified_timestamp ||
|
||||||
0) * 1000
|
0) * 1000
|
||||||
).format(
|
).format("YYYY-MM-DD HH:mm:ss")}
|
||||||
"YYYY-MM-DD HH:mm:ss"
|
|
||||||
)}
|
|
||||||
</Text>
|
</Text>
|
||||||
</Group>
|
</Group>
|
||||||
)}
|
)}
|
||||||
{child[2]?.last_modified_uid && (
|
{child[2]?.last_modified_uid && (
|
||||||
<Group gap={4}>
|
<Group gap={4}>
|
||||||
<Text size="xs">
|
<Text size="xs">最新修改:</Text>
|
||||||
最新修改:
|
|
||||||
</Text>
|
|
||||||
<Text size="xs">
|
<Text size="xs">
|
||||||
{
|
{
|
||||||
userOpts.find(
|
userOpts.find(
|
||||||
@@ -909,9 +937,7 @@ const RightObjectTools: React.FC<RightObjectToolsComponentProps> = (props) => {
|
|||||||
(child[2]
|
(child[2]
|
||||||
?.last_modified_timestamp ||
|
?.last_modified_timestamp ||
|
||||||
0) * 1000
|
0) * 1000
|
||||||
).format(
|
).format("YYYY-MM-DD HH:mm:ss")}
|
||||||
"YYYY-MM-DD HH:mm:ss"
|
|
||||||
)}
|
|
||||||
</Text>
|
</Text>
|
||||||
</Group>
|
</Group>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in New Issue
Block a user