feat: Apply translation automation from select option to multi-select option (#1963)
This commit is contained in:
@@ -170,6 +170,15 @@ const WidgetOptionTypeSwitch: FC<{
|
|||||||
</Stack>
|
</Stack>
|
||||||
);
|
);
|
||||||
case 'multi-select':
|
case 'multi-select':
|
||||||
|
const multiSelectItems = typeof option.data === 'function' ? option.data() : option.data;
|
||||||
|
const multiSelectData = multiSelectItems.map((dataType) => {
|
||||||
|
return !dataType.label
|
||||||
|
? {
|
||||||
|
value: dataType.value,
|
||||||
|
label: t(`descriptor.settings.${key}.data.${dataType.value}`),
|
||||||
|
}
|
||||||
|
: dataType;
|
||||||
|
});
|
||||||
return (
|
return (
|
||||||
<Stack spacing={0}>
|
<Stack spacing={0}>
|
||||||
<Group align="center" spacing="sm">
|
<Group align="center" spacing="sm">
|
||||||
@@ -179,9 +188,10 @@ const WidgetOptionTypeSwitch: FC<{
|
|||||||
{info && <InfoCard message={t(`descriptor.settings.${key}.info`)} link={link} />}
|
{info && <InfoCard message={t(`descriptor.settings.${key}.info`)} link={link} />}
|
||||||
</Group>
|
</Group>
|
||||||
<MultiSelect
|
<MultiSelect
|
||||||
data={option.data}
|
searchable
|
||||||
value={value as string[]}
|
|
||||||
defaultValue={option.defaultValue}
|
defaultValue={option.defaultValue}
|
||||||
|
data={multiSelectData}
|
||||||
|
value={value as string[]}
|
||||||
onChange={(v) => handleChange(key, v)}
|
onChange={(v) => handleChange(key, v)}
|
||||||
withinPortal
|
withinPortal
|
||||||
{...option.inputProps}
|
{...option.inputProps}
|
||||||
@@ -189,8 +199,8 @@ const WidgetOptionTypeSwitch: FC<{
|
|||||||
</Stack>
|
</Stack>
|
||||||
);
|
);
|
||||||
case 'select':
|
case 'select':
|
||||||
const items = typeof option.data === 'function' ? option.data() : option.data;
|
const selectItems = typeof option.data === 'function' ? option.data() : option.data;
|
||||||
const data = items.map((dataType) => {
|
const selectData = selectItems.map((dataType) => {
|
||||||
return !dataType.label
|
return !dataType.label
|
||||||
? {
|
? {
|
||||||
value: dataType.value,
|
value: dataType.value,
|
||||||
@@ -209,7 +219,7 @@ const WidgetOptionTypeSwitch: FC<{
|
|||||||
<Select
|
<Select
|
||||||
searchable
|
searchable
|
||||||
defaultValue={option.defaultValue}
|
defaultValue={option.defaultValue}
|
||||||
data={data}
|
data={selectData}
|
||||||
value={value as string}
|
value={value as string}
|
||||||
onChange={(v) => handleChange(key, v ?? option.defaultValue)}
|
onChange={(v) => handleChange(key, v ?? option.defaultValue)}
|
||||||
withinPortal
|
withinPortal
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ interface ICommonWidgetOptions {
|
|||||||
export type IMultiSelectOptionValue = {
|
export type IMultiSelectOptionValue = {
|
||||||
type: 'multi-select';
|
type: 'multi-select';
|
||||||
defaultValue: string[];
|
defaultValue: string[];
|
||||||
data: DataType[];
|
data: DataType[] | (() => DataType[]);
|
||||||
inputProps?: Partial<MultiSelectProps>;
|
inputProps?: Partial<MultiSelectProps>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user