Skip to content

Commit 8b4d44d

Browse files
committed
#660 Support disabling secondary names for GZMTR stations
1 parent 71b8a9f commit 8b4d44d

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

src/components/side-panel/station-side-panel/info-section.tsx

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Box, Heading } from '@chakra-ui/react';
22
import { updateStationName, updateStationNum, updateStationSecondaryName } from '../../../redux/param/action';
33
import { useRootDispatch, useRootSelector } from '../../../redux';
44
import { RmgStyle } from '../../../constants/constants';
5-
import { RmgFields, RmgFieldsField } from '@railmapgen/rmg-components';
5+
import { RmgButtonGroup, RmgFields, RmgFieldsField } from '@railmapgen/rmg-components';
66
import { useTranslation } from 'react-i18next';
77

88
export default function InfoSection() {
@@ -35,14 +35,33 @@ export default function InfoSection() {
3535
value: name[1],
3636
onChange: (value: string) => dispatch(updateStationName(selectedStation, [name[0], value])),
3737
},
38+
{
39+
type: 'custom',
40+
label: t('Secondary names'),
41+
component: (
42+
<RmgButtonGroup
43+
selections={
44+
[
45+
{ label: t('Yes'), value: true },
46+
{ label: t('No'), value: false },
47+
] as { label: string; value: boolean }[]
48+
}
49+
defaultValue={!!secondaryName}
50+
onChange={flag =>
51+
dispatch(updateStationSecondaryName(selectedStation, flag ? ['', ''] : undefined))
52+
}
53+
/>
54+
),
55+
hidden: ![RmgStyle.GZMTR].includes(style),
56+
},
3857
{
3958
type: 'input',
4059
label: t('StationSidePanel.info.zhSecondary'),
4160
value: secondaryName ? secondaryName[0] : '',
4261
placeholder: '1号航站楼',
4362
onChange: (value: string) =>
4463
dispatch(updateStationSecondaryName(selectedStation, [value, secondaryName ? secondaryName[1] : ''])),
45-
hidden: ![RmgStyle.GZMTR].includes(style),
64+
hidden: !secondaryName || ![RmgStyle.GZMTR].includes(style),
4665
},
4766
{
4867
type: 'input',
@@ -51,7 +70,7 @@ export default function InfoSection() {
5170
placeholder: 'Terminal 1',
5271
onChange: (value: string) =>
5372
dispatch(updateStationSecondaryName(selectedStation, [secondaryName ? secondaryName[0] : '', value])),
54-
hidden: ![RmgStyle.GZMTR].includes(style),
73+
hidden: !secondaryName || ![RmgStyle.GZMTR].includes(style),
5574
},
5675
];
5776

src/i18n/translations/zh-Hans.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@
268268
"Remove station": "删除车站",
269269
"RIGHT END": "线路右端",
270270
"Saved projects": "保存的项目",
271+
"Secondary names": "第二名称",
271272
"Select canvas": "选择画面",
272273
"Span digits over rows": "跨行显示数字",
273274
"Style": "风格",

src/i18n/translations/zh-Hant.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@
260260
"Remove station": "移除車站",
261261
"RIGHT END": "路綫右端",
262262
"Saved projects": "儲存的專案",
263+
"Secondary names": "第二名稱",
263264
"Select canvas": "選擇畫面",
264265
"Span digits over rows": "跨行顯示數字",
265266
"Style": "風格",

0 commit comments

Comments
 (0)