Fix issues with error alert and them being in modals

This commit is contained in:
David Sevilla Martin 2019-12-16 18:59:12 -05:00
parent 2fd3aa8c71
commit 654a0b5da1
No known key found for this signature in database
GPG Key ID: F764F1417E16B15F
7 changed files with 10 additions and 14 deletions

File diff suppressed because one or more lines are too long

2
js/dist/forum.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -247,7 +247,7 @@ export default abstract class Application {
// return new Promise((resolve, reject) => )
return m.request(options)
.catch(error => {
.then(res => res, error => {
this.requestError = error;
let children;
@ -286,6 +286,7 @@ export default abstract class Application {
try {
options.errorHandler(error);
} catch (error) {
console.error(error);
// this.alerts.show(error.alert);
}

View File

@ -1,5 +1,4 @@
import Component, {ComponentProps} from '../Component';
import Alert from './Alert';
import Button from './Button';
import RequestError from "../utils/RequestError";
@ -11,13 +10,13 @@ export default abstract class Modal<T extends ComponentProps = ComponentProps> e
/**
* An alert component to show below the header.
*/
alert: Alert;
alert: Mithril.Vnode;
loading: boolean;
view() {
if (this.alert) {
this.alert.props.dismissible = false;
this.alert.attrs.dismissible = false;
}
return (
@ -38,7 +37,7 @@ export default abstract class Modal<T extends ComponentProps = ComponentProps> e
<h3 className="App-titleControl App-titleControl--text">{this.title()}</h3>
</div>
{alert && <div className="Modal-alert">{this.alert}</div>}
{this.alert && <div className="Modal-alert">{this.alert}</div>}
{this.content()}
</form>

View File

@ -1,7 +1,5 @@
import Mithril from "mithril";
import Alert from "../components/Alert";
export interface RequestErrorResponse extends JSON {
errors?: {
code: string;
@ -17,7 +15,7 @@ export default class RequestError {
options: Mithril.RequestOptions;
xhr: XMLHttpRequest;
response?: RequestErrorResponse;
alert?: Alert;
alert?: Mithril.Vnode;
constructor(status, responseText, options, xhr) {
this.status = status;

View File

@ -39,8 +39,6 @@ export default class LogInModal extends Modal<LogInModalProps> {
oninit(vnode) {
super.oninit(vnode);
console.log('#oninit');
this.identification = m.prop(this.props.identification || '');
this.password = m.prop(this.props.password || '');
@ -178,7 +176,7 @@ export default class LogInModal extends Modal<LogInModalProps> {
onerror(error) {
if (error.status === 401) {
error.alert.props.children = app.translator.trans('core.forum.log_in.invalid_login_message');
error.alert.attrs.children = app.translator.trans('core.forum.log_in.invalid_login_message');
}
super.onerror(error);