fix(accounts): add duplicate action to activity view (#1418)

This commit is contained in:
Ang Wei Feng (Ted)
2026-04-11 05:06:32 +08:00
committed by GitHub
parent a9a7a89f71
commit d6d7df12fd
6 changed files with 72 additions and 3 deletions

View File

@@ -138,8 +138,13 @@ export default class extends Controller {
count > 0;
if (this.hasDuplicateLinkTarget) {
this.duplicateLinkTarget.classList.toggle("hidden", count !== 1);
if (count === 1) {
const selectedRow = this._selectedRow();
const canDuplicate =
count === 1 && selectedRow?.dataset.entryType === "Transaction";
this.duplicateLinkTarget.classList.toggle("hidden", !canDuplicate);
if (canDuplicate) {
const url = new URL(
this.duplicateLinkTarget.href,
window.location.origin,
@@ -158,6 +163,14 @@ export default class extends Controller {
return this.pluralLabelValue;
}
_selectedRow() {
if (this.selectedIdsValue.length !== 1) return null;
return this.rowTargets.find(
(row) => row.dataset.id === this.selectedIdsValue[0],
);
}
_updateGroups() {
this.groupTargets.forEach((group) => {
const rows = this.rowTargets.filter(