Skip to content

Commit ef8cd77

Browse files
committed
chore: Tree select controller naming & description improvement
1 parent da25cf4 commit ef8cd77

File tree

8 files changed

+42
-34
lines changed

8 files changed

+42
-34
lines changed

frontend/src/app/pages/DashBoardPage/components/Widgets/ControllerWidget/ControllerWidgetCore.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export const ControllerWidgetCore: React.FC<{}> = memo(() => {
7575
valueOptions,
7676
valueOptionType,
7777
parentField,
78-
treeType,
78+
buildingMethod,
7979
// sqlOperator,
8080
} = useMemo(() => config as ControllerConfig, [config]);
8181
const title = getWidgetTitle(widget.config.customConfig.props);
@@ -107,7 +107,7 @@ export const ControllerWidgetCore: React.FC<{}> = memo(() => {
107107

108108
if (valueOptionType === 'common') {
109109
if (parentField?.length) {
110-
return convertToTree(dataRows, treeType);
110+
return convertToTree(dataRows, buildingMethod);
111111
}
112112
return dataRows.map(ele => {
113113
const item: RelationFilterValue = {
@@ -122,7 +122,13 @@ export const ControllerWidgetCore: React.FC<{}> = memo(() => {
122122
} else {
123123
return [];
124124
}
125-
}, [dataset?.rows, valueOptionType, valueOptions, parentField, treeType]);
125+
}, [
126+
dataset?.rows,
127+
valueOptionType,
128+
valueOptions,
129+
parentField,
130+
buildingMethod,
131+
]);
126132

127133
const onControllerChange = useCallback(() => {
128134
form.submit();

frontend/src/app/pages/DashBoardPage/pages/BoardEditor/components/ControllerWidgetPanel/ControllerConfig/ValuesSetter/TreeTypeSetter/TreeTypeSetter.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,20 @@ function TreeTypeSetter({ form }: TreeTypeSetterProps) {
4848
return (
4949
<Form.Item
5050
shouldUpdate
51-
label={t('treeSelectType')}
52-
name={['config', 'treeType']}
51+
label={t('treeBuildingMethod')}
52+
name={['config', 'buildingMethod']}
5353
>
5454
<Radio.Group onChange={handleChangeFn}>
55-
<Radio.Button value="treeControl">
56-
{t('treeControl') + ' '}
57-
<Tooltip title={t('treeControlTip')}>
55+
<Radio.Button value="byParent">
56+
{t('byParent') + ' '}
57+
<Tooltip title={t('byParentTip')}>
5858
<QuestionCircleOutlined />
5959
</Tooltip>
6060
</Radio.Button>
6161

62-
<Radio.Button value="treeSelect">
63-
{t('treeSelect') + ' '}
64-
<Tooltip title={t('treeSelectTip')}>
62+
<Radio.Button value="byHierarchy">
63+
{t('byHierarchy') + ' '}
64+
<Tooltip title={t('byHierarchyTip')}>
6565
<QuestionCircleOutlined />
6666
</Tooltip>
6767
</Radio.Button>

frontend/src/app/pages/DashBoardPage/pages/BoardEditor/components/ControllerWidgetPanel/ControllerConfig/ValuesSetter/ValuesOptionsSetter/ValuesOptionsSetter.tsx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ const ValuesOptionsSetter: FC<{
102102
return form?.getFieldValue('config')?.parentField as string[];
103103
}, [form]);
104104

105-
const getTreeType = useCallback(() => {
106-
return form?.getFieldValue('config')?.treeType as string;
105+
const getTreeBuildingMethod = useCallback(() => {
106+
return form?.getFieldValue('config')?.buildingMethod as string;
107107
}, [form]);
108108

109109
const isMultiple = useMemo(() => {
@@ -195,7 +195,7 @@ const ValuesOptionsSetter: FC<{
195195
if (type !== 'view') {
196196
const [viewId, ...columns] = value;
197197
const parentField = getParentField();
198-
const treeType = getTreeType();
198+
const buildingMethod = getTreeBuildingMethod();
199199

200200
if (parentField) {
201201
columns.push(...parentField);
@@ -204,7 +204,7 @@ const ValuesOptionsSetter: FC<{
204204

205205
setOptionValues(
206206
parentField?.length > 0
207-
? convertToTree(dataset?.rows, treeType)
207+
? convertToTree(dataset?.rows, buildingMethod)
208208
: convertToList(dataset?.rows),
209209
);
210210
}
@@ -214,7 +214,7 @@ const ValuesOptionsSetter: FC<{
214214
fetchNewDataset,
215215
getParentField,
216216
getViewOption,
217-
getTreeType,
217+
getTreeBuildingMethod,
218218
],
219219
);
220220

@@ -279,11 +279,11 @@ const ValuesOptionsSetter: FC<{
279279
}
280280
const dataset = await fetchNewDataset(viewId, columns, dataView);
281281
const config: ControllerConfig = getControllerConfig();
282-
const treeType = getTreeType();
282+
const buildingMethod = getTreeBuildingMethod();
283283

284284
setOptionValues(
285285
parentField
286-
? convertToTree(dataset?.rows, treeType)
286+
? convertToTree(dataset?.rows, buildingMethod)
287287
: convertToList(dataset?.rows),
288288
);
289289
setLabelOptions(options);
@@ -300,7 +300,7 @@ const ValuesOptionsSetter: FC<{
300300
fetchNewDataset,
301301
getControllerConfig,
302302
getViewOption,
303-
getTreeType,
303+
getTreeBuildingMethod,
304304
],
305305
);
306306

@@ -387,7 +387,9 @@ const ValuesOptionsSetter: FC<{
387387
<Form.Item name={['config', 'parentField']} noStyle>
388388
<TreeSetter
389389
mode={
390-
getTreeType() === 'treeSelect' ? 'multiple' : undefined
390+
getTreeBuildingMethod() === 'byHierarchy'
391+
? 'multiple'
392+
: undefined
391393
}
392394
onChange={onParentFieldChange}
393395
viewFieldList={labelOptions}
@@ -398,7 +400,7 @@ const ValuesOptionsSetter: FC<{
398400

399401
{getOptionType() === 'common' && (
400402
<Space direction="vertical" style={{ width: '100%' }}>
401-
{!(isTree && getTreeType() === 'treeSelect') && (
403+
{!(isTree && getTreeBuildingMethod() === 'byHierarchy') && (
402404
<Select
403405
showSearch
404406
placeholder={tc('optionLabelField')}

frontend/src/app/pages/DashBoardPage/pages/BoardEditor/components/ControllerWidgetPanel/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export interface ControllerConfig {
4242
assistViewFields?: string[]; //辅助添加view字段
4343
controllerDate?: ControllerDate; //存储时间
4444
parentField?: string[]; //父节点字段
45-
treeType?: 'treeControl' | 'treeSelect'; //树控制器类型
45+
buildingMethod?: 'byParent' | 'byHierarchy'; //树控制器类型
4646

4747
minValue?: number; // slider min
4848
maxValue?: number; // slider max

frontend/src/app/pages/DashBoardPage/pages/BoardEditor/components/ControllerWidgetPanel/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ export const getRangeValueControllerConfig = () => {
288288
export const getDropdownTreeControllerConfig = () => {
289289
const config = getInitControllerConfig();
290290
config.sqlOperator = FilterSqlOperator.In;
291-
config.treeType = 'treeControl';
291+
config.buildingMethod = 'byParent';
292292
config.parentField = [];
293293
return config;
294294
};

frontend/src/app/pages/DashBoardPage/utils/widget.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,7 @@ export const convertToTree = (col, type) => {
836836
let copyCol = CloneValueDeep(col);
837837
let emptyParentList = ['null', 'undefined', 'false'];
838838

839-
if (type === 'treeControl') {
839+
if (type === 'byParent') {
840840
const parent = copyCol?.find(
841841
v => !v[v.length - 1] || emptyParentList.includes(v[v.length - 1]),
842842
) || [null];

frontend/src/locales/en/translation.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,11 +1177,11 @@
11771177
"delete": "Delete",
11781178
"populate": "Populate From Field Values",
11791179
"parentFieldId": "Select Parent Field",
1180-
"treeSelectType": "Select Tree Type",
1181-
"treeControl": "Tree Control",
1182-
"treeControlTip": "Multi-level structure list (folders, organizational structures, categories, countries, etc. Use tree controls to fully display hierarchical relationships.)",
1183-
"treeSelect": "Tree Select",
1184-
"treeSelectTip": "Tree selection control (can be used when the optional data structure is a tree structure, such as company hierarchy, subject system, taxonomy, etc.)"
1180+
"treeBuildingMethod": "Building Method",
1181+
"byParent": "By Parent",
1182+
"byParentTip": "Automatically build a tree by specifying a value field (ID) and a parent field (Parent ID); for example: folder tree",
1183+
"byHierarchy": "By Hierarchy",
1184+
"byHierarchyTip": "Build a tree from multiple dimension fields with natural hierarchical attributes; for example: country, province, city"
11851185
},
11861186
"date": {
11871187
"year": "Year",

frontend/src/locales/zh/translation.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,11 +1175,11 @@
11751175
"delete": "删除",
11761176
"populate": "从字段填充备选项",
11771177
"parentFieldId": "父ID字段",
1178-
"treeSelectType": "树类型选择",
1179-
"treeControl": "树形控件",
1180-
"treeControlTip": "多层次的结构列表(文件夹、组织架构、生物分类、国家地区等等。使用 树控件 可以完整展现其中的层级关系。)",
1181-
"treeSelect": "树选择",
1182-
"treeSelectTip": "树型选择控件(可选择的数据结构是一个树形结构时,可以使用,例如公司层级、学科系统、分类目录等等。)"
1178+
"treeBuildingMethod": "构建树方式",
1179+
"byParent": "父子字段",
1180+
"byParentTip": "通过指定取值字段(ID)和父级字段(Parent ID)来自动构建树;例如:文件夹树",
1181+
"byHierarchy": "层级字段",
1182+
"byHierarchyTip": "通过多个拥有天然层级属性的维度字段来构建树;例如:国家、省份、城市"
11831183
},
11841184
"date": {
11851185
"year": "",

0 commit comments

Comments
 (0)