fix(portal): account summary sort dropdown — drop inline JS for CSP safety

The inline 'onchange=\"window.location.href = this.value\"' attribute on
the sort <select> is the only inline-JS handler in the project's QWeb
templates. Under a strict Content-Security-Policy (script-src 'self')
the handler silently fails, leaving the sort dropdown dead. Replace
with a tiny vanilla-JS file (fp_portal_account_summary.js) that attaches
the listener via class selector .o_fp_sort_select inside the Account
Summary page.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
gsinghpal
2026-05-17 14:23:01 -04:00
parent 77b84ac11b
commit cdc47554ed
3 changed files with 27 additions and 2 deletions

View File

@@ -0,0 +1,25 @@
/**
* Fusion Plating — Portal Account Summary
* Wires the sort dropdown change event to navigate to the option's value
* (which is a fully-formed /my/account_summary URL). Replaces an inline
* `onchange` attribute on the <select> so the template stays CSP-clean.
*/
(function () {
"use strict";
function init() {
document.querySelectorAll(".o_fp_account_summary select.o_fp_sort_select").forEach(function (sel) {
sel.addEventListener("change", function () {
if (sel.value) {
window.location.href = sel.value;
}
});
});
}
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", init);
} else {
init();
}
})();