Skip to content

Commit

Permalink
Merge pull request #630 from lihqi/lhq-1224alpha
Browse files Browse the repository at this point in the history
feat(lb-annotation): Enhance rectangle drawing size validation with i18
  • Loading branch information
lihqi authored Jan 15, 2025
2 parents 5901944 + 5ad3a47 commit 1244c32
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
14 changes: 12 additions & 2 deletions packages/lb-annotation/src/core/toolOperation/rectOperation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import uuid from '../../utils/uuid';
import { BasicToolOperation, IBasicToolOperationProps } from './basicToolOperation';
import TextAttributeClass from './textAttributeClass';
import Selection, { SetDataList } from './Selection';
import { i18n } from '@labelbee/lb-utils';

interface IRectOperationProps extends IBasicToolOperationProps {
drawOutSideTarget?: boolean; // 是否可以在边界外进行标注
Expand Down Expand Up @@ -1172,14 +1173,23 @@ class RectOperation extends BasicToolOperation {
height,
minWidth,
minHeight,
isAttributeConfig = false,
}: {
width: number;
height: number;
minWidth: number;
minHeight: number;
isAttributeConfig?: boolean;
}) {
if (Math.round(width) < minWidth || Math.round(height) < minHeight) {
this.emit('messageInfo', locale.getMessagesByLocale(EMessage.RectErrorSizeNotice, this.lang));
this.emit(
'messageInfo',
i18n.t(
isAttributeConfig
? 'TheSizeOfTheDrawingBoxIsSmallerThanTheMinimumDrawingSizeInTheMainPropertyConfiguration'
: 'TheDrawFrameSizeIsSmallerThanTheMinimumDrawSizeInTheStepConfiguration',
),
);

this.clearDrawingStatus();
this.render();
Expand Down Expand Up @@ -1212,7 +1222,7 @@ class RectOperation extends BasicToolOperation {
const attributeList = this.config?.attributeList ?? [];
const attributeLimit = attributeList.find((i: any) => i.value === attribute)?.limit;
if (attributeLimit) {
limit = attributeLimit;
limit = { ...attributeLimit, isAttributeConfig: true };
}
}

Expand Down
8 changes: 6 additions & 2 deletions packages/lb-utils/src/i18n/resources.json
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,9 @@
"Dialog": "Dialog",
"SelectionOfAnnotation": "Selection of annotation",
"Annotating": "Annotating",
"Group": "Group"
"Group": "Group",
"TheDrawFrameSizeIsSmallerThanTheMinimumDrawSizeInTheStepConfiguration": "The draw frame size is smaller than the minimum draw size in the step configuration",
"TheSizeOfTheDrawingBoxIsSmallerThanTheMinimumDrawingSizeInTheMainPropertyConfiguration": "The size of the drawing box is smaller than the minimum drawing size in the main property configuration"
},
"cn": {
"TextInput": "文本输入",
Expand Down Expand Up @@ -765,6 +767,8 @@
"Dialog": "对话",
"SelectionOfAnnotation": "选中标注",
"Annotating": "正在标注",
"Group": ""
"Group": "",
"TheDrawFrameSizeIsSmallerThanTheMinimumDrawSizeInTheStepConfiguration": "绘制框尺寸小于步骤配置里的最小绘制尺寸",
"TheSizeOfTheDrawingBoxIsSmallerThanTheMinimumDrawingSizeInTheMainPropertyConfiguration": "绘制框尺寸小于主属性配置里的最小绘制尺寸"
}
}

0 comments on commit 1244c32

Please sign in to comment.