mirror of
https://github.com/flarum/framework.git
synced 2025-01-30 22:38:43 +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);
|
return entry.call(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
const { setting, help, ...componentAttrs } = entry;
|
const { setting, help, type, label, ...componentAttrs } = entry;
|
||||||
|
|
||||||
const value = this.setting([setting])();
|
const value = this.setting(setting)();
|
||||||
if (['bool', 'checkbox', 'switch', 'boolean'].includes(componentAttrs.type)) {
|
|
||||||
|
if (['bool', 'checkbox', 'switch', 'boolean'].includes(type)) {
|
||||||
return (
|
return (
|
||||||
<div className="Form-group">
|
<div className="Form-group">
|
||||||
<Switch state={!!value && value !== '0'} onchange={this.settings[setting]} {...componentAttrs}>
|
<Switch state={!!value && value !== '0'} onchange={this.settings[setting]} {...componentAttrs}>
|
||||||
{componentAttrs.label}
|
{label}
|
||||||
</Switch>
|
</Switch>
|
||||||
<div className="helpText">{help}</div>
|
<div className="helpText">{help}</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
} else if (['select', 'dropdown', 'selectdropdown'].includes(componentAttrs.type)) {
|
} else if (['select', 'dropdown', 'selectdropdown'].includes(type)) {
|
||||||
|
const { default: defaultValue, options } = componentAttrs;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="Form-group">
|
<div className="Form-group">
|
||||||
<label>{componentAttrs.label}</label>
|
<label>{label}</label>
|
||||||
<div className="helpText">{help}</div>
|
<div className="helpText">{help}</div>
|
||||||
<Select
|
<Select value={value || defaultValue} options={options} onchange={this.settings[setting]} {...componentAttrs} />
|
||||||
value={value || componentAttrs.default}
|
|
||||||
options={componentAttrs.options}
|
|
||||||
buttonClassName="Button"
|
|
||||||
onchange={this.settings[setting]}
|
|
||||||
{...componentAttrs}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
componentAttrs.className = classList(['FormControl', componentAttrs.className]);
|
componentAttrs.className = classList(['FormControl', componentAttrs.className]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="Form-group">
|
<div className="Form-group">
|
||||||
{componentAttrs.label ? <label>{componentAttrs.label}</label> : ''}
|
{label ? <label>{label}</label> : ''}
|
||||||
<div className="helpText">{help}</div>
|
<div className="helpText">{help}</div>
|
||||||
<input type={componentAttrs.type} bidi={this.setting(setting)} {...componentAttrs} />
|
<input type={type} bidi={this.setting(setting)} {...componentAttrs} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user