REFACTOR: exception controller (#7675)

This commit is contained in:
Joffrey JAFFEUX 2019-06-03 23:34:23 +02:00 committed by GitHub
parent 43a46df075
commit 0c5498c9a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,9 @@
import computed from "ember-addons/ember-computed-decorators";
import {
on,
default as computed
} from "ember-addons/ember-computed-decorators";
var ButtonBackBright = {
const ButtonBackBright = {
classes: "btn-primary",
action: "back",
key: "errors.buttons.back"
@ -28,11 +31,13 @@ export default Ember.Controller.extend({
lastTransition: null,
@computed
isNetwork: function() {
isNetwork() {
// never made it on the wire
if (this.get("thrown.readyState") === 0) return true;
// timed out
if (this.get("thrown.jqTextStatus") === "timeout") return true;
return false;
},
@ -47,9 +52,10 @@ export default Ember.Controller.extend({
networkFixed: false,
loading: false,
_init: function() {
@on("init")
_init() {
this.set("loading", false);
}.on("init"),
},
@computed("isNetwork", "isServer", "isUnknown")
reason() {
@ -99,16 +105,16 @@ export default Ember.Controller.extend({
},
actions: {
back: function() {
back() {
window.history.back();
},
tryLoading: function() {
tryLoading() {
this.set("loading", true);
var self = this;
Ember.run.schedule("afterRender", function() {
self.get("lastTransition").retry();
self.set("loading", false);
Ember.run.schedule("afterRender", () => {
this.lastTransition.retry();
this.set("loading", false);
});
}
}