DiscussionRenamedPost: Always show new title, show old title in tooltip

Refs #428.
This commit is contained in:
Franz Liedke 2016-04-01 10:07:34 +09:00
parent 38e0fc53ab
commit b9b3899dfe
2 changed files with 17 additions and 83 deletions

View File

@ -21253,12 +21253,10 @@ System.register('flarum/components/DiscussionRenamedNotification', ['flarum/comp
});;
'use strict';
System.register('flarum/components/DiscussionRenamedPost', ['flarum/components/Button', 'flarum/components/EventPost'], function (_export, _context) {
var Button, EventPost, DiscussionRenamedPost;
System.register('flarum/components/DiscussionRenamedPost', ['flarum/components/EventPost'], function (_export, _context) {
var EventPost, DiscussionRenamedPost;
return {
setters: [function (_flarumComponentsButton) {
Button = _flarumComponentsButton.default;
}, function (_flarumComponentsEventPost) {
setters: [function (_flarumComponentsEventPost) {
EventPost = _flarumComponentsEventPost.default;
}],
execute: function () {
@ -21271,20 +21269,6 @@ System.register('flarum/components/DiscussionRenamedPost', ['flarum/components/B
}
babelHelpers.createClass(DiscussionRenamedPost, [{
key: 'init',
value: function init() {
var _this2 = this;
babelHelpers.get(Object.getPrototypeOf(DiscussionRenamedPost.prototype), 'init', this).call(this);
this.expanded = false;
// Rerender the post content when we toggle the details.
this.subtree.check(function () {
return _this2.expanded;
});
}
}, {
key: 'icon',
value: function icon() {
return 'pencil';
@ -21292,7 +21276,14 @@ System.register('flarum/components/DiscussionRenamedPost', ['flarum/components/B
}, {
key: 'description',
value: function description(data) {
return [app.translator.trans('core.forum.post_stream.discussion_renamed_text', data), this.toggleButton(), this.expanded ? this.full(data) : null];
var renamed = app.translator.trans('core.forum.post_stream.discussion_renamed_text', data);
var oldName = app.translator.trans('core.forum.post_stream.discussion_renamed_old_text', data);
return m(
'span',
{ title: oldName },
renamed
);
}
}, {
key: 'descriptionData',
@ -21302,11 +21293,7 @@ System.register('flarum/components/DiscussionRenamedPost', ['flarum/components/B
var newTitle = post.content()[1];
return {
'old': m(
'strong',
{ className: 'DiscussionRenamedPost-old' },
oldTitle
),
'old': oldTitle,
'new': m(
'strong',
{ className: 'DiscussionRenamedPost-new' },
@ -21314,25 +21301,6 @@ System.register('flarum/components/DiscussionRenamedPost', ['flarum/components/B
)
};
}
}, {
key: 'full',
value: function full(data) {
return [m('br', null), app.translator.trans('core.forum.post_stream.discussion_renamed_old_text', data), m('br', null), app.translator.trans('core.forum.post_stream.discussion_renamed_new_text', data)];
}
}, {
key: 'toggle',
value: function toggle() {
this.expanded = !this.expanded;
}
}, {
key: 'toggleButton',
value: function toggleButton() {
return Button.component({
className: 'Button Button--default Button--more',
icon: 'ellipsis-h',
onclick: this.toggle.bind(this)
});
}
}]);
return DiscussionRenamedPost;
}(EventPost);

View File

@ -1,4 +1,3 @@
import Button from 'flarum/components/Button';
import EventPost from 'flarum/components/EventPost';
/**
@ -10,27 +9,15 @@ import EventPost from 'flarum/components/EventPost';
* - All of the props for EventPost
*/
export default class DiscussionRenamedPost extends EventPost {
init() {
super.init();
this.expanded = false;
// Rerender the post content when we toggle the details.
this.subtree.check(
() => this.expanded
);
}
icon() {
return 'pencil';
}
description(data) {
return [
app.translator.trans('core.forum.post_stream.discussion_renamed_text', data),
this.toggleButton(),
this.expanded ? this.full(data) : null
];
const renamed = app.translator.trans('core.forum.post_stream.discussion_renamed_text', data);
const oldName = app.translator.trans('core.forum.post_stream.discussion_renamed_old_text', data);
return <span title={oldName}>{renamed}</span>;
}
descriptionData() {
@ -39,29 +26,8 @@ export default class DiscussionRenamedPost extends EventPost {
const newTitle = post.content()[1];
return {
'old': <strong className="DiscussionRenamedPost-old">{oldTitle}</strong>,
'old': oldTitle,
'new': <strong className="DiscussionRenamedPost-new">{newTitle}</strong>
};
}
full(data) {
return [
<br />,
app.translator.trans('core.forum.post_stream.discussion_renamed_old_text', data),
<br />,
app.translator.trans('core.forum.post_stream.discussion_renamed_new_text', data)
];
}
toggle() {
this.expanded = !this.expanded;
}
toggleButton() {
return Button.component({
className: 'Button Button--default Button--more',
icon: 'ellipsis-h',
onclick: this.toggle.bind(this)
});
}
}