Use an extendable ItemList for notification methods

This commit is contained in:
Clark Winkelmann 2018-02-09 02:51:42 +01:00
parent 7721288ac6
commit ff10ed0ea9
No known key found for this signature in database
GPG Key ID: AC336FBC86CCD80B

View File

@ -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.
*