(config: RenderTaskCardMetadataConfig)
| 50 | } |
| 51 | |
| 52 | function createBlockedMetadataPill(config: RenderTaskCardMetadataConfig): HTMLElement | null { |
| 53 | const { metadataLine, card, task, plugin, onBlockedByToggle } = config; |
| 54 | if (!task.isBlocked) { |
| 55 | return null; |
| 56 | } |
| 57 | |
| 58 | const blockedLabel = plugin.i18n.translate("ui.taskCard.blockedBadge"); |
| 59 | const blockedByPaths = getBlockedByTaskPaths(task, plugin.app); |
| 60 | const blockedCount = task.blockedBy?.length ?? 0; |
| 61 | const pillText = blockedCount > 0 ? `${blockedLabel} (${blockedCount})` : blockedLabel; |
| 62 | const blockedPill = metadataLine.createSpan({ |
| 63 | cls: "task-card__metadata-pill task-card__metadata-pill--blocked", |
| 64 | text: pillText, |
| 65 | }); |
| 66 | |
| 67 | if (blockedByPaths.length > 0) { |
| 68 | const toggleLabel = `${blockedLabel} (${blockedByPaths.length})`; |
| 69 | prepareInteractiveControl(blockedPill); |
| 70 | blockedPill.setAttribute("aria-label", toggleLabel); |
| 71 | blockedPill.setAttribute( |
| 72 | "aria-expanded", |
| 73 | String(Boolean(card.querySelector(".task-card__blocked-by"))) |
| 74 | ); |
| 75 | setTooltip(blockedPill, toggleLabel, { placement: "top" }); |
| 76 | blockedPill.addEventListener("click", (event) => { |
| 77 | event.stopPropagation(); |
| 78 | onBlockedByToggle(); |
| 79 | }); |
| 80 | } else { |
| 81 | setTooltip(blockedPill, plugin.i18n.translate("ui.taskCard.blockedBadgeTooltip"), { |
| 82 | placement: "top", |
| 83 | }); |
| 84 | } |
| 85 | |
| 86 | return blockedPill; |
| 87 | } |
| 88 | |
| 89 | function createBlockingMetadataPill(config: RenderTaskCardMetadataConfig): HTMLElement | null { |
| 90 | const { metadataLine, task, plugin } = config; |
no test coverage detected