Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUU] Fix non-admin saving #12412

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions app/webpacker/js/turbo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import "@hotwired/turbo";

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"));
}
});
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, in Rails we arrange code like this in a folder called initializers. Maybe we could do the same with JS next time.

3 changes: 2 additions & 1 deletion app/webpacker/packs/admin.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import "controllers";
import "channels";
import "@hotwired/turbo";
import "../js/turbo";
import "../js/hotkeys";
import "../js/mrujs";
import "../js/matomo";
Expand All @@ -17,3 +17,4 @@ import Trix from "trix";
document.addEventListener("trix-file-accept", (event) => {
event.preventDefault();
});

2 changes: 1 addition & 1 deletion app/webpacker/packs/application.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import "controllers";
import "@hotwired/turbo";
import "../js/turbo";
import "../js/hotkeys";
import "../js/mrujs";
import "../js/matomo";
Expand Down