mirror of
https://github.com/flarum/framework.git
synced 2025-01-29 13:57:30 +08:00
Fix Select-based setting breaking admin pages
This commit is contained in:
parent
c7613af913
commit
ba08eb0039
|
@ -98,39 +98,37 @@ export default class AdminPage extends Page {
|
|||
return entry.call(this);
|
||||
}
|
||||
|
||||
const { setting, help, ...componentAttrs } = entry;
|
||||
const { setting, help, type, label, ...componentAttrs } = entry;
|
||||
|
||||
const value = this.setting([setting])();
|
||||
if (['bool', 'checkbox', 'switch', 'boolean'].includes(componentAttrs.type)) {
|
||||
const value = this.setting(setting)();
|
||||
|
||||
if (['bool', 'checkbox', 'switch', 'boolean'].includes(type)) {
|
||||
return (
|
||||
<div className="Form-group">
|
||||
<Switch state={!!value && value !== '0'} onchange={this.settings[setting]} {...componentAttrs}>
|
||||
{componentAttrs.label}
|
||||
{label}
|
||||
</Switch>
|
||||
<div className="helpText">{help}</div>
|
||||
</div>
|
||||
);
|
||||
} else if (['select', 'dropdown', 'selectdropdown'].includes(componentAttrs.type)) {
|
||||
} else if (['select', 'dropdown', 'selectdropdown'].includes(type)) {
|
||||
const { default: defaultValue, options } = componentAttrs;
|
||||
|
||||
return (
|
||||
<div className="Form-group">
|
||||
<label>{componentAttrs.label}</label>
|
||||
<label>{label}</label>
|
||||
<div className="helpText">{help}</div>
|
||||
<Select
|
||||
value={value || componentAttrs.default}
|
||||
options={componentAttrs.options}
|
||||
buttonClassName="Button"
|
||||
onchange={this.settings[setting]}
|
||||
{...componentAttrs}
|
||||
/>
|
||||
<Select value={value || defaultValue} options={options} onchange={this.settings[setting]} {...componentAttrs} />
|
||||
</div>
|
||||
);
|
||||
} else {
|
||||
componentAttrs.className = classList(['FormControl', componentAttrs.className]);
|
||||
|
||||
return (
|
||||
<div className="Form-group">
|
||||
{componentAttrs.label ? <label>{componentAttrs.label}</label> : ''}
|
||||
{label ? <label>{label}</label> : ''}
|
||||
<div className="helpText">{help}</div>
|
||||
<input type={componentAttrs.type} bidi={this.setting(setting)} {...componentAttrs} />
|
||||
<input type={type} bidi={this.setting(setting)} {...componentAttrs} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user