mirror of
https://github.com/flarum/core.git
synced 2025-10-11 15:04:25 +02:00
* Changed "Rename Discussion" prompt into a modal. * Added DiscussionRenameModal component (Modal) * Changed DiscussionControls.renameAction to use the modal (I may have removed the ability to return a promise) * Added punycode.js back to js/forum dist * Fixed some formatting, removed some unnecessary variables
This commit is contained in:
committed by
Franz Liedke
parent
b7d6ba4893
commit
26d07699e9
67
js/forum/src/components/DiscussionRenameModal.js
Normal file
67
js/forum/src/components/DiscussionRenameModal.js
Normal file
@@ -0,0 +1,67 @@
|
||||
import Modal from 'flarum/components/Modal';
|
||||
import Button from 'flarum/components/Button';
|
||||
|
||||
/**
|
||||
* The 'DiscussionRenameModal' displays a modal dialog with an input to rename a discussion
|
||||
*/
|
||||
export default class DiscussionRenameModal extends Modal {
|
||||
init() {
|
||||
super.init();
|
||||
|
||||
this.discussion = this.props.discussion;
|
||||
this.currentTitle = this.props.currentTitle;
|
||||
this.newTitle = m.prop(this.currentTitle);
|
||||
}
|
||||
|
||||
className() {
|
||||
return 'DiscussionRenameModal Modal--small';
|
||||
}
|
||||
|
||||
title() {
|
||||
return app.translator.trans('core.forum.discussion_controls.rename_modal.title');
|
||||
}
|
||||
|
||||
content() {
|
||||
return (
|
||||
<div className="Modal-body">
|
||||
<div className="Form">
|
||||
<div className="Form-group">
|
||||
<input className="FormControl title" placeholder={this.currentTitle} bidi={this.newTitle} />
|
||||
</div>
|
||||
<div className="Form-group">
|
||||
{Button.component({
|
||||
className: 'Button Button--primary',
|
||||
type: 'submit',
|
||||
loading: this.loading,
|
||||
children: app.translator.trans('core.forum.discussion_controls.rename_modal.submit_button')
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
onsubmit(e) {
|
||||
e.preventDefault();
|
||||
|
||||
this.loading = true;
|
||||
|
||||
const title = this.newTitle;
|
||||
const currentTitle = this.currentTitle;
|
||||
|
||||
// If the title is different to what it was before, then save it. After the
|
||||
// save has completed, update the post stream as there will be a new post
|
||||
// indicating that the discussion was renamed.
|
||||
if (title && title !== currentTitle) {
|
||||
return this.discussion.save({title}).then(() => {
|
||||
if (app.viewingDiscussion(this.discussion)) {
|
||||
app.current.stream.update();
|
||||
}
|
||||
m.redraw();
|
||||
this.hide();
|
||||
});
|
||||
} else {
|
||||
this.hide();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user