Files
openfoodnetwork/app/webpacker/js/turbo.js
Maikel Linke d354317c73 Replace cable_ready report loading w/ Turbo stream
I'm adding TurboPower for the scroll_into_view action. It adds all the
nice CableReady actions to Turbo Streams.

Note that I omitted `block: "start"` because that option is the default
in Javascript. And the generic `action` method doesn't support
parameters like this anyway. I'll work on that in the next commit.

I also re-introduced a race condition by rendering the "loading"
indicator after triggering the report rendering job. I'm planning to
resolve that later.
2024-08-16 14:37:57 +10:00

18 lines
448 B
JavaScript

import "@hotwired/turbo";
import TurboPower from "turbo_power";
TurboPower.initialize(Turbo.StreamActions);
document.addEventListener("turbo:frame-missing", (event) => {
// don't replace frame contents
event.preventDefault();
// show error message instead
status = event.detail.response.status;
if(status == 401) {
alert(I18n.t("errors.unauthorized.message"));
} else {
alert(I18n.t("errors.general_error.message"));
}
});