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'; 'use strict';
System.register('flarum/components/DiscussionRenamedPost', ['flarum/components/Button', 'flarum/components/EventPost'], function (_export, _context) { System.register('flarum/components/DiscussionRenamedPost', ['flarum/components/EventPost'], function (_export, _context) {
var Button, EventPost, DiscussionRenamedPost; var EventPost, DiscussionRenamedPost;
return { return {
setters: [function (_flarumComponentsButton) { setters: [function (_flarumComponentsEventPost) {
Button = _flarumComponentsButton.default;
}, function (_flarumComponentsEventPost) {
EventPost = _flarumComponentsEventPost.default; EventPost = _flarumComponentsEventPost.default;
}], }],
execute: function () { execute: function () {
@ -21271,20 +21269,6 @@ System.register('flarum/components/DiscussionRenamedPost', ['flarum/components/B
} }
babelHelpers.createClass(DiscussionRenamedPost, [{ 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', key: 'icon',
value: function icon() { value: function icon() {
return 'pencil'; return 'pencil';
@ -21292,7 +21276,14 @@ System.register('flarum/components/DiscussionRenamedPost', ['flarum/components/B
}, { }, {
key: 'description', key: 'description',
value: function description(data) { 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', key: 'descriptionData',
@ -21302,11 +21293,7 @@ System.register('flarum/components/DiscussionRenamedPost', ['flarum/components/B
var newTitle = post.content()[1]; var newTitle = post.content()[1];
return { return {
'old': m( 'old': oldTitle,
'strong',
{ className: 'DiscussionRenamedPost-old' },
oldTitle
),
'new': m( 'new': m(
'strong', 'strong',
{ className: 'DiscussionRenamedPost-new' }, { 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; return DiscussionRenamedPost;
}(EventPost); }(EventPost);

View File

@ -1,4 +1,3 @@
import Button from 'flarum/components/Button';
import EventPost from 'flarum/components/EventPost'; import EventPost from 'flarum/components/EventPost';
/** /**
@ -10,27 +9,15 @@ import EventPost from 'flarum/components/EventPost';
* - All of the props for EventPost * - All of the props for EventPost
*/ */
export default class DiscussionRenamedPost extends 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() { icon() {
return 'pencil'; return 'pencil';
} }
description(data) { description(data) {
return [ const renamed = app.translator.trans('core.forum.post_stream.discussion_renamed_text', data);
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);
this.toggleButton(),
this.expanded ? this.full(data) : null return <span title={oldName}>{renamed}</span>;
];
} }
descriptionData() { descriptionData() {
@ -39,29 +26,8 @@ export default class DiscussionRenamedPost extends EventPost {
const newTitle = post.content()[1]; const newTitle = post.content()[1];
return { return {
'old': <strong className="DiscussionRenamedPost-old">{oldTitle}</strong>, 'old': oldTitle,
'new': <strong className="DiscussionRenamedPost-new">{newTitle}</strong> '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)
});
}
} }