create-pmos 0.398.0 → 0.400.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (515) hide show
  1. package/package.json +30 -25
  2. package/payload/KIT-VERSION +1 -1
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/workspace/briefing-premium-adddoc-test.js +19 -15
  7. package/workspace/briefing-premium-board-test.js +82 -50
  8. package/workspace/briefing-premium-calendar-2-test.js +36 -36
  9. package/workspace/briefing-premium-calendar-3-test.js +39 -39
  10. package/workspace/briefing-premium-calendar-test.js +23 -24
  11. package/workspace/briefing-premium-doc-edit-test.js +8 -10
  12. package/workspace/briefing-premium-initiative-test.js +38 -16
  13. package/workspace/briefing-premium-insights-test.js +114 -37
  14. package/workspace/briefing-premium-metrics-test.js +6 -4
  15. package/workspace/briefing-premium-products-test.js +10 -7
  16. package/workspace/briefing-premium-sources-test.js +25 -22
  17. package/workspace/briefing-premium-test.js +48 -43
  18. package/workspace/briefing-premium-work-test.js +16 -11
  19. package/workspace/c3-capture-test.js +0 -17
  20. package/workspace/changelog.json +29 -0
  21. package/workspace/ev-everywhere-test.js +210 -0
  22. package/workspace/fixtures/premium-viewer-fixtures.js +11 -6
  23. package/workspace/guide/briefing-premium.md +2 -2
  24. package/workspace/guide/home.md +58 -19
  25. package/workspace/guide/index.md +1 -1
  26. package/workspace/guide/layout.md +2 -2
  27. package/workspace/guide/notes.md +2 -2
  28. package/workspace/guide/phone-companion.md +1 -1
  29. package/workspace/lib/board-grill.js +63 -0
  30. package/workspace/lib/board-premium.js +36 -5
  31. package/workspace/lib/initiative-layout.js +77 -0
  32. package/workspace/lib/insights-premium.js +3 -2
  33. package/workspace/lib/insights-records.js +21 -7
  34. package/workspace/lib/meeting-points.js +52 -0
  35. package/workspace/lib/news-for-you.js +88 -0
  36. package/workspace/lib/notes-series.js +29 -6
  37. package/workspace/lib/report-confirm.js +48 -0
  38. package/workspace/lib/route-modules.js +9 -9
  39. package/workspace/lib/routes-board-docs.js +46 -0
  40. package/workspace/lib/routes-board-grill.js +90 -0
  41. package/workspace/lib/routes-home-review.js +108 -0
  42. package/workspace/lib/routes-initiative-layout.js +57 -0
  43. package/workspace/lib/routes-insights-premium.js +4 -1
  44. package/workspace/lib/routes-insights-records.js +8 -4
  45. package/workspace/lib/routes-meeting-points.js +37 -0
  46. package/workspace/lib/routes-news.js +57 -0
  47. package/workspace/lib/routes-notes.js +2 -1
  48. package/workspace/lib/routes-phone-day.js +18 -9
  49. package/workspace/lib/routes-report-confirm.js +31 -0
  50. package/workspace/lib/routes-search.js +38 -0
  51. package/workspace/lib/routes-slash.js +95 -0
  52. package/workspace/lib/search-index.js +176 -0
  53. package/workspace/package-lock.json +2 -2
  54. package/workspace/package.json +1 -2
  55. package/workspace/premium-board-actions-test.js +86 -50
  56. package/workspace/premium-briefing-depth-test.js +55 -54
  57. package/workspace/premium-chat-chart-tab-test.js +4 -2
  58. package/workspace/premium-chat-goal-view-test.js +1 -1
  59. package/workspace/premium-chat-report-tab-test.js +16 -2
  60. package/workspace/premium-chat-term-test.js +0 -10
  61. package/workspace/premium-core-doc-issue-test.js +15 -13
  62. package/workspace/premium-menu-rows-test.js +1 -1
  63. package/workspace/premium-phone-card-test.js +7 -5
  64. package/workspace/premium-report-read-test.js +55 -18
  65. package/workspace/premium-vw-backlog-test.js +2 -2
  66. package/workspace/premium-vw-cal-test.js +50 -35
  67. package/workspace/premium-vw-doc-test.js +10 -11
  68. package/workspace/premium-vw-item-test.js +1 -1
  69. package/workspace/premium-vw-jira-test.js +2 -2
  70. package/workspace/premium-vw-meet-test.js +37 -40
  71. package/workspace/premium-vw-notes-test.js +21 -19
  72. package/workspace/premium-vw-rec-test.js +11 -12
  73. package/workspace/premium-welcome-test.js +3 -3
  74. package/workspace/premium-work-depth-test.js +5 -6
  75. package/workspace/public/capture.html +23 -0
  76. package/workspace/public/pm/bd-acts.js +303 -225
  77. package/workspace/public/pm/bd-asks.js +261 -0
  78. package/workspace/public/pm/bd-pop.js +59 -0
  79. package/workspace/public/pm/bd-span.js +49 -13
  80. package/workspace/public/pm/bd-views.js +169 -0
  81. package/workspace/public/pm/c3-base.js +47 -0
  82. package/workspace/public/pm/c3-capture.js +1 -1
  83. package/workspace/public/pm/c3-ini-ui.js +1 -1
  84. package/workspace/public/pm/c3-sheet.js +1 -1
  85. package/workspace/public/pm/c3-toast.js +1 -1
  86. package/workspace/public/pm/console3.css +3 -0
  87. package/workspace/public/pm/cozy-board.css +301 -0
  88. package/workspace/public/pm/cozy-ev.css +228 -0
  89. package/workspace/public/pm/cozy-evmodel.js +106 -0
  90. package/workspace/public/pm/cozy-evui.js +47 -0
  91. package/workspace/public/pm/cozy-home.css +20 -5
  92. package/workspace/public/pm/cozy-insights.css +148 -10
  93. package/workspace/public/pm/cozy-nav.js +103 -39
  94. package/workspace/public/pm/cozy-news.js +140 -0
  95. package/workspace/public/pm/cozy-search.js +203 -0
  96. package/workspace/public/pm/cozy-settings.js +198 -0
  97. package/workspace/public/pm/cozy-sources.js +89 -0
  98. package/workspace/public/pm/cozy-today.css +220 -0
  99. package/workspace/public/pm/cozy-viewer.js +5 -2
  100. package/workspace/public/pm/cozy-vw-mtg.css +350 -0
  101. package/workspace/public/pm/cozy-vw-rp.css +152 -0
  102. package/workspace/public/pm/cozy.css +9 -0
  103. package/workspace/public/pm/goal-chat.js +5 -1
  104. package/workspace/public/pm/home-adddoc.js +5 -5
  105. package/workspace/public/pm/home-app.js +365 -70
  106. package/workspace/public/pm/home-around.js +24 -126
  107. package/workspace/public/pm/home-chat.js +77 -18
  108. package/workspace/public/pm/home-data.js +9 -7
  109. package/workspace/public/pm/home-dictate.js +57 -0
  110. package/workspace/public/pm/home-draft.js +6 -6
  111. package/workspace/public/pm/home-ini-model.js +190 -0
  112. package/workspace/public/pm/home-ini.css +171 -0
  113. package/workspace/public/pm/home-ini.js +466 -0
  114. package/workspace/public/pm/home-list.js +289 -0
  115. package/workspace/public/pm/home-more.js +18 -135
  116. package/workspace/public/pm/home-phone-card.js +13 -8
  117. package/workspace/public/pm/home-review.js +103 -0
  118. package/workspace/public/pm/home-task.js +67 -0
  119. package/workspace/public/pm/home-today.js +148 -0
  120. package/workspace/public/pm/home-work.js +63 -28
  121. package/workspace/public/pm/note-dock.js +1 -2
  122. package/workspace/public/pm/notes-links.js +1 -2
  123. package/workspace/public/pm/notes-task.js +3 -4
  124. package/workspace/public/pm/premium-board.js +164 -40
  125. package/workspace/public/pm/premium-chart-tab.js +4 -5
  126. package/workspace/public/pm/premium-first.js +5 -7
  127. package/workspace/public/pm/premium-initiative-head.js +3 -3
  128. package/workspace/public/pm/premium-insights.js +499 -202
  129. package/workspace/public/pm/premium-mtg-present.js +138 -0
  130. package/workspace/public/pm/premium-mtg-replay.js +142 -0
  131. package/workspace/public/pm/premium-report-read.js +216 -52
  132. package/workspace/public/pm/premium-report-tab.js +44 -19
  133. package/workspace/public/pm/premium-shell.js +7 -7
  134. package/workspace/public/pm/premium-vw-cal.js +150 -60
  135. package/workspace/public/pm/premium-vw-doc.css +20 -2
  136. package/workspace/public/pm/premium-vw-doc.js +22 -7
  137. package/workspace/public/pm/premium-vw-mtg.js +488 -261
  138. package/workspace/public/pm/premium-vw-notes.js +61 -0
  139. package/workspace/public/pm/rp-parts.js +269 -0
  140. package/workspace/public/pm/view-notes.js +2 -2
  141. package/workspace/public/premium-board.html +4 -3
  142. package/workspace/public/premium-insights.html +10 -10
  143. package/workspace/public/premium.html +3 -1
  144. package/workspace/r/m1.png +0 -0
  145. package/workspace/r/m2.png +0 -0
  146. package/workspace/r/m3.png +0 -0
  147. package/workspace/r/nl.png +0 -0
  148. package/workspace/replaced-tests.json +435 -0
  149. package/workspace/run-tests.js +323 -28
  150. package/workspace/server.js +15 -10
  151. package/workspace/test-files.json +3 -140
  152. package/workspace/test-lists/base.json +1 -2
  153. package/workspace/test-lists/c3-desktop-light-load.json +1 -2
  154. package/workspace/test-lists/c3-initiative-boards.json +1 -2
  155. package/workspace/test-lists/c3-meeting-focus.json +2 -12
  156. package/workspace/test-lists/c3-work-agent.json +1 -2
  157. package/workspace/test-lists/calendar-tidy-up.json +1 -2
  158. package/workspace/test-lists/console3-reports.json +1 -2
  159. package/workspace/test-lists/docs-three-way-sync.json +1 -2
  160. package/workspace/test-lists/extension-capture.json +5 -0
  161. package/workspace/test-lists/initiative-layout.json +9 -0
  162. package/workspace/test-lists/jira-wbs.json +1 -2
  163. package/workspace/test-lists/legacy-cleanup-a.json +9 -0
  164. package/workspace/test-lists/meeting-material.json +1 -2
  165. package/workspace/test-lists/meeting-notes.json +2 -36
  166. package/workspace/test-lists/meeting-replay.json +1 -2
  167. package/workspace/test-lists/mm-capture.json +2 -12
  168. package/workspace/test-lists/my-work.json +2 -10
  169. package/workspace/test-lists/onboarding-firstrun.json +2 -12
  170. package/workspace/test-lists/people-directory.json +1 -2
  171. package/workspace/test-lists/premium-uncovered-meetings.json +9 -0
  172. package/workspace/test-lists/premium-uncovered-reports.json +9 -0
  173. package/workspace/test-lists/run2-a.json +1 -2
  174. package/workspace/test-lists/run2-d.json +2 -19
  175. package/workspace/test-lists/run3-b.json +1 -2
  176. package/workspace/test-lists/run3-c.json +2 -12
  177. package/workspace/test-lists/run4-b.json +1 -2
  178. package/workspace/test-lists/run4-d.json +1 -5
  179. package/workspace/test-lists/run5-c.json +1 -11
  180. package/workspace/test-lists/run6.json +1 -5
  181. package/workspace/test-lists/uf-everywhere.json +15 -0
  182. package/workspace/test-lists/uf-home.json +9 -0
  183. package/workspace/test-lists/uncovered-board.json +9 -0
  184. package/workspace/test-lists/workspace-launch-flags.json +2 -12
  185. package/workspace/test-lists/workspace-profile-detection.json +2 -10
  186. package/workspace/test-timings.json +242 -123
  187. package/workspace/c3-briefing-test.js +0 -136
  188. package/workspace/c3-core-docs-test.js +0 -170
  189. package/workspace/c3-driver-fixture.js +0 -64
  190. package/workspace/c3-driver-test.js +0 -169
  191. package/workspace/c3-foundation-test.js +0 -163
  192. package/workspace/c3-ib-items-test.js +0 -114
  193. package/workspace/c3-ib-more-test.js +0 -146
  194. package/workspace/c3-ib-triage-backlog-test.js +0 -128
  195. package/workspace/c3-ini-harness.js +0 -66
  196. package/workspace/c3-ini-life-test.js +0 -167
  197. package/workspace/c3-initiatives-test.js +0 -186
  198. package/workspace/c3-light-load-test.js +0 -112
  199. package/workspace/c3-one-home-test.js +0 -149
  200. package/workspace/c3-phone-test.js +0 -289
  201. package/workspace/c3-quiet-test.js +0 -157
  202. package/workspace/c3-report-design-real-test.js +0 -264
  203. package/workspace/c3-report-design-test.js +0 -442
  204. package/workspace/c3-report-setup-test.js +0 -192
  205. package/workspace/c3-report-structure-real-test.js +0 -248
  206. package/workspace/c3-report-structure-test.js +0 -397
  207. package/workspace/c3-reports-test.js +0 -288
  208. package/workspace/c3-scan-test.js +0 -517
  209. package/workspace/c3-sessions-panel-test.js +0 -365
  210. package/workspace/c3-settings-test.js +0 -204
  211. package/workspace/c3-updates-test.js +0 -131
  212. package/workspace/c3-work-test.js +0 -260
  213. package/workspace/cut-stub.js +0 -40
  214. package/workspace/first-paint-audit.js +0 -160
  215. package/workspace/lib/c3-full-console.js +0 -15
  216. package/workspace/lib/engine/derived/trust.js +0 -3
  217. package/workspace/lib/engine/plan-forecast.js +0 -342
  218. package/workspace/lib/engine/report-families.js +0 -175
  219. package/workspace/lib/engine/truth-table.js +0 -57
  220. package/workspace/lib/routes-c3-init.js +0 -54
  221. package/workspace/lib/routes-c3-life.js +0 -120
  222. package/workspace/lib/routes-c3-timeline.js +0 -192
  223. package/workspace/lib/routes-forecast.js +0 -86
  224. package/workspace/lib/routes-releases.js +0 -130
  225. package/workspace/lib/routes-report-facts.js +0 -85
  226. package/workspace/lib/routes-report-families.js +0 -33
  227. package/workspace/lib/routes-signals.js +0 -51
  228. package/workspace/lib/routes-timeline.js +0 -197
  229. package/workspace/public/c3.html +0 -35
  230. package/workspace/public/index.html +0 -156
  231. package/workspace/public/pm/app.js +0 -831
  232. package/workspace/public/pm/bd-board.js +0 -159
  233. package/workspace/public/pm/bd-drag.js +0 -59
  234. package/workspace/public/pm/bd-model.js +0 -152
  235. package/workspace/public/pm/bd-timeline.js +0 -233
  236. package/workspace/public/pm/bd-tree.js +0 -244
  237. package/workspace/public/pm/board-copy.js +0 -59
  238. package/workspace/public/pm/board-read.js +0 -38
  239. package/workspace/public/pm/branches-sheet.js +0 -56
  240. package/workspace/public/pm/breakdown-api.js +0 -58
  241. package/workspace/public/pm/breakdown-copy.js +0 -138
  242. package/workspace/public/pm/briefing-deck.js +0 -441
  243. package/workspace/public/pm/briefing-model.js +0 -251
  244. package/workspace/public/pm/c3-ambient.js +0 -100
  245. package/workspace/public/pm/c3-audience-link.js +0 -21
  246. package/workspace/public/pm/c3-audience.js +0 -46
  247. package/workspace/public/pm/c3-boot.js +0 -13
  248. package/workspace/public/pm/c3-breakdown.js +0 -240
  249. package/workspace/public/pm/c3-brief-data.js +0 -11
  250. package/workspace/public/pm/c3-brief-mentions.js +0 -137
  251. package/workspace/public/pm/c3-brief-needs.js +0 -288
  252. package/workspace/public/pm/c3-brief-pulse.js +0 -112
  253. package/workspace/public/pm/c3-brief-summary.js +0 -139
  254. package/workspace/public/pm/c3-brief-today.js +0 -79
  255. package/workspace/public/pm/c3-brief.js +0 -279
  256. package/workspace/public/pm/c3-cal-strategy.js +0 -529
  257. package/workspace/public/pm/c3-calendar.js +0 -965
  258. package/workspace/public/pm/c3-calpop.js +0 -111
  259. package/workspace/public/pm/c3-case.js +0 -196
  260. package/workspace/public/pm/c3-core-docs.css +0 -18
  261. package/workspace/public/pm/c3-core-docs.js +0 -236
  262. package/workspace/public/pm/c3-daypart.js +0 -176
  263. package/workspace/public/pm/c3-demo-boards.js +0 -764
  264. package/workspace/public/pm/c3-demo-brief-ix.js +0 -350
  265. package/workspace/public/pm/c3-demo-brief-page.js +0 -70
  266. package/workspace/public/pm/c3-demo-cal-ix.js +0 -74
  267. package/workspace/public/pm/c3-demo-cal2.js +0 -66
  268. package/workspace/public/pm/c3-demo-cal3.js +0 -173
  269. package/workspace/public/pm/c3-demo-cal4.js +0 -169
  270. package/workspace/public/pm/c3-demo-cal5.js +0 -52
  271. package/workspace/public/pm/c3-demo-coredocs.js +0 -221
  272. package/workspace/public/pm/c3-demo-data.js +0 -552
  273. package/workspace/public/pm/c3-demo-focus.js +0 -181
  274. package/workspace/public/pm/c3-demo-init.js +0 -430
  275. package/workspace/public/pm/c3-demo-life.js +0 -77
  276. package/workspace/public/pm/c3-demo-material.js +0 -58
  277. package/workspace/public/pm/c3-demo-misc2.js +0 -34
  278. package/workspace/public/pm/c3-demo-phone.js +0 -48
  279. package/workspace/public/pm/c3-demo-plan2.js +0 -30
  280. package/workspace/public/pm/c3-demo-rd.js +0 -432
  281. package/workspace/public/pm/c3-demo-rep-ix.js +0 -126
  282. package/workspace/public/pm/c3-demo-rep2.js +0 -130
  283. package/workspace/public/pm/c3-demo-rep3.js +0 -138
  284. package/workspace/public/pm/c3-demo-rs.js +0 -287
  285. package/workspace/public/pm/c3-demo-term.js +0 -153
  286. package/workspace/public/pm/c3-demo-time.js +0 -49
  287. package/workspace/public/pm/c3-demo-work-ix.js +0 -32
  288. package/workspace/public/pm/c3-demo.js +0 -131
  289. package/workspace/public/pm/c3-design-studio.js +0 -369
  290. package/workspace/public/pm/c3-doc-formats.js +0 -153
  291. package/workspace/public/pm/c3-doc-sheet.js +0 -1230
  292. package/workspace/public/pm/c3-dock.js +0 -206
  293. package/workspace/public/pm/c3-docs.js +0 -291
  294. package/workspace/public/pm/c3-driver-work.js +0 -110
  295. package/workspace/public/pm/c3-driver.css +0 -18
  296. package/workspace/public/pm/c3-driver.js +0 -298
  297. package/workspace/public/pm/c3-focus.css +0 -304
  298. package/workspace/public/pm/c3-focus.js +0 -983
  299. package/workspace/public/pm/c3-ib-docs.js +0 -92
  300. package/workspace/public/pm/c3-ib-initiatives.js +0 -201
  301. package/workspace/public/pm/c3-ib-items.js +0 -210
  302. package/workspace/public/pm/c3-ib-releases.js +0 -48
  303. package/workspace/public/pm/c3-ib-sprints.js +0 -201
  304. package/workspace/public/pm/c3-ib-triage.js +0 -177
  305. package/workspace/public/pm/c3-ii-tabs.js +0 -252
  306. package/workspace/public/pm/c3-ini-life.css +0 -34
  307. package/workspace/public/pm/c3-ini-life.js +0 -379
  308. package/workspace/public/pm/c3-ini-records.js +0 -197
  309. package/workspace/public/pm/c3-ini-timeline.js +0 -278
  310. package/workspace/public/pm/c3-ini-work.js +0 -139
  311. package/workspace/public/pm/c3-init-extras.js +0 -170
  312. package/workspace/public/pm/c3-initiatives.js +0 -852
  313. package/workspace/public/pm/c3-lifecycle-panels.js +0 -479
  314. package/workspace/public/pm/c3-look.js +0 -27
  315. package/workspace/public/pm/c3-material.css +0 -22
  316. package/workspace/public/pm/c3-material.js +0 -321
  317. package/workspace/public/pm/c3-md.js +0 -3
  318. package/workspace/public/pm/c3-misc-panels.js +0 -89
  319. package/workspace/public/pm/c3-new-session.js +0 -110
  320. package/workspace/public/pm/c3-notes.js +0 -751
  321. package/workspace/public/pm/c3-phone-boot.js +0 -47
  322. package/workspace/public/pm/c3-phone-detail.js +0 -97
  323. package/workspace/public/pm/c3-phone-model.js +0 -3
  324. package/workspace/public/pm/c3-phone.css +0 -66
  325. package/workspace/public/pm/c3-phone.js +0 -444
  326. package/workspace/public/pm/c3-plan-panels.js +0 -163
  327. package/workspace/public/pm/c3-plan.js +0 -193
  328. package/workspace/public/pm/c3-quiet.css +0 -113
  329. package/workspace/public/pm/c3-quiet.js +0 -177
  330. package/workspace/public/pm/c3-replay.css +0 -133
  331. package/workspace/public/pm/c3-replay.js +0 -429
  332. package/workspace/public/pm/c3-report-deck.css +0 -163
  333. package/workspace/public/pm/c3-report-deck.js +0 -598
  334. package/workspace/public/pm/c3-report-frame.css +0 -20
  335. package/workspace/public/pm/c3-report-print.css +0 -20
  336. package/workspace/public/pm/c3-report-setup.css +0 -67
  337. package/workspace/public/pm/c3-report-setup.js +0 -298
  338. package/workspace/public/pm/c3-report-store.js +0 -244
  339. package/workspace/public/pm/c3-report-structure.css +0 -44
  340. package/workspace/public/pm/c3-report-structure.js +0 -473
  341. package/workspace/public/pm/c3-reports.css +0 -68
  342. package/workspace/public/pm/c3-reports.js +0 -377
  343. package/workspace/public/pm/c3-roadmap.js +0 -249
  344. package/workspace/public/pm/c3-scan-api.js +0 -167
  345. package/workspace/public/pm/c3-scan-next.js +0 -248
  346. package/workspace/public/pm/c3-scan-setup.js +0 -313
  347. package/workspace/public/pm/c3-scan-words.js +0 -41
  348. package/workspace/public/pm/c3-scan.css +0 -74
  349. package/workspace/public/pm/c3-scan.js +0 -93
  350. package/workspace/public/pm/c3-session-chat.js +0 -103
  351. package/workspace/public/pm/c3-session-conv.js +0 -165
  352. package/workspace/public/pm/c3-session-term.js +0 -216
  353. package/workspace/public/pm/c3-settings.css +0 -85
  354. package/workspace/public/pm/c3-settings.js +0 -1045
  355. package/workspace/public/pm/c3-shell.js +0 -628
  356. package/workspace/public/pm/c3-signals.js +0 -196
  357. package/workspace/public/pm/c3-strategy-panels.js +0 -45
  358. package/workspace/public/pm/c3-swipe.js +0 -230
  359. package/workspace/public/pm/c3-terminal-data.js +0 -48
  360. package/workspace/public/pm/c3-terminal-edge.js +0 -91
  361. package/workspace/public/pm/c3-terminal-icons.js +0 -40
  362. package/workspace/public/pm/c3-terminal-results.js +0 -141
  363. package/workspace/public/pm/c3-terminal.js +0 -52
  364. package/workspace/public/pm/c3-tickets.js +0 -163
  365. package/workspace/public/pm/c3-timeline.js +0 -201
  366. package/workspace/public/pm/calendar-views.js +0 -1049
  367. package/workspace/public/pm/console3-lift.md +0 -220
  368. package/workspace/public/pm/cozy-home.js +0 -172
  369. package/workspace/public/pm/cozy-initiative.css +0 -138
  370. package/workspace/public/pm/cycle-review.js +0 -125
  371. package/workspace/public/pm/data.js +0 -1577
  372. package/workspace/public/pm/dest-board.js +0 -444
  373. package/workspace/public/pm/dest-docs.js +0 -530
  374. package/workspace/public/pm/dest-initiatives.js +0 -162
  375. package/workspace/public/pm/dest-mywork.js +0 -307
  376. package/workspace/public/pm/dest-notes.js +0 -537
  377. package/workspace/public/pm/dest-people.js +0 -449
  378. package/workspace/public/pm/dest-reports.js +0 -383
  379. package/workspace/public/pm/dest-settings.js +0 -601
  380. package/workspace/public/pm/dest-today.js +0 -267
  381. package/workspace/public/pm/display-word.js +0 -56
  382. package/workspace/public/pm/doc-editor.js +0 -473
  383. package/workspace/public/pm/doc-graph.js +0 -272
  384. package/workspace/public/pm/doc-health-panel.js +0 -110
  385. package/workspace/public/pm/doc-rail.js +0 -167
  386. package/workspace/public/pm/doc-remote.js +0 -180
  387. package/workspace/public/pm/dock-sessions.js +0 -472
  388. package/workspace/public/pm/dock.js +0 -216
  389. package/workspace/public/pm/fixture.js +0 -821
  390. package/workspace/public/pm/flag-picker.js +0 -104
  391. package/workspace/public/pm/frame-copy.js +0 -278
  392. package/workspace/public/pm/freshness-line.js +0 -149
  393. package/workspace/public/pm/handoff-box.js +0 -82
  394. package/workspace/public/pm/initiative-list.js +0 -235
  395. package/workspace/public/pm/initiative-sheet.js +0 -331
  396. package/workspace/public/pm/initiatives-api.js +0 -95
  397. package/workspace/public/pm/initiatives-copy.js +0 -287
  398. package/workspace/public/pm/initiatives-timeline-copy.js +0 -59
  399. package/workspace/public/pm/initiatives-timeline.js +0 -410
  400. package/workspace/public/pm/initiatives-ui.js +0 -291
  401. package/workspace/public/pm/item-sheet.js +0 -268
  402. package/workspace/public/pm/keep-card.js +0 -204
  403. package/workspace/public/pm/lifecycle-lens-model.js +0 -246
  404. package/workspace/public/pm/lifecycle-lens.js +0 -276
  405. package/workspace/public/pm/lifecycle.js +0 -111
  406. package/workspace/public/pm/mobile.css +0 -366
  407. package/workspace/public/pm/mobile.js +0 -581
  408. package/workspace/public/pm/modes-live.js +0 -453
  409. package/workspace/public/pm/modes.js +0 -147
  410. package/workspace/public/pm/my-work-card.js +0 -51
  411. package/workspace/public/pm/my-work-data.js +0 -36
  412. package/workspace/public/pm/new-initiative-sheet.js +0 -169
  413. package/workspace/public/pm/next-step-ui.js +0 -190
  414. package/workspace/public/pm/outbox-panel.js +0 -125
  415. package/workspace/public/pm/palette-copy.js +0 -55
  416. package/workspace/public/pm/palette.js +0 -343
  417. package/workspace/public/pm/panel-breakdown.js +0 -702
  418. package/workspace/public/pm/panel-cockpit.js +0 -425
  419. package/workspace/public/pm/panel-detail.js +0 -1513
  420. package/workspace/public/pm/panel-initiatives.js +0 -929
  421. package/workspace/public/pm/panel-newsess.js +0 -709
  422. package/workspace/public/pm/panel-repos.js +0 -741
  423. package/workspace/public/pm/panel-tabs.js +0 -1506
  424. package/workspace/public/pm/panel-trees.js +0 -204
  425. package/workspace/public/pm/people-link.js +0 -106
  426. package/workspace/public/pm/phone-deck.js +0 -167
  427. package/workspace/public/pm/pm-work-view.js +0 -1533
  428. package/workspace/public/pm/portfolio-report.js +0 -61
  429. package/workspace/public/pm/premium-acts.js +0 -280
  430. package/workspace/public/pm/premium-brief.js +0 -111
  431. package/workspace/public/pm/premium-chat.js +0 -22
  432. package/workspace/public/pm/premium-doc-sheet.js +0 -312
  433. package/workspace/public/pm/premium-initiative.js +0 -324
  434. package/workspace/public/pm/premium-insights.css +0 -228
  435. package/workspace/public/pm/premium-metric-tiles.js +0 -68
  436. package/workspace/public/pm/premium-report-brief.js +0 -132
  437. package/workspace/public/pm/premium-vw-rec.js +0 -67
  438. package/workspace/public/pm/premium-wide.css +0 -30
  439. package/workspace/public/pm/print.css +0 -44
  440. package/workspace/public/pm/provider-cards.js +0 -136
  441. package/workspace/public/pm/registry.js +0 -203
  442. package/workspace/public/pm/release-card.js +0 -110
  443. package/workspace/public/pm/releases-view.js +0 -248
  444. package/workspace/public/pm/report-families-view.js +0 -505
  445. package/workspace/public/pm/report-slides.js +0 -438
  446. package/workspace/public/pm/report-tab.js +0 -33
  447. package/workspace/public/pm/report-view.js +0 -337
  448. package/workspace/public/pm/reports-copy.js +0 -134
  449. package/workspace/public/pm/roadmap.js +0 -294
  450. package/workspace/public/pm/run-card.js +0 -260
  451. package/workspace/public/pm/sessions-panel.js +0 -219
  452. package/workspace/public/pm/sheet-jira.js +0 -353
  453. package/workspace/public/pm/shell-bell.js +0 -163
  454. package/workspace/public/pm/shell-model.js +0 -83
  455. package/workspace/public/pm/shell-phone.js +0 -124
  456. package/workspace/public/pm/shell-readaloud.js +0 -53
  457. package/workspace/public/pm/shell-recording.js +0 -274
  458. package/workspace/public/pm/shell-ticker.js +0 -90
  459. package/workspace/public/pm/sig-watch.js +0 -41
  460. package/workspace/public/pm/slide-confirm.js +0 -163
  461. package/workspace/public/pm/slides-copy.js +0 -52
  462. package/workspace/public/pm/status-banner.js +0 -95
  463. package/workspace/public/pm/tab-doc.js +0 -859
  464. package/workspace/public/pm/tab-gone.js +0 -21
  465. package/workspace/public/pm/tab-term.js +0 -1210
  466. package/workspace/public/pm/tab-web.js +0 -90
  467. package/workspace/public/pm/timeline-copy.js +0 -48
  468. package/workspace/public/pm/timeline-forecast-view.js +0 -164
  469. package/workspace/public/pm/today-agenda.js +0 -331
  470. package/workspace/public/pm/today-cards.js +0 -244
  471. package/workspace/public/pm/today-copy.js +0 -506
  472. package/workspace/public/pm/today-day.js +0 -1371
  473. package/workspace/public/pm/today-goals.js +0 -297
  474. package/workspace/public/pm/today-jobs.js +0 -84
  475. package/workspace/public/pm/today-mentions.js +0 -50
  476. package/workspace/public/pm/topbar.js +0 -202
  477. package/workspace/public/pm/triage-card.js +0 -60
  478. package/workspace/public/pm/undo-hold.js +0 -103
  479. package/workspace/public/pm/view-addrepo.js +0 -208
  480. package/workspace/public/pm/view-files.js +0 -197
  481. package/workspace/public/pm/view-livenotes.js +0 -399
  482. package/workspace/public/pm/view-today.js +0 -13
  483. package/workspace/public/pm/view-validate.js +0 -171
  484. package/workspace/public/pm/welcome.js +0 -391
  485. package/workspace/public/pm/work-place.js +0 -68
  486. package/workspace/public/pm/xlsx-read.js +0 -117
  487. package/workspace/public/welcome.html +0 -22
  488. package/workspace/test-lists/browser-suites-green.json +0 -5
  489. package/workspace/test-lists/c3-core-docs.json +0 -9
  490. package/workspace/test-lists/c3-doc-sheet-rich.json +0 -6
  491. package/workspace/test-lists/c3-doc-sheet-size.json +0 -6
  492. package/workspace/test-lists/c3-doc-sheet-v2.json +0 -6
  493. package/workspace/test-lists/c3-ib-items.json +0 -9
  494. package/workspace/test-lists/c3-ib-more.json +0 -9
  495. package/workspace/test-lists/c3-ib-triage-backlog.json +0 -9
  496. package/workspace/test-lists/c3-ini-life.json +0 -9
  497. package/workspace/test-lists/c3-meeting-board.json +0 -5
  498. package/workspace/test-lists/c3-meeting-card.json +0 -5
  499. package/workspace/test-lists/c3-notes-place.json +0 -5
  500. package/workspace/test-lists/c3-notes-series.json +0 -5
  501. package/workspace/test-lists/calendar-time-page.json +0 -5
  502. package/workspace/test-lists/calpop.json +0 -4
  503. package/workspace/test-lists/console3-briefing.json +0 -9
  504. package/workspace/test-lists/console3-foundation.json +0 -9
  505. package/workspace/test-lists/console3-work-page.json +0 -9
  506. package/workspace/test-lists/premium-brief-parity.json +0 -9
  507. package/workspace/test-lists/report-design-studio-ui.json +0 -5
  508. package/workspace/test-lists/report-structure-ui.json +0 -11
  509. package/workspace/test-lists/report-workspace-ui.json +0 -5
  510. package/workspace/test-lists/run3-a.json +0 -5
  511. package/workspace/test-lists/run3-d.json +0 -6
  512. package/workspace/test-lists/run4-c.json +0 -13
  513. package/workspace/test-lists/today-goals-jobs-ui.json +0 -5
  514. package/workspace/test-lists/today-mentions-cards.json +0 -5
  515. package/workspace/test-lists/workspace-tabs-declutter.json +0 -13
@@ -1,852 +0,0 @@
1
- /* pm/c3-initiatives.js — the Initiatives tab of /c3.html (mockup v5, src/pages/34-initiatives.js, approved 2026-10-11).
2
- * Hierarchy: Portfolio > Board > Initiative > Epic > Story, Task or Bug. A board offers workflow templates and a default; each
3
- * initiative runs its own workflow. A board with "Build and deliver" on mirrors a Jira project (its items, Releases and Sprints); a
4
- * board with it off has PMOS tasks only. c3-shell.js hands the pane to mountInitiatives(pane, { ws, workspaces, demo, showTab }).
5
- *
6
- * WHAT THIS FILE DRAWS
7
- * Portfolio breadcrumb, the sentence on board health, the boards (one row each: health, owner, Build and deliver, the category
8
- * stack, risk, new asks, next release), a card per category across the boards, the asks waiting, and the timeline
9
- * across boards (board > initiative > epic). "New board" opens a sheet (name, Build and deliver, Jira key, default
10
- * workflow).
11
- * Board breadcrumb, Dashboard and Board settings, the sentence, the setup chips (Build and deliver, Jira, PMOS tasks, the
12
- * default workflow), then the tabs Summary · Initiatives · Triage · Backlog · Board · Timeline · Releases · Docs ·
13
- * Sprints (Releases and Sprints only when Build and deliver is on). Summary is drawn here; the rest come from the registry.
14
- * Initiative breadcrumb, the sentence, status and warning chips, the stepper of its own workflow (a press is POST /api/boards/move;
15
- * the warnings show, nothing is blocked), Edit workflow, the tools of the current stage and a More tools menu, then the
16
- * tabs Overview · Breakdown · Docs · Jira items (Build and deliver only) · Timeline · History, from the registry.
17
- * Sheets Board settings (POST /api/boards/settings), New board (POST /api/boards/create), New initiative (an ask added and
18
- * accepted at once: POST /api/boards/asks/add then asks/accept, then ini-workflow when it picks another template),
19
- * and the workflow editor in two modes: one initiative's stages (POST /api/boards/ini-workflow) or the board's own
20
- * workflow, the one its initiatives without their own run (POST /api/boards/workflow).
21
- *
22
- * URL STATE `init=` with history.replaceState, read back on load:
23
- * (none) Portfolio
24
- * docs Portfolio, Documents view (the core documents of the Portfolio)
25
- * board:<board>:<tab>[:<filter>] a board tab; <filter> is a query string (cat=Do&view=risk), each part URI-encoded
26
- * ini:<board>:<id>:<tab>[:<tool>] an initiative tab; <tool> is the tool the Overview shows first
27
- *
28
- * THE TAB REGISTRY registerBoardTab(id, mount) · registerInitiativeTab(id, mount). Modules, each in its own guarded import():
29
- * ./c3-ib-initiatives.js ./c3-ib-triage.js ./c3-ib-items.js (backlog, board, timeline) ./c3-ib-releases.js ./c3-ib-docs.js
30
- * ./c3-ib-sprints.js ./c3-ii-tabs.js (the six initiative tabs)
31
- * mount(host, ctx) draws into host and may return (or resolve to) a function called when the PM leaves the tab. The ctx, frozen:
32
- * ws, board (a row of GET /api/boards: id, name, full, template, workflow, build, jira, offer, defTpl, tracker, sprints, health,
33
- * counts, asks, nextRelease), today ('YYYY-MM-DD' from the server), tab, filter (board tabs), row, history, tools, toolsByCat, tool
34
- * (initiative tabs), api.get/post, go(loc), openInitiative(id, tab?, board?), openBoard(id, tab?, filter?), toast, openSheet,
35
- * refresh() (read the boards again and draw), redraw() (draw the current place again, keeping the reads), demo, showTab,
36
- * moveTo(id, stage) -> Promise<{ ok, row, warnings }>, openWorkflow(row), openBoardSettings(), newInitiative()
37
- *
38
- * Every control is a <button> (primitives.js button() through c3-ini-ui.js btn()); geometry is a --in-… custom property; no dialog. */
39
- import { el } from './dom.js';
40
- import { ensureComponentsCss } from './primitives.js';
41
- import { pmGet, pmPost } from './http.js';
42
- import { ensureC3Css } from './pm-work-view.js';
43
- import { openSheet, closeSheet } from './c3-sheet.js';
44
- import { toast } from './c3-toast.js';
45
- import {
46
- btn, geo, icon, pbtn, pill, lk, ib, chip, tag, st, note, lbl, mono, sw, jiraLabel, plural, trunc, day, daysBetween, statusChip, healthSt, HEALTH, ownerChip, ownerText,
47
- stageChip, stepsMini, progChip, dateChip, list, empty, sect, card, nrow, crumbs, lh, segTabs, cols, hbs, hbr, kv, chgl, chgli, openMenu, closeMenu, CATS, PORTFOLIO, put, ensureIniCss
48
- } from './c3-ini-ui.js';
49
- import { TEMPLATES, BOARD_TEMPLATES, isBuildStage, templateBuilds, offered, wfOf, catOf, kindOf, tplName, TOOL_META, toolLabel, toolIcon, loadItems, dropItems, workTlRows, iniTlRow, rescheduleTask, lockedToast } from './c3-ini-work.js';
50
- import { timeline, tlInit, tlRange } from './c3-ini-timeline.js';
51
- import { RECORD_META, recordToolsFor } from './c3-ini-records.js';
52
- import { agentSetting, loadAgentMode, MODES as AGENT_MODES } from './c3-driver.js';
53
- import { scanPortfolioSection, scanPointer } from './c3-scan-setup.js';
54
- import { lifeBanner, pageMenu, ensureLifeCss } from './c3-ini-life.js';
55
- import { coreDocs, segBadge } from './c3-core-docs.js';
56
-
57
- export { btn, geo };
58
- export { TEMPLATES, CATS };
59
-
60
- /* ── the registry ── */
61
- export const BOARD_TABS = {};
62
- export const INITIATIVE_TABS = {};
63
- export function registerBoardTab(id, mount) { if (typeof mount === 'function') BOARD_TABS[id] = mount; }
64
- export function registerInitiativeTab(id, mount) { if (typeof mount === 'function') INITIATIVE_TABS[id] = mount; }
65
-
66
- export const BOARD_TAB_LIST = [['summary', 'Summary', 'report'], ['initiatives', 'Initiatives', 'init'], ['triage', 'Triage', 'inbox'], ['backlog', 'Backlog', 'todo'], ['board', 'Board', 'cols'], ['timeline', 'Timeline', 'cal'], ['releases', 'Releases', 'out'], ['docs', 'Docs', 'doc'], ['sprints', 'Sprints', 'clock']];
67
- export const INI_TAB_LIST = [['overview', 'Overview', 'init'], ['breakdown', 'Breakdown', 'tree'], ['docs', 'Docs', 'doc'], ['tickets', 'Jira items', 'check'], ['timeline', 'Timeline', 'cal'], ['history', 'History', 'undo']];
68
- const BUILD_ONLY = ['releases', 'sprints'];
69
- const BOARD_IDS = BOARD_TAB_LIST.map((t) => t[0]);
70
- const INI_IDS = INI_TAB_LIST.map((t) => t[0]);
71
- const MODULES = ['./c3-ib-initiatives.js', './c3-ib-triage.js', './c3-ib-items.js', './c3-ib-releases.js', './c3-ib-docs.js', './c3-ib-sprints.js', './c3-ii-tabs.js'];
72
- let modulesReady = null;
73
- /** Import every tab module once. A failed import is recorded, never thrown. */
74
- export function loadTabModules() {
75
- if (!modulesReady) modulesReady = Promise.all(MODULES.map((p) => import(p).then(() => null, (e) => ({ path: p, error: String((e && e.message) || e) })))).then((r) => r.filter(Boolean));
76
- return modulesReady;
77
- }
78
- const SELF_WHY = 'This board follows the PMOS ladder. The repository derives each stage from its records, so a stage cannot be moved or edited here.';
79
- /** "Product workflow" or "Product workflow (edited)": the board's own workflow. */
80
- export function workflowLabel(b) {
81
- if (b && b.self) return 'PMOS ladder';
82
- const t = TEMPLATES[b && b.template];
83
- return t ? t.name + ' workflow' + (b.templateEdited ? ' (edited)' : '') : 'Custom workflow';
84
- }
85
-
86
- /* ── the location in the URL ── */
87
- const dec = (s) => { try { return decodeURIComponent(s); } catch { return s; } };
88
- /** `init=` value -> { view, board, id, tab, filter, tool }. Anything unreadable is the Portfolio. */
89
- export function parseLoc(s) {
90
- const p = String(s || '').split(':').map(dec);
91
- if (p[0] === 'board' && p[1]) return { view: 'board', board: p[1], tab: BOARD_IDS.includes(p[2]) ? p[2] : 'summary', filter: p[3] ? Object.fromEntries(new URLSearchParams(p[3])) : {} };
92
- if (p[0] === 'ini' && p[1] && p[2]) return { view: 'ini', board: p[1], id: p[2], tab: INI_IDS.includes(p[3]) ? p[3] : 'overview', tool: p[4] || '' };
93
- if (p[0] === 'docs') return { view: 'portfolio', tab: 'docs' };
94
- return { view: 'portfolio' };
95
- }
96
- /** The inverse of parseLoc; '' for the Portfolio. */
97
- export function formatLoc(loc) {
98
- const e = encodeURIComponent;
99
- if (loc && loc.view === 'portfolio') return loc.tab === 'docs' ? 'docs' : '';
100
- if (!loc || !loc.board) return '';
101
- if (loc.view === 'board') {
102
- const f = Object.entries(loc.filter || {}).filter(([, v]) => v !== '' && v != null);
103
- return ['board', e(loc.board), e(loc.tab || 'summary')].join(':') + (f.length ? ':' + e(new URLSearchParams(f).toString()) : '');
104
- }
105
- return ['ini', e(loc.board), e(loc.id), e(loc.tab || 'overview')].join(':') + (loc.tool ? ':' + e(loc.tool) : '');
106
- }
107
-
108
- function ensureCss() {
109
- ensureC3Css();
110
- ensureComponentsCss();
111
- ensureIniCss(); // after components.css, so the reset in c3-initiatives.css comes after the primitive's own rules
112
- ensureLifeCss();
113
- }
114
- const warnChip = (w) => st('warn', 'alert', w, { title: 'An order rule, shown as a warning. It never blocks.', 'data-ini-warning': w });
115
- const buildTag = (b) => (b.build ? el('span', { class: 'tag' }, icon('jira', 'sm'), jiraLabel(b) ? 'Jira · ' + jiraLabel(b) : 'Jira not set') : el('span', { class: 'tag' }, 'PMOS tasks only'));
116
- const errLine = (text) => el('div', { class: 'fold w', role: 'alert', 'data-ini': 'error' }, icon('alert', 'sm'), text);
117
- const sentenceOf = (bad, warn) => (bad.length || warn.length
118
- ? [bad.length ? plural(bad.length, 'board') + (bad.length === 1 ? ' is' : ' are') + ' off track' : '', warn.length ? plural(warn.length, 'board') + ' need' + (warn.length === 1 ? 's' : '') + ' attention' : ''].filter(Boolean).join(', ')
119
- : 'Every board is on track');
120
-
121
- /* ════════════════════════════════════════════════════════════════════════════════════════════════════════════════════ */
122
-
123
- export function mountInitiatives(pane, opts) {
124
- opts = opts || {};
125
- ensureCss();
126
- loadTabModules();
127
- const P = { loc: parseLoc(new URLSearchParams(location.search).get('init')), boards: null, today: null, seq: 0, dispose: null, ini: null };
128
- const root = el('div', { class: 'calwrap ini', 'data-ini': 'page' });
129
- put(pane, root);
130
-
131
- /* ── the api, with the board's ws ── */
132
- const apiFor = (ws) => ({
133
- get(path, params) {
134
- const q = new URLSearchParams();
135
- if (ws) q.set('ws', ws);
136
- for (const [k, v] of Object.entries(params || {})) if (v !== '' && v != null) q.set(k, String(v));
137
- const s = q.toString();
138
- const url = path + (s ? (path.includes('?') ? '&' : '?') + s : '');
139
- // A board read answers { pending } while the repository is first read. Ask again every 2 s for up to a minute.
140
- return (async () => {
141
- for (let n = 0; ; n++) {
142
- const r = await pmGet(url);
143
- if (!(r && r.pending) || n >= 30 || !path.startsWith('/api/boards')) return r;
144
- await new Promise((res) => setTimeout(res, 2000));
145
- }
146
- })();
147
- },
148
- post(path, body) { return pmPost(path, { ws, ...(body || {}) }); },
149
- });
150
- const pageApi = apiFor(opts.ws || '');
151
-
152
- function writeUrl() {
153
- try {
154
- const u = new URL(location.href); const v = formatLoc(P.loc);
155
- if (v) u.searchParams.set('init', v); else u.searchParams.delete('init');
156
- if (u.href !== location.href) history.replaceState(history.state, '', u);
157
- } catch { /* no history */ }
158
- }
159
- function go(loc) {
160
- const l = { ...(loc || { view: 'portfolio' }) };
161
- if (l.view === 'portfolio') l.tab = l.tab === 'docs' ? 'docs' : 'overview';
162
- if (l.view === 'board') { l.tab = BOARD_IDS.includes(l.tab) ? l.tab : 'summary'; l.filter = l.filter || {}; }
163
- if (l.view === 'ini') { l.tab = INI_IDS.includes(l.tab) ? l.tab : 'overview'; l.tool = l.tool || ''; }
164
- P.loc = l; writeUrl(); draw();
165
- }
166
- const openBoard = (id, tab, filter) => go({ view: 'board', board: id, tab: tab || 'summary', filter: filter || {} });
167
- const refresh = () => { P.boards = null; P.ini = null; dropItems(); draw(); };
168
- // The Briefing's Horizon scan card opens a board's Triage or settings (c3-scan.js goBoard). A page that is not built yet reads the address instead.
169
- // A report deck's live initiative link sends { id } (c3-report-deck.js openInitiative): the initiative opens on the board in view, else the first board.
170
- if (typeof window !== 'undefined') { if (window.__iniGo) window.removeEventListener('pmos:ini-go', window.__iniGo); window.__iniGo = (e) => { const d = (e && e.detail) || {}; if (!root.isConnected) return; if (d.id) { const b = d.board || (P.loc && P.loc.board) || (P.boards && P.boards[0] && P.boards[0].id); if (b) go({ view: 'ini', board: b, id: d.id, tab: d.tab || 'overview' }); return; } if (d.loc != null) go(parseLoc(d.loc)); else if (d.board) openBoard(d.board, d.tab || 'summary'); }; window.addEventListener('pmos:ini-go', window.__iniGo); }
171
- const redraw = () => draw();
172
-
173
- async function loadBoards() {
174
- if (P.boards) return P.boards;
175
- for (let k = 0; k < 20; k++) {
176
- const r = await pageApi.get('/api/boards');
177
- if (r && r.ok && r.pending) { status('Reading the repository. The boards show when it is read.'); await new Promise((res) => setTimeout(res, 3000)); continue; }
178
- if (!r || !r.ok) throw new Error((r && r.error) || 'no answer');
179
- P.boards = Array.isArray(r.boards) ? r.boards : [];
180
- P.today = r.today || P.today || isoToday();
181
- return P.boards;
182
- }
183
- throw new Error('the repository is taking long to read. Reload in a moment.');
184
- }
185
- const findBoard = (id) => { const all = (P.boards || []).filter((b) => b.id === id); return all.find((b) => b.ws === opts.ws) || all[0] || null; };
186
- function status(text) { put(root, note(text)); root.firstChild.setAttribute('role', 'status'); root.firstChild.setAttribute('data-ini', 'status'); }
187
-
188
- async function draw() {
189
- const token = ++P.seq;
190
- const live = () => token === P.seq;
191
- if (P.dispose) { const d = P.dispose; P.dispose = null; try { d(); } catch { /* the view cleans its own */ } }
192
- closeMenu();
193
- if (!P.boards) status('Reading the boards');
194
- let boards;
195
- try { boards = await loadBoards(); } catch (e) { if (live()) put(root, errLine('The boards could not be read: ' + e.message)); return; }
196
- if (!live()) return;
197
- root.dataset.iniView = P.loc.view;
198
- if (P.loc.view === 'portfolio') return drawPortfolio(boards, token);
199
- const b = findBoard(P.loc.board);
200
- if (!b) { put(root, pathCrumbs(null), errLine('No board "' + P.loc.board + '" is in the portfolio. It may have been renamed or removed.')); return; }
201
- if (P.loc.view === 'board') return drawBoard(b, token);
202
- return drawIni(b, token);
203
- }
204
-
205
- function pathCrumbs(b, row, right) {
206
- const parts = [{ t: PORTFOLIO, ic: 'cols', go: b ? () => go({ view: 'portfolio' }) : null, attrs: { 'data-ini-crumb': 'portfolio' } }];
207
- if (b) parts.push({ t: b.name, go: row ? () => openBoard(b.id, 'initiatives') : null, attrs: { 'data-ini-crumb': 'board' } });
208
- if (row) parts.push({ t: row.id + ' ' + trunc(row.title || '', 44), attrs: { 'data-ini-crumb': 'initiative' } });
209
- return crumbs(parts, right);
210
- }
211
-
212
- /* ── the ctx a tab is handed ── */
213
- function makeCtx(b, extra) {
214
- const ws = b.ws || opts.ws || '';
215
- const ctx = {
216
- ws, board: b, today: P.today || isoToday(), row: null, history: [], tools: [], toolsByCat: null, tab: '', filter: {}, tool: '', ...extra,
217
- api: apiFor(ws), go,
218
- openInitiative: (id, tab, board) => go({ view: 'ini', board: board || b.id, id, tab: tab || 'overview' }),
219
- openBoard, toast, openSheet, refresh, redraw, demo: !!opts.demo, showTab: typeof opts.showTab === 'function' ? opts.showTab : () => {},
220
- moveTo: (id, stage) => moveTo(b, id, stage),
221
- openWorkflow: (row) => openWorkflow(b, row),
222
- openBoardSettings: () => openBoardSettings(b),
223
- newInitiative: () => openNewIni(b),
224
- };
225
- return Object.freeze(ctx);
226
- }
227
- async function mountTab(host, mount, label, ctx, token) {
228
- await loadTabModules();
229
- if (token !== P.seq) return;
230
- const m = (ctx.row ? INITIATIVE_TABS : BOARD_TABS)[ctx.tab] || mount;
231
- if (typeof m !== 'function') { put(host, note('The ' + label + ' view is not built yet.')); return; }
232
- try {
233
- const d = await m(host, ctx);
234
- if (typeof d === 'function') { if (token === P.seq) P.dispose = d; else d(); }
235
- } catch (e) {
236
- if (token === P.seq) put(host, errLine('The ' + label + ' view could not draw: ' + String((e && e.message) || e)));
237
- }
238
- }
239
-
240
- /* ════════ PORTFOLIO ════════ */
241
- /** Overview | Documents, under the breadcrumb of the Portfolio. */
242
- function pfTabs(cur, badge) {
243
- return segTabs([['overview', 'Overview', 'cols'], ['docs', 'Documents', 'doc', badge]], cur, (k) => go(k === 'docs' ? { view: 'portfolio', tab: 'docs' } : { view: 'portfolio' }), 'Portfolio views', { 'data-ini': 'pf-tabs' });
244
- }
245
- const setBadge = (badge, r) => { const n = r && r.summary ? (Number(r.summary.draft) || 0) + (Number(r.summary.due) || 0) : 0; badge.textContent = String(n); badge.hidden = !n; };
246
- /** The Portfolio's Documents view: its core set, the question it answers and the drafts waiting (c3-core-docs.js). */
247
- function drawPortfolioDocs(boards, token) {
248
- const asks = boards.reduce((n, b) => n + (Number(b.asks) || 0), 0);
249
- const total = boards.reduce((n, b) => n + ((b.counts || {}).total || 0), 0);
250
- const badge = segBadge(0);
251
- const lhHost = el('div', { class: 'cd-host' });
252
- const cd = coreDocs({ api: pageApi, level: 'portfolio', ws: opts.ws || (boards[0] && boards[0].ws) || '', today: P.today, toast, nav: { reports: () => (opts.showTab || (() => {}))('rep'), tab: () => {}, tool: () => {},
253
- // Run a scan: the Horizon scan section, with Scan now, lives on the Portfolio Overview.
254
- scan: () => { go({ view: 'portfolio' }); setTimeout(() => { const h = root.querySelector('[data-scan-setup]'); if (h && h.scrollIntoView) h.scrollIntoView({ block: 'start' }); }, 400); } },
255
- onData: (r) => { setBadge(badge, r); put(lhHost, lh('doc', 'Portfolio documents', PORTFOLIO + ': the documents leadership reads to judge the bets. ' + (r.docs.filter((d) => d.st === 'draft').length ? plural(r.docs.filter((d) => d.st === 'draft').length, 'draft') + ' to review, ' : '') + r.docs.filter((d) => d.st === 'due').length + ' due.')); } });
256
- P.dispose = () => cd.dispose();
257
- put(root, pathCrumbs(null, null, el('div', { class: 'chips2' }, mono(plural(boards.length, 'board') + ' · ' + plural(total, 'initiative') + ' · ' + plural(asks, 'new ask')), pbtn('primary', 'New board', 'plus', { 'data-ini': 'new-board', onclick: () => openNewBoard() }))),
258
- pfTabs('docs', badge),
259
- el('div', { class: 'calbody', 'data-ini': 'pf-docs' }, lhHost, cols(cd.left, cd.right)));
260
- }
261
- async function drawPortfolio(boards, token) {
262
- if (P.loc.tab === 'docs') return drawPortfolioDocs(boards, token);
263
- const asks = boards.reduce((n, b) => n + (Number(b.asks) || 0), 0);
264
- const total = boards.reduce((n, b) => n + ((b.counts && b.counts.total) || 0), 0);
265
- const bad = boards.filter((b) => b.health === 'bad'); const warn = boards.filter((b) => b.health === 'warn');
266
- const tlHost = el('div', { 'data-ini': 'pf-timeline' }, note('Reading the work items of each board'));
267
- const byCatAll = Object.fromEntries(CATS.map((c) => [c, boards.reduce((n, b) => n + (((b.counts || {}).byCat || {})[c] || 0), 0)]));
268
- const maxCat = Math.max(1, ...CATS.map((c) => byCatAll[c]));
269
- const askBoards = boards.filter((b) => Number(b.asks) > 0);
270
- const left = sect({ ic: 'cols', title: 'Boards', count: boards.length },
271
- boards.length ? list(boards.map(boardRow), { 'data-ini': 'boards' }) : empty('No board yet. Each repository gets one when it is read. Press New board to add one.'),
272
- note('A board holds initiatives. Each initiative runs its own workflow, and boards that build a product also mirror Jira.'));
273
- const right = [
274
- card({ ic: 'flag', title: 'Where the initiatives are', sub: 'across the boards' },
275
- hbs(CATS.map((c) => el('div', { class: 'ini-c', 'data-cat': c }, hbr([sw(c), ' ', c], byCatAll[c], byCatAll[c] / maxCat, 'acc', { class: 'hbr ini-c', 'data-cat': c })))),
276
- note('Stages roll up into Discover, Plan, Do and Learn, so boards on different workflows compare.')),
277
- card({ ic: 'inbox', title: 'Asks waiting for triage' },
278
- askBoards.length ? chgl(askBoards.map((b) => el('li', null, icon('inbox', 'sm'), lk({ onclick: () => openBoard(b.id, 'triage'), 'data-ini-asks': b.id }, b.name), el('span', { class: 'tag' }, plural(Number(b.asks), 'new ask')))))
279
- : note('No new asks on any board.')),
280
- ];
281
- const badge = segBadge(0);
282
- pageApi.get('/api/core-docs', { level: 'portfolio' }).then((r) => { if (token === P.seq) setBadge(badge, r); }, () => {});
283
- put(root,
284
- pathCrumbs(null, null, el('div', { class: 'chips2' }, mono(plural(boards.length, 'board') + ' · ' + plural(total, 'initiative') + ' · ' + plural(asks, 'new ask')),
285
- pbtn('primary', 'New board', 'plus', { 'data-ini': 'new-board', onclick: () => openNewBoard() }))),
286
- pfTabs('overview', badge),
287
- el('div', { class: 'calbody', 'data-ini': 'portfolio' },
288
- lh('cols', sentenceOf(bad, warn), PORTFOLIO + ': boards hold initiatives, initiatives hold epics, epics hold stories, tasks and bugs. Stages roll up into Discover, Plan, Do and Learn so boards compare.'),
289
- // The Horizon scan runs for the whole portfolio (c3-scan-setup.js): its section is here, with Scan now always visible. Not in demo mode.
290
- opts.demo ? null : scanPortfolioSection({ ws: opts.ws || (boards[0] && boards[0].ws) || '', boardCount: boards.length, showTab: opts.showTab }),
291
- cols(left, right),
292
- sect({ ic: 'cal', title: 'Timeline across boards', right: mono('Board > initiative > epic') }, tlHost)));
293
- /* the cross-board timeline: board > the initiatives that are featured, at risk or carry work > their epics */
294
- const reads = await Promise.all(boards.map((b) => loadItems(makeCtx(b, {})).then((r) => ({ b, r }))));
295
- if (token !== P.seq) return;
296
- const rows = []; let more = 0;
297
- for (const { b, r } of reads) {
298
- if (!r.ok) continue;
299
- const ctx = makeCtx(b, {});
300
- const withWork = new Set(r.items.map((w) => w.ini));
301
- const now = r.initiatives.filter((i) => ['on track', 'at risk', 'late'].includes(i.status) && i.start && i.end && (i.horizon === 'now' || withWork.has(i.id) || i.featured));
302
- const pick = [...now.filter((i) => withWork.has(i.id) || i.featured), ...now.filter((i) => !withWork.has(i.id) && !i.featured && ['at risk', 'late'].includes(i.status)).sort((x, y) => String(x.end).localeCompare(String(y.end))).slice(0, 2)].slice(0, 6);
303
- more += now.length - pick.length;
304
- if (!pick.length) continue;
305
- pick.sort((x, y) => String(x.start).localeCompare(String(y.start)));
306
- const s = pick.map((i) => i.start).sort()[0]; const e = pick.map((i) => i.end).sort().pop();
307
- const avg = pick.reduce((n, i) => n + (Number(i.progress) || 0), 0) / pick.length;
308
- rows.push({ uid: 'b:' + b.id, label: b.name + ' · ' + pick.length + ' of ' + now.length, start: s, end: e, progress: avg, cls: 'grp', tone: b.health === 'bad' ? 'bad' : b.health === 'warn' ? 'warn' : 'ok',
309
- open: () => openBoard(b.id, 'timeline'), tip: { t: b.name + (b.full ? ' · ' + b.full : ''), p: Math.round(avg * 100) + '%', st: HEALTH[b.health] || 'No health yet', o: b.owner || '', src: b.build ? 'Board · Jira ' + jiraLabel(b) : 'Board · PMOS tasks only', hint: 'Click the row to fold the board' },
310
- kids: pick.map((i) => iniTlRow(ctx, i, workTlRows(ctx, r.items.filter((w) => w.ini === i.id), () => { dropItems(ctx); draw(); }), b)) });
311
- }
312
- const { from, to } = tlRange(P.today);
313
- const node = timeline({ key: 'pf', rows, from, to, today: P.today, markers: [], defOpen: boards.map((b) => 'b:' + b.id), head: 'Board > initiative > epic',
314
- onMove: (task, days, uid) => { const b = (reads.find(({ r }) => r.items.some((w) => w.ref === task)) || {}).b; if (b) rescheduleTask(makeCtx(b, {}), task, days, () => draw()); },
315
- onLocked: (k) => lockedToast(makeCtx(boards[0] || {}, {}), k) });
316
- put(tlHost, node, note('Featured, at-risk and active initiatives with dates. ' + (more ? plural(more, 'more is', 'more are') + ' on each board\'s Timeline.' : 'Each board\'s Timeline shows all of its own.')));
317
- requestAnimationFrame(() => tlInit(tlHost));
318
- }
319
- function boardRow(b) {
320
- const c = b.counts || {}; const by = c.byCat || {}; const tot = CATS.reduce((n, k) => n + (by[k] || 0), 0) || 1;
321
- const asks = Number(b.asks) || 0; const rel = b.nextRelease;
322
- const stack = el('div', { class: 'ini-stack', role: 'img', 'aria-label': CATS.map((k) => k + ' ' + (by[k] || 0)).join(', ') },
323
- ...CATS.filter((k) => by[k]).map((k) => geo(el('i', { class: 'ini-c', 'data-cat': k }), { '--in-f': ((by[k] || 0) / tot).toFixed(3) })));
324
- const after = [stack,
325
- el('div', { class: 'chips' }, ...CATS.map((k) => chip(sw(k), k + ' ', el('b', null, String(by[k] || 0))))),
326
- el('div', { class: 'chips' },
327
- c.risk ? st('warn', 'alert', c.risk + ' at risk') : null, c.late ? st('bad', 'clock', c.late + ' late') : null, !c.risk && !c.late ? chip('No risk flags') : null,
328
- asks ? lk({ onclick: () => openBoard(b.id, 'triage'), 'data-ini-asks': b.id }, icon('inbox', 'sm'), plural(asks, 'new ask')) : null,
329
- rel ? chip(icon('out', 'sm'), 'Next release ' + (rel.name || rel.id || '') + (rel.at || rel.date ? ' · ' + day(rel.at || rel.date) : ''), rel.status ? tag(rel.status) : null) : b.build ? chip('No release planned') : null)];
330
- return nrow({ ic: 'cols', hot: b.health === 'bad' || b.health === 'warn', title: b.name, onOpen: () => openBoard(b.id), openLabel: 'Open ' + b.name, sub: b.full || '',
331
- chips: [healthSt(b.health), ownerChip(b.owner), b.build ? chip(icon('bolt', 'sm'), 'Build and deliver') : null, buildTag(b),
332
- lk({ onclick: () => openBoard(b.id, 'initiatives'), 'data-ini-count': b.id }, icon('init', 'sm'), plural(c.total || 0, 'initiative'))],
333
- after, right: [ib('Open ' + b.name, 'next', { onclick: () => openBoard(b.id), 'data-ini-open-board': b.id })], attrs: { 'data-ini-board': b.id } });
334
- }
335
-
336
- /* ════════ BOARD ════════ */
337
- async function drawBoard(b, token) {
338
- let tab = P.loc.tab;
339
- if (BUILD_ONLY.includes(tab) && !b.build) tab = 'summary';
340
- const ctx0 = makeCtx(b, {});
341
- const items = await loadItems(ctx0);
342
- if (token !== P.seq) return;
343
- const work = items.items; const jiraN = work.filter((w) => w.src === 'jira').length; const pmN = work.length - jiraN;
344
- const c = b.counts || {}; const asks = Number(b.asks) || 0; const risk = (c.risk || 0) + (c.late || 0);
345
- const tabs = BOARD_TAB_LIST.filter(([k]) => b.build || !BUILD_ONLY.includes(k)).map(([k, l, ic]) => [k, l, ic,
346
- k === 'triage' && asks ? el('span', { class: 'bdg' }, String(asks)) : k === 'initiatives' ? el('span', { class: 'bdg g' }, String(c.total || 0)) : k === 'backlog' && items.ok ? el('span', { class: 'bdg g' }, String(work.filter((w) => w.status !== 'Done' && w.kind !== 'Epic').length)) : null]);
347
- const host = el('div', { class: 'calbody', 'data-ini-panel': tab });
348
- const def = TEMPLATES[b.defTpl] || TEMPLATES[b.template] || TEMPLATES.product;
349
- put(root,
350
- pathCrumbs(b, null, el('div', { class: 'chips2' }, pbtn('outline', 'Dashboard', 'report', { onclick: () => ctx0.showTab('rep') }),
351
- ib('Board settings', 'settings', { 'data-ini': 'board-settings', 'aria-haspopup': 'dialog', onclick: () => openBoardSettings(b) }))),
352
- el('div', { class: 'calbody', 'data-ini-board-page': b.id },
353
- lh('cols', b.name + (b.full ? ' · ' + b.full : ''), (HEALTH[b.health] || 'No health yet') + (risk ? ', ' + risk + ' at risk or late' : '') + (asks ? ', ' + plural(asks, 'new ask') + ' to triage' : '') + '. '
354
- + plural(c.total || 0, 'initiative') + (items.ok ? ', ' + plural(work.filter((w) => w.kind === 'Epic').length, 'epic') + ', ' + plural(work.filter((w) => w.kind !== 'Epic').length, 'item') : '') + '.'),
355
- el('div', { class: 'chips2', 'aria-label': 'Board setup', 'data-ini': 'setup' },
356
- ...(b.build ? [st('ok', 'bolt', 'Build and deliver on'), chip(icon('jira', 'sm'), jiraLabel(b) ? [(b.jiraProjects || []).length > 1 ? 'Jira projects ' : 'Jira project ', el('b', { class: 'mono' }, jiraLabel(b)), ' · ' + plural(jiraN, 'item')] : 'No Jira project set'), chip('PMOS tasks ' + pmN)]
357
- : [chip(icon('x', 'sm'), 'Build and deliver off'), chip('No Jira · ' + plural(pmN, 'PMOS task'))]),
358
- chip(icon('flag', 'sm'), 'New initiatives start with ' + def.name), lk({ onclick: () => openBoardSettings(b), 'data-ini': 'setup-change' }, 'Change')),
359
- b.self ? note(SELF_WHY) : null,
360
- segTabs(tabs, tab, (k) => openBoard(b.id, k), 'Board views', { 'data-ini': 'board-tabs' }),
361
- host));
362
- mountTab(host, tab === 'summary' ? mountSummary : null, (BOARD_TAB_LIST.find((t) => t[0] === tab) || [])[1], makeCtx(b, { tab, filter: P.loc.filter || {} }), token);
363
- }
364
-
365
- /* Summary: initiatives at a glance, where they stand, what needs attention */
366
- async function mountSummary(host, ctx) {
367
- const b = ctx.board;
368
- const r = await loadItems(ctx);
369
- if (!r.ok) { put(host, errLine('The board could not be read: ' + r.error + '.')); return; }
370
- const inis = r.initiatives; const work = r.items; const open = inis.filter((i) => ['on track', 'at risk', 'late'].includes(i.status)); // on hold, done and cancelled are not open
371
- const risk = inis.filter((i) => ['at risk', 'late'].includes(i.status)).sort((x, y) => String(x.end || '9').localeCompare(String(y.end || '9')));
372
- const withWork = new Set(work.map((w) => w.ini));
373
- /* up to six open initiatives: the ones with work, featured, or Now and not on track first, then the rest by end date */
374
- const prio = (i) => withWork.has(i.id) || i.featured || (i.horizon === 'now' && i.status !== 'on track') ? 1 : 0;
375
- const glance = [...open].sort((x, y) => (prio(y) - prio(x)) || (withWork.has(y.id) - withWork.has(x.id)) || ((y.featured ? 1 : 0) - (x.featured ? 1 : 0)) || String(x.end || '9').localeCompare(String(y.end || '9'))).slice(0, 6);
376
- const epicsOf = (id) => work.filter((w) => w.ini === id && w.kind === 'Epic').length;
377
- const iniGlance = (i) => nrow({ ic: i.status === 'late' || i.status === 'at risk' ? 'alert' : 'init', hot: i.status === 'late' || i.status === 'at risk', title: i.title, onOpen: () => ctx.openInitiative(i.id), openLabel: 'Open ' + i.id,
378
- chips: [chipMono(i.id), stepsMini(wfOf(i, b), i.stage, tplName(i, b)), statusChip(i.status), progChip(i.progress || 0, toneOf(i)), ownerChip(i.owner), dateChip(i.start, i.end, i.status !== 'done' && i.end && daysBetween(ctx.today, i.end) < 0), chip(icon('bolt', 'sm'), plural(epicsOf(i.id), 'epic'))],
379
- right: [ib('Open ' + i.id, 'next', { onclick: () => ctx.openInitiative(i.id) })], attrs: { 'data-ini-row': i.id } });
380
- const att = risk.slice(0, 5).map((i) => nrow({ ic: 'alert', hot: true, title: i.id + ' ' + i.title, onOpen: () => ctx.openInitiative(i.id),
381
- chips: [statusChip(i.status), stageChip(i.stage, catOf(wfOf(i, b), i.stage)), ownerChip(i.owner), chip(icon('cal', 'sm'), i.end ? 'ends ' + day(i.end) : 'No end date')], attrs: { 'data-ini-risk': i.id } }));
382
- const byCat = (c) => open.filter((i) => catOf(wfOf(i, b), i.stage) === c).length; const maxN = Math.max(1, ...CATS.map(byCat));
383
- const items = work.filter((w) => w.kind !== 'Epic'); const tot = Math.max(1, items.length); const nSt = (s) => items.filter((w) => w.status === s).length;
384
- const goIni = (filter) => ctx.openBoard(b.id, 'initiatives', filter);
385
- const rel = b.build && b.nextRelease;
386
- put(host, cols(
387
- [sect({ ic: 'init', title: 'Initiatives at a glance', count: open.length, right: lk({ onclick: () => goIni({ view: 'all' }), 'data-ini': 'all-initiatives' }, 'All ' + plural(inis.length, 'initiative')) },
388
- glance.length ? list(glance.map(iniGlance), { 'data-ini': 'glance' }) : empty('No open initiatives yet. Accept an ask in Triage to start one.')),
389
- sect({ ic: 'alert', title: 'Needs attention', count: risk.length, right: risk.length > att.length ? lk({ onclick: () => goIni({ view: 'risk' }) }, 'See all ' + risk.length) : null },
390
- att.length ? list(att) : empty('Nothing at risk.'))],
391
- [card({ ic: 'flag', title: 'Where the initiatives are', sub: 'each on its own workflow' },
392
- hbs(CATS.map((c) => btn({ class: 'ini-hbb', 'data-ini-catgo': c, title: 'See ' + c + ' initiatives', onclick: () => goIni({ view: 'all', cat: c }) }, hbr([sw(c), ' ', c], byCat(c), byCat(c) / maxN, 'acc', { class: 'hbr ini-c', 'data-cat': c })))),
393
- note('Stages roll up into four categories. Press one to list its initiatives.')),
394
- card({ ic: 'todo', title: 'Work items', sub: b.build ? 'Jira ' + jiraLabel(b) + ' and PMOS' : 'PMOS tasks' },
395
- hbs(['To do', 'In progress', 'In review', 'Done'].map((s) => hbr(s, nSt(s), nSt(s) / tot, s === 'Done' ? 'ok' : s === 'To do' ? 'pm' : 'acc'))),
396
- el('div', { class: 'chips2' }, lk({ onclick: () => ctx.openBoard(b.id, 'board') }, 'Open the Board'), lk({ onclick: () => ctx.openBoard(b.id, 'timeline') }, 'Open the Timeline'))),
397
- card({ ic: 'report', title: 'At a glance' }, chgl([
398
- el('li', null, icon('bolt', 'sm'), lk({ onclick: () => goIni({ view: 'all', cat: 'Do' }) }, 'Open initiatives in Do'), tag(String(byCat('Do')))),
399
- el('li', null, icon('alert', 'sm'), lk({ onclick: () => goIni({ view: 'risk' }) }, 'At risk or late'), tag(String(risk.length))),
400
- el('li', null, icon('user', 'sm'), lk({ onclick: () => goIni({ view: 'noowner' }) }, 'No owner'), tag(String(open.filter((i) => !i.owner).length))),
401
- el('li', null, icon('inbox', 'sm'), lk({ onclick: () => ctx.openBoard(b.id, 'triage') }, 'New asks'), tag(String(Number(b.asks) || 0)))], { 'data-ini': 'at-a-glance' })),
402
- card({ ic: 'report', title: 'Board dashboard', sub: 'in Reports' },
403
- rel ? note('Next release: ' + (rel.name || rel.id) + (rel.at || rel.date ? ' · ' + day(rel.at || rel.date) : '')) : null,
404
- el('div', { class: 'chips2' }, pbtn('outline', 'Open the ' + b.name + ' dashboard', 'next', { onclick: () => ctx.showTab('rep') })))]));
405
- }
406
-
407
- /* ════════ BOARD SETTINGS, NEW BOARD, NEW INITIATIVE ════════ */
408
- const checkbox = (on, label, attrs, onchange) => el('label', { class: 'ini-chk' }, el('input', { type: 'checkbox', checked: !!on, ...(attrs || {}), onchange }), el('span', null, ...[].concat(label)));
409
- const flowOf = (stages) => { const out = []; stages.forEach((s, k) => { if (k) out.push(icon('next', 'sm')); out.push(stageChip(s.name, s.cat)); }); return el('div', { class: 'chips2' }, ...out); };
410
- const tplCase = (k) => el('div', { class: 'case', 'data-ini': 'tpl-case' }, el('p', { class: 'sit' }, TEMPLATES[k].use), flowOf(TEMPLATES[k].stages));
411
- function tplSeg(allowed, cur, onPick, label, extra) {
412
- return el('div', { class: 'seg ini-seg', role: 'group', 'aria-label': label },
413
- ...Object.keys(TEMPLATES).map((k) => btn({ 'aria-pressed': String(cur === k), 'data-ini-tpl': k, disabled: !allowed.includes(k), title: allowed.includes(k) ? TEMPLATES[k].use : templateBuilds(k) ? 'Needs Build and deliver' : 'Not offered', onclick: () => onPick(k) },
414
- TEMPLATES[k].name, extra && extra === k ? el('span', { class: 'dim' }, ' default') : null)));
415
- }
416
-
417
- function openBoardSettings(b) {
418
- if (b.self) { openSheet({ title: 'Board settings · ' + b.name, icon: 'lock', body: el('div', { class: 'ini-form' }, note(SELF_WHY)) }); return; }
419
- const B = { build: b.build !== false, jira: jiraLabel(b), offer: new Set(offered(b)), def: b.defTpl || offered(b)[0], err: '', busy: false };
420
- const host = el('div', { class: 'ini-form', 'data-ini': 'settings-form' });
421
- const sh = openSheet({ title: 'Board settings · ' + b.name, icon: 'cols', body: host, wide: true });
422
- let usage = null;
423
- loadItems(makeCtx(b, {})).then((r) => { usage = r; render(); });
424
- // The Agent setting (c3-driver.js): read once, and saved at once when a mode is pressed (POST /api/driver/mode). Not in demo mode.
425
- const A = { mode: null, err: '', busy: false };
426
- // The Horizon scan runs for the whole portfolio: Board settings holds only a pointer to its setup (c3-scan-setup.js). Not in demo mode.
427
- const scanNode = opts.demo ? null : scanPointer(b.ws || opts.ws || '');
428
- if (!opts.demo) loadAgentMode(apiFor(b.ws), b.id).then((r) => { if (r.ok) A.mode = r.mode; else A.err = r.error; render(); });
429
- async function pickAgent(mode) {
430
- if (A.busy || mode === A.mode) return;
431
- A.busy = true; A.err = ''; render();
432
- const r = await apiFor(b.ws).post('/api/driver/mode', { board: b.id, mode });
433
- A.busy = false;
434
- if (!r || !r.ok) A.err = 'The agent setting was not saved: ' + ((r && r.error) || 'no answer') + '.';
435
- else { A.mode = r.mode; toast(b.name + ': Agent ' + (AGENT_MODES.find((m) => m[0] === r.mode) || [0, r.mode])[1] + '.'); }
436
- render('[data-drv-mode="' + A.mode + '"]');
437
- }
438
- function render(focusSel) {
439
- const allowed = (k) => B.build || !templateBuilds(k);
440
- for (const k of [...B.offer]) if (!allowed(k)) B.offer.delete(k);
441
- if (!B.offer.size) B.offer.add(Object.keys(TEMPLATES).find(allowed));
442
- if (!B.offer.has(B.def)) B.def = [...B.offer][0];
443
- const inis = usage && usage.ok ? usage.initiatives : [];
444
- const jiraN = usage && usage.ok ? usage.items.filter((w) => w.src === 'jira').length : 0;
445
- const usingBuild = inis.filter((i) => wfOf(i, b).some(isBuildStage)).length;
446
- const jira = el('input', { type: 'text', value: B.jira, 'aria-label': 'Jira project keys', placeholder: 'Project keys, e.g. IDPF, LB', 'data-ini': 'jira-key', oninput: (e) => { B.jira = e.target.value; } });
447
- put(host,
448
- note('Settings for the board. Workflows belong to each initiative; here you choose which templates the board offers and which one new initiatives start with.'),
449
- checkbox(B.build, [el('b', null, 'Build and deliver'), ': this board builds a product and mirrors Jira'], { 'data-ini': 'build' }, (e) => { B.build = e.target.checked; if (B.build) Object.keys(TEMPLATES).filter(templateBuilds).forEach((k) => B.offer.add(k)); render('[data-ini="build"]'); }),
450
- B.build ? el('div', { class: 'ini-field' }, lbl('JIRA PROJECTS'), el('div', { class: 'form' }, jira), note('One or more Jira projects, separated by commas. Shows their epics, stories, tasks and bugs next to PMOS tasks, and adds the Sprints and Releases tabs (mirrored, read-only). Link each initiative to its Jira epics on the initiative page.'))
451
- : note('Off: Backlog, Board and Timeline show PMOS tasks only. No Sprints or Releases tab, and initiatives choose workflows without Build and Deliver.'),
452
- !B.build && b.build ? el('div', { class: 'fold w', role: 'alert', 'data-ini': 'build-off-warning' }, icon('alert', 'sm'), el('span', null, plural(jiraN, 'Jira item') + ' will be hidden from this board.' + (usingBuild ? ' ' + plural(usingBuild, 'initiative') + ' use Build or Deliver stages; they keep them until you edit their workflow.' : ''))) : null,
453
- lbl('WORKFLOWS THIS BOARD OFFERS'),
454
- chgl(Object.keys(TEMPLATES).map((k) => el('li', null,
455
- checkbox(B.offer.has(k), [el('b', null, TEMPLATES[k].name), ' ', el('span', { class: 'dim' }, TEMPLATES[k].stages.map((s) => s.name).join(' > '))], { 'data-ini-offer': k, disabled: !allowed(k) },
456
- (e) => { if (e.target.checked) B.offer.add(k); else if (B.offer.size > 1) B.offer.delete(k); render('[data-ini-offer="' + k + '"]'); }),
457
- el('span'), tag(allowed(k) ? plural(inis.filter((i) => i.template === k).length, 'uses it', 'use it') : 'needs Build and deliver'))), { 'data-ini': 'offer' }),
458
- lbl('DEFAULT FOR NEW INITIATIVES AND ACCEPTED ASKS'),
459
- tplSeg([...B.offer], B.def, (k) => { B.def = k; render('[data-ini-tpl="' + k + '"]'); }, 'Default workflow'),
460
- tplCase(B.def),
461
- opts.demo ? null : agentSetting(A, { onPick: pickAgent }),
462
- scanNode,
463
- el('div', { class: 'chips2' }, el('span', { class: 'dim ini-note' }, 'Initiatives that do not run their own workflow run the board\'s: ' + workflowLabel(b) + '.'), lk({ 'data-ini': 'edit-board-workflow', onclick: () => openBoardWorkflow(b) }, 'Edit the board\'s workflow')),
464
- B.err ? errLine(B.err) : null,
465
- el('div', { class: 'chips2' }, pbtn('primary', B.busy ? 'Saving' : 'Save board settings', null, { 'data-ini': 'settings-save', disabled: B.busy, onclick: save }), pbtn('ghost', 'Cancel', null, { onclick: () => sh.close() })));
466
- if (focusSel) { const f = host.querySelector(focusSel); if (f) f.focus(); }
467
- }
468
- async function save() {
469
- const key = B.jira.trim();
470
- if (B.build && key && !key.split(/[,\s]+/).filter(Boolean).every((k) => /^[A-Za-z][A-Za-z0-9_]{0,19}$/.test(k))) { B.err = 'Each Jira project key is a letter, then letters, digits or _. Separate keys with a comma.'; render(); return; }
471
- B.busy = true; B.err = ''; render();
472
- const body = { board: b.id, buildDeliver: B.build, offer: [...B.offer], defTpl: B.def };
473
- if (B.build) body.jira = key;
474
- const r = await apiFor(b.ws).post('/api/boards/settings', body);
475
- B.busy = false;
476
- if (!r || !r.ok) { B.err = 'The settings were not saved: ' + ((r && r.error) || 'no answer') + '.'; render(); return; }
477
- sh.close();
478
- const nb = r.board || {};
479
- toast(b.name + ': Build and deliver ' + (nb.build ? 'on' + (jiraLabel(nb) ? ', mirroring Jira ' + jiraLabel(nb) : '') : 'off, PMOS tasks only') + '. New initiatives start with ' + (TEMPLATES[nb.defTpl] || TEMPLATES[B.def]).name + '.');
480
- refresh();
481
- }
482
- render();
483
- }
484
-
485
- function openNewBoard() {
486
- const wsList = (opts.workspaces || []).filter((w) => w && w.id);
487
- const N = { name: '', build: true, jira: '', tpl: 'product', ws: opts.ws || (wsList[0] && wsList[0].id) || '', err: '', busy: false };
488
- const host = el('div', { class: 'ini-form', 'data-ini': 'new-board-form' });
489
- const sh = openSheet({ title: 'New board', icon: 'plus', body: host, wide: true });
490
- const name = el('input', { type: 'text', placeholder: 'For example: Partner portal', 'aria-label': 'Board name', 'data-ini': 'nb-name', oninput: (e) => { N.name = e.target.value; } });
491
- function render(focusSel) {
492
- const allowed = Object.keys(TEMPLATES).filter((k) => N.build || !templateBuilds(k));
493
- if (!allowed.includes(N.tpl)) N.tpl = allowed[0];
494
- put(host,
495
- note('A board sits in the ' + PORTFOLIO + ' and holds initiatives. Each initiative picks its own workflow; the board only offers templates and a default.'),
496
- lbl('BOARD NAME'), el('div', { class: 'form' }, name),
497
- wsList.length > 1 ? el('label', { class: 'ini-field' }, lbl('WORKSPACE'), el('select', { 'data-ini': 'nb-ws', onchange: (e) => { N.ws = e.target.value; } }, ...wsList.map((w) => el('option', { value: w.id, selected: w.id === N.ws }, w.name || w.id)))) : null,
498
- checkbox(N.build, [el('b', null, 'Build and deliver'), ': this board builds a product and mirrors Jira'], { 'data-ini': 'nb-build' }, (e) => { N.build = e.target.checked; render('[data-ini="nb-build"]'); }),
499
- N.build ? el('div', { class: 'ini-field' }, lbl('JIRA PROJECTS'), el('div', { class: 'form' }, el('input', { type: 'text', value: N.jira, placeholder: 'Project keys, e.g. PP, PPM', 'aria-label': 'Jira project keys', 'data-ini': 'nb-jira', oninput: (e) => { N.jira = e.target.value; } })),
500
- note('Epics, stories, tasks and bugs from this project show next to PMOS tasks. Sprints and releases are mirrored, read-only.'))
501
- : note('Off: no Jira. Initiatives here use workflows without Build and Deliver, and the work is PMOS tasks. Good for a microsite run by an agency, an office move or hiring.'),
502
- lbl('DEFAULT WORKFLOW FOR NEW INITIATIVES'), tplSeg(allowed, N.tpl, (k) => { N.tpl = k; render('[data-ini-tpl="' + k + '"]'); }, 'Default workflow'), tplCase(N.tpl),
503
- note('Any initiative can switch to another offered workflow, or edit its own stages, from the initiative page.'),
504
- N.err ? errLine(N.err) : null,
505
- el('div', { class: 'chips2' }, pbtn('primary', N.busy ? 'Creating' : 'Create board', null, { 'data-ini': 'nb-create', disabled: N.busy, onclick: create }), pbtn('ghost', 'Cancel', null, { onclick: () => sh.close() })));
506
- if (focusSel) { const f = host.querySelector(focusSel); if (f) f.focus(); }
507
- }
508
- async function create() {
509
- const n = N.name.trim();
510
- if (!n) { N.err = 'Give the board a name.'; render(); name.focus(); return; }
511
- const kind = TEMPLATES[N.tpl].kind;
512
- const template = kind === 'simple' ? 'simple' : kind === 'project' || !N.build ? 'project' : 'product';
513
- const body = { name: n, template, buildDeliver: N.build, offer: Object.keys(TEMPLATES).filter((k) => N.build || !templateBuilds(k)), defTpl: N.tpl };
514
- if (N.build && N.jira.trim()) body.jira = N.jira.trim();
515
- N.busy = true; N.err = ''; render();
516
- const r = await apiFor(N.ws).post('/api/boards/create', body);
517
- N.busy = false;
518
- if (!r || !r.ok) { N.err = 'The board was not created: ' + ((r && r.error) || 'no answer') + '.'; render(); return; }
519
- sh.close();
520
- toast('Board ' + n + ' created' + (N.build ? (body.jira ? ', mirroring Jira ' + body.jira.toUpperCase() : ', Build and deliver on') : ', PMOS tasks only') + '. New initiatives start with ' + TEMPLATES[N.tpl].name + '.');
521
- P.boards = null;
522
- go({ view: 'board', board: (r.board && r.board.id) || n, tab: 'triage' });
523
- }
524
- render();
525
- name.focus();
526
- }
527
-
528
- /* New initiative: the server creates an initiative only by accepting an ask, so this sheet adds the ask and accepts it at once. */
529
- function openNewIni(b) {
530
- const offer = offered(b);
531
- const F = { title: '', anchor: '', lane: 'feature', tpl: offer.includes(b.defTpl) ? b.defTpl : offer[0], err: '', busy: false };
532
- const host = el('div', { class: 'ini-form', 'data-ini': 'new-ini-form' });
533
- const sh = openSheet({ title: 'New initiative · ' + b.name, icon: 'plus', body: host, wide: true });
534
- const title = el('input', { type: 'text', 'aria-label': 'Initiative title', placeholder: 'e.g. Enable passwordless login with email OTP', 'data-ini': 'ni-title', oninput: (e) => { F.title = e.target.value; } });
535
- // The anchor is picked from what the OKR files and the health budgets declare (GET /api/boards/anchors), so a typed
536
- // word the writer refuses (D59) cannot be sent. With nothing declared, or no answer, the field takes typed text.
537
- const pick = el('select', { 'aria-label': 'Anchor', 'data-ini': 'ni-anchor', disabled: true, onchange: (e) => { F.anchor = e.target.value; } },
538
- el('option', { value: '' }, 'Reading the key results and health budgets'));
539
- const typed = el('input', { type: 'text', 'aria-label': 'Anchor', placeholder: 'A key result or health:<id>, e.g. health:tech', 'data-ini': 'ni-anchor', oninput: (e) => { F.anchor = e.target.value; } });
540
- F.anchors = null;
541
- const anchorField = () => (F.anchors && !F.anchors.length ? typed : pick);
542
- const anchorNote = () => (F.anchors && !F.anchors.length
543
- ? 'No key result or health budget could be read' + (F.anchorsErr ? ' (' + F.anchorsErr + ')' : '') + '. Type an anchor declared in planning/okrs/.'
544
- : 'Every initiative anchors to a key result or a health budget. PMOS refuses one without it.');
545
- apiFor(b.ws).get('/api/boards/anchors', { board: b.id }).then((r) => {
546
- F.anchors = r && r.ok && Array.isArray(r.anchors) ? r.anchors : [];
547
- F.anchorsErr = r && r.ok ? r.error || '' : (r && r.error) || 'no answer';
548
- const groups = [];
549
- for (const a of F.anchors) { let g = groups.find((x) => x.name === a.group); if (!g) groups.push(g = { name: a.group, items: [] }); g.items.push(a); }
550
- put(pick, el('option', { value: '' }, 'Pick a key result or a health budget'),
551
- ...groups.map((g) => el('optgroup', { label: g.name }, ...g.items.map((a) => el('option', { value: a.value, selected: a.value === F.anchor }, a.label)))));
552
- pick.disabled = false;
553
- if (host.isConnected) render();
554
- });
555
- function render(focusSel) {
556
- put(host,
557
- note('Lives in ' + PORTFOLIO + ' > ' + b.name + '. It gets its own workflow: pick one of the templates this board offers. You can edit its stages later. It is recorded as an ask you accepted.'),
558
- lbl('TITLE'), el('div', { class: 'form' }, title),
559
- anchorField() === pick ? el('label', { class: 'ini-field' }, lbl('ANCHOR'), pick) : [lbl('ANCHOR'), el('div', { class: 'form' }, typed)], note(anchorNote()),
560
- el('label', { class: 'ini-field' }, lbl('LANE'), el('select', { 'aria-label': 'Lane', 'data-ini': 'ni-lane', onchange: (e) => { F.lane = e.target.value; } }, ...['feature', 'discovery', 'chore', 'incident', 'content', 'prototype'].map((l) => el('option', { value: l, selected: l === F.lane }, l)))),
561
- lbl('WORKFLOW'), tplSeg(offer, F.tpl, (k) => { F.tpl = k; render('[data-ini-tpl="' + k + '"]'); }, 'Workflow', b.defTpl), tplCase(F.tpl),
562
- b.build ? null : note(b.name + ' does not build a product, so workflows with Build and Deliver are not offered.'),
563
- F.err ? errLine(F.err) : null,
564
- el('div', { class: 'chips2' }, pbtn('primary', F.busy ? 'Creating' : 'Create initiative', null, { 'data-ini': 'ni-create', disabled: F.busy, onclick: create }), pbtn('ghost', 'Cancel', null, { onclick: () => sh.close() })));
565
- if (focusSel) { const f = host.querySelector(focusSel); if (f) f.focus(); }
566
- }
567
- async function create() {
568
- const t = F.title.trim(); const a = F.anchor.trim();
569
- if (!t || !a) { F.err = !t ? 'Give the initiative a title.' : 'Give it an anchor: a key result or a health budget.'; render(); (t ? anchorField() : title).focus(); return; }
570
- const api = apiFor(b.ws);
571
- F.busy = true; F.err = ''; render();
572
- const add = await api.post('/api/boards/asks/add', { board: b.id, line: t, source: 'New initiative, typed by you' });
573
- const askId = add && add.ok && add.ask && add.ask.id;
574
- const acc = askId ? await api.post('/api/boards/asks/accept', { board: b.id, ask: askId, title: t, lane: F.lane, anchor: a }) : add;
575
- const id = acc && acc.ok && acc.initiative && (acc.initiative.id || acc.initiative);
576
- if (!id) { F.busy = false; F.err = 'The initiative was not created: ' + ((acc && acc.error) || 'no answer') + '.'; render(); return; }
577
- if (F.tpl !== b.defTpl) {
578
- const stages = TEMPLATES[F.tpl].stages.map((s) => ({ name: s.name, cat: s.cat }));
579
- await api.post('/api/boards/ini-workflow', { board: b.id, id, template: F.tpl, stages, moveTo: stages[0].name });
580
- }
581
- sh.close();
582
- toast(id + ' created with the ' + TEMPLATES[F.tpl].name + ' workflow.');
583
- P.boards = null; dropItems();
584
- go({ view: 'ini', board: b.id, id, tab: 'overview' });
585
- }
586
- render();
587
- title.focus();
588
- }
589
-
590
- /* ════════ THE WORKFLOW EDITOR: one initiative's stages, or the board's own ════════ */
591
- function openWorkflow(b, row) {
592
- if (b.self) { openSheet({ title: 'Workflow · ' + row.id, icon: 'lock', body: el('div', { class: 'ini-form' }, note(SELF_WHY)) }); return; }
593
- const offer = offered(b);
594
- const now = wfOf(row, b);
595
- let seq = 0;
596
- const W = { tpl: row.template || null, draft: now.map((s) => ({ key: 'k' + (++seq), name: s.name, cat: s.cat, was: s.name })), confirm: false, err: '', busy: false };
597
- const host = el('div', { class: 'ini-form', 'data-ini': 'wf-editor' });
598
- const sh = openSheet({ title: 'Workflow · ' + row.id, icon: 'cols', body: host, wide: true });
599
- const mv = () => {
600
- const kept = new Map(W.draft.filter((d) => d.was).map((d) => [d.was, d.name.trim()]));
601
- if (kept.has(row.stage)) return { to: kept.get(row.stage), removed: false };
602
- const k = now.findIndex((s) => s.name === row.stage);
603
- for (let j = k - 1; j >= 0; j--) if (kept.has(now[j].name)) return { to: kept.get(now[j].name), removed: true };
604
- const same = W.draft.find((d) => d.cat === catOf(now, row.stage));
605
- return { to: ((same || W.draft[0] || {}).name || '').trim(), removed: true };
606
- };
607
- const rowsUi = stageRows(W, { current: row.stage, build: b.build !== false, onChange: () => { W.confirm = false; render(); } });
608
- function render(focusSel) {
609
- const m = mv();
610
- put(host,
611
- note('The ordered stages of ' + row.id + ' only. Other initiatives on ' + b.name + ' keep their own. Each stage sits in one category so the portfolio can compare. No conditions or validators, by design: moving work is your call.'),
612
- el('div', { class: 'chips2', role: 'group', 'aria-label': 'Start from a template' }, el('span', { class: 'dim' }, 'Start from a template'),
613
- ...Object.keys(TEMPLATES).map((k) => pill({ 'aria-pressed': String(W.tpl === k), 'data-wf-tpl': k, disabled: !offer.includes(k), title: offer.includes(k) ? TEMPLATES[k].use : templateBuilds(k) && b.build === false ? 'Needs Build and deliver on the board' : 'Not offered on this board',
614
- onclick: () => { W.tpl = k; W.draft = TEMPLATES[k].stages.map((s) => ({ key: 'k' + (++seq), name: s.name, cat: s.cat, was: now.some((o) => o.name === s.name) ? s.name : null })); W.confirm = false; W.err = ''; render('[data-wf-tpl="' + k + '"]'); } }, TEMPLATES[k].name))),
615
- b.build === false ? note(b.name + ' has Build and deliver off, so Build and Deliver stages are not offered. Turn it on in the board settings to use them.') : null,
616
- rowsUi.list(),
617
- el('div', { class: 'chips2' }, pbtn('outline', 'Add stage', 'plus', { 'data-wf-add': '', onclick: () => { W.draft.push({ key: 'k' + (++seq), name: 'New stage', cat: 'Do', was: null }); W.confirm = false; render(); const ins = host.querySelectorAll('[data-wf-name]'); const last = ins[ins.length - 1]; if (last) { last.focus(); last.select(); } } })),
618
- m.removed && !W.confirm ? note(row.id + ' is in ' + row.stage + ', which you removed. It moves to ' + (m.to || 'the first stage') + ' when you save.') : null,
619
- W.err ? errLine(W.err) : null,
620
- W.confirm ? el('div', { class: 'fold w ini-confirm', role: 'alert', 'data-ini': 'wf-confirm' }, el('b', null, 'Move ' + row.id + ' from ' + row.stage + ' to ' + m.to + ' before saving?'),
621
- el('span', { class: 'dim' }, 'The move is recorded in the initiative\'s history as your act.'),
622
- el('div', { class: 'chips2' }, pbtn('primary', 'Move it and save', null, { 'data-wf-confirm': '', onclick: () => save(true) }), pbtn('outline', 'Keep editing', null, { 'data-wf-back': '', onclick: () => { W.confirm = false; render(); } }))) : null,
623
- el('div', { class: 'chips2' }, pbtn('primary', W.busy ? 'Saving' : 'Save workflow', null, { 'data-wf-save': '', disabled: W.busy, onclick: () => save(false) }), pbtn('ghost', 'Cancel', null, { onclick: () => sh.close() })));
624
- if (focusSel) { const f = host.querySelector(focusSel); if (f) f.focus(); }
625
- if (W.confirm) { const c = host.querySelector('[data-ini="wf-confirm"]'); if (c && c.scrollIntoView) c.scrollIntoView({ block: 'nearest' }); }
626
- }
627
- rowsUi.render = render;
628
- async function save(force) {
629
- const names = W.draft.map((d) => d.name.trim());
630
- W.err = names.some((n) => !n) ? 'Every stage needs a name.' : new Set(names.map((n) => n.toLowerCase())).size !== names.length ? 'Two stages have the same name.'
631
- : b.build === false && W.draft.some(isBuildStage) ? 'Build and Deliver need a board with Build and deliver on. ' + b.name + ' has it off.' : '';
632
- if (W.err) { W.confirm = false; render(); return; }
633
- const m = mv();
634
- if (m.removed && !force) { W.confirm = true; render(); return; }
635
- W.busy = true; render();
636
- const r = await apiFor(b.ws).post('/api/boards/ini-workflow', { board: b.id, id: row.id, template: W.tpl || undefined, stages: W.draft.map((d) => ({ name: d.name.trim(), cat: d.cat, was: d.was || undefined })), moveTo: m.removed ? m.to : undefined });
637
- W.busy = false;
638
- if (!r || !r.ok) { W.err = 'The workflow was not saved: ' + ((r && r.error) || 'no answer') + '.'; W.confirm = false; render(); return; }
639
- sh.close();
640
- toast('Workflow saved for ' + row.id + (r.moved ? '. Moved to ' + r.moved.to : '') + '.');
641
- P.ini = null; P.boards = null; dropItems(); draw();
642
- }
643
- render('[data-wf-name="0"]');
644
- }
645
-
646
- /** The stage rows of an editor, one line each: grip (drag to reorder), category swatch, name, category, up, down, remove; under the name only
647
- * the chips that add something (current stage, was, new, counts, a Build warning). o.render is set by the caller. */
648
- function stageRows(W, o) {
649
- let dragFrom = null;
650
- const api = { render: () => {} };
651
- api.list = () => list(W.draft.map((s, k) => {
652
- const grip = el('span', { class: 'ki ini-grip', draggable: 'true', 'data-wf-drag': String(k), title: 'Drag to reorder', 'aria-hidden': 'true' }, icon('grip'));
653
- grip.addEventListener('dragstart', (e) => { dragFrom = k; try { e.dataTransfer.setData('text/plain', 'wf'); e.dataTransfer.effectAllowed = 'move'; const r = grip.closest('[data-wf-row]'); if (r) e.dataTransfer.setDragImage(r, 10, 10); } catch { /* no data transfer */ } });
654
- const li = el('li', { class: 'nrow', 'data-wf-row': String(k) }, grip,
655
- el('div', { class: 'nb' },
656
- el('div', { class: 'form' }, sw(s.cat),
657
- el('input', { type: 'text', value: s.name, 'aria-label': 'Stage ' + (k + 1) + ' name', 'data-wf-name': String(k), oninput: (e) => { s.name = e.target.value; } }),
658
- el('select', { 'aria-label': 'Stage ' + (k + 1) + ' category', 'data-wf-cat': String(k), onchange: (e) => { s.cat = e.target.value; o.onChange(); } }, ...CATS.map((c) => el('option', { value: c, selected: c === s.cat }, c)))),
659
- chipsOf(o.current && s.was === o.current ? chip('current stage') : null,
660
- s.was ? (s.was !== s.name.trim() ? chip('was ' + s.was) : null) : tag('new'),
661
- o.counts && s.was ? chip(plural(Number(o.counts[s.was]) || 0, 'initiative')) : null,
662
- !o.build && isBuildStage(s) ? st('warn', 'alert', 'needs Build and deliver') : null)),
663
- el('div', { class: 'acts' },
664
- ib('Move ' + s.name + ' up', el('span', { class: 'ini-up' }, icon('next', 'sm')), { 'data-wf-up': String(k), disabled: k === 0, onclick: () => { [W.draft[k - 1], W.draft[k]] = [W.draft[k], W.draft[k - 1]]; o.onChange(); focusIn('[data-wf-up="' + (k - 1) + '"]', '[data-wf-down="' + (k - 1) + '"]'); } }),
665
- ib('Move ' + s.name + ' down', el('span', { class: 'ini-down' }, icon('next', 'sm')), { 'data-wf-down': String(k), disabled: k === W.draft.length - 1, onclick: () => { [W.draft[k + 1], W.draft[k]] = [W.draft[k], W.draft[k + 1]]; o.onChange(); focusIn('[data-wf-down="' + (k + 1) + '"]', '[data-wf-up="' + (k + 1) + '"]'); } }),
666
- ib('Remove ' + s.name, 'x', { 'data-wf-del': String(k), disabled: W.draft.length < 2, onclick: () => { if (W.draft.length > 1) W.draft.splice(k, 1); o.onChange(); focusIn('[data-wf-del="' + Math.min(k, W.draft.length - 1) + '"]', '[data-wf-add]'); } })));
667
- li.addEventListener('dragover', (e) => { if (dragFrom == null) return; e.preventDefault(); li.classList.add('over'); });
668
- li.addEventListener('dragleave', () => li.classList.remove('over'));
669
- li.addEventListener('drop', (e) => { if (dragFrom == null) return; e.preventDefault(); const [m] = W.draft.splice(dragFrom, 1); W.draft.splice(k, 0, m); dragFrom = null; o.onChange(); });
670
- li.addEventListener('dragend', () => { dragFrom = null; li.classList.remove('over'); });
671
- return li;
672
- }), { 'data-ini': 'wf-list' });
673
- const chipsOf = (...c) => (c.some(Boolean) ? el('div', { class: 'chips' }, ...c) : null);
674
- const focusIn = (a, b2) => { const sheetEl = document.querySelector('[data-ini="wf-editor"]'); if (!sheetEl) return; const f = sheetEl.querySelector(a); if (f && !f.disabled) f.focus(); else { const g = sheetEl.querySelector(b2); if (g) g.focus(); } };
675
- return api;
676
- }
677
-
678
- /* The board's own workflow: what an initiative that does not run its own workflow runs. Removing a stage that holds such initiatives asks
679
- * where they go (POST /api/boards/workflow, moveRemoved). */
680
- async function openBoardWorkflow(b) {
681
- if (b.self) return;
682
- let seq = 0;
683
- const counts = {};
684
- const W = { tpl: b.template, draft: (b.workflow || []).map((s) => ({ key: 'k' + (++seq), name: s.name, cat: s.cat, hint: s.hint || '', was: s.name })), targets: {}, err: '', busy: false };
685
- const host = el('div', { class: 'ini-form', 'data-ini': 'wf-editor', 'data-ini-mode': 'board' });
686
- const sh = openSheet({ title: 'Board workflow · ' + b.name, icon: 'cols', body: host, wide: true });
687
- const r0 = await loadItems(makeCtx(b, {}));
688
- for (const i of r0.initiatives || []) if (!i.template) counts[i.stage] = (counts[i.stage] || 0) + 1;
689
- const old = (b.workflow || []).map((s) => s.name);
690
- const removed = () => old.filter((n) => !W.draft.some((d) => d.was === n));
691
- const target = (n) => { const names = W.draft.map((d) => d.name.trim()); if (names.includes(W.targets[n])) return W.targets[n]; const k = old.indexOf(n); for (let j = k - 1; j >= 0; j--) { const d = W.draft.find((x) => x.was === old[j]); if (d) return d.name.trim(); } return names[0] || ''; };
692
- const rowsUi = stageRows(W, { build: b.build !== false, counts, onChange: () => render() });
693
- function render(focusSel) {
694
- const gone = removed().filter((n) => Number(counts[n]) > 0);
695
- put(host,
696
- note('The stages that ' + b.name + '\'s initiatives run when they have no workflow of their own. Each initiative can still pick its own from the templates the board offers.'),
697
- el('div', { class: 'chips2', role: 'group', 'aria-label': 'Start from a template' }, el('span', { class: 'dim' }, 'Start from a template'),
698
- ...BOARD_TEMPLATES.map((k) => pill({ 'aria-pressed': String(W.tpl === k), 'data-wf-tpl': k, disabled: b.build === false && templateBuilds(k), onclick: () => { W.tpl = k; W.draft = TEMPLATES[k].stages.map((s) => ({ key: 'k' + (++seq), name: s.name, cat: s.cat, hint: '', was: old.includes(s.name) ? s.name : null })); render('[data-wf-tpl="' + k + '"]'); } }, TEMPLATES[k].name))),
699
- rowsUi.list(),
700
- el('div', { class: 'chips2' }, pbtn('outline', 'Add stage', 'plus', { 'data-wf-add': '', onclick: () => { W.draft.push({ key: 'k' + (++seq), name: 'New stage', cat: 'Do', hint: '', was: null }); render('[data-wf-name="' + (W.draft.length - 1) + '"]'); } })),
701
- gone.length ? el('div', { class: 'fold w ini-confirm', 'data-ini': 'wf-moves' }, el('b', null, 'Where do their initiatives go?'),
702
- ...gone.map((n) => el('label', { class: 'chips2' }, plural(Number(counts[n]), 'initiative') + ' in ' + n + ' move to',
703
- el('select', { 'data-wf-target': n, 'aria-label': 'Stage for the initiatives of ' + n, onchange: (e) => { W.targets[n] = e.target.value; } }, ...W.draft.map((d) => d.name.trim()).filter(Boolean).map((x) => el('option', { value: x, selected: x === target(n) }, x))))),
704
- el('span', { class: 'dim' }, 'Each move is recorded in the initiative history as your act.')) : null,
705
- W.err ? errLine(W.err) : null,
706
- el('div', { class: 'chips2' }, pbtn('primary', W.busy ? 'Saving' : 'Save workflow', null, { 'data-wf-save': '', disabled: W.busy, onclick: save }), pbtn('ghost', 'Cancel', null, { onclick: () => sh.close() })));
707
- if (focusSel) { const f = host.querySelector(focusSel); if (f) f.focus(); }
708
- }
709
- async function save() {
710
- const names = W.draft.map((d) => d.name.trim());
711
- W.err = names.some((n) => !n) ? 'Every stage needs a name.' : new Set(names.map((n) => n.toLowerCase())).size !== names.length ? 'Two stages have the same name.' : '';
712
- if (W.err) { render(); return; }
713
- const moveRemoved = {}; for (const n of removed()) if (Number(counts[n]) > 0) moveRemoved[n] = target(n);
714
- W.busy = true; render();
715
- const r = await apiFor(b.ws).post('/api/boards/workflow', { board: b.id, stages: W.draft.map((d) => ({ name: d.name.trim(), cat: d.cat, hint: d.hint || '', was: d.was || undefined })), moveRemoved, template: W.tpl });
716
- W.busy = false;
717
- if (!r || !r.ok) { W.err = 'The workflow was not saved: ' + ((r && r.error) || 'no answer') + '.'; render(); return; }
718
- sh.close();
719
- toast('Board workflow saved.' + (Number(r.moved) ? ' ' + plural(Number(r.moved), 'initiative') + ' moved to a new stage.' : ''));
720
- refresh();
721
- }
722
- render('[data-wf-name="0"]');
723
- }
724
-
725
- /* ════════ INITIATIVE ════════ */
726
- async function drawIni(b, token) {
727
- const { id } = P.loc;
728
- if (!P.ini || P.ini.id !== id || P.ini.board !== b.id) {
729
- status('Reading ' + id);
730
- const r = await apiFor(b.ws).get('/api/boards/initiative', { board: b.id, id });
731
- if (token !== P.seq) return;
732
- if (!r || !r.ok || !r.row) {
733
- put(root, pathCrumbs(b, { id, title: '' }), errLine(r && r.pending ? 'Reading the repository. Open the page again in a moment.' : 'The initiative could not be read: ' + ((r && r.error) || 'no answer') + '.'));
734
- return;
735
- }
736
- P.ini = { id, board: b.id, row: r.row, history: r.history || [], tools: r.tools || [], toolsByCat: r.toolsByCat || null, b: { ...b, ...(r.board || {}), counts: b.counts, asks: b.asks, nextRelease: b.nextRelease } };
737
- }
738
- const { row, history, tools, toolsByCat } = P.ini; const bb = P.ini.b;
739
- let tab = P.loc.tab; if (tab === 'tickets' && !bb.build) tab = 'overview';
740
- const ctxI = makeCtx(bb, { row, history, tools, toolsByCat, tab, tool: P.loc.tool || '' });
741
- const items = await loadItems(ctxI);
742
- if (token !== P.seq) return;
743
- const work = items.items.filter((w) => w.ini === row.id);
744
- const wf = wfOf(row, bb); const idx = wf.findIndex((s) => s.name === row.stage); const cat = row.cat || catOf(wf, row.stage);
745
- const warnings = Array.isArray(row.warnings) ? row.warnings : [];
746
- // c3-initiative-declutter: three rows above the content. The breadcrumb carries the title, status and warnings;
747
- // the stepper carries a gear for the workflow and one Tools menu; the tabs carry the counts.
748
- const kind = kindOf(row, bb);
749
- const toolList = [...recordToolsFor(kind, cat, bb.build).map((id) => ({ id, label: RECORD_META[id][0], rec: true })), ...(Array.isArray(tools) ? tools : []).map((t) => (typeof t === 'string' ? { id: t } : t)).filter((t) => t && t.id)];
750
- const toolsBtn = pill({ 'data-ini': 'tools', 'aria-haspopup': 'menu', 'aria-expanded': 'false', onclick: (e) => openTools(e.currentTarget, row, bb, cat, kind, toolList) }, icon('bolt', 'sm'), 'Tools');
751
- const stepper = el('div', { class: 'calbar' },
752
- el('span', { class: 'chips2' },
753
- el('div', { class: 'seg ini-seg', role: 'group', 'aria-label': 'Workflow position', 'data-ini': 'stepper' },
754
- ...wf.map((s, k) => btn({ 'aria-pressed': String(k === idx), 'aria-current': k === idx ? 'step' : 'false', 'data-ini-step': s.name, title: bb.self ? SELF_WHY : k === idx ? 'Current stage' : 'Move to ' + s.name, onclick: () => stepTo(s.name) },
755
- k < idx ? icon('check', 'sm') : sw(s.cat), s.name))),
756
- ib('Edit workflow', 'settings', { 'data-ini': 'edit-workflow', 'aria-haspopup': 'dialog', title: tplName(row, bb) + ' workflow, now in ' + cat + '. You decide when it moves. Edit workflow', onclick: () => openWorkflow(bb, row) })),
757
- toolsBtn);
758
- const tabs = INI_TAB_LIST.filter(([k]) => k !== 'tickets' || bb.build).map(([k, l, ic]) => [k, l, ic,
759
- k === 'breakdown' && work.length ? el('span', { class: 'bdg g' }, String(work.length)) : k === 'tickets' ? el('span', { class: 'bdg g' }, String(work.filter((w) => w.src === 'jira').length)) : null]);
760
- const host = el('div', { class: 'calbody', 'data-ini-panel': tab });
761
- // c3-initiative-lifecycle: a hold, cancel or resume is derived in a child process, so the page reads again until it shows it.
762
- const ex = P.expect;
763
- if (ex && ex.id === row.id && ex.kind === 'status' && (ex.status ? row.status !== ex.status : ['on hold', 'cancelled'].includes(row.status)) && (ex.tries = (ex.tries || 0) + 1) < 10) {
764
- setTimeout(() => { if (token === P.seq && P.expect === ex) { P.ini = null; draw(); } }, 800);
765
- } else if (ex && ex.id === row.id) P.expect = null;
766
- const L = { ctx: ctxI, done: (change) => { P.expect = change || null; P.ini = null; P.boards = null; dropItems(); draw(); } };
767
- const own = [{ kids: [icon('report', 'sm'), 'Dashboard'], attrs: { 'data-ini-act': 'dashboard' }, onPick: () => ctxI.showTab('rep') },
768
- bb.build ? { kids: [icon('jira', 'sm'), (row.epics || []).length ? 'Jira epics ' + row.epics.join(', ') : 'Link Jira epics'], attrs: { 'data-ini': 'jira-epics' }, onPick: () => openEpics(bb, row) } : null].filter(Boolean);
769
- put(root,
770
- pathCrumbs(bb, row, el('div', { class: 'chips2' },
771
- el('span', { class: 'chips2', 'data-ini': 'ini-chips' }, statusChip(row.status), el('span', { class: 'chips2', 'data-ini': 'warnings', 'aria-live': 'polite' }, ...warnings.map(warnChip))),
772
- ib('Actions for ' + row.id, 'more', { 'data-il-menu': row.id, 'aria-haspopup': 'menu', 'aria-expanded': 'false', title: 'Dashboard, Jira epics, pause, cancel, merge or archive', onclick: (e) => pageMenu(e.currentTarget, L, row, own) }))),
773
- el('div', { class: 'calbody', 'data-ini-page': row.id },
774
- lifeBanner(L, row),
775
- stepper, bb.self ? note(SELF_WHY) : null,
776
- segTabs(tabs, tab, (k) => go({ view: 'ini', board: bb.id, id: row.id, tab: k }), 'Initiative views', { 'data-ini': 'ini-tabs' }),
777
- host));
778
- if (P.focusStep) { const f = stepper.querySelector('[data-ini-step="' + CSS.escape(P.focusStep) + '"]'); P.focusStep = null; if (f) f.focus(); }
779
- mountTab(host, null, (INI_TAB_LIST.find((t) => t[0] === tab) || [])[1], ctxI, token);
780
- }
781
- /* The Jira epics of an initiative: the daily Jira check reads each one and the issues under it, read-only. */
782
- function openEpics(b, row) {
783
- const E = { text: (row.epics || []).join(', '), err: '', busy: false };
784
- const host = el('div', { class: 'ini-form', 'data-ini': 'epics-form' });
785
- const sh = openSheet({ title: 'Jira epics · ' + row.id, icon: 'bolt', body: host });
786
- function render() {
787
- const input = el('input', { type: 'text', value: E.text, 'aria-label': 'Jira epic keys', placeholder: 'Epic keys, e.g. IDPF-2685, LB-120', 'data-ini': 'epics-input', oninput: (e) => { E.text = e.target.value; } });
788
- put(host,
789
- note('The Jira epics this initiative runs on. The daily Jira check reads each epic and the issues under it, read-only, and shows them as its Jira items.' + (jiraLabel(b) ? ' ' + b.name + ' mirrors Jira ' + jiraLabel(b) + '.' : '')),
790
- row.epicsFrom === 'record' ? note('Now from the initiative record (jira: ' + row.epics.join(', ') + '). Saving here takes over from it.') : null,
791
- el('div', { class: 'ini-field' }, lbl('JIRA EPICS'), el('div', { class: 'form' }, input)),
792
- E.err ? errLine(E.err) : null,
793
- el('div', { class: 'chips2' }, pbtn('primary', E.busy ? 'Saving' : 'Save epics', null, { 'data-ini': 'epics-save', disabled: E.busy, onclick: save }), pbtn('ghost', 'Cancel', null, { onclick: () => sh.close() })));
794
- input.focus();
795
- }
796
- async function save() {
797
- const keys = E.text.split(/[,\s]+/).filter(Boolean);
798
- if (!keys.every((k) => /^[A-Za-z][A-Za-z0-9_]*-\d+$/.test(k))) { E.err = 'An epic key is a project key, a dash and a number, like IDPF-2685. Separate keys with a comma.'; render(); return; }
799
- E.busy = true; E.err = ''; render();
800
- const r = await apiFor(b.ws).post('/api/boards/ini-epics', { board: b.id, id: row.id, epics: keys });
801
- E.busy = false;
802
- if (!r || !r.ok) { E.err = 'The epics were not saved: ' + ((r && r.error) || 'no answer') + '.'; render(); return; }
803
- sh.close();
804
- toast(keys.length ? row.id + ' runs on Jira ' + keys.map((k) => k.toUpperCase()).join(', ') + '. The next Jira check reads them.' : row.id + ' has no Jira epic now.');
805
- P.ini = null; dropItems(); draw();
806
- }
807
- render();
808
- }
809
- function pickTool(id) {
810
- if (P.loc.tab !== 'overview' || P.loc.tool !== id) { go({ ...P.loc, tab: 'overview', tool: id }); return; }
811
- const n = root.querySelector('[data-ini-tool-card="' + CSS.escape(id) + '"]');
812
- if (n) { n.scrollIntoView({ behavior: 'smooth', block: 'start' }); n.classList.add('ini-flash'); setTimeout(() => n.classList.remove('ini-flash'), 1400); }
813
- }
814
- /* One Tools menu: this stage's tools first, then the other stages' tools under their stage names. */
815
- function openTools(anchor, row, b, cat, kind, here) {
816
- const byCat = (P.ini && P.ini.toolsByCat) || {};
817
- const recOf = (c) => recordToolsFor(kind, c, b.build).map((id) => ({ id, label: RECORD_META[id][0], rec: true }));
818
- const seen = new Set([...(byCat[cat] || []), ...recOf(cat), ...here].map((t) => t.id));
819
- const items = here.length ? [{ group: 'For ' + row.stage }, ...here.map((t) => ({ kids: [icon(t.rec ? RECORD_META[t.id][1] : toolIcon(t.id), 'sm'), toolLabel(t)], current: P.loc.tool === t.id, attrs: { 'data-ini-tool': t.id }, onPick: () => pickTool(t.id) }))] : [];
820
- for (const s of wfOf(row, b)) {
821
- const ks = [...recOf(s.cat), ...(byCat[s.cat] || [])].filter((t) => !seen.has(t.id)); ks.forEach((t) => seen.add(t.id));
822
- if (ks.length) items.push({ group: s.name }, ...ks.map((t) => ({ kids: [icon(t.rec ? RECORD_META[t.id][1] : toolIcon(t.id), 'sm'), toolLabel(t)], attrs: { 'data-ini-moretool': t.id }, onPick: () => go({ ...P.loc, tab: 'overview', tool: t.id }) })));
823
- }
824
- openMenu(anchor, { label: 'Tools', items: items.length ? items : [{ label: 'No tools for this workflow.', disabled: true, onPick: () => {} }] });
825
- }
826
- async function stepTo(stage) {
827
- const ini = P.ini; if (!ini) return;
828
- const r = await moveTo(ini.b, ini.row.id, stage);
829
- if (r && r.ok) { P.focusStep = stage; draw(); }
830
- }
831
- /** Move an initiative to a stage of its own workflow: POST /api/boards/move; warnings are shown, never a block. */
832
- async function moveTo(b, id, stage) {
833
- if (b.self) { toast(SELF_WHY); return { ok: false }; }
834
- const r = await apiFor(b.ws).post('/api/boards/move', { board: b.id, id, to: stage });
835
- if (!r || !r.ok) { toast({ text: 'The move did not save: ' + ((r && r.error) || 'no answer') + '.', tone: 'error' }); return { ok: false }; }
836
- const warnings = Array.isArray(r.warnings) ? r.warnings : [];
837
- toast(id + ' moved to ' + stage + '.' + (warnings.length ? ' Warning: ' + warnings.join(', ') + '. Not blocked.' : ''));
838
- if (P.ini && P.ini.id === id) { P.ini.row = { ...P.ini.row, ...(r.row || {}), stage, warnings: (r.row && r.row.warnings) || warnings }; P.ini.history = [{ kind: 'move', at: new Date().toISOString(), by: 'You', from: null, to: stage, warnings }, ...P.ini.history]; P.ini = null; }
839
- P.boards = null; dropItems();
840
- loadBoards().catch(() => null);
841
- return { ok: true, row: r.row, warnings };
842
- }
843
-
844
- writeUrl();
845
- draw();
846
- return { go, refresh, get location() { return { ...P.loc }; }, close: () => { closeMenu(); closeSheet(); } };
847
- }
848
-
849
- const chipMono = (t) => el('span', { class: 'chip2 mono' }, t);
850
- const toneOf = (i) => (i.status === 'late' ? 'bad' : i.status === 'at risk' ? 'warn' : 'ok');
851
- function isoToday() { const d = new Date(); return d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0') + '-' + String(d.getDate()).padStart(2, '0'); }
852
- export { ownerText, kv, TOOL_META };