mirror of
https://github.com/flarum/framework.git
synced 2024-11-25 09:41:49 +08:00
Convert EditCustomCssModal into a SettingsModal
This commit is contained in:
parent
27556fea38
commit
786c2fcfa5
|
@ -1,12 +1,6 @@
|
|||
import Modal from 'flarum/components/Modal';
|
||||
import Button from 'flarum/components/Button';
|
||||
import saveSettings from 'flarum/utils/saveSettings';
|
||||
|
||||
export default class EditCustomCssModal extends Modal {
|
||||
init() {
|
||||
this.customLess = m.prop(app.data.settings.custom_less || '');
|
||||
}
|
||||
import SettingsModal from 'flarum/components/SettingsModal';
|
||||
|
||||
export default class EditCustomCssModal extends SettingsModal {
|
||||
className() {
|
||||
return 'EditCustomCssModal Modal--large';
|
||||
}
|
||||
|
@ -15,36 +9,16 @@ export default class EditCustomCssModal extends Modal {
|
|||
return app.translator.trans('core.admin.edit_css.title');
|
||||
}
|
||||
|
||||
content() {
|
||||
return (
|
||||
<div className="Modal-body">
|
||||
<p>{app.translator.trans('core.admin.edit_css.customize_text', {a: <a href="https://github.com/flarum/core/tree/master/less" target="_blank"/>})}</p>
|
||||
|
||||
<div className="Form">
|
||||
<div className="Form-group">
|
||||
<textarea className="FormControl" rows="30" value={this.customLess()} onchange={m.withAttr('value', this.customLess)}/>
|
||||
</div>
|
||||
|
||||
<div className="Form-group">
|
||||
{Button.component({
|
||||
className: 'Button Button--primary',
|
||||
type: 'submit',
|
||||
children: app.translator.trans('core.admin.edit_css.submit_button'),
|
||||
loading: this.loading
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
form() {
|
||||
return [
|
||||
<p>{app.translator.trans('core.admin.edit_css.customize_text', {a: <a href="https://github.com/flarum/core/tree/master/less" target="_blank"/>})}</p>,
|
||||
<div className="Form-group">
|
||||
<textarea className="FormControl" rows="30" bidi={this.setting('custom_less')}/>
|
||||
</div>
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
onsubmit(e) {
|
||||
e.preventDefault();
|
||||
|
||||
this.loading = true;
|
||||
|
||||
saveSettings({
|
||||
custom_less: this.customLess()
|
||||
}).then(() => window.location.reload());
|
||||
onsaved() {
|
||||
window.location.reload();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,8 +68,12 @@ export default class SettingsModal extends Modal {
|
|||
this.loading = true;
|
||||
|
||||
saveSettings(this.dirty()).then(
|
||||
this.hide.bind(this),
|
||||
this.onsaved.bind(this),
|
||||
this.loaded.bind(this)
|
||||
);
|
||||
}
|
||||
|
||||
onsaved() {
|
||||
this.hide();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user