Files
framework/js/forum/src/components/edit-composer.js
Toby Zerner 9135749bb4 Rename JS sub-components so that descriptors are before the noun, not after
To be consistent with the naming in PHP world.

e.g. ReplyComposer instead of ComposerReply
2015-05-18 18:50:24 +09:30

55 lines
1.4 KiB
JavaScript

import ItemList from 'flarum/utils/item-list';
import ComposerBody from 'flarum/components/composer-body';
import Alert from 'flarum/components/alert';
import ActionButton from 'flarum/components/action-button';
/**
The composer body for editing a post. Sets the initial content to the
content of the post that is being edited, and adds a title control to
indicate which post is being edited.
*/
export default class EditComposer extends ComposerBody {
constructor(props) {
props.submitLabel = props.submitLabel || 'Save Changes';
props.confirmExit = props.confirmExit || 'You have not saved your changes. Do you wish to discard them?';
props.originalContent = props.originalContent || props.post.content();
props.user = props.user || props.post.user();
super(props);
}
headerItems() {
var items = new ItemList();
var post = this.props.post;
items.add('title', m('h3', [
'Editing ',
m('a', {href: app.route.discussion(post.discussion(), post.number()), config: m.route}, 'Post #'+post.number()),
' in ', post.discussion().title()
]));
return items;
}
data() {
return {
content: this.content()
};
}
onsubmit() {
var post = this.props.post;
this.loading(true);
m.redraw();
post.save(this.data()).then(post => {
app.composer.hide();
m.redraw();
}, response => {
this.loading(false);
m.redraw();
});
}
}