mirror of
https://github.com/flarum/core.git
synced 2025-07-10 11:26:24 +02:00
Improve client XHR error handling
The default XHR error handler produce an alert which is appropriate to the response status code. It can be overridden per-request (by specifying the `errorHandler` option) so that the alert can be suppressed or displayed in a different position (e.g. inside a modal). ref #118
This commit is contained in:
@ -102,11 +102,7 @@ export default class EditUserModal extends Modal {
|
||||
);
|
||||
}
|
||||
|
||||
onsubmit(e) {
|
||||
e.preventDefault();
|
||||
|
||||
this.loading = true;
|
||||
|
||||
data() {
|
||||
const groups = Object.keys(this.groups)
|
||||
.filter(id => this.groups[id]())
|
||||
.map(id => app.store.getById('groups', id));
|
||||
@ -121,12 +117,19 @@ export default class EditUserModal extends Modal {
|
||||
data.password = this.password();
|
||||
}
|
||||
|
||||
this.props.user.save(data).then(
|
||||
() => this.hide(),
|
||||
response => {
|
||||
return data;
|
||||
}
|
||||
|
||||
onsubmit(e) {
|
||||
e.preventDefault();
|
||||
|
||||
this.loading = true;
|
||||
|
||||
this.props.user.save(this.data(), {errorHandler: this.onerror.bind(this)})
|
||||
.then(this.hide.bind(this))
|
||||
.catch(() => {
|
||||
this.loading = false;
|
||||
this.handleErrors(response);
|
||||
}
|
||||
);
|
||||
m.redraw();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user