35 lines
1.2 KiB
JavaScript
35 lines
1.2 KiB
JavaScript
(() => {
|
|
"use strict";
|
|
|
|
const form = document.getElementById("dedupeWorkspace");
|
|
const portfolio = document.getElementById("portfolioId");
|
|
const table = document.getElementById("dedupeCaseTable");
|
|
if (!form || !portfolio || !table) return;
|
|
|
|
portfolio.addEventListener("change", () => form.requestSubmit());
|
|
|
|
const openCase = (row) => {
|
|
const caseId = row?.dataset.caseId;
|
|
if (!caseId) return;
|
|
const contextPath = document.body.dataset.contextPath || "";
|
|
const url = `${contextPath}/ver/dedupefound?uuid=${encodeURIComponent(caseId)}`;
|
|
const dialog = window.MatrixFrameDialog;
|
|
if (!dialog?.open) {
|
|
window.location.assign(url);
|
|
return;
|
|
}
|
|
dialog.open(url, "Dedupe Details").then((result) => {
|
|
if (Number(result) === 1) row.remove();
|
|
});
|
|
};
|
|
|
|
table.addEventListener("click", (event) =>
|
|
openCase(event.target.closest("tr[data-case-id]")));
|
|
table.addEventListener("keydown", (event) => {
|
|
if (event.key === "Enter" || event.key === " ") {
|
|
event.preventDefault();
|
|
openCase(event.target.closest("tr[data-case-id]"));
|
|
}
|
|
});
|
|
})();
|