mirror of
https://github.com/flarum/framework.git
synced 2025-02-24 02:49:40 +08:00
Use ItemList for EditTagModal fields (#59)
This commit is contained in:
parent
8a99757648
commit
4aabd35605
@ -1,5 +1,6 @@
|
||||
import Modal from 'flarum/components/Modal';
|
||||
import Button from 'flarum/components/Button';
|
||||
import ItemList from 'flarum/utils/ItemList';
|
||||
import { slug } from 'flarum/utils/string';
|
||||
|
||||
import tagLabel from '../../common/helpers/tagLabel';
|
||||
@ -38,39 +39,48 @@ export default class EditTagModal extends Modal {
|
||||
return (
|
||||
<div className="Modal-body">
|
||||
<div className="Form">
|
||||
<div className="Form-group">
|
||||
{this.fields().toArray()}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
fields() {
|
||||
const items = new ItemList();
|
||||
|
||||
items.add('name', <div className="Form-group">
|
||||
<label>{app.translator.trans('flarum-tags.admin.edit_tag.name_label')}</label>
|
||||
<input className="FormControl" placeholder={app.translator.trans('flarum-tags.admin.edit_tag.name_placeholder')} value={this.name()} oninput={e => {
|
||||
this.name(e.target.value);
|
||||
this.slug(slug(e.target.value));
|
||||
}}/>
|
||||
</div>
|
||||
</div>, 50);
|
||||
|
||||
<div className="Form-group">
|
||||
items.add('slug', <div className="Form-group">
|
||||
<label>{app.translator.trans('flarum-tags.admin.edit_tag.slug_label')}</label>
|
||||
<input className="FormControl" value={this.slug()} oninput={m.withAttr('value', this.slug)}/>
|
||||
</div>
|
||||
</div>, 40);
|
||||
|
||||
<div className="Form-group">
|
||||
items.add('description', <div className="Form-group">
|
||||
<label>{app.translator.trans('flarum-tags.admin.edit_tag.description_label')}</label>
|
||||
<textarea className="FormControl" value={this.description()} oninput={m.withAttr('value', this.description)}/>
|
||||
</div>
|
||||
</div>, 30);
|
||||
|
||||
<div className="Form-group">
|
||||
items.add('color', <div className="Form-group">
|
||||
<label>{app.translator.trans('flarum-tags.admin.edit_tag.color_label')}</label>
|
||||
<input className="FormControl" placeholder="#aaaaaa" value={this.color()} oninput={m.withAttr('value', this.color)}/>
|
||||
</div>
|
||||
</div>, 20);
|
||||
|
||||
<div className="Form-group">
|
||||
items.add('hidden', <div className="Form-group">
|
||||
<div>
|
||||
<label className="checkbox">
|
||||
<input type="checkbox" value="1" checked={this.isHidden()} onchange={m.withAttr('checked', this.isHidden)}/>
|
||||
{app.translator.trans('flarum-tags.admin.edit_tag.hide_label')}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>, 10);
|
||||
|
||||
<div className="Form-group">
|
||||
items.add('submit', <div className="Form-group">
|
||||
{Button.component({
|
||||
type: 'submit',
|
||||
className: 'Button Button--primary EditTagModal-save',
|
||||
@ -82,10 +92,9 @@ export default class EditTagModal extends Modal {
|
||||
{app.translator.trans('flarum-tags.admin.edit_tag.delete_tag_button')}
|
||||
</button>
|
||||
) : ''}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
</div>, -10);
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
submitData() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user