From 71c75900cf1cc43c1f840494994eb8a0ef09f9c6 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Wed, 30 Mar 2016 20:41:15 +0900 Subject: [PATCH] Extract EventPost description into separate method This makes it easier to override in subclasses. In preparation for #428. --- framework/core/js/forum/dist/app.js | 7 ++++++- framework/core/js/forum/src/components/EventPost.js | 12 +++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/framework/core/js/forum/dist/app.js b/framework/core/js/forum/dist/app.js index 81ff0f78e..6047d182b 100644 --- a/framework/core/js/forum/dist/app.js +++ b/framework/core/js/forum/dist/app.js @@ -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() { diff --git a/framework/core/js/forum/src/components/EventPost.js b/framework/core/js/forum/src/components/EventPost.js index 1abe92554..7cfcbbefd 100644 --- a/framework/core/js/forum/src/components/EventPost.js +++ b/framework/core/js/forum/src/components/EventPost.js @@ -34,7 +34,7 @@ export default class EventPost extends Post { return [ icon(this.icon(), {className: 'EventPost-icon'}),
- {app.translator.transChoice(this.descriptionKey(), data.count, data)} + {this.description(data)}
]; } @@ -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. *