Support suggesting boolean settings

This commit is contained in:
redphx 2024-09-04 16:59:18 +07:00
parent 53d67616c3
commit 29f6413306
2 changed files with 7 additions and 0 deletions

View File

@ -140,6 +140,10 @@ export class SettingElement {
!(e as any).ignoreOnChange && onChange(e, (e.target as HTMLInputElement).checked);
});
($control as any).setValue = (value: boolean) => {
$control.checked = !!value;
};
return $control;
}

View File

@ -2,6 +2,7 @@ import type { PrefKey } from "@/enums/pref-keys";
import type { NumberStepperParams, SettingDefinitions } from "@/types/setting-definition";
import { BxEvent } from "../bx-event";
import { SettingElementType } from "../setting-element";
import { t } from "../translation";
export class BaseSettingsStore {
private storage: Storage;
@ -145,6 +146,8 @@ export class BaseSettingsStore {
if (value in options) {
return options[value];
}
} else if (typeof value === 'boolean') {
return value ? t('on') : t('off')
}
return value.toString();