mirror of
https://github.com/flarum/core.git
synced 2025-08-09 01:46:35 +02:00
update: forum/components/NotificationGrid
This commit is contained in:
committed by
Franz Liedke
parent
f72d118bec
commit
68caf45f33
@@ -12,7 +12,9 @@ import ItemList from '../../common/utils/ItemList';
|
|||||||
* - `user`
|
* - `user`
|
||||||
*/
|
*/
|
||||||
export default class NotificationGrid extends Component {
|
export default class NotificationGrid extends Component {
|
||||||
init() {
|
oninit(vnode) {
|
||||||
|
super.oninit(vnode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Information about the available notification methods.
|
* Information about the available notification methods.
|
||||||
*
|
*
|
||||||
@@ -36,7 +38,7 @@ export default class NotificationGrid extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
view() {
|
view() {
|
||||||
const preferences = this.props.user.preferences();
|
const preferences = this.attrs.user.preferences();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<table className="NotificationGrid">
|
<table className="NotificationGrid">
|
||||||
@@ -62,12 +64,12 @@ export default class NotificationGrid extends Component {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<td className="NotificationGrid-checkbox">
|
<td className="NotificationGrid-checkbox">
|
||||||
{Checkbox.component({
|
<Checkbox
|
||||||
state: !!preferences[key],
|
state={!!preferences[key]}
|
||||||
loading: this.loading[key],
|
loading={this.loading[key]}
|
||||||
disabled: !(key in preferences),
|
disabled={!(key in preferences)}
|
||||||
onchange: () => this.toggle([key]),
|
onchange={this.toggle.bind(this, [key])}
|
||||||
})}
|
/>
|
||||||
</td>
|
</td>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
@@ -104,7 +106,7 @@ export default class NotificationGrid extends Component {
|
|||||||
* @param {Array} keys
|
* @param {Array} keys
|
||||||
*/
|
*/
|
||||||
toggle(keys) {
|
toggle(keys) {
|
||||||
const user = this.props.user;
|
const user = this.attrs.user;
|
||||||
const preferences = user.preferences();
|
const preferences = user.preferences();
|
||||||
const enabled = !preferences[keys[0]];
|
const enabled = !preferences[keys[0]];
|
||||||
|
|
||||||
@@ -128,7 +130,7 @@ export default class NotificationGrid extends Component {
|
|||||||
* @param {String} method
|
* @param {String} method
|
||||||
*/
|
*/
|
||||||
toggleMethod(method) {
|
toggleMethod(method) {
|
||||||
const keys = this.types.map((type) => this.preferenceKey(type.name, method)).filter((key) => key in this.props.user.preferences());
|
const keys = this.types.map((type) => this.preferenceKey(type.name, method)).filter((key) => key in this.attrs.user.preferences());
|
||||||
|
|
||||||
this.toggle(keys);
|
this.toggle(keys);
|
||||||
}
|
}
|
||||||
@@ -139,7 +141,7 @@ export default class NotificationGrid extends Component {
|
|||||||
* @param {String} type
|
* @param {String} type
|
||||||
*/
|
*/
|
||||||
toggleType(type) {
|
toggleType(type) {
|
||||||
const keys = this.methods.map((method) => this.preferenceKey(type, method.name)).filter((key) => key in this.props.user.preferences());
|
const keys = this.methods.map((method) => this.preferenceKey(type, method.name)).filter((key) => key in this.attrs.user.preferences());
|
||||||
|
|
||||||
this.toggle(keys);
|
this.toggle(keys);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user