From 982cbe4b49e06c44fb2cf9f839486d37f47fedd5 Mon Sep 17 00:00:00 2001 From: Clark Winkelmann Date: Fri, 9 Feb 2018 02:51:42 +0100 Subject: [PATCH] Use an extendable ItemList for notification methods --- .../forum/src/components/NotificationGrid.js | 34 ++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/framework/core/js/forum/src/components/NotificationGrid.js b/framework/core/js/forum/src/components/NotificationGrid.js index f33d05405..51397071d 100644 --- a/framework/core/js/forum/src/components/NotificationGrid.js +++ b/framework/core/js/forum/src/components/NotificationGrid.js @@ -18,10 +18,7 @@ export default class NotificationGrid extends Component { * * @type {Array} */ - this.methods = [ - {name: 'alert', icon: 'bell', label: app.translator.trans('core.forum.settings.notify_by_web_heading')}, - {name: 'email', icon: 'envelope-o', label: app.translator.trans('core.forum.settings.notify_by_email_heading')} - ]; + this.methods = this.notificationMethods().toArray(); /** * A map of notification type-method combinations to the checkbox instances @@ -164,6 +161,35 @@ export default class NotificationGrid extends Component { return 'notify_' + type + '_' + method; } + /** + * Build an item list for the notification methods to display in the grid. + * + * Each notification method is an object which has the following properties: + * + * - `name` The name of the notification method. + * - `icon` The icon to display in the column header. + * - `label` The label to display in the column header. + * + * @return {ItemList} + */ + notificationMethods() { + const items = new ItemList(); + + items.add('alert', { + name: 'alert', + icon: 'bell', + label: app.translator.trans('core.forum.settings.notify_by_web_heading'), + }); + + items.add('email', { + name: 'email', + icon: 'envelope-o', + label: app.translator.trans('core.forum.settings.notify_by_email_heading'), + }); + + return items; + } + /** * Build an item list for the notification types to display in the grid. *