Files
sure/app/javascript/controllers/bank_search_controller.js
dripsmvcp 98ca1608f4 fix(enable_banking): match bank list search against BIC, not just name (#1874)
* fix(enable_banking): match bank list search against BIC, not just name

Bank-search filter on the Enable Banking bank-selection modal only indexed
`aspsp[:name]`, so users searching by BIC code (e.g. `INGDDEFF`) got no
results even when the bank was rendered in the list. Switch the per-item
data attribute to a `name + BIC` haystack and read from it in the Stimulus
controller, so either token matches.

Refs #1814

* style(bank_search): apply Biome formatting to forEach callback (#1874 review)
2026-05-24 13:43:36 +02:00

20 lines
585 B
JavaScript

import { Controller } from "@hotwired/stimulus";
export default class extends Controller {
static targets = ["input", "item", "emptyState"];
filter() {
const query = this.inputTarget.value.toLocaleLowerCase().trim();
let visibleCount = 0;
this.itemTargets.forEach((item) => {
const haystack = (item.dataset.bankSearch ?? "").toLocaleLowerCase();
const match = haystack.includes(query);
item.style.display = match ? "" : "none";
if (match) visibleCount++;
});
this.emptyStateTarget.classList.toggle("hidden", visibleCount > 0);
}
}