mirror of
https://github.com/ajnart/homarr.git
synced 2026-01-31 11:49:14 +01:00
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>
|
||||
);
|
||||
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 (
|
||||
<Stack spacing={0}>
|
||||
<Group align="center" spacing="sm">
|
||||
@@ -179,9 +188,10 @@ const WidgetOptionTypeSwitch: FC<{
|
||||
{info && <InfoCard message={t(`descriptor.settings.${key}.info`)} link={link} />}
|
||||
</Group>
|
||||
<MultiSelect
|
||||
data={option.data}
|
||||
value={value as string[]}
|
||||
searchable
|
||||
defaultValue={option.defaultValue}
|
||||
data={multiSelectData}
|
||||
value={value as string[]}
|
||||
onChange={(v) => handleChange(key, v)}
|
||||
withinPortal
|
||||
{...option.inputProps}
|
||||
@@ -189,8 +199,8 @@ const WidgetOptionTypeSwitch: FC<{
|
||||
</Stack>
|
||||
);
|
||||
case 'select':
|
||||
const items = typeof option.data === 'function' ? option.data() : option.data;
|
||||
const data = items.map((dataType) => {
|
||||
const selectItems = typeof option.data === 'function' ? option.data() : option.data;
|
||||
const selectData = selectItems.map((dataType) => {
|
||||
return !dataType.label
|
||||
? {
|
||||
value: dataType.value,
|
||||
@@ -209,7 +219,7 @@ const WidgetOptionTypeSwitch: FC<{
|
||||
<Select
|
||||
searchable
|
||||
defaultValue={option.defaultValue}
|
||||
data={data}
|
||||
data={selectData}
|
||||
value={value as string}
|
||||
onChange={(v) => handleChange(key, v ?? option.defaultValue)}
|
||||
withinPortal
|
||||
|
||||
@@ -60,7 +60,7 @@ interface ICommonWidgetOptions {
|
||||
export type IMultiSelectOptionValue = {
|
||||
type: 'multi-select';
|
||||
defaultValue: string[];
|
||||
data: DataType[];
|
||||
data: DataType[] | (() => DataType[]);
|
||||
inputProps?: Partial<MultiSelectProps>;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user