Extract EventPost description into separate method

This makes it easier to override in subclasses.
In preparation for #428.
This commit is contained in:
Franz Liedke 2016-03-30 20:41:15 +09:00
parent 9ae189bb9f
commit bc11ec68dd
2 changed files with 17 additions and 2 deletions

View File

@ -21923,7 +21923,7 @@ System.register('flarum/components/EventPost', ['flarum/components/Post', 'flaru
return [icon(this.icon(), { className: 'EventPost-icon' }), m(
'div',
{ 'class': 'EventPost-info' },
app.translator.transChoice(this.descriptionKey(), data.count, data)
this.description(data)
)];
}
}, {
@ -21931,6 +21931,11 @@ System.register('flarum/components/EventPost', ['flarum/components/Post', 'flaru
value: function icon() {
return '';
}
}, {
key: 'description',
value: function description(data) {
return app.translator.transChoice(this.descriptionKey(), data.count, data);
}
}, {
key: 'descriptionKey',
value: function descriptionKey() {

View File

@ -34,7 +34,7 @@ export default class EventPost extends Post {
return [
icon(this.icon(), {className: 'EventPost-icon'}),
<div class="EventPost-info">
{app.translator.transChoice(this.descriptionKey(), data.count, data)}
{this.description(data)}
</div>
];
}
@ -48,6 +48,16 @@ export default class EventPost extends Post {
return '';
}
/**
* Get the description text for the event.
*
* @param {Object} data
* @return {String|Object} The description to render in the DOM
*/
description(data) {
return app.translator.transChoice(this.descriptionKey(), data.count, data);
}
/**
* Get the translation key for the description of the event.
*