create-pmos 0.399.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.
- package/package.json +18 -13
- package/payload/KIT-VERSION +1 -1
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/workspace/briefing-premium-adddoc-test.js +2 -2
- package/workspace/briefing-premium-board-test.js +2 -2
- package/workspace/briefing-premium-doc-edit-test.js +2 -8
- package/workspace/briefing-premium-test.js +3 -2
- package/workspace/briefing-premium-work-test.js +9 -4
- package/workspace/c3-capture-test.js +0 -17
- package/workspace/changelog.json +17 -0
- package/workspace/guide/briefing-premium.md +2 -2
- package/workspace/guide/home.md +20 -2
- package/workspace/guide/layout.md +2 -2
- package/workspace/guide/notes.md +2 -2
- package/workspace/guide/phone-companion.md +1 -1
- package/workspace/lib/route-modules.js +1 -9
- package/workspace/lib/routes-phone-day.js +18 -9
- package/workspace/lib/routes-slash.js +95 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -2
- package/workspace/premium-chat-goal-view-test.js +1 -1
- package/workspace/premium-chat-term-test.js +0 -10
- package/workspace/premium-menu-rows-test.js +1 -1
- package/workspace/premium-phone-card-test.js +2 -2
- package/workspace/premium-vw-doc-test.js +1 -8
- package/workspace/premium-work-depth-test.js +2 -3
- package/workspace/public/capture.html +23 -0
- package/workspace/public/pm/c3-base.js +47 -0
- package/workspace/public/pm/c3-capture.js +1 -1
- package/workspace/public/pm/c3-ini-ui.js +1 -1
- package/workspace/public/pm/c3-sheet.js +1 -1
- package/workspace/public/pm/c3-toast.js +1 -1
- package/workspace/public/pm/console3.css +3 -0
- package/workspace/public/pm/cozy-home.css +20 -5
- package/workspace/public/pm/cozy-today.css +5 -2
- package/workspace/public/pm/cozy-viewer.js +4 -2
- package/workspace/public/pm/cozy.css +9 -0
- package/workspace/public/pm/goal-chat.js +5 -1
- package/workspace/public/pm/home-app.js +47 -26
- package/workspace/public/pm/home-chat.js +10 -4
- package/workspace/public/pm/home-data.js +3 -1
- package/workspace/public/pm/home-dictate.js +7 -4
- package/workspace/public/pm/home-ini.js +12 -2
- package/workspace/public/pm/home-list.js +20 -7
- package/workspace/public/pm/home-more.js +2 -2
- package/workspace/public/pm/home-phone-card.js +9 -4
- package/workspace/public/pm/home-review.js +2 -3
- package/workspace/public/pm/home-today.js +10 -6
- package/workspace/public/pm/home-work.js +15 -8
- package/workspace/public/pm/note-dock.js +1 -2
- package/workspace/public/pm/notes-links.js +1 -2
- package/workspace/public/pm/notes-task.js +3 -4
- package/workspace/public/pm/premium-board.js +1 -1
- package/workspace/public/pm/premium-initiative-head.js +3 -3
- package/workspace/public/pm/premium-vw-doc.css +20 -2
- package/workspace/public/pm/premium-vw-doc.js +22 -7
- package/workspace/public/pm/view-notes.js +2 -2
- package/workspace/replaced-tests.json +435 -0
- package/workspace/run-tests.js +323 -28
- package/workspace/server.js +15 -10
- package/workspace/test-files.json +3 -140
- package/workspace/test-lists/base.json +1 -2
- package/workspace/test-lists/c3-desktop-light-load.json +1 -2
- package/workspace/test-lists/c3-initiative-boards.json +1 -2
- package/workspace/test-lists/c3-meeting-focus.json +2 -12
- package/workspace/test-lists/c3-work-agent.json +1 -2
- package/workspace/test-lists/calendar-tidy-up.json +1 -2
- package/workspace/test-lists/console3-reports.json +1 -2
- package/workspace/test-lists/docs-three-way-sync.json +1 -2
- package/workspace/test-lists/extension-capture.json +5 -0
- package/workspace/test-lists/jira-wbs.json +1 -2
- package/workspace/test-lists/legacy-cleanup-a.json +9 -0
- package/workspace/test-lists/meeting-material.json +1 -2
- package/workspace/test-lists/meeting-notes.json +2 -36
- package/workspace/test-lists/meeting-replay.json +1 -2
- package/workspace/test-lists/mm-capture.json +2 -12
- package/workspace/test-lists/my-work.json +2 -10
- package/workspace/test-lists/onboarding-firstrun.json +2 -12
- package/workspace/test-lists/people-directory.json +1 -2
- package/workspace/test-lists/run2-a.json +1 -2
- package/workspace/test-lists/run2-d.json +2 -19
- package/workspace/test-lists/run3-b.json +1 -2
- package/workspace/test-lists/run3-c.json +2 -12
- package/workspace/test-lists/run4-b.json +1 -2
- package/workspace/test-lists/run4-d.json +1 -5
- package/workspace/test-lists/run5-c.json +1 -11
- package/workspace/test-lists/run6.json +1 -5
- package/workspace/test-lists/workspace-launch-flags.json +2 -12
- package/workspace/test-lists/workspace-profile-detection.json +2 -10
- package/workspace/test-timings.json +242 -123
- package/workspace/c3-briefing-test.js +0 -136
- package/workspace/c3-core-docs-test.js +0 -170
- package/workspace/c3-driver-fixture.js +0 -64
- package/workspace/c3-driver-test.js +0 -169
- package/workspace/c3-foundation-test.js +0 -163
- package/workspace/c3-ib-items-test.js +0 -114
- package/workspace/c3-ib-more-test.js +0 -146
- package/workspace/c3-ib-triage-backlog-test.js +0 -128
- package/workspace/c3-ini-harness.js +0 -66
- package/workspace/c3-ini-life-test.js +0 -167
- package/workspace/c3-initiatives-test.js +0 -186
- package/workspace/c3-light-load-test.js +0 -112
- package/workspace/c3-one-home-test.js +0 -149
- package/workspace/c3-phone-test.js +0 -289
- package/workspace/c3-quiet-test.js +0 -157
- package/workspace/c3-report-design-real-test.js +0 -264
- package/workspace/c3-report-design-test.js +0 -442
- package/workspace/c3-report-setup-test.js +0 -192
- package/workspace/c3-report-structure-real-test.js +0 -248
- package/workspace/c3-report-structure-test.js +0 -397
- package/workspace/c3-reports-test.js +0 -288
- package/workspace/c3-scan-test.js +0 -517
- package/workspace/c3-sessions-panel-test.js +0 -365
- package/workspace/c3-settings-test.js +0 -204
- package/workspace/c3-updates-test.js +0 -131
- package/workspace/c3-work-test.js +0 -260
- package/workspace/cut-stub.js +0 -40
- package/workspace/first-paint-audit.js +0 -160
- package/workspace/lib/c3-full-console.js +0 -15
- package/workspace/lib/engine/derived/trust.js +0 -3
- package/workspace/lib/engine/plan-forecast.js +0 -342
- package/workspace/lib/engine/report-families.js +0 -175
- package/workspace/lib/engine/truth-table.js +0 -57
- package/workspace/lib/routes-c3-init.js +0 -54
- package/workspace/lib/routes-c3-life.js +0 -120
- package/workspace/lib/routes-c3-timeline.js +0 -192
- package/workspace/lib/routes-forecast.js +0 -86
- package/workspace/lib/routes-releases.js +0 -130
- package/workspace/lib/routes-report-facts.js +0 -85
- package/workspace/lib/routes-report-families.js +0 -33
- package/workspace/lib/routes-signals.js +0 -51
- package/workspace/lib/routes-timeline.js +0 -197
- package/workspace/public/c3.html +0 -35
- package/workspace/public/index.html +0 -156
- package/workspace/public/pm/app.js +0 -831
- package/workspace/public/pm/bd-board.js +0 -159
- package/workspace/public/pm/bd-drag.js +0 -59
- package/workspace/public/pm/bd-model.js +0 -152
- package/workspace/public/pm/bd-timeline.js +0 -233
- package/workspace/public/pm/bd-tree.js +0 -244
- package/workspace/public/pm/board-copy.js +0 -59
- package/workspace/public/pm/board-read.js +0 -38
- package/workspace/public/pm/branches-sheet.js +0 -56
- package/workspace/public/pm/breakdown-api.js +0 -58
- package/workspace/public/pm/breakdown-copy.js +0 -138
- package/workspace/public/pm/briefing-deck.js +0 -441
- package/workspace/public/pm/briefing-model.js +0 -251
- package/workspace/public/pm/c3-ambient.js +0 -100
- package/workspace/public/pm/c3-audience-link.js +0 -21
- package/workspace/public/pm/c3-audience.js +0 -46
- package/workspace/public/pm/c3-boot.js +0 -13
- package/workspace/public/pm/c3-breakdown.js +0 -240
- package/workspace/public/pm/c3-brief-data.js +0 -11
- package/workspace/public/pm/c3-brief-mentions.js +0 -137
- package/workspace/public/pm/c3-brief-needs.js +0 -288
- package/workspace/public/pm/c3-brief-pulse.js +0 -112
- package/workspace/public/pm/c3-brief-summary.js +0 -139
- package/workspace/public/pm/c3-brief-today.js +0 -79
- package/workspace/public/pm/c3-brief.js +0 -279
- package/workspace/public/pm/c3-cal-strategy.js +0 -529
- package/workspace/public/pm/c3-calendar.js +0 -965
- package/workspace/public/pm/c3-calpop.js +0 -111
- package/workspace/public/pm/c3-case.js +0 -196
- package/workspace/public/pm/c3-core-docs.css +0 -18
- package/workspace/public/pm/c3-core-docs.js +0 -236
- package/workspace/public/pm/c3-daypart.js +0 -176
- package/workspace/public/pm/c3-demo-boards.js +0 -764
- package/workspace/public/pm/c3-demo-brief-ix.js +0 -350
- package/workspace/public/pm/c3-demo-brief-page.js +0 -70
- package/workspace/public/pm/c3-demo-cal-ix.js +0 -74
- package/workspace/public/pm/c3-demo-cal2.js +0 -66
- package/workspace/public/pm/c3-demo-cal3.js +0 -173
- package/workspace/public/pm/c3-demo-cal4.js +0 -169
- package/workspace/public/pm/c3-demo-cal5.js +0 -52
- package/workspace/public/pm/c3-demo-coredocs.js +0 -221
- package/workspace/public/pm/c3-demo-data.js +0 -552
- package/workspace/public/pm/c3-demo-focus.js +0 -181
- package/workspace/public/pm/c3-demo-init.js +0 -430
- package/workspace/public/pm/c3-demo-life.js +0 -77
- package/workspace/public/pm/c3-demo-material.js +0 -58
- package/workspace/public/pm/c3-demo-misc2.js +0 -34
- package/workspace/public/pm/c3-demo-phone.js +0 -48
- package/workspace/public/pm/c3-demo-plan2.js +0 -30
- package/workspace/public/pm/c3-demo-rd.js +0 -432
- package/workspace/public/pm/c3-demo-rep-ix.js +0 -126
- package/workspace/public/pm/c3-demo-rep2.js +0 -130
- package/workspace/public/pm/c3-demo-rep3.js +0 -138
- package/workspace/public/pm/c3-demo-rs.js +0 -287
- package/workspace/public/pm/c3-demo-term.js +0 -153
- package/workspace/public/pm/c3-demo-time.js +0 -49
- package/workspace/public/pm/c3-demo-work-ix.js +0 -32
- package/workspace/public/pm/c3-demo.js +0 -131
- package/workspace/public/pm/c3-design-studio.js +0 -369
- package/workspace/public/pm/c3-doc-formats.js +0 -153
- package/workspace/public/pm/c3-doc-sheet.js +0 -1230
- package/workspace/public/pm/c3-dock.js +0 -206
- package/workspace/public/pm/c3-docs.js +0 -291
- package/workspace/public/pm/c3-driver-work.js +0 -110
- package/workspace/public/pm/c3-driver.css +0 -18
- package/workspace/public/pm/c3-driver.js +0 -298
- package/workspace/public/pm/c3-focus.css +0 -304
- package/workspace/public/pm/c3-focus.js +0 -983
- package/workspace/public/pm/c3-ib-docs.js +0 -92
- package/workspace/public/pm/c3-ib-initiatives.js +0 -201
- package/workspace/public/pm/c3-ib-items.js +0 -210
- package/workspace/public/pm/c3-ib-releases.js +0 -48
- package/workspace/public/pm/c3-ib-sprints.js +0 -201
- package/workspace/public/pm/c3-ib-triage.js +0 -177
- package/workspace/public/pm/c3-ii-tabs.js +0 -252
- package/workspace/public/pm/c3-ini-life.css +0 -34
- package/workspace/public/pm/c3-ini-life.js +0 -379
- package/workspace/public/pm/c3-ini-records.js +0 -197
- package/workspace/public/pm/c3-ini-timeline.js +0 -278
- package/workspace/public/pm/c3-ini-work.js +0 -139
- package/workspace/public/pm/c3-init-extras.js +0 -170
- package/workspace/public/pm/c3-initiatives.js +0 -852
- package/workspace/public/pm/c3-lifecycle-panels.js +0 -479
- package/workspace/public/pm/c3-look.js +0 -27
- package/workspace/public/pm/c3-material.css +0 -22
- package/workspace/public/pm/c3-material.js +0 -321
- package/workspace/public/pm/c3-md.js +0 -3
- package/workspace/public/pm/c3-misc-panels.js +0 -89
- package/workspace/public/pm/c3-new-session.js +0 -110
- package/workspace/public/pm/c3-notes.js +0 -751
- package/workspace/public/pm/c3-phone-boot.js +0 -47
- package/workspace/public/pm/c3-phone-detail.js +0 -97
- package/workspace/public/pm/c3-phone-model.js +0 -3
- package/workspace/public/pm/c3-phone.css +0 -66
- package/workspace/public/pm/c3-phone.js +0 -444
- package/workspace/public/pm/c3-plan-panels.js +0 -163
- package/workspace/public/pm/c3-plan.js +0 -193
- package/workspace/public/pm/c3-quiet.css +0 -113
- package/workspace/public/pm/c3-quiet.js +0 -177
- package/workspace/public/pm/c3-replay.css +0 -133
- package/workspace/public/pm/c3-replay.js +0 -429
- package/workspace/public/pm/c3-report-deck.css +0 -163
- package/workspace/public/pm/c3-report-deck.js +0 -598
- package/workspace/public/pm/c3-report-frame.css +0 -20
- package/workspace/public/pm/c3-report-print.css +0 -20
- package/workspace/public/pm/c3-report-setup.css +0 -67
- package/workspace/public/pm/c3-report-setup.js +0 -298
- package/workspace/public/pm/c3-report-store.js +0 -244
- package/workspace/public/pm/c3-report-structure.css +0 -44
- package/workspace/public/pm/c3-report-structure.js +0 -473
- package/workspace/public/pm/c3-reports.css +0 -68
- package/workspace/public/pm/c3-reports.js +0 -377
- package/workspace/public/pm/c3-roadmap.js +0 -249
- package/workspace/public/pm/c3-scan-api.js +0 -167
- package/workspace/public/pm/c3-scan-next.js +0 -248
- package/workspace/public/pm/c3-scan-setup.js +0 -313
- package/workspace/public/pm/c3-scan-words.js +0 -41
- package/workspace/public/pm/c3-scan.css +0 -74
- package/workspace/public/pm/c3-scan.js +0 -93
- package/workspace/public/pm/c3-session-chat.js +0 -103
- package/workspace/public/pm/c3-session-conv.js +0 -165
- package/workspace/public/pm/c3-session-term.js +0 -216
- package/workspace/public/pm/c3-settings.css +0 -85
- package/workspace/public/pm/c3-settings.js +0 -1045
- package/workspace/public/pm/c3-shell.js +0 -628
- package/workspace/public/pm/c3-signals.js +0 -196
- package/workspace/public/pm/c3-strategy-panels.js +0 -45
- package/workspace/public/pm/c3-swipe.js +0 -230
- package/workspace/public/pm/c3-terminal-data.js +0 -48
- package/workspace/public/pm/c3-terminal-edge.js +0 -91
- package/workspace/public/pm/c3-terminal-icons.js +0 -40
- package/workspace/public/pm/c3-terminal-results.js +0 -141
- package/workspace/public/pm/c3-terminal.js +0 -52
- package/workspace/public/pm/c3-tickets.js +0 -163
- package/workspace/public/pm/c3-timeline.js +0 -201
- package/workspace/public/pm/calendar-views.js +0 -1049
- package/workspace/public/pm/console3-lift.md +0 -220
- package/workspace/public/pm/cozy-home.js +0 -172
- package/workspace/public/pm/cozy-initiative.css +0 -138
- package/workspace/public/pm/cycle-review.js +0 -125
- package/workspace/public/pm/data.js +0 -1577
- package/workspace/public/pm/dest-board.js +0 -444
- package/workspace/public/pm/dest-docs.js +0 -530
- package/workspace/public/pm/dest-initiatives.js +0 -162
- package/workspace/public/pm/dest-mywork.js +0 -307
- package/workspace/public/pm/dest-notes.js +0 -537
- package/workspace/public/pm/dest-people.js +0 -449
- package/workspace/public/pm/dest-reports.js +0 -383
- package/workspace/public/pm/dest-settings.js +0 -601
- package/workspace/public/pm/dest-today.js +0 -267
- package/workspace/public/pm/display-word.js +0 -56
- package/workspace/public/pm/doc-editor.js +0 -473
- package/workspace/public/pm/doc-graph.js +0 -272
- package/workspace/public/pm/doc-health-panel.js +0 -110
- package/workspace/public/pm/doc-rail.js +0 -167
- package/workspace/public/pm/doc-remote.js +0 -180
- package/workspace/public/pm/dock-sessions.js +0 -472
- package/workspace/public/pm/dock.js +0 -216
- package/workspace/public/pm/fixture.js +0 -821
- package/workspace/public/pm/flag-picker.js +0 -104
- package/workspace/public/pm/frame-copy.js +0 -278
- package/workspace/public/pm/freshness-line.js +0 -149
- package/workspace/public/pm/handoff-box.js +0 -82
- package/workspace/public/pm/initiative-list.js +0 -235
- package/workspace/public/pm/initiative-sheet.js +0 -331
- package/workspace/public/pm/initiatives-api.js +0 -95
- package/workspace/public/pm/initiatives-copy.js +0 -287
- package/workspace/public/pm/initiatives-timeline-copy.js +0 -59
- package/workspace/public/pm/initiatives-timeline.js +0 -410
- package/workspace/public/pm/initiatives-ui.js +0 -291
- package/workspace/public/pm/item-sheet.js +0 -268
- package/workspace/public/pm/keep-card.js +0 -204
- package/workspace/public/pm/lifecycle-lens-model.js +0 -246
- package/workspace/public/pm/lifecycle-lens.js +0 -276
- package/workspace/public/pm/lifecycle.js +0 -111
- package/workspace/public/pm/mobile.css +0 -366
- package/workspace/public/pm/mobile.js +0 -581
- package/workspace/public/pm/modes-live.js +0 -453
- package/workspace/public/pm/modes.js +0 -147
- package/workspace/public/pm/my-work-card.js +0 -51
- package/workspace/public/pm/my-work-data.js +0 -36
- package/workspace/public/pm/new-initiative-sheet.js +0 -169
- package/workspace/public/pm/next-step-ui.js +0 -190
- package/workspace/public/pm/outbox-panel.js +0 -125
- package/workspace/public/pm/palette-copy.js +0 -55
- package/workspace/public/pm/palette.js +0 -343
- package/workspace/public/pm/panel-breakdown.js +0 -702
- package/workspace/public/pm/panel-cockpit.js +0 -425
- package/workspace/public/pm/panel-detail.js +0 -1513
- package/workspace/public/pm/panel-initiatives.js +0 -929
- package/workspace/public/pm/panel-newsess.js +0 -709
- package/workspace/public/pm/panel-repos.js +0 -741
- package/workspace/public/pm/panel-tabs.js +0 -1506
- package/workspace/public/pm/panel-trees.js +0 -204
- package/workspace/public/pm/people-link.js +0 -106
- package/workspace/public/pm/phone-deck.js +0 -167
- package/workspace/public/pm/pm-work-view.js +0 -1533
- package/workspace/public/pm/portfolio-report.js +0 -61
- package/workspace/public/pm/premium-acts.js +0 -280
- package/workspace/public/pm/premium-brief.js +0 -111
- package/workspace/public/pm/premium-chat.js +0 -22
- package/workspace/public/pm/premium-doc-sheet.js +0 -312
- package/workspace/public/pm/premium-initiative.js +0 -324
- package/workspace/public/pm/premium-insights.css +0 -228
- package/workspace/public/pm/premium-metric-tiles.js +0 -68
- package/workspace/public/pm/premium-report-brief.js +0 -132
- package/workspace/public/pm/premium-vw-rec.js +0 -67
- package/workspace/public/pm/premium-wide.css +0 -30
- package/workspace/public/pm/print.css +0 -44
- package/workspace/public/pm/provider-cards.js +0 -136
- package/workspace/public/pm/registry.js +0 -203
- package/workspace/public/pm/release-card.js +0 -110
- package/workspace/public/pm/releases-view.js +0 -248
- package/workspace/public/pm/report-families-view.js +0 -505
- package/workspace/public/pm/report-slides.js +0 -438
- package/workspace/public/pm/report-tab.js +0 -33
- package/workspace/public/pm/report-view.js +0 -337
- package/workspace/public/pm/reports-copy.js +0 -134
- package/workspace/public/pm/roadmap.js +0 -294
- package/workspace/public/pm/run-card.js +0 -260
- package/workspace/public/pm/sessions-panel.js +0 -219
- package/workspace/public/pm/sheet-jira.js +0 -353
- package/workspace/public/pm/shell-bell.js +0 -163
- package/workspace/public/pm/shell-model.js +0 -83
- package/workspace/public/pm/shell-phone.js +0 -124
- package/workspace/public/pm/shell-readaloud.js +0 -53
- package/workspace/public/pm/shell-recording.js +0 -274
- package/workspace/public/pm/shell-ticker.js +0 -90
- package/workspace/public/pm/sig-watch.js +0 -41
- package/workspace/public/pm/slide-confirm.js +0 -163
- package/workspace/public/pm/slides-copy.js +0 -52
- package/workspace/public/pm/status-banner.js +0 -95
- package/workspace/public/pm/tab-doc.js +0 -859
- package/workspace/public/pm/tab-gone.js +0 -21
- package/workspace/public/pm/tab-term.js +0 -1210
- package/workspace/public/pm/tab-web.js +0 -90
- package/workspace/public/pm/timeline-copy.js +0 -48
- package/workspace/public/pm/timeline-forecast-view.js +0 -164
- package/workspace/public/pm/today-agenda.js +0 -331
- package/workspace/public/pm/today-cards.js +0 -244
- package/workspace/public/pm/today-copy.js +0 -506
- package/workspace/public/pm/today-day.js +0 -1371
- package/workspace/public/pm/today-goals.js +0 -297
- package/workspace/public/pm/today-jobs.js +0 -84
- package/workspace/public/pm/today-mentions.js +0 -50
- package/workspace/public/pm/topbar.js +0 -202
- package/workspace/public/pm/triage-card.js +0 -60
- package/workspace/public/pm/undo-hold.js +0 -103
- package/workspace/public/pm/view-addrepo.js +0 -208
- package/workspace/public/pm/view-files.js +0 -197
- package/workspace/public/pm/view-livenotes.js +0 -399
- package/workspace/public/pm/view-today.js +0 -13
- package/workspace/public/pm/view-validate.js +0 -171
- package/workspace/public/pm/welcome.js +0 -391
- package/workspace/public/pm/work-place.js +0 -68
- package/workspace/public/pm/xlsx-read.js +0 -117
- package/workspace/public/welcome.html +0 -22
- package/workspace/test-lists/browser-suites-green.json +0 -5
- package/workspace/test-lists/c3-core-docs.json +0 -9
- package/workspace/test-lists/c3-doc-sheet-rich.json +0 -6
- package/workspace/test-lists/c3-doc-sheet-size.json +0 -6
- package/workspace/test-lists/c3-doc-sheet-v2.json +0 -6
- package/workspace/test-lists/c3-ib-items.json +0 -9
- package/workspace/test-lists/c3-ib-more.json +0 -9
- package/workspace/test-lists/c3-ib-triage-backlog.json +0 -9
- package/workspace/test-lists/c3-ini-life.json +0 -9
- package/workspace/test-lists/c3-meeting-board.json +0 -5
- package/workspace/test-lists/c3-meeting-card.json +0 -5
- package/workspace/test-lists/c3-notes-place.json +0 -5
- package/workspace/test-lists/c3-notes-series.json +0 -5
- package/workspace/test-lists/calendar-time-page.json +0 -5
- package/workspace/test-lists/calpop.json +0 -4
- package/workspace/test-lists/console3-briefing.json +0 -9
- package/workspace/test-lists/console3-foundation.json +0 -9
- package/workspace/test-lists/console3-work-page.json +0 -9
- package/workspace/test-lists/premium-brief-parity.json +0 -9
- package/workspace/test-lists/report-design-studio-ui.json +0 -5
- package/workspace/test-lists/report-structure-ui.json +0 -11
- package/workspace/test-lists/report-workspace-ui.json +0 -5
- package/workspace/test-lists/run3-a.json +0 -5
- package/workspace/test-lists/run3-d.json +0 -6
- package/workspace/test-lists/run4-c.json +0 -13
- package/workspace/test-lists/today-goals-jobs-ui.json +0 -5
- package/workspace/test-lists/today-mentions-cards.json +0 -5
- package/workspace/test-lists/workspace-tabs-declutter.json +0 -13
|
@@ -1,1533 +0,0 @@
|
|
|
1
|
-
/* pm/pm-work-view.js — the Work view of My work, built on the console3 mockup's own markup and CSS (initiative
|
|
2
|
-
* planning-flows-and-agent-sessions). The mockup (prototype/pmos-console-handoff/mockups/console3.html) is the UI: the rows
|
|
3
|
-
* (.nrow with .rv, .ki, .nb, .tt, .chips, .xp), the lens bar (.calbar, .seg), the add line (.c3add, .chips2), the case file
|
|
4
|
-
* (.case, .c3jf, .c3steps), the Focus card (.card.sect) and the swipe gesture are the mockup's; the styles are pm/console3.css
|
|
5
|
-
* (see pm/console3-lift.md). This file keeps the real data calls and draws what they return, nothing else.
|
|
6
|
-
*
|
|
7
|
-
* mountPmWork(host, ctx) draws once per host; disposePmWork(host) removes it.
|
|
8
|
-
* Views (initiative console3-work-page, planning/prd/console3-work-page-prd.md): Inbox, Today, Upcoming, Waiting, Someday and Review.
|
|
9
|
-
* The SERVER places every item and answers `work`, `review`, `focus` and `counts`; this file draws them and never copies an item from
|
|
10
|
-
* one view to another. The right column of every view is Focus (up to three jobs, each with the reason: Accept, Edit, Not today; a row opens the
|
|
11
|
-
* job's sheet) (initiative console3-work-parity). Today is Overdue, Due today and Flagged. Upcoming is Next 7 days by day, then a Later card. Review
|
|
12
|
-
* also carries the agent's drafts section that Briefing used to show. Review is a weekly pass, one item at a time (Keep, Change, Drop). An item done outside PMOS
|
|
13
|
-
* (`kind: offline`) shows the person and offers Done with an optional outcome, Not yet and Drop, and "Looks done?" with Confirm when
|
|
14
|
-
* it carries `evidence`; PMOS never closes it by itself.
|
|
15
|
-
* Routes (lib/routes-pm-items.js). Every write is a page press through pmPost:
|
|
16
|
-
* GET /api/pm-items POST /api/pm-items/{add,edit,remove,undo,done,reopen,unpark,flag,defer,someday,waiting,notyet,keep,steps/add,steps/who,steps/plan}
|
|
17
|
-
* POST /api/pm-items/focus/{accept,dismiss,clear} POST /api/pm-jobs/{add,edit,delete}
|
|
18
|
-
* A row opens its CASE FILE in place (c3-expand.js + c3-case.js: the job sentence, evidence, options with a recommendation, a slide to
|
|
19
|
-
* confirm), then the shared actions (Flag, Not before, Someday, Waiting, Drop); the editable fields sit inside it behind "Edit details".
|
|
20
|
-
* A row swipes (c3-swipe.js) and takes keys: right = the right-hand action of its view (done, in Today, ...), left = the left-hand one
|
|
21
|
-
* (tomorrow, Someday, ...); j and k move, and the arrows do the swipes. Every action offers Undo through the reverse route (reopen,
|
|
22
|
-
* unpark, flag back, defer back, waiting back, undo). Anything that would send something to a person is an outward option: its slide is
|
|
23
|
-
* drawn disabled ("no channel connected"); nothing is sent.
|
|
24
|
-
* In demo mode (/c3.html?demo=1, window.__c3demo) the answers of the writes are laid over the fixtures in memory (`applyOv`) and placed
|
|
25
|
-
* with work-place.js, the server's rule; the agent run of a row with a suggested move is a mock that only walks the steps and shows a
|
|
26
|
-
* labelled draft. ctx.go(tab) opens another tab. The microphone is drawn disabled.
|
|
27
|
-
*
|
|
28
|
-
* The helpers c3ic, c3ring, ensureC3Css and c3Phone are shared with briefing-deck.js and calendar-views.js. */
|
|
29
|
-
import { el } from './dom.js';
|
|
30
|
-
import { button } from './primitives.js';
|
|
31
|
-
import { pmGet, pmPost } from './http.js';
|
|
32
|
-
import { renderCase } from './c3-case.js';
|
|
33
|
-
import { parseMd, toDom } from './cozy-md.js';
|
|
34
|
-
import { makeXp, attachExpand } from './c3-expand.js';
|
|
35
|
-
import { attachSwipe } from './c3-swipe.js';
|
|
36
|
-
import { toast } from './c3-toast.js';
|
|
37
|
-
import { openSheet } from './c3-sheet.js';
|
|
38
|
-
import { c3btn } from './page-agent.js';
|
|
39
|
-
import { onBriefing, loadBriefing } from './shell-ticker.js';
|
|
40
|
-
import { reviewSection } from './c3-brief.js';
|
|
41
|
-
import { VIEWS, REVIEW_DAYS, workPlace, arrives, buildWork, addIso, daysBetween, untouchedDays } from './work-place.js';
|
|
42
|
-
|
|
43
|
-
/* ── shared with the Briefing and Calendar views: the stylesheet, the icon sprite, the ring, the phone class ───────── */
|
|
44
|
-
|
|
45
|
-
const SVG_NS = 'http://www.w3.org/2000/svg';
|
|
46
|
-
/* The mockup's icon sprite (console3.html lines 970 to 1026, ids renamed c3i-*, plus the c3 layer's edit and trash). */
|
|
47
|
-
const SPRITE = '<symbol id="c3i-sun" viewBox="0 0 24 24"><circle cx="12" cy="12" r="4"/><path d="M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"/></symbol><symbol id="c3i-star" viewBox="0 0 24 24"><path d="M12 3l2.6 5.6 6.1.7-4.5 4.2 1.2 6L12 16.5 6.6 19.5l1.2-6L3.3 9.3l6.1-.7z"/></symbol><symbol id="c3i-moon" viewBox="0 0 24 24"><path d="M20 14a8 8 0 11-10-10 6 6 0 0010 10z"/></symbol><symbol id="c3i-cal" viewBox="0 0 24 24"><rect x="4" y="5" width="16" height="15" rx="2"/><path d="M4 10h16M8 3v4M16 3v4"/></symbol><symbol id="c3i-inbox" viewBox="0 0 24 24"><path d="M4 13l2-8h12l2 8M4 13v6h16v-6M4 13h5l1 2h4l1-2h5"/></symbol><symbol id="c3i-todo" viewBox="0 0 24 24"><rect x="4" y="4" width="16" height="16" rx="3"/><path d="M8 12l3 3 5-6"/></symbol><symbol id="c3i-init" viewBox="0 0 24 24"><path d="M12 3l9 5-9 5-9-5 9-5zM3 13l9 5 9-5"/></symbol><symbol id="c3i-report" viewBox="0 0 24 24"><path d="M5 20V10M12 20V4M19 20v-7"/></symbol><symbol id="c3i-notes" viewBox="0 0 24 24"><path d="M6 3h9l4 4v14H6zM14 3v5h5M9 13h7M9 17h5"/></symbol><symbol id="c3i-user" viewBox="0 0 24 24"><circle cx="12" cy="8" r="4"/><path d="M4 21c0-4 4-6 8-6s8 2 8 6"/></symbol><symbol id="c3i-doc" viewBox="0 0 24 24"><path d="M6 3h9l4 4v14H6zM14 3v5h5"/></symbol><symbol id="c3i-sheet" viewBox="0 0 24 24"><rect x="4" y="4" width="16" height="16" rx="2"/><path d="M4 10h16M4 15h16M10 4v16"/></symbol><symbol id="c3i-img" viewBox="0 0 24 24"><rect x="3" y="4" width="18" height="16" rx="2"/><circle cx="9" cy="10" r="2"/><path d="M21 16l-5-5-9 9"/></symbol><symbol id="c3i-pdf" viewBox="0 0 24 24"><path d="M6 3h9l4 4v14H6zM14 3v5h5M9 15h6M9 18h4"/></symbol><symbol id="c3i-term" viewBox="0 0 24 24"><rect x="3" y="4" width="18" height="16" rx="2"/><path d="M7 9l3 3-3 3M13 15h4"/></symbol><symbol id="c3i-branch" viewBox="0 0 24 24"><circle cx="6" cy="5" r="2"/><circle cx="6" cy="19" r="2"/><circle cx="18" cy="9" r="2"/><path d="M6 7v10M18 11c0 4-6 3-12 6"/></symbol><symbol id="c3i-repo" viewBox="0 0 24 24"><path d="M5 4h11a3 3 0 013 3v13H8a3 3 0 01-3-3zM5 17a3 3 0 013-3h11"/></symbol><symbol id="c3i-flag" viewBox="0 0 24 24"><path d="M6 21V4M6 5h11l-2 4 2 4H6"/></symbol><symbol id="c3i-clock" viewBox="0 0 24 24"><circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/></symbol><symbol id="c3i-alert" viewBox="0 0 24 24"><path d="M12 3l10 18H2zM12 10v5M12 18v.5"/></symbol><symbol id="c3i-check" viewBox="0 0 24 24"><path d="M5 12l5 5 9-10"/></symbol><symbol id="c3i-x" viewBox="0 0 24 24"><path d="M6 6l12 12M18 6L6 18"/></symbol><symbol id="c3i-eye" viewBox="0 0 24 24"><path d="M2 12s4-7 10-7 10 7 10 7-4 7-10 7S2 12 2 12z"/><circle cx="12" cy="12" r="3"/></symbol><symbol id="c3i-undo" viewBox="0 0 24 24"><path d="M4 12a8 8 0 108-8M4 4v6h6"/></symbol><symbol id="c3i-out" viewBox="0 0 24 24"><path d="M5 12h14M13 6l6 6-6 6"/></symbol><symbol id="c3i-shield" viewBox="0 0 24 24"><path d="M12 3l8 3v6c0 5-3.5 8-8 9-4.5-1-8-4-8-9V6z"/></symbol><symbol id="c3i-mic" viewBox="0 0 24 24"><rect x="9" y="3" width="6" height="11" rx="3"/><path d="M5 11a7 7 0 0014 0M12 18v3"/></symbol><symbol id="c3i-clip" viewBox="0 0 24 24"><rect x="6" y="4" width="12" height="17" rx="2"/><path d="M9 4h6v3H9zM9 12h6M9 16h4"/></symbol><symbol id="c3i-search" viewBox="0 0 24 24"><circle cx="11" cy="11" r="7"/><path d="M21 21l-5-5"/></symbol><symbol id="c3i-phone" viewBox="0 0 24 24"><rect x="7" y="2" width="10" height="20" rx="2"/><path d="M11 18h2"/></symbol><symbol id="c3i-cloud" viewBox="0 0 24 24"><path d="M7 18a4 4 0 010-8 5 5 0 019.6-1A4.5 4.5 0 0117 18z"/></symbol><symbol id="c3i-bolt" viewBox="0 0 24 24"><path d="M13 2L4 14h7l-1 8 9-12h-7z"/></symbol><symbol id="c3i-plus" viewBox="0 0 24 24"><path d="M12 5v14M5 12h14"/></symbol><symbol id="c3i-scale" viewBox="0 0 24 24"><path d="M12 3v18M5 7h14M5 7l-3 7a3 3 0 006 0zM19 7l-3 7a3 3 0 006 0z"/></symbol><symbol id="c3i-reply" viewBox="0 0 24 24"><path d="M9 7L4 12l5 5M4 12h10a6 6 0 016 6"/></symbol><symbol id="c3i-info" viewBox="0 0 24 24"><circle cx="12" cy="12" r="9"/><path d="M12 11v6M12 7.5v.5"/></symbol><symbol id="c3i-wait" viewBox="0 0 24 24"><path d="M7 3h10M7 21h10M8 3c0 5 8 5 8 9s-8 4-8 9"/></symbol><symbol id="c3i-up" viewBox="0 0 24 24"><path d="M7 11v9H4v-9zM7 11l4-8c2 0 3 1 3 3v3h5a2 2 0 012 2l-1 6a2 2 0 01-2 2H7"/></symbol><symbol id="c3i-cols" viewBox="0 0 24 24"><rect x="3" y="4" width="18" height="16" rx="2"/><path d="M9 4v16M15 4v16"/></symbol><symbol id="c3i-fold" viewBox="0 0 24 24"><rect x="3" y="4" width="18" height="16" rx="2"/><path d="M15 4v16"/></symbol><symbol id="c3i-spark" viewBox="0 0 24 24"><path d="M12 3l2 5 5 2-5 2-2 5-2-5-5-2 5-2z"/></symbol><symbol id="c3i-target" viewBox="0 0 24 24"><circle cx="12" cy="12" r="9"/><circle cx="12" cy="12" r="5"/><circle cx="12" cy="12" r="1"/></symbol><symbol id="c3i-filter" viewBox="0 0 24 24"><path d="M3 5h18l-7 8v6l-4-2v-4z"/></symbol><symbol id="c3i-mail" viewBox="0 0 24 24"><rect x="3" y="5" width="18" height="14" rx="2"/><path d="M3 7l9 6 9-6"/></symbol><symbol id="c3i-lock" viewBox="0 0 24 24"><rect x="5" y="11" width="14" height="10" rx="2"/><path d="M8 11V8a4 4 0 018 0v3"/></symbol><symbol id="c3i-play" viewBox="0 0 24 24"><path d="M7 4l13 8-13 8z"/></symbol><symbol id="c3i-stop" viewBox="0 0 24 24"><rect x="6" y="6" width="12" height="12" rx="1"/></symbol><symbol id="i-pause" viewBox="0 0 24 24"><path d="M8 5v14M16 5v14"/></symbol><symbol id="c3i-prev" viewBox="0 0 24 24"><path d="M15 6l-6 6 6 6"/></symbol><symbol id="c3i-next" viewBox="0 0 24 24"><path d="M9 6l6 6-6 6"/></symbol><symbol id="c3i-tree" viewBox="0 0 24 24"><path d="M5 4h7v4H5zM13 10h7v4h-7zM13 17h7v4h-7zM8 8v11h5M8 12h5"/></symbol><symbol id="c3i-org" viewBox="0 0 24 24"><path d="M9 3h6v5H9zM3 16h6v5H3zM15 16h6v5h-6zM12 8v4M6 16v-4h12v4"/></symbol><symbol id="c3i-drop" viewBox="0 0 24 24"><path d="M12 3c4 5 6 8 6 11a6 6 0 01-12 0c0-3 2-6 6-11z"/></symbol><symbol id="c3i-more" viewBox="0 0 24 24"><path d="M5 12h.01M12 12h.01M19 12h.01" stroke-width="3"/></symbol><symbol id="c3i-zin" viewBox="0 0 24 24"><circle cx="11" cy="11" r="7"/><path d="M21 21l-5-5M8 11h6M11 8v6"/></symbol><symbol id="c3i-zout" viewBox="0 0 24 24"><circle cx="11" cy="11" r="7"/><path d="M21 21l-5-5M8 11h6"/></symbol><symbol id="c3i-bell" viewBox="0 0 24 24"><path d="M6 17v-6a6 6 0 0112 0v6l2 2H4zM10 21h4"/></symbol><symbol id="c3i-vol" viewBox="0 0 24 24"><path d="M4 9v6h4l5 4V5L8 9zM16.5 8.5a5 5 0 010 7M19 6a8.5 8.5 0 010 12"/></symbol><symbol id="c3i-menu" viewBox="0 0 24 24"><path d="M4 7h16M4 12h16M4 17h16"/></symbol><symbol id="c3i-edit" viewBox="0 0 24 24"><path d="M4 20h4L19 9l-4-4L4 16v4zM13.5 6.5l4 4"/></symbol><symbol id="c3i-trash" viewBox="0 0 24 24"><path d="M4 7h16M9 7V4h6v3M6 7l1 13h10l1-13"/></symbol><symbol id="c3i-bold" viewBox="0 0 24 24"><path d="M7 4h6a4 4 0 010 8H7zM7 12h7a4 4 0 010 8H7z"/></symbol><symbol id="c3i-italic" viewBox="0 0 24 24"><path d="M10 4h8M6 20h8M14 4l-4 16"/></symbol><symbol id="c3i-code" viewBox="0 0 24 24"><path d="M8 7l-5 5 5 5M16 7l5 5-5 5"/></symbol><symbol id="c3i-link" viewBox="0 0 24 24"><path d="M10 14a4 4 0 006 0l3-3a4 4 0 00-6-6l-1 1M14 10a4 4 0 00-6 0l-3 3a4 4 0 006 6l1-1"/></symbol><symbol id="c3i-ul" viewBox="0 0 24 24"><path d="M9 6h11M9 12h11M9 18h11M4.5 6h.01M4.5 12h.01M4.5 18h.01" /></symbol><symbol id="c3i-ol" viewBox="0 0 24 24"><path d="M10 6h10M10 12h10M10 18h10M4 4h1v4M4 8h2M4 14.5c0-1 2-1 2 0s-2 2-2 3.5h2"/></symbol><symbol id="c3i-task" viewBox="0 0 24 24"><rect x="3" y="4" width="6" height="6" rx="1"/><path d="M4.5 7l1 1 2-2M12 7h9M3 14h6v6H3zM12 17h9"/></symbol><symbol id="c3i-quote" viewBox="0 0 24 24"><path d="M4 6h16M8 12h12M8 18h12M4 11v8"/></symbol><symbol id="c3i-table" viewBox="0 0 24 24"><rect x="3" y="4" width="18" height="16" rx="2"/><path d="M3 10h18M3 15h18M10 4v16"/></symbol><symbol id="c3i-hr" viewBox="0 0 24 24"><path d="M3 12h18M7 6h10M7 18h10"/></symbol><symbol id="c3i-redo" viewBox="0 0 24 24"><path d="M20 12a8 8 0 11-8-8M20 4v6h-6"/></symbol><symbol id="c3i-git" viewBox="0 0 24 24"><circle cx="12" cy="12" r="3"/><path d="M3 12h6M15 12h6"/></symbol><symbol id="c3i-md" viewBox="0 0 24 24"><rect x="2" y="5" width="20" height="14" rx="2"/><path d="M6 15V9l3 3 3-3v6M16 9v6M14 13l2 2 2-2"/></symbol><symbol id="c3i-copy" viewBox="0 0 24 24"><rect x="8" y="8" width="12" height="12" rx="2"/><path d="M16 8V5a1 1 0 00-1-1H5a1 1 0 00-1 1v10a1 1 0 001 1h3"/></symbol>';
|
|
48
|
-
|
|
49
|
-
/** Link console3.css once, from this module's own folder (the same way primitives.js links components.css). */
|
|
50
|
-
export function ensureC3Css() {
|
|
51
|
-
if (typeof document === 'undefined' || document.querySelector('link[data-c3]')) return;
|
|
52
|
-
const l = document.createElement('link');
|
|
53
|
-
l.rel = 'stylesheet';
|
|
54
|
-
l.href = new URL('./console3.css', import.meta.url).href;
|
|
55
|
-
l.setAttribute('data-c3', '');
|
|
56
|
-
document.head.appendChild(l);
|
|
57
|
-
if (!document.getElementById('c3-sprite') && document.body) {
|
|
58
|
-
const d = document.createElement('div');
|
|
59
|
-
d.id = 'c3-sprite';
|
|
60
|
-
d.setAttribute('aria-hidden', 'true');
|
|
61
|
-
d.style.cssText = 'position:absolute;width:0;height:0;overflow:hidden';
|
|
62
|
-
d.innerHTML = '<svg width="0" height="0" aria-hidden="true"><defs>' + SPRITE + '</defs></svg>';
|
|
63
|
-
document.body.appendChild(d);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/** The mockup's ic(): <svg class="ic sm"><use href="#c3i-name"/></svg>. */
|
|
68
|
-
export function c3ic(name, cls) {
|
|
69
|
-
const s = document.createElementNS(SVG_NS, 'svg');
|
|
70
|
-
s.setAttribute('class', 'ic' + (cls ? ' ' + cls : ''));
|
|
71
|
-
s.setAttribute('aria-hidden', 'true');
|
|
72
|
-
const u = document.createElementNS(SVG_NS, 'use');
|
|
73
|
-
u.setAttribute('href', '#c3i-' + name);
|
|
74
|
-
s.appendChild(u);
|
|
75
|
-
return s;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/** The mockup's ring(done, total, size), built as DOM. A label replaces the "done/total" text in the middle. */
|
|
79
|
-
export function c3ring(done, total, size, label) {
|
|
80
|
-
const long = String(label || done + '/' + total).length > 5; // "322/322" does not fit a 44px ring: grow it and use the smaller size
|
|
81
|
-
if (long) size = Math.max(size, 64);
|
|
82
|
-
const r = size / 2 - 5; const cc = 2 * Math.PI * r; const p = total ? done / total : 0; const c = size / 2;
|
|
83
|
-
const s = document.createElementNS(SVG_NS, 'svg');
|
|
84
|
-
const set = (n, o) => { for (const k in o) n.setAttribute(k, o[k]); return n; };
|
|
85
|
-
set(s, { width: size, height: size, viewBox: `0 0 ${size} ${size}`, role: 'img', 'aria-label': label ? String(label) : `${done} of ${total}` });
|
|
86
|
-
s.appendChild(set(document.createElementNS(SVG_NS, 'circle'), { cx: c, cy: c, r, fill: 'none', stroke: 'var(--muted)', 'stroke-width': 6 }));
|
|
87
|
-
s.appendChild(set(document.createElementNS(SVG_NS, 'circle'), { cx: c, cy: c, r, fill: 'none', class: 'rg', stroke: 'var(--acc)', 'stroke-width': 6, 'stroke-linecap': 'round', 'stroke-dasharray': `${cc * p} ${cc}`, transform: `rotate(-90 ${c} ${c})` }));
|
|
88
|
-
const t = set(document.createElementNS(SVG_NS, 'text'), { x: c, y: c + 4, 'text-anchor': 'middle', class: 't', style: 'font-size:' + (long ? '10px' : 'var(--fs-2)') });
|
|
89
|
-
t.textContent = label ? String(label) : `${done}/${total}`;
|
|
90
|
-
s.appendChild(t);
|
|
91
|
-
return s;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/** The mockup's `.ph` phone class, driven by one media query so the view and a real phone behave the same. Returns the stop function. */
|
|
95
|
-
export function c3Phone(root) {
|
|
96
|
-
if (typeof matchMedia !== 'function') return () => {};
|
|
97
|
-
const q = matchMedia('(max-width:640px)');
|
|
98
|
-
const on = () => root.classList.toggle('ph', q.matches);
|
|
99
|
-
on();
|
|
100
|
-
if (q.addEventListener) q.addEventListener('change', on); else q.addListener(on);
|
|
101
|
-
return () => { if (q.removeEventListener) q.removeEventListener('change', on); else q.removeListener(on); };
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/** The mockup's ib(): an icon button. */
|
|
105
|
-
export function c3ib(label, icon, attrs, cls) {
|
|
106
|
-
return el('button', { type: 'button', class: 'ib ' + (cls || ''), title: label, 'aria-label': label, ...(attrs || {}) }, c3ic(icon));
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/* ── copy and constants ──────────────────────────────────────────────────────────────────────────────────────────── */
|
|
110
|
-
|
|
111
|
-
const API = '/api/pm-items';
|
|
112
|
-
const JOBS = '/api/pm-jobs';
|
|
113
|
-
/* The seven views (initiative console3-work-page, PRD R1): five places an open item can be, the weekly Review pass, and Done:
|
|
114
|
-
* what the PM finished in the last 30 days (c3-work-agent amendment 18). */
|
|
115
|
-
const LENSES = [['inbox', 'Inbox'], ['today', 'Today'], ['upcoming', 'Upcoming'], ['waiting', 'Waiting'], ['someday', 'Someday'], ['review', 'Review'], ['done', 'Done']];
|
|
116
|
-
const WLI = { inbox: 'inbox', today: 'sun', upcoming: 'cal', waiting: 'wait', someday: 'moon', review: 'check', done: 'todo' };
|
|
117
|
-
const DONE_DAYS = 30;
|
|
118
|
-
const WHO = ['you', 'agent-drafts', 'agent-does'];
|
|
119
|
-
const OUTWARD = /\b(send|sends|sending|email|emails|message|messages|tell|post|reply to)\b/i; // mirrors lib/item-steps.js
|
|
120
|
-
const RESOLVES_TIP = 'Your work. The team task is separate: close it in its initiative.';
|
|
121
|
-
|
|
122
|
-
export const COPY = Object.freeze({
|
|
123
|
-
addPlaceholder: 'Add work: type or speak',
|
|
124
|
-
addLabel: 'Add work', addBtn: 'Add', hint: 'Try: Send Dewi the new date by Fri',
|
|
125
|
-
addsTo: 'adds to', noJob: 'no job yet', waitingOn: (w) => 'waiting on ' + w,
|
|
126
|
-
empty: 'Nothing here.', noJobGroup: 'No job yet', jobs: 'Jobs to be done', noJobs: 'No jobs yet.',
|
|
127
|
-
addJob: 'Add a job', addJobPlaceholder: 'when I plan a release, I want honest dates, so Dana can trust them',
|
|
128
|
-
groupJob: 'Group by job to be done', groupTime: 'Group by time', loading: 'Reading…',
|
|
129
|
-
micOff: 'Speak is off on this line: on-device dictation runs in Notes, in the classic app (/classic.html). Type the item here.',
|
|
130
|
-
jobsNote: 'The count is every item in the job, across all views. Tap a job to edit or delete it.',
|
|
131
|
-
legend: ['open', 'done'], readError: 'Your items could not be read.', saveError: 'Nothing was saved.',
|
|
132
|
-
removed: 'Removed.', undo: 'Undo', restored: 'Restored.', tooLate: 'Too late to undo.', drop: 'Drop',
|
|
133
|
-
reassigned: (n) => (n === 1 ? '1 item now has no job.' : `${n} items now have no job.`),
|
|
134
|
-
progress: (d, t) => `${d} of ${t} done`,
|
|
135
|
-
jobLine: (j) => `When ${j.when}, I want ${j.want}, so ${j.so}.`,
|
|
136
|
-
/* The header of each view (the mockup's INTRO): a bold line and a dim line. */
|
|
137
|
-
lens: {
|
|
138
|
-
inbox: 'Decide when or whether', today: 'Overdue, due today and flagged', upcoming: 'The next 7 days, then anything later',
|
|
139
|
-
waiting: 'Things you handed to someone', someday: 'Parked on purpose', review: 'A weekly pass over items without a date',
|
|
140
|
-
done: 'What you finished',
|
|
141
|
-
},
|
|
142
|
-
lensSub: {
|
|
143
|
-
inbox: 'Nothing here has a date. Tap Decide to give each item a day, park it or drop it.',
|
|
144
|
-
today: 'Focus says which jobs matter most today.',
|
|
145
|
-
upcoming: 'A "not before" date keeps an item out of Today until it arrives.',
|
|
146
|
-
waiting: 'You expect these back. Nudge when one goes quiet.',
|
|
147
|
-
someday: 'Nothing here asks for attention until the weekly Review.',
|
|
148
|
-
review: 'Items in Inbox, Waiting or Someday that nobody touched for 7 days, most stale first. One at a time: keep it, change it, or drop it.',
|
|
149
|
-
done: 'The last 30 days, newest first, with the outcome you wrote. Reopen puts an item back where it was.',
|
|
150
|
-
},
|
|
151
|
-
sect: { inbox: 'Inbox', waiting: 'Waiting', someday: 'Someday', overdue: 'Overdue', dueToday: 'Due today', flagged: 'Flagged', next7: 'Next 7 days', later: 'Later' },
|
|
152
|
-
decisions: (n) => ` ${n} decision${n === 1 ? '' : 's'} wait${n === 1 ? 's' : ''} in Briefing, Needs you.`, openBriefing: 'Open Briefing',
|
|
153
|
-
inboxNote: 'New asks for initiatives are triaged in', initiatives: 'Initiatives', inboxNoteEnd: '. This inbox is only for your own work.',
|
|
154
|
-
clear: 'Clear', beyond: 'beyond 7 days', nothingLater: 'Nothing beyond 7 days.', tomorrowHead: 'Tomorrow',
|
|
155
|
-
decide: 'Decide', nudge: 'Nudge', doneBtn: 'Done',
|
|
156
|
-
nudged: (w) => `Nudge to ${w} drafted. No channel is connected, so nothing is sent.`,
|
|
157
|
-
emptyView: {
|
|
158
|
-
inbox: 'Inbox is empty. Capture anything that crosses your mind.', today: 'Nothing due, overdue or flagged. Pick from Upcoming when you are ready.',
|
|
159
|
-
upcoming: 'Nothing dated in the days ahead.', waiting: 'Nobody owes you anything right now.', someday: 'Nothing parked.',
|
|
160
|
-
done: 'Nothing done in the last 30 days. Items you mark done land here.',
|
|
161
|
-
},
|
|
162
|
-
/* Done (c3-work-agent amendment 18) */
|
|
163
|
-
doneSum: (w, m) => `${w} done in the last 7 days, ${m} in 30 days. Older items stay in their job's sheet.`,
|
|
164
|
-
doneSect: { today: 'Today', yday: 'Yesterday', week: 'Earlier this week', older: 'Earlier, last 30 days' }, doneLegend: 'Reopen puts it back',
|
|
165
|
-
doneAt: (t) => 'Done ' + t, reopen: 'Reopen', backTo: (v) => 'Back to ' + v, reopened: (v) => `Reopened. It is back in ${v}.`,
|
|
166
|
-
how: { you: 'You marked it done', agent: 'Closed from the agent draft', posted: 'Agent posted it', step: 'Agent did the step you approved', confirmed: 'You confirmed it' },
|
|
167
|
-
done: 'Done', doneToast: 'Marked done.', steps: 'Steps', noSteps: 'No steps yet.', addStep: 'Add a step',
|
|
168
|
-
who: { you: 'You', 'agent-drafts': 'Agent drafts', 'agent-does': 'Agent does' },
|
|
169
|
-
whoOutward: 'Sends to a person: the agent drafts, you slide to send.', options: 'Options', plan: 'Plan the steps',
|
|
170
|
-
/* Focus (PRD R4; console3-work-parity R2) */
|
|
171
|
-
focus: 'Focus: jobs to be done', focusNone: 'No focus for today. Everything below still counts.',
|
|
172
|
-
focusPinned: 'Focus today', accept: 'Accept', editTitle: 'Edit title', edit: 'Edit', notToday: 'Not today', unpin: 'Unpin', save: 'Save', cancel: 'Cancel',
|
|
173
|
-
why: (w) => 'Why: ' + w, focusAccepted: 'Added to Focus today', focusDismissed: 'Not today. PMOS will suggest it again tomorrow.', focusCleared: 'Unpinned.',
|
|
174
|
-
markedNot: (n) => `${n} marked not today.`, bringBack2: 'Bring back', broughtBack: 'Brought back.', newJob: 'New job', jobSheet: 'Job to be done',
|
|
175
|
-
/* offline work and the shared actions (PRD R6) */
|
|
176
|
-
offline: 'outside PMOS', offlineNote: (p) => 'Happens outside PMOS' + (p ? ', with ' + p : '') + '. Tell PMOS how it went.',
|
|
177
|
-
outcome: 'What came out of it (optional)', notYet: 'Not yet:', laterToday: 'Later today', tomorrow: 'Tomorrow', nextWeek: 'Next week',
|
|
178
|
-
looksDone: 'Looks done?', confirm: 'Confirm done', flag: 'Flag', unflag: 'Unflag', notBefore: 'Not before', someday: 'Someday', bringBack: 'Bring back',
|
|
179
|
-
waitingField: 'Waiting on', waitingWho: 'Who?', stopWaiting: 'Stop waiting', flagged: 'Flagged',
|
|
180
|
-
notBeforeChip: (d) => 'Not before ' + d, advances: (t) => 'Advances team task ' + t, suggested: 'Suggested', agentSuggests: (t) => 'Agent can: ' + t, moved: (n) => `Moved ${n}×`,
|
|
181
|
-
overdue: (n) => (n === 1 ? 'Overdue since yesterday' : `${n} days overdue`), dueToday: 'Due today', dueOn: (d) => 'Due ' + d,
|
|
182
|
-
waitingSince: (w, since, ago) => `Waiting for ${w}` + (since ? ` since ${since}` : '') + (ago ? ` (${ago})` : ''), repeats: (r) => 'Repeats ' + String(r).toLowerCase(),
|
|
183
|
-
/* Review (PRD R7) */
|
|
184
|
-
reviewHead: 'Weekly review', keep: 'Keep', change: 'Change', next: 'Done changing, next', reviewDone: 'Review done',
|
|
185
|
-
reviewDoneText: (n) => `You looked at ${n} item${n === 1 ? '' : 's'}. Anything you changed or dropped has moved to its new view.`,
|
|
186
|
-
reviewNone: 'Nothing waits for review. Every item was touched in the last 7 days.', again: 'Start another pass',
|
|
187
|
-
untouched: (n) => `Untouched for ${n} days`, livesIn: (v) => 'Lives in ' + v, upNext: 'Up next: ',
|
|
188
|
-
kept: 'Kept. It comes back if nobody touches it for another week.',
|
|
189
|
-
});
|
|
190
|
-
const insts = new WeakMap();
|
|
191
|
-
|
|
192
|
-
/* The toast is the shared one (c3-toast.js): the text and, for an action that can be taken back, an Undo button. One at a time. */
|
|
193
|
-
const say = toast;
|
|
194
|
-
|
|
195
|
-
/* ── the demo overlay ────────────────────────────────────────────────────────────────────────────────────────────── *
|
|
196
|
-
* In /c3.html?demo=1 every write is answered { ok: true } and the fixtures never change, so the page keeps what the PM did in
|
|
197
|
-
* memory (`inst.ov`) and lays it over each read, then places the items with the server's rule (work-place.js). Real mode has no
|
|
198
|
-
* overlay: the server places every item and every press re-reads. */
|
|
199
|
-
const DEMO = () => typeof window !== 'undefined' && !!window.__c3demo;
|
|
200
|
-
const newOv = () => ({ done: new Set(), gone: new Set(), edits: new Map(), added: [], steps: new Map(), who: new Map(), focus: new Map(), jobsAdded: [], jobEdits: new Map(), jobsGone: new Map(), seq: 0 });
|
|
201
|
-
|
|
202
|
-
function applyOv(base, ov) {
|
|
203
|
-
const d = JSON.parse(JSON.stringify(base));
|
|
204
|
-
const jobOfItem = {};
|
|
205
|
-
const wasDone = new Set((d.items || []).filter((i) => i.done).map((i) => i.id));
|
|
206
|
-
const items = [...ov.added.slice().reverse(), ...(d.items || [])].filter((i) => !ov.gone.has(i.id)).map((i) => {
|
|
207
|
-
const e = ov.edits.get(i.id) || {};
|
|
208
|
-
const m = { ...i, ...e };
|
|
209
|
-
m.done = e.done !== undefined ? !!e.done : !!(i.done || ov.done.has(i.id)); // a reopen (done: false) also reopens a fixture's done item
|
|
210
|
-
m.steps = [...(i.steps || []), ...(ov.steps.get(i.id) || [])].map((s) => (ov.who.has(s.id) ? { ...s, who: ov.who.get(s.id) } : s));
|
|
211
|
-
jobOfItem[m.id] = m.job;
|
|
212
|
-
return m;
|
|
213
|
-
});
|
|
214
|
-
const placed = buildWork(items, d.today, d.review_days || REVIEW_DAYS);
|
|
215
|
-
d.items = items; d.work = placed.work; d.review = placed.review; d.counts = placed.counts;
|
|
216
|
-
/* Focus: an accept pins, a dismiss hides for the day, a clear undoes either; a suggestion whose items are all closed goes */
|
|
217
|
-
const F = d.focus || { suggestions: [], accepted: [] };
|
|
218
|
-
const open = new Set(items.filter((i) => !i.done).map((i) => i.id));
|
|
219
|
-
const live = (f) => !(f.item_ids || []).length || f.item_ids.some((id) => open.has(id));
|
|
220
|
-
const st = (k) => ov.focus.get(k);
|
|
221
|
-
d.focus = {
|
|
222
|
-
accepted: [...(F.accepted || []).filter((a) => !st(a.key)), ...[...ov.focus.values()].filter((x) => x.state === 'acc').map((x) => x.f)],
|
|
223
|
-
suggestions: (F.suggestions || []).filter((s) => (!st(s.key) || st(s.key).state === 'clear') && live(s)).slice(0, 3),
|
|
224
|
-
dismissed: [...new Set([...(F.dismissed || []), ...[...ov.focus.entries()].filter(([, x]) => x.state === 'no').map(([k]) => k)])].filter((k) => !st(k) || st(k).state === 'no'),
|
|
225
|
-
};
|
|
226
|
-
const jobs = [...(d.jobs || []), ...ov.jobsAdded].filter((j) => !ov.jobsGone.has(j.id)).map((j) => ({ ...j, ...(ov.jobEdits.get(j.id) || {}) }));
|
|
227
|
-
jobs.forEach((j) => {
|
|
228
|
-
j.done = (j.done || 0) + [...ov.done].filter((id) => !wasDone.has(id) && jobOfItem[id] === j.id).length;
|
|
229
|
-
j.total = (j.total || 0) + ov.added.filter((a) => a.job === j.id).length;
|
|
230
|
-
});
|
|
231
|
-
d.jobs = jobs;
|
|
232
|
-
return d;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
/** Record in the overlay what a demo press would have changed. `body` and `r` are the press and its answer. */
|
|
236
|
-
function applyLocal(inst, path, body, r) {
|
|
237
|
-
const ov = inst.ov; const id = body && body.id;
|
|
238
|
-
const today = (inst.base && inst.base.today) || iso(new Date());
|
|
239
|
-
const cur = id && ((inst.data && inst.data.items) || []).find((i) => i.id === id);
|
|
240
|
-
const now = new Date().toISOString();
|
|
241
|
-
const edit = (f) => ov.edits.set(id, { ...(ov.edits.get(id) || {}), ...(f || {}), touched_at: now }); // the server stamps touched_at on every event
|
|
242
|
-
switch (path.replace(API, '').replace(JOBS, '/job')) {
|
|
243
|
-
case '/done': ov.done.add(id); edit({ done: true, done_at: new Date(today + 'T' + new Date().toTimeString().slice(0, 8)).toISOString(), done_how: body.how || 'you', ...(body.outcome ? { outcome: body.outcome } : {}) }); break; // done_at: now, on the fixture's day
|
|
244
|
-
case '/reopen': ov.done.delete(id); edit({ done: false, done_at: null, done_how: null }); break;
|
|
245
|
-
case '/park': case '/someday': edit({ parked: true }); break;
|
|
246
|
-
case '/unpark': edit({ parked: false }); break;
|
|
247
|
-
case '/edit': edit(body.fields); break;
|
|
248
|
-
case '/flag': edit({ flagged: !!body.flagged }); break;
|
|
249
|
-
case '/defer': edit({ defer: body.until || null }); break;
|
|
250
|
-
case '/waiting': edit({ waiting_on: body.on || null }); break;
|
|
251
|
-
case '/notyet': {
|
|
252
|
-
const n = body.when === 'tomorrow' ? 1 : body.when === 'next-week' ? 7 : 0;
|
|
253
|
-
edit({ not_yet_count: ((cur && cur.not_yet_count) || 0) + 1, ...(n ? { defer: (r && r.defer) || addIso(today, n) } : {}) });
|
|
254
|
-
break;
|
|
255
|
-
}
|
|
256
|
-
case '/keep': edit(); break;
|
|
257
|
-
case '/focus/accept': ov.focus.set(body.key, { state: 'acc', f: { key: body.key, title: body.title, why: body.why, item_ids: body.item_ids || [], job: body.job || null } }); break;
|
|
258
|
-
case '/focus/dismiss': ov.focus.set(body.key, { state: 'no' }); break;
|
|
259
|
-
case '/focus/clear': ov.focus.set(body.key, { state: 'clear' }); break;
|
|
260
|
-
case '/add': {
|
|
261
|
-
const p = previewParse(body.line, today);
|
|
262
|
-
const item = { ...(r.item || {}), id: (r.item && r.item.id) || 'item-demo-add' + (++ov.seq), title: p.title || String(body.line), due: p.due, priority: p.priority, waiting_on: p.waiting_on, job: null, steps: [], created_at: now, touched_at: now };
|
|
263
|
-
ov.added.push(item);
|
|
264
|
-
r.item = item;
|
|
265
|
-
break;
|
|
266
|
-
}
|
|
267
|
-
case '/remove': ov.gone.add(id); break;
|
|
268
|
-
case '/undo': ov.gone.delete(id); break;
|
|
269
|
-
case '/steps/add': { const l = ov.steps.get(id) || []; l.push({ id: 'step-demo' + (++ov.seq), text: body.text, who: 'you', done: false }); ov.steps.set(id, l); break; }
|
|
270
|
-
case '/steps/who': ov.who.set(body.step_id, body.who); break;
|
|
271
|
-
case '/steps/plan': {
|
|
272
|
-
const l = ov.steps.get(id) || [];
|
|
273
|
-
[['Read the item and what it links to', 'agent-does'], ['Draft the first pass or the message', 'agent-drafts'], ['Check it and decide', 'you']].forEach(([text, who]) => l.push({ id: 'step-demo' + (++ov.seq), text, who, done: false }));
|
|
274
|
-
ov.steps.set(id, l);
|
|
275
|
-
break;
|
|
276
|
-
}
|
|
277
|
-
case '/job/add': {
|
|
278
|
-
const m = (re) => { const x = String(body.line || '').match(re); return x ? x[1].trim().replace(/[,;]$/, '') : ''; };
|
|
279
|
-
const job = { id: 'job-demo-new' + (++ov.seq), when: m(/\bwhen\s+(.+?)(?=,?\s*I want\b|,?\s*so\b|$)/i), want: m(/\bI want\s+(.+?)(?=,?\s*so\b|$)/i), so: m(/\bso\s+(.+)$/i), done: 0, total: 0, ...(body.name ? { mock_name: body.name } : {}) };
|
|
280
|
-
ov.jobsAdded.push(job);
|
|
281
|
-
break;
|
|
282
|
-
}
|
|
283
|
-
case '/job/edit': ov.jobEdits.set(id, { ...(ov.jobEdits.get(id) || {}), ...body.fields }); break;
|
|
284
|
-
case '/job/delete': {
|
|
285
|
-
ov.jobsGone.set(id, true);
|
|
286
|
-
((inst.data && inst.data.items) || []).filter((i) => i.job === id).forEach((i) => ov.edits.set(i.id, { ...(ov.edits.get(i.id) || {}), job: body.reassign_to || null }));
|
|
287
|
-
r.reassigned = ((inst.data && inst.data.items) || []).filter((i) => i.job === id).length;
|
|
288
|
-
break;
|
|
289
|
-
}
|
|
290
|
-
default: break;
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
export function mountPmWork(host, ctx) {
|
|
295
|
-
let inst = insts.get(host);
|
|
296
|
-
if (inst) return;
|
|
297
|
-
if (ctx && ctx.FIXTURE) return;
|
|
298
|
-
ensureC3Css();
|
|
299
|
-
inst = { host, ctx: ctx || {}, root: el('div', { class: 'c3 calwrap wk', 'data-pm-work': '' }), data: null, base: null, ov: newOv(), lens: 'today',
|
|
300
|
-
opens: new Set(), picks: new Map(), asks: new Map(), editing: new Set(), planning: new Set(), runs: new Map(), trays: new Set(), cases: new Set(), timers: new Set(), hidden: new Set(),
|
|
301
|
-
focEdit: new Set(), rv: { ids: null, handled: new Set(), changing: false }, decisions: 0, drafts: null, draftsSig: '', draftsHost: el('div', { 'data-pm-review-drafts': '' }) };
|
|
302
|
-
inst.body = el('div', { class: 'calbody pmw-body' });
|
|
303
|
-
inst.bar = el('div', { class: 'calbar' });
|
|
304
|
-
inst.addBox = addLine(inst);
|
|
305
|
-
inst.root.append(inst.addBox, inst.bar, inst.body);
|
|
306
|
-
inst.stopPhone = c3Phone(inst.root);
|
|
307
|
-
insts.set(host, inst);
|
|
308
|
-
host.appendChild(inst.root);
|
|
309
|
-
if (inst.ctx.onLens) inst.ctx.onLens(inst.lens);
|
|
310
|
-
inst.stopBrief = onBriefing((b) => briefRead(inst, b)); // the decisions that wait in Briefing, and the drafts the Review view carries
|
|
311
|
-
loadBriefing();
|
|
312
|
-
load(inst);
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
export function disposePmWork(host) {
|
|
316
|
-
const inst = insts.get(host);
|
|
317
|
-
if (!inst) return;
|
|
318
|
-
if (inst.stopPhone) inst.stopPhone();
|
|
319
|
-
if (inst.stopBrief) inst.stopBrief();
|
|
320
|
-
disposeCases(inst);
|
|
321
|
-
inst.timers.forEach((t) => clearTimeout(t));
|
|
322
|
-
inst.root.remove();
|
|
323
|
-
insts.delete(host);
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
function disposeCases(inst) { inst.cases.forEach((c) => { try { c.c3case.dispose(); } catch { /* already gone */ } }); inst.cases.clear(); }
|
|
327
|
-
const later = (inst, fn, ms) => { const t = setTimeout(() => { inst.timers.delete(t); if (insts.get(inst.host) === inst) fn(); }, ms); inst.timers.add(t); };
|
|
328
|
-
|
|
329
|
-
/* ── reads and presses ───────────────────────────────────────────────────────────────────────────────────────────── */
|
|
330
|
-
|
|
331
|
-
/* The Initiative Driver's open Work proposals (c3-driver-work.js), read with the list. Null when there are none to draw: demo mode, an old server, no answer. */
|
|
332
|
-
async function driverRead(inst) {
|
|
333
|
-
if (DEMO() || inst.ctx.FIXTURE) return null;
|
|
334
|
-
try { const m = await import('./c3-driver-work.js'); const o = await m.loadDriverOpen(inst.ctx.ws); return o ? { m, ws: o.ws, mode: o.mode, targets: o.targets || {} } : null; } catch { return null; }
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
async function load(inst) {
|
|
338
|
-
const [r, drv] = await Promise.all([pmGet(API), driverRead(inst)]);
|
|
339
|
-
inst.drv = drv;
|
|
340
|
-
inst.base = r && r.ok ? r : null;
|
|
341
|
-
inst.data = inst.base && DEMO() ? applyOv(inst.base, inst.ov) : inst.base;
|
|
342
|
-
if (!inst.data) say({ text: (r && r.error) || COPY.readError, tone: 'error' });
|
|
343
|
-
if (insts.get(inst.host) === inst) draw(inst);
|
|
344
|
-
/* an agent that is queued, working or posting changes on its own: read again until it stops (c3-work-agent) */
|
|
345
|
-
const busy = inst.data && !DEMO() && (inst.data.items || []).some((i) => i.agent && AGENT_BUSY.includes(i.agent.state));
|
|
346
|
-
if (busy && !inst.agentPoll) { inst.agentPoll = true; later(inst, () => { inst.agentPoll = false; load(inst); }, AGENT_POLL_MS); }
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
async function press(inst, path, body, { quiet } = {}) {
|
|
350
|
-
const r = await pmPost(path, body);
|
|
351
|
-
if (!r || !r.ok) { say({ text: (r && r.error) || COPY.saveError, tone: 'error' }); return null; }
|
|
352
|
-
if (DEMO()) applyLocal(inst, path, body, r);
|
|
353
|
-
if (!quiet) await load(inst);
|
|
354
|
-
return r;
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
/* One action on an item, as the mockup does it: the row leaves, a toast says what happened and offers Undo. `spec` =
|
|
358
|
-
* { route, body, text, undo: async (r) => boolean, leave } and every route is an existing page-press route. */
|
|
359
|
-
async function act(inst, rowEl, spec) {
|
|
360
|
-
const r = await press(inst, spec.route.startsWith('/api/') ? spec.route : API + spec.route, spec.body, { quiet: true });
|
|
361
|
-
if (!r) return false;
|
|
362
|
-
const leaves = spec.leave !== false;
|
|
363
|
-
if (rowEl && leaves) rowEl.classList.add('leave'); // the mockup's .leave: fade and slide out (console3.html line 76)
|
|
364
|
-
say({
|
|
365
|
-
text: spec.text, timeout: r.undo_ms || 6000, actionLabel: spec.undo ? COPY.undo : undefined,
|
|
366
|
-
onAction: spec.undo ? async () => { const u = await spec.undo(r); if (u) say({ text: COPY.restored, timeout: 2500 }); await load(inst); } : undefined,
|
|
367
|
-
});
|
|
368
|
-
later(inst, () => load(inst), rowEl && leaves ? 230 : 0);
|
|
369
|
-
return true;
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
const undoBy = (inst, route, body) => async () => !!(await press(inst, API + route, body, { quiet: true }));
|
|
373
|
-
/* Does the change move the item out of the view on screen? Then its row leaves; otherwise it stays and redraws. */
|
|
374
|
-
const leaves = (inst, item, patch) => inst.lens === 'review' || workPlace({ ...item, ...patch }, inst.data.today) !== inst.lens;
|
|
375
|
-
|
|
376
|
-
/* `how` says how it closed, for the Done view: 'you' (the default), 'agent' (from the agent draft) or 'confirmed' (offline work the PM confirmed). */
|
|
377
|
-
const doneAct = (inst, item, row, text, outcome, how) => act(inst, row, { route: '/done', body: { id: item.id, ...(outcome ? { outcome } : {}), ...(how ? { how } : {}) }, text: text || COPY.doneToast, undo: undoBy(inst, '/reopen', { id: item.id }) });
|
|
378
|
-
const dropAct = (inst, item, row) => act(inst, row, { route: '/remove', body: { id: item.id }, text: COPY.removed, undo: undoBy(inst, '/undo', { id: item.id }) });
|
|
379
|
-
const todayAct = (inst, item, row) => act(inst, row, { route: '/edit', body: { id: item.id, fields: { due: inst.data.today, defer: null } }, text: 'In Today.',
|
|
380
|
-
undo: undoBy(inst, '/edit', { id: item.id, fields: { due: item.due || null, defer: item.defer || null } }), leave: leaves(inst, item, { due: inst.data.today, defer: null }) });
|
|
381
|
-
const flagAct = (inst, item, row) => { const on = !item.flagged; return act(inst, row, { route: '/flag', body: { id: item.id, flagged: on }, text: on ? 'Flagged for today.' : 'Unflagged.', undo: undoBy(inst, '/flag', { id: item.id, flagged: !on }), leave: leaves(inst, item, { flagged: on }) }); };
|
|
382
|
-
const deferAct = (inst, item, row, until) => act(inst, row, { route: '/defer', body: { id: item.id, until }, text: until ? COPY.notBeforeChip(dayLabel(until)) + '.' : 'Not before cleared.',
|
|
383
|
-
undo: undoBy(inst, '/defer', { id: item.id, until: item.defer || null }), leave: leaves(inst, item, { defer: until }) });
|
|
384
|
-
const somedayAct = (inst, item, row) => act(inst, row, { route: '/someday', body: { id: item.id }, text: 'Parked in Someday.', undo: undoBy(inst, '/unpark', { id: item.id }), leave: leaves(inst, item, { parked: true }) });
|
|
385
|
-
const unparkAct = (inst, item, row) => act(inst, row, { route: '/unpark', body: { id: item.id }, text: 'Back from Someday.', undo: undoBy(inst, '/someday', { id: item.id }), leave: leaves(inst, item, { parked: false }) });
|
|
386
|
-
const waitAct = (inst, item, row, on) => act(inst, row, { route: '/waiting', body: { id: item.id, on }, text: on ? 'Waiting on ' + on + '.' : 'No longer waiting.',
|
|
387
|
-
undo: undoBy(inst, '/waiting', { id: item.id, on: item.waiting_on || null }), leave: leaves(inst, item, { waiting_on: on }) });
|
|
388
|
-
function notYetAct(inst, item, row, when) {
|
|
389
|
-
const today = inst.data.today; const n = when === 'tomorrow' ? 1 : when === 'next-week' ? 7 : 0;
|
|
390
|
-
return act(inst, row, { route: '/notyet', body: { id: item.id, when }, text: n ? 'Not yet. Back in Today on ' + dayLabel(addIso(today, n)) + '.' : 'Not yet. It stays in Today for later.',
|
|
391
|
-
undo: undoBy(inst, '/defer', { id: item.id, until: item.defer || null }), leave: n ? leaves(inst, item, { defer: addIso(today, n) }) : false });
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
/* Focus (PRD R4): accept pins a job to Today, Not today hides it for the day, Unpin takes it back; each offers Undo. */
|
|
395
|
-
const focusBody = (f) => ({ key: f.key, title: f.title, why: f.why, item_ids: f.item_ids || [], ...(f.job ? { job: f.job } : {}) });
|
|
396
|
-
const focusAccept = (inst, f) => { inst.focEdit.delete(f.key); return act(inst, null, { route: '/focus/accept', body: focusBody(f), text: COPY.focusAccepted, undo: undoBy(inst, '/focus/clear', { key: f.key }), leave: false }); };
|
|
397
|
-
const focusDismiss = (inst, f) => act(inst, null, { route: '/focus/dismiss', body: { key: f.key }, text: COPY.focusDismissed, undo: undoBy(inst, '/focus/clear', { key: f.key }), leave: false });
|
|
398
|
-
const focusClear = (inst, f) => act(inst, null, { route: '/focus/clear', body: { key: f.key }, text: COPY.focusCleared, undo: undoBy(inst, '/focus/accept', focusBody(f)), leave: false });
|
|
399
|
-
|
|
400
|
-
function lensOfItem(inst, id) {
|
|
401
|
-
for (const l of VIEWS) if ((views(inst)[l] || []).some((i) => i.id === id)) return l;
|
|
402
|
-
return inst.lens;
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
async function cycleWho(inst, item, step) {
|
|
406
|
-
const outward = OUTWARD.test(step.text);
|
|
407
|
-
const next = WHO[(WHO.indexOf(step.who) + 1) % WHO.length];
|
|
408
|
-
// Outward steps stay agent-drafts; the server enforces it too.
|
|
409
|
-
if (outward) { say({ text: COPY.whoOutward, timeout: 3000 }); if (step.who === 'agent-drafts') return; }
|
|
410
|
-
await press(inst, API + '/steps/who', { step_id: step.id, who: outward ? 'agent-drafts' : next });
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
function planSteps(inst, item) {
|
|
414
|
-
inst.planning.add(item.id); inst.opens.add(item.id); draw(inst);
|
|
415
|
-
later(inst, async () => { await press(inst, API + '/steps/plan', { id: item.id }, { quiet: true }); inst.planning.delete(item.id); await load(inst); }, 800);
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
/* ── the add line: a client preview of the server parser (lib/pm-items.js parseLine), so the chips match what is saved ── */
|
|
419
|
-
|
|
420
|
-
const DAYS = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'];
|
|
421
|
-
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
422
|
-
const iso = (d) => d.toISOString().slice(0, 10);
|
|
423
|
-
const nextMonday = (s) => { const d = new Date(s + 'T00:00:00Z'); return addIso(s, ((8 - d.getUTCDay()) % 7) || 7); };
|
|
424
|
-
const dayLabel = (s) => { const d = new Date(String(s).slice(0, 10) + 'T00:00:00Z'); return DAYS[d.getUTCDay()].slice(0, 1).toUpperCase() + DAYS[d.getUTCDay()].slice(1, 3) + ' ' + d.getUTCDate() + ' ' + MON[d.getUTCMonth()]; };
|
|
425
|
-
|
|
426
|
-
function previewParse(text, todayIso) {
|
|
427
|
-
let rest = String(text || '').trim();
|
|
428
|
-
const out = { title: '', due: null, priority: null, waiting_on: null };
|
|
429
|
-
const p = rest.match(/\bP([1-3])\b/i) || rest.match(/(?:^|\s)!([1-3])(?=\s|$)/); // "P1" or the shorthand "!1" (the server parser reads both)
|
|
430
|
-
if (p) { out.priority = 'P' + p[1]; rest = rest.replace(p[0], ' '); }
|
|
431
|
-
const w = rest.match(/\bwaiting on\s+([^,;]+?)(?=\s+(?:by|due|P[1-3])\b|$)/i);
|
|
432
|
-
if (w) { out.waiting_on = w[1].trim(); rest = rest.replace(w[0], ' '); }
|
|
433
|
-
const t = new Date(todayIso + 'T00:00:00Z');
|
|
434
|
-
const di = rest.match(/\b(?:due|by)\s+(\d{4}-\d{2}-\d{2})\b/i);
|
|
435
|
-
const dw = rest.match(/\b(?:due|by)\s+(today|tomorrow|sun(?:day)?|mon(?:day)?|tue(?:s(?:day)?)?|wed(?:nesday)?|thu(?:r(?:s(?:day)?)?)?|fri(?:day)?|sat(?:urday)?)\b/i);
|
|
436
|
-
if (di) { out.due = di[1]; rest = rest.replace(di[0], ' '); }
|
|
437
|
-
else if (dw) {
|
|
438
|
-
const k = dw[1].toLowerCase();
|
|
439
|
-
const d = new Date(t.getTime());
|
|
440
|
-
if (k === 'tomorrow') d.setUTCDate(d.getUTCDate() + 1);
|
|
441
|
-
else if (k !== 'today') d.setUTCDate(d.getUTCDate() + ((DAYS.findIndex((w) => w.startsWith(k.slice(0, 3))) - d.getUTCDay() + 7) % 7));
|
|
442
|
-
out.due = iso(d);
|
|
443
|
-
rest = rest.replace(dw[0], ' ');
|
|
444
|
-
}
|
|
445
|
-
out.title = rest.replace(/\s+/g, ' ').replace(/[,;]\s*$/, '').trim();
|
|
446
|
-
return out;
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
const labelOf = (id) => (LENSES.find((l) => l[0] === id) || [])[1] || id;
|
|
450
|
-
const small = 'font-size:var(--fs-2)';
|
|
451
|
-
|
|
452
|
-
/* The mockup's c3prev(): "adds to", a .tag with the view the server will place the line in (PRD R2), then .chip2 / .fl / .st chips. */
|
|
453
|
-
function previewChips(inst, text) {
|
|
454
|
-
const today = (inst.data && inst.data.today) || iso(new Date());
|
|
455
|
-
if (!text.trim()) return [el('span', { class: 'dim mono', style: small }, COPY.hint)];
|
|
456
|
-
const o = previewParse(text, today);
|
|
457
|
-
if (!o.title) return [el('span', { class: 'dim mono', style: small }, 'The line needs a title.')];
|
|
458
|
-
const out = [el('span', { class: 'dim mono wk-sm' }, COPY.addsTo), el('span', { class: 'tag', 'data-pm-lands': workPlace(o, today) }, labelOf(workPlace(o, today)))];
|
|
459
|
-
if (o.due) out.push(el('span', { class: 'chip2' }, c3ic('cal', 'sm'), o.due));
|
|
460
|
-
if (o.priority) out.push(el('span', { class: 'fl ' + o.priority.toLowerCase() }, o.priority));
|
|
461
|
-
if (o.waiting_on) out.push(el('span', { class: 'chip2' }, c3ic('wait', 'sm'), COPY.waitingOn(o.waiting_on)));
|
|
462
|
-
out.push(el('span', { class: 'st warn' }, c3ic('target', 'sm'), COPY.noJob));
|
|
463
|
-
return out;
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
/* The mockup's c3addLine(): .c3add > .form (input, add button) + .chips2 with the live chips. The microphone is drawn disabled (see addLine). */
|
|
467
|
-
function addLine(inst) {
|
|
468
|
-
const input = el('input', { type: 'text', placeholder: COPY.addPlaceholder, 'aria-label': COPY.addLabel, autocomplete: 'off', 'data-pm-add': API + '/add' });
|
|
469
|
-
const chips = el('div', { class: 'chips2', 'data-pm-chips': '' }, previewChips(inst, ''));
|
|
470
|
-
inst.chips = chips; inst.input = input;
|
|
471
|
-
const send = async () => {
|
|
472
|
-
const line = input.value.trim();
|
|
473
|
-
if (!line) return;
|
|
474
|
-
const before = (inst.data && inst.data.today) || iso(new Date());
|
|
475
|
-
const o = previewParse(line, before);
|
|
476
|
-
const r = await press(inst, API + '/add', { line }, { quiet: true });
|
|
477
|
-
if (!r) return;
|
|
478
|
-
input.value = ''; chips.replaceChildren(...previewChips(inst, ''));
|
|
479
|
-
inst.lens = workPlace(o, before); if (inst.ctx.onLens) inst.ctx.onLens(inst.lens);
|
|
480
|
-
if (r.item) inst.opens.add(r.item.id);
|
|
481
|
-
say({ text: 'Added to ' + labelOf(inst.lens), timeout: r.undo_ms || 6000, actionLabel: COPY.undo, onAction: async () => { if (r.item) await press(inst, API + '/remove', { id: r.item.id }, { quiet: true }); await load(inst); } });
|
|
482
|
-
await load(inst);
|
|
483
|
-
if (DEMO() && r.item) later(inst, () => planSteps(inst, r.item), 900); // the mockup's agent plans the steps a moment after the add; real mode waits for the PM to press "Plan the steps"
|
|
484
|
-
};
|
|
485
|
-
input.addEventListener('input', () => chips.replaceChildren(...previewChips(inst, input.value)));
|
|
486
|
-
input.addEventListener('keydown', (e) => { if (e.key === 'Enter' && !e.isComposing) send(); });
|
|
487
|
-
const add = c3ib(COPY.addBtn, 'plus', { 'data-pm-add-send': '', onClick: send }, 'pri');
|
|
488
|
-
// The mockup's microphone (c3addLine). Disabled: the on-device dictation (whisper.cpp) belongs to a Notes document and needs the
|
|
489
|
-
// server; nothing on this page may record, and the browser recogniser is not on-device.
|
|
490
|
-
const mic = c3ib(COPY.micOff, 'mic', { 'data-off': '', 'data-pm-mic': '', onclick: () => say({ text: 'The microphone needs the app. Nothing was recorded: type the item here.', timeout: 4200 }) });
|
|
491
|
-
return el('div', { class: 'c3add' }, el('div', { class: 'form' }, input, mic, add), chips);
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
/* ── rows and the case file ──────────────────────────────────────────────────────────────────────────────────────── */
|
|
495
|
-
|
|
496
|
-
const jobById = (inst, id) => (inst.data.jobs || []).find((j) => j.id === id);
|
|
497
|
-
/* The five places, as the server answers them (`work`). An older server that sends only `lists` is read through the same five names. */
|
|
498
|
-
function views(inst) {
|
|
499
|
-
const d = inst.data || {};
|
|
500
|
-
if (d.work) return d.work;
|
|
501
|
-
const L = d.lists || {};
|
|
502
|
-
return { inbox: L.triage || [], today: L.today || [], upcoming: [...(L.week || []), ...(L.later || []).filter((i) => !i.parked)], waiting: L.waiting || [], someday: (L.later || []).filter((i) => i.parked) };
|
|
503
|
-
}
|
|
504
|
-
const shown = (inst, id) => ((id === 'review' ? (inst.data || {}).review : views(inst)[id]) || []).filter((i) => !inst.hidden.has(i.id) && !i.done);
|
|
505
|
-
const countOf = (inst, id) => {
|
|
506
|
-
if (id === 'done') return doneItems(inst).filter((i) => doneAgo(inst, i) <= 0).length; // the Done badge: items done today
|
|
507
|
-
const c = (inst.data || {}).counts; return c && typeof c[id] === 'number' ? c[id] : shown(inst, id).length;
|
|
508
|
-
};
|
|
509
|
-
const itemById = (inst, id) => ((inst.data && inst.data.items) || []).find((i) => i.id === id)
|
|
510
|
-
|| [...VIEWS.map((v) => views(inst)[v] || []).flat(), ...((inst.data && inst.data.review) || [])].find((i) => i.id === id);
|
|
511
|
-
/* The title of the team task a Work item advances (PRD R8): the item's own copy, then a map the answer may carry, else the id. */
|
|
512
|
-
const resolvesTitle = (inst, item) => item.resolves_title || ((inst.data && inst.data.resolves_titles) || {})[item.resolves] || item.resolves;
|
|
513
|
-
|
|
514
|
-
/* The mockup's .c3jf: a label (.dim.mono) and an input on one line (console3.html line 4651). */
|
|
515
|
-
function field(label, input) { return el('label', null, el('span', { class: 'dim mono' }, label), input); }
|
|
516
|
-
/* A text button of the Work page (the mockup's .pill). */
|
|
517
|
-
function pill(label, icon, attrs) {
|
|
518
|
-
const b = button({ label, variant: 'ghost', attrs: { ...(attrs || {}), class: 'pill' } });
|
|
519
|
-
if (icon) b.prepend(c3ic(icon, 'sm'));
|
|
520
|
-
return b;
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
function editField(inst, item, label, shortLabel, kind, key, value) {
|
|
524
|
-
const input = el(kind === 'select' ? 'select' : 'input', { 'aria-label': label, 'data-pm-edit': item.id + ':' + key, ...(kind === 'date' ? { type: 'date' } : kind === 'text' ? { type: 'text' } : {}) });
|
|
525
|
-
if (kind === 'select') {
|
|
526
|
-
const opts = key === 'job'
|
|
527
|
-
? [['', COPY.noJobGroup], ...(inst.data.jobs || []).map((j) => [j.id, j.want])]
|
|
528
|
-
: [['', 'None'], ['P1', 'P1'], ['P2', 'P2'], ['P3', 'P3']];
|
|
529
|
-
opts.forEach(([v, t]) => input.appendChild(el('option', { value: v }, t)));
|
|
530
|
-
}
|
|
531
|
-
input.value = value || '';
|
|
532
|
-
input.addEventListener('change', async () => {
|
|
533
|
-
const v = input.value.trim();
|
|
534
|
-
const old = item[key] === undefined ? null : item[key];
|
|
535
|
-
const r = await press(inst, API + '/edit', { id: item.id, fields: { [key]: v === '' && key !== 'title' ? null : v } });
|
|
536
|
-
if (r) say({ text: 'Saved', timeout: 5000, actionLabel: COPY.undo, onAction: async () => { await press(inst, API + '/edit', { id: item.id, fields: { [key]: old } }); } });
|
|
537
|
-
});
|
|
538
|
-
return field(shortLabel, input);
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
/* The editable fields of an item (title, due, not before, priority, waiting on, job): in the case file behind "Edit details", and Review's Change. */
|
|
542
|
-
const editForm = (inst, item) => el('div', { class: 'c3jf', 'data-pm-edit-form': item.id },
|
|
543
|
-
editField(inst, item, 'Title', 'Title', 'text', 'title', item.title),
|
|
544
|
-
editField(inst, item, 'Due', 'Due', 'date', 'due', item.due),
|
|
545
|
-
editField(inst, item, COPY.notBefore, COPY.notBefore, 'date', 'defer', item.defer),
|
|
546
|
-
editField(inst, item, 'Priority', 'Priority', 'select', 'priority', item.priority),
|
|
547
|
-
editField(inst, item, 'Waiting on', 'Waiting', 'text', 'waiting_on', item.waiting_on),
|
|
548
|
-
editField(inst, item, 'Job', 'Job', 'select', 'job', item.job));
|
|
549
|
-
|
|
550
|
-
/* The mockup's c3stepsHtml(): .c3steps > .c3sh + ul > li (.c3sg, .c3stt, .chips2 with the who pill) + an add input (line 4595). */
|
|
551
|
-
function stepsBlock(inst, item) {
|
|
552
|
-
if (inst.planning.has(item.id)) return el('div', { class: 'fold a', 'data-pm-planning': item.id, role: 'status' }, c3ic('spark', 'sm'), 'The agent is reading the item and planning the steps');
|
|
553
|
-
const list = item.steps || [];
|
|
554
|
-
if (!list.length) return el('div', { class: 'chips2' }, el('button', { type: 'button', class: 'chip2 lk', 'data-pm-plan': item.id, onclick: () => planSteps(inst, item) }, c3ic('spark', 'sm'), COPY.plan));
|
|
555
|
-
const input = el('input', { type: 'text', placeholder: COPY.addStep, 'aria-label': COPY.addStep, 'data-pm-step-add': item.id });
|
|
556
|
-
input.addEventListener('keydown', async (e) => {
|
|
557
|
-
if (e.key !== 'Enter' || !input.value.trim()) return;
|
|
558
|
-
if (await press(inst, API + '/steps/add', { id: item.id, text: input.value.trim() })) input.value = '';
|
|
559
|
-
});
|
|
560
|
-
const rows = list.map((st) => {
|
|
561
|
-
const outward = OUTWARD.test(st.text);
|
|
562
|
-
const who = el('button', { type: 'button', class: 'pill', 'data-who': st.who, 'data-pm-who': st.id, title: outward ? COPY.whoOutward : 'Who does this step. Tap to change.' }, COPY.who[st.who] || st.who);
|
|
563
|
-
who.addEventListener('click', () => cycleWho(inst, item, st));
|
|
564
|
-
return el('li', { class: st.done ? 'ok' : outward ? 'warn' : '', 'data-pm-step': st.id },
|
|
565
|
-
el('span', { class: 'c3sg' }, c3ic(st.done ? 'check' : st.who === 'you' ? 'user' : 'spark', 'sm')),
|
|
566
|
-
el('span', { class: 'c3stt' + (st.done ? ' dn' : '') }, st.text, outward && !st.done ? [' ', el('span', { class: 'tag' }, 'needs your slide')] : null),
|
|
567
|
-
el('span', { class: 'chips2' }, who));
|
|
568
|
-
});
|
|
569
|
-
const dn = list.filter((s) => s.done).length;
|
|
570
|
-
return el('div', { class: 'c3steps', 'data-pm-steps': item.id },
|
|
571
|
-
el('div', { class: 'c3sh' }, el('h4', null, c3ic('tree', 'sm'), COPY.steps), el('span', { class: 'dim mono' }, COPY.progress(dn, list.length))),
|
|
572
|
-
el('ul', null, rows),
|
|
573
|
-
el('div', { class: 'form' }, input));
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
/* ── the shared actions and offline work (PRD R6) ──────────────────────────────────────────────────────────────────── */
|
|
577
|
-
|
|
578
|
-
const rowOf = (inst, item) => inst.root.querySelector('[data-pm-item="' + item.id + '"]');
|
|
579
|
-
|
|
580
|
-
/** Flag, Not before, Someday, Waiting and Drop: every item has them in its case file. Each goes through act(), so each offers Undo. */
|
|
581
|
-
function quickActs(inst, item, { noDrop } = {}) {
|
|
582
|
-
const today = inst.data.today;
|
|
583
|
-
const date = el('input', { type: 'date', 'aria-label': COPY.notBefore, 'data-pm-defer': item.id, min: addIso(today, 1) });
|
|
584
|
-
date.value = item.defer && item.defer > today ? item.defer : '';
|
|
585
|
-
date.addEventListener('change', () => { if (date.value && date.value !== item.defer) deferAct(inst, item, rowOf(inst, item), date.value); });
|
|
586
|
-
const who = el('input', { type: 'text', placeholder: COPY.waitingWho, 'aria-label': COPY.waitingField, 'data-pm-wait-on': item.id, autocomplete: 'off' });
|
|
587
|
-
who.addEventListener('keydown', (e) => { if (e.key === 'Enter' && !e.isComposing && who.value.trim()) waitAct(inst, item, rowOf(inst, item), who.value.trim()); });
|
|
588
|
-
return el('div', { class: 'wkq', 'data-pm-quick': item.id },
|
|
589
|
-
pill(item.flagged ? COPY.unflag : COPY.flag, 'flag', { 'data-pm-flag': item.id, 'aria-pressed': String(!!item.flagged), onclick: () => flagAct(inst, item, rowOf(inst, item)) }),
|
|
590
|
-
el('label', { class: 'wkq-f' }, el('span', { class: 'dim mono' }, COPY.notBefore), date),
|
|
591
|
-
item.parked ? pill(COPY.bringBack, 'sun', { 'data-pm-unpark': item.id, onclick: () => unparkAct(inst, item, rowOf(inst, item)) })
|
|
592
|
-
: pill(COPY.someday, 'moon', { 'data-pm-someday': item.id, onclick: () => somedayAct(inst, item, rowOf(inst, item)) }),
|
|
593
|
-
item.waiting_on ? pill(COPY.stopWaiting, 'wait', { 'data-pm-unwait': item.id, onclick: () => waitAct(inst, item, rowOf(inst, item), null) })
|
|
594
|
-
: el('label', { class: 'wkq-f' }, el('span', { class: 'dim mono' }, COPY.waitingField), who),
|
|
595
|
-
noDrop ? null : pill(COPY.drop, 'trash', { 'data-pm-drop': item.id, onclick: () => dropAct(inst, item, rowOf(inst, item)) }));
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
/** An item done outside PMOS: who it involves, Done with an optional outcome, Not yet, Drop, and "Looks done?" when there is proof.
|
|
599
|
-
* PMOS never closes it by itself: Confirm is the PM's press. */
|
|
600
|
-
function offlineBlock(inst, item) {
|
|
601
|
-
const out = el('input', { type: 'text', placeholder: COPY.outcome, 'aria-label': COPY.outcome, 'data-pm-outcome': item.id, autocomplete: 'off' });
|
|
602
|
-
const doneNow = () => { const v = out.value.trim(); return doneAct(inst, item, rowOf(inst, item), v ? 'Done. The outcome is saved.' : 'Done.', v || undefined); };
|
|
603
|
-
out.addEventListener('keydown', (e) => { if (e.key === 'Enter' && !e.isComposing) doneNow(); });
|
|
604
|
-
return el('div', { class: 'wkoff', 'data-pm-offline': item.id },
|
|
605
|
-
el('p', { class: 'wkoff-n' }, c3ic('user', 'sm'), COPY.offlineNote(item.person)),
|
|
606
|
-
item.evidence ? el('div', { class: 'wkev', 'data-pm-evidence': item.id }, c3ic('eye', 'sm'), el('span', { class: 'wk-min' }, el('b', null, COPY.looksDone + ' '), item.evidence),
|
|
607
|
-
pill(COPY.confirm, 'check', { class: 'pill pri', 'data-pm-confirm': item.id, onclick: () => doneAct(inst, item, rowOf(inst, item), 'Done. You confirmed it.', undefined, 'confirmed') })) : null,
|
|
608
|
-
el('div', { class: 'wkq' }, el('span', { class: 'form wkoff-o' }, out), pill(COPY.done, 'check', { class: 'pill pri', 'data-pm-offline-done': item.id, onclick: doneNow })),
|
|
609
|
-
el('div', { class: 'wkq' }, el('span', { class: 'dim mono' }, COPY.notYet),
|
|
610
|
-
...[['later-today', COPY.laterToday], ['tomorrow', COPY.tomorrow], ['next-week', COPY.nextWeek]].map(([w, l]) => pill(l, null, { 'data-pm-notyet': w, onclick: () => notYetAct(inst, item, rowOf(inst, item), w) })),
|
|
611
|
-
pill(COPY.drop, 'trash', { 'data-pm-drop': item.id, onclick: () => dropAct(inst, item, rowOf(inst, item)) })));
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
/* ── the case model of one item (console3.html genTask line 3216, agDecor line 5126) ─────────────────────────────────────────── */
|
|
615
|
-
|
|
616
|
-
const OUT_REASON = 'No channel connected, so this stays a draft. Nothing is sent.';
|
|
617
|
-
const fx = (...a) => a;
|
|
618
|
-
|
|
619
|
-
/** The options of an item by its view. Each: { id, l, rec, fx, outward, run(row) } where run does the work through a press route.
|
|
620
|
-
* An offline item has none: it acts through its own block (Done, Not yet, Looks done). */
|
|
621
|
-
function lensOptions(inst, item, lens) {
|
|
622
|
-
const who = item.waiting_on || 'them';
|
|
623
|
-
const today = inst.data.today; const tom = addIso(today, 1); const mon = nextMonday(today);
|
|
624
|
-
const o = (id, l, rec, f, run, extra) => ({ id, l, rec: !!rec, fx: f, run, ...(extra || {}) });
|
|
625
|
-
if (item.kind === 'offline') return { conf: 0, cta: '', opts: [] };
|
|
626
|
-
const doneO = (rec) => o('done', 'Mark it done', rec, [fx('check', 'Closes the item', 'ok')], (r) => doneAct(inst, item, r, 'Done.'));
|
|
627
|
-
const todayO = (rec) => o('today', 'Do it today', rec, [fx('sun', 'Moves to Today', 'ok')], (r) => todayAct(inst, item, r));
|
|
628
|
-
const deferO = (d, rec) => o('defer-' + d, COPY.notBeforeChip(dayLabel(d)), rec, [fx('moon', 'Out of Today until then')], (r) => deferAct(inst, item, r, d));
|
|
629
|
-
const somedayO = () => o('someday', 'Park it in Someday', 0, [fx('moon', 'Back in the weekly Review')], (r) => somedayAct(inst, item, r));
|
|
630
|
-
const dropO = () => o('drop', 'Drop it', 0, [fx('x', 'Gone, with Undo', 'warn')], (r) => dropAct(inst, item, r));
|
|
631
|
-
if (lens === 'waiting') {
|
|
632
|
-
return { conf: 80, cta: 'Slide to nudge', sit: 'Waiting on ' + who + '. ' + (item.why || 'No reply yet.'), opts: [
|
|
633
|
-
o('nudge', 'Nudge ' + who + ' now (drafted)', 1, [fx('out', 'Goes to Review first', 'ok')], null, { outward: true }),
|
|
634
|
-
o('unwait', 'Stop waiting: it is yours again', 0, [fx('check', 'Leaves Waiting', 'ok')], (r) => waitAct(inst, item, r, null)),
|
|
635
|
-
o('wait', 'Keep waiting', 0, [fx('clock', 'Ages another day', 'warn')], () => say({ text: 'Still waiting.', timeout: 2500 })),
|
|
636
|
-
] };
|
|
637
|
-
}
|
|
638
|
-
if (lens === 'someday') return { conf: 66, cta: 'Slide to bring it back', sit: 'Parked on purpose. It only matters again when you give it a date.', opts: [
|
|
639
|
-
o('back', 'Bring it back', 1, [fx('check', 'Placed by its dates again', 'ok')], (r) => unparkAct(inst, item, r)), dropO()] };
|
|
640
|
-
if (lens === 'upcoming') return { conf: 70, cta: 'Slide to keep the date', opts: [
|
|
641
|
-
o('keep', 'Keep the date', 1, [fx('check', 'On plan', 'ok')], () => say({ text: 'Kept.', timeout: 2500 })), todayO(0), somedayO()] };
|
|
642
|
-
if (lens === 'today') return { conf: 82, cta: 'Slide to finish', opts: [doneO(1), deferO(tom, 0), deferO(mon, 0)] };
|
|
643
|
-
return { conf: 78, cta: 'Slide to decide', opts: [todayO(1), deferO(mon, 0), somedayO(), dropO()] };
|
|
644
|
-
}
|
|
645
|
-
|
|
646
|
-
/** { model, run } for an item: the model goes to renderCase(), `run(id, row)` does what the picked option says. */
|
|
647
|
-
function itemCase(inst, item, lens) {
|
|
648
|
-
const ix = item.ix || {}; const mock = item.mock_row === true;
|
|
649
|
-
const j = item.job && jobById(inst, item.job);
|
|
650
|
-
const L = lensOptions(inst, item, lens);
|
|
651
|
-
if (!mock && item.agent && item.kind !== 'offline') return agentCase(inst, item, L);
|
|
652
|
-
const jm = j && (j.mock_name || j.want);
|
|
653
|
-
const evidence = ix.chg ? ix.chg.slice() : (() => {
|
|
654
|
-
const c = [];
|
|
655
|
-
if (ix.why) c.push(['info', ix.why[0], ix.why[1] || '']);
|
|
656
|
-
else if (item.why) c.push(['info', item.why, item.src || '']);
|
|
657
|
-
if (j) c.push(['target', 'Job: ' + jm, 'JTBD']);
|
|
658
|
-
if (item.resolves) c.push(['init', COPY.advances(resolvesTitle(inst, item)), 'team task']);
|
|
659
|
-
if (mock && item.mins) c.push(['clock', 'About ' + (item.mins <= 2 ? 'under 2' : item.mins) + ' min', 'effort']);
|
|
660
|
-
if (item.due) c.push(['cal', 'Due ' + item.due, '']);
|
|
661
|
-
if (item.defer && item.defer > inst.data.today) c.push(['moon', COPY.notBeforeChip(dayLabel(item.defer)), '']);
|
|
662
|
-
if (item.priority && !mock) c.push(['flag', 'Priority ' + item.priority, '']);
|
|
663
|
-
if (item.waiting_on) c.push(['wait', 'Waiting on ' + item.waiting_on, '']);
|
|
664
|
-
return c.slice(0, 3);
|
|
665
|
-
})();
|
|
666
|
-
const model = {
|
|
667
|
-
id: 'task:' + item.id, sit: ix.sit || L.sit || (j ? COPY.jobLine(j) : (item.why || (mock ? item.title : 'No job to be done yet. File it under one below, or leave it.'))),
|
|
668
|
-
chg: evidence, conf: ix.conf || L.conf, cta: L.cta, unsure: ix.unsure || '', ign: ix.ign || '', outboxReason: OUT_REASON,
|
|
669
|
-
opts: L.opts.map((x) => ({ id: x.id, l: x.l, rec: x.rec, fx: x.fx, outward: !!x.outward })), why: '',
|
|
670
|
-
};
|
|
671
|
-
const run = {}; L.opts.forEach((x) => { if (x.run) run[x.id] = x.run; });
|
|
672
|
-
/* the agent's suggested move (mock rows): a recommended first option, and the run's result once it has run */
|
|
673
|
-
const rs = inst.runs.get(item.id);
|
|
674
|
-
if (mock && item.agent_move && ix.move) {
|
|
675
|
-
if (rs && rs.phase === 'work') { model.opts = []; model.move = ''; }
|
|
676
|
-
else if (rs && rs.phase === 'done') {
|
|
677
|
-
const res = (ix[rs.intent] && ix[rs.intent].h ? ix[rs.intent] : (ix.res || {}));
|
|
678
|
-
model.move = ''; model.quote = res.draft || ''; model.sit = res.h || model.sit;
|
|
679
|
-
model.chg = (res.claims || []).map(([label, text]) => ({ label, text }));
|
|
680
|
-
model.conf = 80; model.unsure = ''; model.ign = res.draft ? 'It stays a draft and the item waits.' : '';
|
|
681
|
-
const keep = { id: 'keep', l: res.draft ? 'Keep it as a draft' : 'Keep the result and decide later', rec: 0, fx: [fx('check', 'Nothing leaves the repo', 'ok')] };
|
|
682
|
-
model.opts = res.draft
|
|
683
|
-
? [{ id: 'send', l: 'Send exactly this text to ' + res.out, rec: 1, outward: true, fx: [fx('lock', 'Outward: bound to this exact text', 'warn'), fx('out', 'Goes to ' + res.out, 'warn')] }, keep]
|
|
684
|
-
: [{ id: 'accept', l: 'Accept the result', rec: 1, fx: [fx('check', 'Recorded as your acceptance', 'ok')] }, keep];
|
|
685
|
-
model.cta = res.draft ? 'Slide to send' : 'Slide to accept';
|
|
686
|
-
run.accept = (r) => doneAct(inst, item, r, 'Accepted. Recorded as your press.');
|
|
687
|
-
run.keep = () => say({ text: 'Kept.', timeout: 2500 });
|
|
688
|
-
} else {
|
|
689
|
-
model.move = ix.move + ' · swipe right, or slide below';
|
|
690
|
-
model.opts = [{ id: 'agmv', l: 'Let the agent act: ' + ix.move, rec: 1, fx: [fx('spark', 'The suggested move, taken by an agent', 'ok'), fx('shield', 'Inside the repo; outward only as a draft', 'ok')] }, ...model.opts.map((x) => ({ ...x, rec: 0 }))];
|
|
691
|
-
model.cta = 'Slide to let the agent act';
|
|
692
|
-
run.agmv = () => { say({ text: 'The agent is working on it. Anything outward stays a draft for your slide.', timeout: 4000 }); startRun(inst, item, 'res'); }; // the toast is the case's slide; a swipe starts the run without one, as the mockup does
|
|
693
|
-
}
|
|
694
|
-
}
|
|
695
|
-
return { model, run };
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
/* The agent run (mock): nothing runs. A strip walks the steps of the move, then the result is a labelled draft for the PM to read. */
|
|
699
|
-
function startRun(inst, item, intent) {
|
|
700
|
-
if (inst.runs.get(item.id) && inst.runs.get(item.id).phase === 'work') { say({ text: 'A session is already working on this.', timeout: 2500 }); return; }
|
|
701
|
-
const ix = item.ix || {}; const steps = (ix.steps && ix.steps.length ? ix.steps : ['Reading the item']).slice();
|
|
702
|
-
const st = { phase: 'work', i: 0, steps, intent };
|
|
703
|
-
inst.runs.set(item.id, st); inst.trays.delete(item.id); inst.opens.add(item.id);
|
|
704
|
-
draw(inst);
|
|
705
|
-
const tick = () => {
|
|
706
|
-
if (inst.runs.get(item.id) !== st) return;
|
|
707
|
-
st.i += 1;
|
|
708
|
-
if (st.i >= steps.length) { st.phase = 'done'; draw(inst); return; }
|
|
709
|
-
draw(inst); later(inst, tick, 800);
|
|
710
|
-
};
|
|
711
|
-
later(inst, tick, 800);
|
|
712
|
-
}
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
/* ── the agent on a Jira, WBS or morning-brief item (initiative c3-work-agent, planning/prd/c3-work-agent-prd.md) ────────
|
|
716
|
-
* item.agent = { state: suggest|queued|working|ready|sending|sent|failed, suggest, instruction, draft: { summary, body }, sent, error, … }
|
|
717
|
-
* from lib/work-assigned.js. The suggestion is an option the PM picks; the day task does the work; nothing goes outward
|
|
718
|
-
* until the PM holds Post (POST /api/my-work/decide approve). Stop ends a task that has not delivered (POST /api/my-work/stop). */
|
|
719
|
-
const AGENT_BUSY = ['queued', 'working', 'sending'];
|
|
720
|
-
const AGENT_POLL_MS = 15000;
|
|
721
|
-
const hhmm = (iso) => { const d = new Date(iso); return Number.isNaN(d.getTime()) ? '' : String(d.getHours()).padStart(2, '0') + ':' + String(d.getMinutes()).padStart(2, '0'); };
|
|
722
|
-
const minsAgo = (iso) => { const t = Date.parse(iso); if (!Number.isFinite(t)) return ''; const m = Math.max(0, Math.round((Date.now() - t) / 60000)); return m < 1 ? 'just now' : m < 60 ? m + ' min ago' : Math.floor(m / 60) + ' h ago'; };
|
|
723
|
-
// where a post goes: Jira for a ticket; for an item the morning brief suggests, the place it came from (amendment 10)
|
|
724
|
-
const PLACE = { mail: 'email', slack: 'Slack', jira: 'Jira', confluence: 'Confluence', github: 'GitHub', drive: 'Drive', figma: 'Figma', calendar: 'the calendar', wispr: 'Wispr' };
|
|
725
|
-
const isMine = (item) => item.source === 'local' && !item.origin; // an item the PM added in Work (amendment 11): no place to post to
|
|
726
|
-
const whereOf = (item) => (item.origin === 'jira' ? 'Jira' : isMine(item) ? 'anyone' : PLACE[item.place] || 'its source');
|
|
727
|
-
const AG = {
|
|
728
|
-
can: (t) => 'Agent can: ' + t, queued: 'Agent: queued', working: (ago) => 'Agent: working' + (ago ? ' · started ' + ago : ''), ready: 'Agent: draft ready',
|
|
729
|
-
sending: 'Agent: posting', sent: (w, at) => 'Posted to ' + w + (at ? ' ' + at : ''), failed: (asks) => (asks ? 'Agent: needs you' : 'Agent stopped'),
|
|
730
|
-
sitSuggest: (w) => `The agent can draft this for you. You read it here first. Nothing goes to ${w} until you post it.`,
|
|
731
|
-
canMine: 'Agent can draft a first version',
|
|
732
|
-
sitMine: 'The agent can draft a first version of this for you. You read it here. Nothing leaves PMOS.',
|
|
733
|
-
handedMine: 'Handed to the agent. Its draft stays here in PMOS.', keptMine: 'Kept. The draft stays on this item.',
|
|
734
|
-
sitQueued: 'Queued. The agent starts as soon as a session is free. You can close this page.',
|
|
735
|
-
sitWorking: 'The agent is working on it. You can close this page: the item keeps its state.',
|
|
736
|
-
sitReady: (at, w) => `Draft ready${at ? ' at ' + at : ''}. Nothing went to ${w}.`,
|
|
737
|
-
sitSending: (k) => `Posting to ${k}. A session does exactly the step you approved and nothing else.`,
|
|
738
|
-
sitSent: (at, w) => `You posted it to ${w}${at ? ' at ' + at : ''}.`,
|
|
739
|
-
sitFailed: (why, asks) => (asks && why ? why.charAt(0).toUpperCase() + why.slice(1) + ' Nothing was sent.' : `The agent stopped${why ? ': ' + why : '.'} Nothing was sent.`),
|
|
740
|
-
openSession: 'Open the session',
|
|
741
|
-
willDo: 'What the agent will do: ', change: 'Change what the agent does', askLabel: 'What the agent will do',
|
|
742
|
-
draftIt: 'Let the agent draft this', tryAgain: 'Try again', post: (k) => 'Post it to ' + k, back: 'Send it back with a note', keepDraft: 'Keep it as a draft',
|
|
743
|
-
sitRedraft: (w) => `The agent is redrafting with your note. Nothing went to ${w}.`, sitRedraftMine: 'The agent is redrafting with your note. The draft stays here in PMOS.',
|
|
744
|
-
orDecide: 'Or decide', conv: 'Conversation with the agent', show: 'Show', hide: 'Hide', showAll: 'Show all', showLess: 'Show less', open: 'Open', copy: 'Copy', copied: 'Copied.',
|
|
745
|
-
send: 'Send to the agent', replyWhat: (w) => `The agent drafts it again. ${w ? `Nothing goes to ${w} or to anyone.` : 'Nothing leaves PMOS.'}`,
|
|
746
|
-
theDraft: 'the draft above', beingRedrafted: 'being redrafted',
|
|
747
|
-
round: (n) => 'Agent draft, round ' + n, yours: 'Edited by you', viewRound: (n) => 'View round ' + n, viewEdit: 'View your edit',
|
|
748
|
-
noteLabel: 'Tell the agent what to change', openDraft: 'Open the draft', editDraft: 'Edit the draft', edited: 'Edited by you. Post sends your text.',
|
|
749
|
-
savedDraft: (w) => `Saved. Post sends your text to ${w}.`, savedMine: 'Saved. The draft stays here.',
|
|
750
|
-
doneIt: 'Mark it done', doneFx: 'Closes the item. Nothing is posted', doneToast: 'Done. Nothing was posted.', draftSheet: (k) => 'Draft for ' + k, stop: 'stop',
|
|
751
|
-
handed: (w) => `Handed to the agent. Nothing goes to ${w} until you post it.`, stopped: 'Stopped. Nothing was kept.', kept: 'Kept as a draft. Post it when you are ready.',
|
|
752
|
-
posting: 'Approved. A session posts exactly this text.', sentBack: 'Sent back with your note. The agent drafts it again.', retried: 'The agent tries again.',
|
|
753
|
-
needNote: 'Say what to change first: type a note, then send it back.', link: 'Open what was posted',
|
|
754
|
-
// a draft that names one step in another system (amendment 17): approving it starts a session with Claude in Chrome
|
|
755
|
-
doIt: (s) => 'Do it: ' + s, stepLine: 'Step when you approve: ', stepFx1: 'Outward: this one step, as you', stepFx2: 'A new session with Chrome does only this',
|
|
756
|
-
doing: 'Approved. A session with Chrome does exactly this step.', sitStepReady: (at) => `Draft ready${at ? ' at ' + at : ''}. The step has not run.`,
|
|
757
|
-
sitStepping: 'Doing the step you approved. A session with Chrome does exactly that step and nothing else.',
|
|
758
|
-
stepping: 'Agent: doing the step', stepDone: 'Agent: step done', sitStepDone: (at) => `The agent did the step you approved${at ? ' at ' + at : ''}.`, stepLink: 'Open what it made',
|
|
759
|
-
};
|
|
760
|
-
|
|
761
|
-
function agentChip(item) {
|
|
762
|
-
const a = item.agent; if (!a || item.mock_row) return null;
|
|
763
|
-
const st = (cls, ic, text, spin) => el('span', { class: cls + ' wk-agent-st', 'data-pm-agent-state': a.state, 'data-pm-suggest': item.id, title: text }, spin ? el('span', { class: 'c3spin' }, c3ic(ic, 'sm')) : c3ic(ic, 'sm'), el('span', { class: 'wk-agent-tx' }, text));
|
|
764
|
-
if (a.state === 'suggest') return st('chip2', 'spark', isMine(item) ? AG.canMine : AG.can(a.instruction || a.suggest || ''));
|
|
765
|
-
if (a.state === 'queued') return st('st', 'clock', AG.queued);
|
|
766
|
-
if (a.state === 'working') return st('st c3strip', 'spark', AG.working(minsAgo(a.started_at)), true);
|
|
767
|
-
if (a.state === 'ready') return st('st ok', 'check', AG.ready);
|
|
768
|
-
const step = a.draft && a.draft.step;
|
|
769
|
-
if (a.state === 'sending') return st('st c3strip', 'out', step ? AG.stepping : AG.sending, true);
|
|
770
|
-
if (a.state === 'sent') return st('st ok', 'out', step ? AG.stepDone : AG.sent(whereOf(item), a.sent && a.sent.at ? hhmm(a.sent.at) : ''));
|
|
771
|
-
if (a.state === 'failed') return st('tag warn', 'alert', AG.failed(a.asks));
|
|
772
|
-
return null;
|
|
773
|
-
}
|
|
774
|
-
|
|
775
|
-
async function agentPress(inst, path, body, text) {
|
|
776
|
-
const r = await pmPost(path, body);
|
|
777
|
-
if (!r || !r.ok) { say({ text: (r && r.error) || COPY.saveError, tone: 'error' }); return false; }
|
|
778
|
-
inst.picks.delete(body.item);
|
|
779
|
-
say({ text, timeout: 4000 });
|
|
780
|
-
await load(inst);
|
|
781
|
-
return true;
|
|
782
|
-
}
|
|
783
|
-
|
|
784
|
-
function agentCase(inst, item, L) {
|
|
785
|
-
const a = item.agent; const w = whereOf(item); const k = item.key || (item.origin === 'brief' ? w : item.title);
|
|
786
|
-
const o = (id, l, f, run, extra) => ({ id, l, rec: 0, fx: f, run, ...(extra || {}) });
|
|
787
|
-
const own = L.opts.slice(0, 2).map((x) => ({ ...x, rec: 0 }));
|
|
788
|
-
const ask = () => inst.asks.get(item.id) || a.instruction || a.suggest || '';
|
|
789
|
-
let sit = ''; let opts = []; const quote = ''; const chg = []; let outbox = false; let cta = ''; let agentAsk = null; let before = null;
|
|
790
|
-
const extras = [];
|
|
791
|
-
const strip = (spin, ic, text) => el('div', { class: 'c3ag', 'data-pm-agent-strip': item.id }, el('div', { class: 'fold a', role: 'status' }, spin ? el('span', { class: 'c3spin' }, c3ic(ic, 'sm')) : c3ic(ic, 'sm'), ' ' + text + ' ',
|
|
792
|
-
c3btn('chip2 lk', { 'data-pm-agent-stop': item.id }, [c3ic('stop', 'sm'), AG.stop], () => agentPress(inst, '/api/my-work/stop', { item: item.id }, AG.stopped))));
|
|
793
|
-
if (a.state === 'suggest' || a.state === 'failed') {
|
|
794
|
-
sit = a.state === 'failed' ? AG.sitFailed(a.error, a.asks) : isMine(item) ? AG.sitMine : AG.sitSuggest(w);
|
|
795
|
-
if (a.state === 'failed' && a.session) extras.push(el('div', { class: 'chips2' }, c3btn('chip2 lk', { 'data-pm-agent-session': a.session }, [c3ic('term', 'sm'), AG.openSession], () => openAgentSession(a.session, item))));
|
|
796
|
-
const brief = () => agentPress(inst, '/api/my-work/act', { action: 'brief', item: item.id, instruction: ask(), ws: inst.ctx.ws }, isMine(item) ? AG.handedMine : AG.handed(w));
|
|
797
|
-
const retry = () => agentPress(inst, '/api/my-work/decide', { item: item.id, action: 'retry' }, AG.retried);
|
|
798
|
-
opts = [o('agent', a.state === 'failed' ? AG.tryAgain : AG.draftIt, [fx('spark', 'Drafts it here in PMOS', 'ok'), fx('lock', 'Nothing goes to ' + w, 'ok')], a.state === 'failed' ? retry : brief), ...own];
|
|
799
|
-
cta = 'Slide to let the agent draft';
|
|
800
|
-
if (a.state === 'suggest') {
|
|
801
|
-
const editing = inst.editing.has('ask:' + item.id);
|
|
802
|
-
const input = el('input', { type: 'text', value: ask(), 'aria-label': AG.askLabel, 'data-pm-agent-ask': item.id, autocomplete: 'off' });
|
|
803
|
-
const save = () => { const v = input.value.trim(); if (v) inst.asks.set(item.id, v); inst.editing.delete('ask:' + item.id); draw(inst); };
|
|
804
|
-
input.addEventListener('keydown', (e) => { if (e.key === 'Enter' && !e.isComposing) save(); });
|
|
805
|
-
extras.push(el('div', { class: 'c3ag', 'data-pm-agent-will': item.id }, el('div', { class: 'dim mono wk-agent-will' }, c3ic('spark', 'sm'), ' ' + AG.willDo + (editing ? '' : ask())),
|
|
806
|
-
editing ? el('div', { class: 'form wk-agent-ask' }, input, button({ label: COPY.save, variant: 'outline', size: 'sm', onClick: save })) : null));
|
|
807
|
-
if (!editing) agentAsk = c3btn('chip2 lk', { 'data-pm-agent-change': item.id }, [c3ic('edit', 'sm'), AG.change], () => { inst.editing.add('ask:' + item.id); draw(inst); });
|
|
808
|
-
}
|
|
809
|
-
} else if (a.state === 'queued' || a.state === 'working') {
|
|
810
|
-
// a redraft after the PM's note shows the draft and the conversation above the strip (amendment 15)
|
|
811
|
-
const redraft = !!(a.draft && a.draft.body);
|
|
812
|
-
sit = redraft ? (isMine(item) ? AG.sitRedraftMine : AG.sitRedraft(w)) : a.state === 'queued' ? AG.sitQueued : AG.sitWorking;
|
|
813
|
-
if (redraft) extras.push(draftCard(inst, item, k, true), conversation(inst, item, true));
|
|
814
|
-
extras.push(a.state === 'queued' ? strip(false, 'clock', 'Queued' + (a.decided_at ? ' at ' + hhmm(a.decided_at) : ''))
|
|
815
|
-
: strip(true, 'spark', (redraft ? 'Redrafting with your note' : 'Working') + (a.started_at ? ' · started ' + minsAgo(a.started_at) : '')));
|
|
816
|
-
} else if (a.state === 'ready') {
|
|
817
|
-
const step = a.draft && a.draft.step;
|
|
818
|
-
sit = step ? AG.sitStepReady('') : AG.sitReady('', w);
|
|
819
|
-
outbox = true; cta = step ? 'Hold to do it' : 'Hold to post';
|
|
820
|
-
const mine = isMine(item);
|
|
821
|
-
opts = [
|
|
822
|
-
// a step in another system replaces the post: the approved send does the step (amendment 17)
|
|
823
|
-
step ? o('step', AG.doIt(step), [fx('lock', AG.stepFx1, 'warn'), fx('out', AG.stepFx2, 'warn')], () => agentPress(inst, '/api/my-work/decide', { item: item.id, action: 'approve' }, AG.doing), { outward: true }) : null,
|
|
824
|
-
mine || step ? null : o('post', AG.post(k), [fx('lock', 'Outward: exactly this text', 'warn'), fx('out', 'Goes to ' + w + ' as you', 'warn')], () => agentPress(inst, '/api/my-work/decide', { item: item.id, action: 'approve' }, AG.posting), { outward: true }),
|
|
825
|
-
mine ? o('done', AG.doneIt, [fx('check', AG.doneFx, 'ok')], (r) => doneAct(inst, item, r, AG.doneToast, undefined, 'agent')) : null,
|
|
826
|
-
o('edit', AG.editDraft, [fx('edit', step ? 'The step then uses your version' : mine ? 'Your version replaces the draft here' : 'Post then sends your version', 'ok')], () => openDraft(item, inst, true)),
|
|
827
|
-
o('keep', AG.keepDraft, [fx('check', 'Nothing leaves PMOS', 'ok')], () => say({ text: mine ? AG.keptMine : AG.kept, timeout: 3000 })),
|
|
828
|
-
mine ? null : o('done', AG.doneIt, [fx('check', AG.doneFx, 'ok')], (r) => doneAct(inst, item, r, AG.doneToast, undefined, 'agent')),
|
|
829
|
-
].filter(Boolean);
|
|
830
|
-
extras.push(draftCard(inst, item, k, false), conversation(inst, item, false, w));
|
|
831
|
-
before = el('div', { class: 'wk-conv-h', 'data-pm-agent-decide': item.id }, el('span', { class: 'dim mono' }, c3ic('check', 'sm'), AG.orDecide));
|
|
832
|
-
} else if (a.state === 'sending') {
|
|
833
|
-
sit = a.draft && a.draft.step ? AG.sitStepping : AG.sitSending(k);
|
|
834
|
-
if (a.draft && a.draft.body) extras.push(draftCard(inst, item, k, false), conversation(inst, item, false));
|
|
835
|
-
} else if (a.state === 'sent') {
|
|
836
|
-
sit = a.draft && a.draft.step ? AG.sitStepDone(a.sent && a.sent.at ? hhmm(a.sent.at) : '') : AG.sitSent(a.sent && a.sent.at ? hhmm(a.sent.at) : '', w);
|
|
837
|
-
opts = L.opts.map((x) => ({ ...x }));
|
|
838
|
-
if (a.draft && a.draft.body) extras.push(draftCard(inst, item, k, false), conversation(inst, item, false));
|
|
839
|
-
if (a.sent && a.sent.link) extras.push(el('div', { class: 'chips2' }, el('a', { class: 'chip2 lk', href: a.sent.link, target: '_blank', rel: 'noopener noreferrer' }, c3ic('out', 'sm'), a.draft && a.draft.step ? AG.stepLink : AG.link)));
|
|
840
|
-
}
|
|
841
|
-
if (opts.length) opts[0].rec = 1;
|
|
842
|
-
const model = { id: 'task:' + item.id, sit, quote, chg, conf: 0, cta, opts: opts.map((x) => ({ id: x.id, l: x.l, rec: x.rec, fx: x.fx, outward: !!x.outward })), why: '', outbox,
|
|
843
|
-
outboxReason: OUT_REASON, agentAsk, agentExtras: () => extras, agentBeforeOpts: before };
|
|
844
|
-
const run = {}; opts.forEach((x) => { if (x.run) run[x.id] = x.run; });
|
|
845
|
-
return { model, run };
|
|
846
|
-
}
|
|
847
|
-
|
|
848
|
-
/* ── the draft and the conversation with the agent (c3-work-agent amendment 15, mockup "Agent Draft Conversation") ──────── */
|
|
849
|
-
|
|
850
|
-
/** The turns on an item's task, oldest first: the PM's ask, then the log (drafts, notes, edits, the post). A task from before
|
|
851
|
-
* the log has its current draft only. Each draft or edit carries its round label and body. */
|
|
852
|
-
function turnsOf(item) {
|
|
853
|
-
const a = item.agent || {}; const d = a.draft || {};
|
|
854
|
-
let log = Array.isArray(a.log) && a.log.length ? a.log.slice() : d.body ? [{ who: 'agent', kind: 'draft', at: null, text: d.summary || '', body: d.body }] : [];
|
|
855
|
-
// an edit made before the log, or the draft body that the log does not hold: the current text is the last version
|
|
856
|
-
const last = [...log].reverse().find((t) => t.body);
|
|
857
|
-
if (d.body && last && last.body !== d.body) log.push({ who: 'pm', kind: 'edit', at: d.edited_at || null, body: d.body });
|
|
858
|
-
const ask = a.instruction || a.suggest || '';
|
|
859
|
-
const out = ask ? [{ who: 'pm', kind: 'ask', at: null, text: ask }] : [];
|
|
860
|
-
let round = 0;
|
|
861
|
-
for (const t of log) out.push(t.body ? { ...t, label: t.who === 'agent' ? AG.round(++round) : AG.yours, round: t.who === 'agent' ? round : 0 } : t);
|
|
862
|
-
return out;
|
|
863
|
-
}
|
|
864
|
-
|
|
865
|
-
const copyText = (text) => { try { navigator.clipboard.writeText(String(text || '')).then(() => say({ text: AG.copied, timeout: 2000 }), () => {}); } catch { /* no clipboard */ } };
|
|
866
|
-
|
|
867
|
-
/** The draft as a document card: what it is, which version, Open and Copy, the document clipped with Show all. */
|
|
868
|
-
function draftCard(inst, item, k, busy) {
|
|
869
|
-
const a = item.agent; const d = a.draft || {};
|
|
870
|
-
const cur = [...turnsOf(item)].reverse().find((t) => t.body) || { label: AG.round(1), at: d.at || null };
|
|
871
|
-
const all = inst.editing.has('all:' + item.id);
|
|
872
|
-
const long = String(d.body || '').length > 900 || String(d.body || '').split('\n').length > 16;
|
|
873
|
-
const body = el('div', { class: 'ds-md wk-agent-md' + (long && !all ? ' wk-doc-clip' : ''), 'data-pm-agent-doc-body': item.id }, toDom(parseMd(String(d.body || '')), document));
|
|
874
|
-
return el('section', { class: 'card wk-doc', 'data-pm-agent-doc': item.id, 'aria-label': 'The draft' },
|
|
875
|
-
el('div', { class: 'wk-doc-h' },
|
|
876
|
-
el('div', { class: 'chips' }, el('span', { class: 'tag' }, a.state === 'sent' ? 'posted' : 'draft'), busy ? el('span', { class: 'tag' }, AG.beingRedrafted) : null,
|
|
877
|
-
el('b', { class: 'wk-doc-to' }, isMine(item) ? 'Draft for you' : AG.draftSheet(k)),
|
|
878
|
-
el('span', { class: 'chip2', 'data-pm-agent-version': item.id }, c3ic(cur.kind === 'edit' ? 'edit' : 'spark', 'sm'), cur.label + (cur.at ? ' · ' + hhmm(cur.at) : ''))),
|
|
879
|
-
el('div', { class: 'chips2' }, c3btn('chip2 lk', { 'data-pm-agent-draft': item.id }, [c3ic('eye', 'sm'), AG.open], () => openDraft(item, inst)),
|
|
880
|
-
c3btn('chip2 lk', { 'data-pm-agent-copy': item.id }, [c3ic('copy', 'sm'), AG.copy], () => copyText(d.body)))),
|
|
881
|
-
d.step ? el('div', { class: 'dim mono wk-agent-will', 'data-pm-agent-step': item.id }, c3ic('out', 'sm'), ' ' + AG.stepLine + d.step) : null,
|
|
882
|
-
body,
|
|
883
|
-
long ? c3btn('chip2 lk', { 'data-pm-agent-all': item.id, 'aria-expanded': String(all) }, [c3ic(all ? 'zout' : 'zin', 'sm'), all ? AG.showLess : AG.showAll],
|
|
884
|
-
() => { if (all) inst.editing.delete('all:' + item.id); else inst.editing.add('all:' + item.id); draw(inst); }) : null);
|
|
885
|
-
}
|
|
886
|
-
|
|
887
|
-
/** The conversation: one line per turn, then the reply box that sends the draft back (only while a draft waits). */
|
|
888
|
-
function conversation(inst, item, busy, w) {
|
|
889
|
-
const a = item.agent; const turns = turnsOf(item); const n = turns.length;
|
|
890
|
-
const only = n <= 2 && !busy; const show = !only || inst.editing.has('thr:' + item.id);
|
|
891
|
-
const cur = [...turns].reverse().find((t) => t.body);
|
|
892
|
-
const lead = { ask: isMine(item) ? 'added' : 'asked', note: 'sent it back', edit: 'edited the draft', post: 'posted it' };
|
|
893
|
-
const line = (t) => {
|
|
894
|
-
const you = t.who !== 'agent';
|
|
895
|
-
const text = t.kind === 'note' ? el('blockquote', { class: 'qd' }, t.text || '') : t.kind === 'draft' ? el('p', null, t.text || 'Drafted it') : t.kind === 'ask' ? el('p', null, t.text) : null;
|
|
896
|
-
const ver = !t.body ? null : t === cur ? el('span', { class: 'tag' }, a.state === 'sent' ? 'posted' : AG.theDraft)
|
|
897
|
-
: c3btn('chip2 lk', { 'data-pm-agent-round': String(t.round || 0) }, [c3ic('eye', 'sm'), t.kind === 'edit' ? AG.viewEdit : AG.viewRound(t.round)], () => openDraft(item, inst, false, t));
|
|
898
|
-
return el('li', { class: you ? 'you' : 'ag' }, c3ic(you ? 'user' : 'spark', 'sm'),
|
|
899
|
-
el('div', { class: 'wk-turn' }, el('div', { class: 'wk-who' }, el('b', null, you ? 'You' : 'Agent'), el('span', { class: 'dim mono' }, [t.at ? hhmm(t.at) : '', lead[t.kind] || ''].filter(Boolean).join(' · '))),
|
|
900
|
-
text, ver ? el('div', { class: 'chips2' }, ver) : null));
|
|
901
|
-
};
|
|
902
|
-
const head = el('div', { class: 'wk-conv-h' }, el('span', { class: 'dim mono' }, c3ic('reply', 'sm'), AG.conv), el('span', { class: 'tag' }, String(n)),
|
|
903
|
-
only ? c3btn('chip2 lk', { 'data-pm-agent-thread': item.id, 'aria-expanded': String(show) }, [c3ic(show ? 'zout' : 'zin', 'sm'), show ? AG.hide : AG.show],
|
|
904
|
-
() => { if (show) inst.editing.delete('thr:' + item.id); else inst.editing.add('thr:' + item.id); draw(inst); }) : null);
|
|
905
|
-
let reply = null;
|
|
906
|
-
if (a.state === 'ready') {
|
|
907
|
-
const ta = el('textarea', { rows: '2', placeholder: AG.noteLabel, 'aria-label': AG.noteLabel, 'data-pm-agent-note-in': item.id });
|
|
908
|
-
ta.value = inst.asks.get('note:' + item.id) || '';
|
|
909
|
-
ta.addEventListener('input', () => inst.asks.set('note:' + item.id, ta.value));
|
|
910
|
-
const send = () => {
|
|
911
|
-
const v = ta.value.trim();
|
|
912
|
-
if (!v) { say({ text: AG.needNote, timeout: 3500 }); ta.focus(); return; }
|
|
913
|
-
inst.asks.delete('note:' + item.id);
|
|
914
|
-
agentPress(inst, '/api/my-work/decide', { item: item.id, action: 'revise', note: v }, AG.sentBack);
|
|
915
|
-
};
|
|
916
|
-
ta.addEventListener('keydown', (e) => { if (e.key === 'Enter' && !e.shiftKey && !e.isComposing) { e.preventDefault(); send(); } });
|
|
917
|
-
reply = el('div', { class: 'wk-reply', 'data-pm-agent-note': item.id }, ta,
|
|
918
|
-
el('div', { class: 'wk-reply-f' }, el('span', { class: 'dim' }, c3ic('lock', 'sm'), ' ' + AG.replyWhat(isMine(item) ? '' : w)),
|
|
919
|
-
button({ label: AG.send, variant: 'primary', size: 'sm', onClick: send, attrs: { 'data-pm-agent-send': item.id } })));
|
|
920
|
-
}
|
|
921
|
-
return el('div', { class: 'wk-conv', 'data-pm-agent-conv': item.id }, head, show ? el('ol', { class: 'chgl wk-thr', role: 'list' }, ...turns.map(line)) : null, reply);
|
|
922
|
-
}
|
|
923
|
-
|
|
924
|
-
function openAgentSession(id, item) {
|
|
925
|
-
try { window.dispatchEvent(new CustomEvent('pmos:open-session', { detail: { id, name: 'Job · ' + (item.key || item.title || '') } })); } catch { /* no event */ }
|
|
926
|
-
}
|
|
927
|
-
|
|
928
|
-
/* The agent's draft drawn the way a document is (c3-md.js, as the document sheet draws it): headings, lists, tables, bold. */
|
|
929
|
-
const draftMd = (text) => el('div', { class: 'ds-md wk-agent-md' }, toDom(parseMd(String(text || '')), document));
|
|
930
|
-
|
|
931
|
-
/* The agent's draft opens in the document sheet, the one every other document opens in (amendment 16): Read with its outline,
|
|
932
|
-
* Edit (Save keeps the PM's text as the draft, so Post sends exactly that text: amendment 13), Proposals (a note sends the draft
|
|
933
|
-
* back to the agent), Edit log (the conversation with the agent) and Health. An earlier version (ver) opens read-only. */
|
|
934
|
-
async function openDraft(item, inst, editing, ver) {
|
|
935
|
-
const a = item.agent || {}; const d = a.draft || {};
|
|
936
|
-
const live = !!inst && a.state === 'ready' && !ver;
|
|
937
|
-
const w = whereOf(item); const mine = isMine(item);
|
|
938
|
-
const what = { ask: mine ? 'added the item' : 'asked', draft: 'drafted it', note: 'sent it back', edit: 'edited the draft', post: 'posted it' };
|
|
939
|
-
const log = turnsOf(item).map((t) => ({ who: t.who === 'agent' ? 'agent' : 'pm', what: (t.body ? t.label + ': ' : '') + (what[t.kind] || t.kind), at: t.at || null, text: t.kind === 'draft' ? t.text : t.kind === 'note' || t.kind === 'ask' ? t.text : '' }));
|
|
940
|
-
const why = ver ? 'This is an earlier version. The draft on the item is the newest one.'
|
|
941
|
-
: a.state === 'sent' ? 'This is the text that was posted. It is kept on the item, not as a file.'
|
|
942
|
-
: 'This draft is kept on the item, not as a file. ' + (mine ? 'It stays here in PMOS.' : 'Nothing is in ' + w + ' yet. Post it from the item, after you read it.');
|
|
943
|
-
const generated = { text: ver ? ver.body || '' : d.body || '', why, log, health: { passed: 0, total: 0, checks: [], err: 'Health checks run on stored documents. This draft is kept on the item.' } };
|
|
944
|
-
if (live) {
|
|
945
|
-
generated.save = async (text) => {
|
|
946
|
-
const v = String(text || '').trim();
|
|
947
|
-
if (!v) return { ok: false, error: 'The draft cannot be empty. Send it back with a note instead.' };
|
|
948
|
-
const r = await pmPost('/api/my-work/decide', { item: item.id, action: 'edit', body: v });
|
|
949
|
-
if (r && r.ok) load(inst);
|
|
950
|
-
return r || { ok: false, error: COPY.saveError };
|
|
951
|
-
};
|
|
952
|
-
generated.saved = mine ? AG.savedMine : AG.savedDraft(w);
|
|
953
|
-
generated.ask = async (note) => {
|
|
954
|
-
const r = await pmPost('/api/my-work/decide', { item: item.id, action: 'revise', note });
|
|
955
|
-
if (r && r.ok) { say({ text: AG.sentBack, timeout: 3500 }); load(inst); }
|
|
956
|
-
return r || { ok: false, error: COPY.saveError };
|
|
957
|
-
};
|
|
958
|
-
generated.askWhy = 'The agent drafts it again with your note, on the item. ' + AG.replyWhat(mine ? '' : w);
|
|
959
|
-
}
|
|
960
|
-
const title = (ver ? ver.label + (ver.at ? ' · ' + hhmm(ver.at) : '') + ' · ' : '') + (mine ? 'Draft: ' + (item.title || '') : AG.draftSheet(item.key || item.title));
|
|
961
|
-
const relations = () => el('ul', { class: 'ds-rel', 'data-pm-agent-rel': item.id }, el('li', null, c3ic(item.url ? 'out' : 'doc', 'sm'),
|
|
962
|
-
item.url ? el('a', { class: 'ds-rlk', href: item.url, target: '_blank', rel: 'noopener noreferrer' }, item.key || item.title, el('small', null, 'the item this draft is for')) : el('span', { class: 'ds-rlk' }, item.title || '', el('small', null, 'the item this draft is for'))));
|
|
963
|
-
const { openDocSheet } = await import('./c3-doc-sheet.js');
|
|
964
|
-
return openDocSheet({ ws: inst && inst.ctx ? inst.ctx.ws : '', doc: { path: '', name: title, ty: 'Draft', v: ver ? '' : (d.edited_at ? 'edited by you' : ''), st: a.state === 'sent' ? 'issued' : 'draft', ini: '', iniName: mine ? 'Work' : w },
|
|
965
|
-
mode: editing && live ? 'edit' : 'read', generated, relations });
|
|
966
|
-
}
|
|
967
|
-
|
|
968
|
-
/** The case file element of an item: c3-case.js plus what is Work's own (offline work, the shared actions, the steps, the agent tray, the edit fields). */
|
|
969
|
-
function caseFile(inst, item, lens) {
|
|
970
|
-
const { model, run } = itemCase(inst, item, lens);
|
|
971
|
-
const root = renderCase(model, {
|
|
972
|
-
picked: inst.picks.get(item.id), outbox: !!model.outbox, noConf: !item.mock_row,
|
|
973
|
-
renderQuote: item.agent && !item.mock_row ? draftMd : undefined,
|
|
974
|
-
onPick: (id) => { inst.picks.set(item.id, id); },
|
|
975
|
-
onConfirm: ({ option }) => {
|
|
976
|
-
const fn = run[option.id];
|
|
977
|
-
if (fn) fn(rowOf(inst, item));
|
|
978
|
-
},
|
|
979
|
-
});
|
|
980
|
-
root.setAttribute('data-pm-case', item.id);
|
|
981
|
-
const extras = [];
|
|
982
|
-
const rs = inst.runs.get(item.id);
|
|
983
|
-
const agent = item.mock_row && item.agent_move && (item.ix || {}).move;
|
|
984
|
-
if (item.kind === 'offline') extras.push(offlineBlock(inst, item));
|
|
985
|
-
if (model.agentExtras) extras.push(...model.agentExtras());
|
|
986
|
-
if (model.agentBeforeOpts) { const op = root.querySelector('.opts'); if (op) op.before(model.agentBeforeOpts); }
|
|
987
|
-
if (item.agent && !item.mock_row && ['ready', 'sending', 'sent', 'queued', 'working'].includes(item.agent.state)) root.classList.add('wk-ag');
|
|
988
|
-
if (rs && rs.phase === 'work') {
|
|
989
|
-
extras.push(el('div', { class: 'c3ag', 'data-ag': item.id }, el('div', { class: 'fold a', role: 'status' }, el('span', { class: 'c3spin' }, c3ic('spark', 'sm')), rs.steps[Math.min(rs.i, rs.steps.length - 1)] + ' · ' + (Math.min(rs.i, rs.steps.length - 1) + 1) + ' of ' + rs.steps.length,
|
|
990
|
-
el('button', { type: 'button', class: 'chip2 lk', 'data-pm-agent-stop': item.id, onclick: () => { inst.runs.delete(item.id); say({ text: 'Stopped. Nothing was kept.', timeout: 2500 }); draw(inst); } }, c3ic('stop', 'sm'), 'stop'))));
|
|
991
|
-
} else if (rs && rs.phase === 'done') {
|
|
992
|
-
extras.push(el('div', { class: 'chips2' }, el('button', { type: 'button', class: 'chip2 lk', 'data-pm-agent-discard': item.id, onclick: () => { inst.runs.delete(item.id); inst.picks.delete(item.id); draw(inst); } }, c3ic('undo', 'sm'), 'discard the run')));
|
|
993
|
-
}
|
|
994
|
-
if (inst.trays.has(item.id) && agent && !rs) {
|
|
995
|
-
const ch = (label, intent) => el('button', { type: 'button', class: 'pill', 'data-pm-agent-chip': intent, onclick: () => { inst.trays.delete(item.id); startRun(inst, item, intent); } }, label);
|
|
996
|
-
const input = el('input', { type: 'text', placeholder: 'Reply to the agent…', 'aria-label': 'Reply to the agent', autocomplete: 'off', 'data-pm-agent-reply': item.id });
|
|
997
|
-
input.addEventListener('keydown', (e) => { if (e.key === 'Enter' && input.value.trim()) { inst.trays.delete(item.id); startRun(inst, item, 'res'); } });
|
|
998
|
-
extras.push(el('div', { class: 'chips2', 'data-pm-tray': item.id }, ch('Ask for evidence', 'ev'), ch('Show other options', 'res'), el('span', { class: 'form', style: 'flex:1;min-width:160px' }, input),
|
|
999
|
-
c3ib('Speak is off on this line: nothing on this page records. Type the reply here.', 'mic', { 'data-off': '', onclick: () => say({ text: 'The microphone needs the app. Nothing was recorded: type the reply here.', timeout: 4200 }) }, 'sm'),
|
|
1000
|
-
c3ib('Close the reply', 'x', { onClick: () => { inst.trays.delete(item.id); draw(inst); } }, 'sm')));
|
|
1001
|
-
}
|
|
1002
|
-
const showSteps = !(rs && rs.phase) && item.kind !== 'offline' && !(item.agent && !item.mock_row && item.agent.state !== 'sent' && !isMine(item) && !(item.steps || []).length) && (inst.planning.has(item.id) || (item.steps || []).length || (!agent && (!item.mock_row || item.src === 'You')));
|
|
1003
|
-
if (showSteps) extras.push(stepsBlock(inst, item));
|
|
1004
|
-
const anchor = root.querySelector('.c3ag') || root.querySelector('.sit');
|
|
1005
|
-
if (anchor) anchor.after(...extras); else root.prepend(...extras);
|
|
1006
|
-
root.append(quickActs(inst, item, { noDrop: item.kind === 'offline' }));
|
|
1007
|
-
/* the editable fields stay in the case file behind an Edit button (title, due, not before, priority, waiting on, job) */
|
|
1008
|
-
const form = editForm(inst, item); form.hidden = !inst.editing.has(item.id);
|
|
1009
|
-
const edit = el('button', { type: 'button', class: 'chip2 lk', 'aria-expanded': String(inst.editing.has(item.id)), 'data-pm-edit-toggle': item.id,
|
|
1010
|
-
onclick: () => { const on = !inst.editing.has(item.id); if (on) inst.editing.add(item.id); else inst.editing.delete(item.id); form.hidden = !on; edit.setAttribute('aria-expanded', String(on)); } }, c3ic('edit', 'sm'), 'Edit details');
|
|
1011
|
-
const ft = root.querySelector('.cft') || root.appendChild(el('div', { class: 'cft' }));
|
|
1012
|
-
if (model.agentAsk) ft.append(model.agentAsk);
|
|
1013
|
-
ft.append(edit);
|
|
1014
|
-
root.append(form);
|
|
1015
|
-
return root;
|
|
1016
|
-
}
|
|
1017
|
-
|
|
1018
|
-
/* ── swipe: the mockup's workSwipe (console3.html line 3250) and the agent's swapped glyphs (line 5136) ─────────────────────── */
|
|
1019
|
-
|
|
1020
|
-
function swipeSpec(inst, item, lens) {
|
|
1021
|
-
const mock = item.mock_row === true; const today = inst.data.today;
|
|
1022
|
-
if (mock && item.agent_move && (item.ix || {}).move) {
|
|
1023
|
-
return {
|
|
1024
|
-
right: { label: 'Agent acts', icon: 'spark', fn: () => startRun(inst, item, 'res') },
|
|
1025
|
-
left: { label: 'Reply', icon: 'reply', fn: () => { if (inst.runs.get(item.id) && inst.runs.get(item.id).phase === 'work') { say({ text: 'A session is already working on this.', timeout: 2500 }); return; } inst.trays.add(item.id); inst.opens.add(item.id); draw(inst); later(inst, () => { const i = inst.root.querySelector('[data-pm-agent-reply="' + item.id + '"]'); if (i) i.focus(); }, 30); } },
|
|
1026
|
-
};
|
|
1027
|
-
}
|
|
1028
|
-
const someday = { label: 'Someday', icon: 'moon', fn: (r) => somedayAct(inst, item, r) };
|
|
1029
|
-
const inToday = { label: 'In Today', icon: 'sun', fn: (r) => todayAct(inst, item, r) };
|
|
1030
|
-
if (lens === 'inbox' || lens === 'upcoming') return { right: inToday, left: someday };
|
|
1031
|
-
if (lens === 'today') return { right: { label: 'Done', icon: 'check', fn: (r) => doneAct(inst, item, r, 'Done.') },
|
|
1032
|
-
left: item.kind === 'offline' ? { label: 'Not yet', icon: 'moon', fn: (r) => notYetAct(inst, item, r, 'tomorrow') } : { label: 'Tomorrow', icon: 'moon', fn: (r) => deferAct(inst, item, r, addIso(today, 1)) } };
|
|
1033
|
-
if (lens === 'waiting') return {
|
|
1034
|
-
right: { label: 'Nudge', icon: 'out', fn: () => say({ text: 'No channel connected: a nudge to ' + (item.waiting_on || 'them') + ' is not sent.', timeout: 4000 }) },
|
|
1035
|
-
left: { label: 'Keep waiting', icon: 'wait', fn: () => say({ text: 'Still waiting.', timeout: 2500 }) } };
|
|
1036
|
-
return { right: { label: 'Bring back', icon: 'sun', fn: (r) => unparkAct(inst, item, r) }, left: { label: 'Drop', icon: 'trash', fn: (r) => dropAct(inst, item, r) } };
|
|
1037
|
-
}
|
|
1038
|
-
|
|
1039
|
-
/* Open or close a case file in place with c3-expand.js, so the mockup's .xp height transition (grid-template-rows) plays. */
|
|
1040
|
-
function expandRow(inst, row, key, build, onClose) {
|
|
1041
|
-
const xp = makeXp();
|
|
1042
|
-
const xi = xp.firstChild;
|
|
1043
|
-
row.__exp = attachExpand(row, xp, {
|
|
1044
|
-
key, initial: inst.opens.has(key),
|
|
1045
|
-
onToggle: (on) => {
|
|
1046
|
-
if (on) {
|
|
1047
|
-
inst.opens.add(key);
|
|
1048
|
-
const c = build(); inst.cases.add(c); xi.replaceChildren(c);
|
|
1049
|
-
} else {
|
|
1050
|
-
inst.opens.delete(key);
|
|
1051
|
-
later(inst, () => { if (!xp.classList.contains('open')) { xi.querySelectorAll('.case').forEach((c) => { if (c.c3case) { c.c3case.dispose(); inst.cases.delete(c); } }); xi.replaceChildren(); } }, 340);
|
|
1052
|
-
if (onClose) onClose();
|
|
1053
|
-
}
|
|
1054
|
-
},
|
|
1055
|
-
});
|
|
1056
|
-
return xp;
|
|
1057
|
-
}
|
|
1058
|
-
|
|
1059
|
-
const KIND_ICON = { reply: 'reply', decide: 'scale', review: 'eye', do: 'check' }; // the mockup's KIC
|
|
1060
|
-
/* The mockup's time-left bar (.fuse) with its text, for an item that carries `left` ({ text, pct, tone }). */
|
|
1061
|
-
const fuseBar = (l) => { const c = l.tone === 'warn' ? 'var(--warning)' : 'var(--acc)'; return el('div', { class: 'chips2', style: 'margin-top:6px;gap:8px' }, el('div', { class: 'fuse' }, el('i', { style: 'width:' + Math.round(l.pct * 100) + '%;background:' + c })), el('span', { class: 'mono', style: 'font-size:var(--fs-1);color:' + c }, l.text)); };
|
|
1062
|
-
|
|
1063
|
-
/* "yesterday", "7 days ago": how long ago a day was (the mockup's ago()). */
|
|
1064
|
-
const ago = (from, today) => { const n = daysBetween(from, today); return n <= 0 ? 'today' : n === 1 ? 'yesterday' : n + ' days ago'; };
|
|
1065
|
-
|
|
1066
|
-
/* The due chip of a row (the mockup's dueChip): a tag for overdue and for today, a calendar chip for a later day. */
|
|
1067
|
-
function dueChip(inst, item) {
|
|
1068
|
-
if (!item.due) return null;
|
|
1069
|
-
const today = inst.data.today; const due = String(item.due).slice(0, 10);
|
|
1070
|
-
if (due < today) return el('span', { class: 'tag cal3-tone-bad', 'data-pm-due': 'overdue' }, COPY.overdue(daysBetween(due, today)));
|
|
1071
|
-
if (due === today) return el('span', { class: 'tag cal3-tone-warn', 'data-pm-due': 'today' }, COPY.dueToday + (item.time ? ' ' + item.time : ''));
|
|
1072
|
-
return el('span', { class: 'chip2', 'data-pm-due': 'later' }, c3ic('cal', 'sm'), COPY.dueOn(dayLabel(due)));
|
|
1073
|
-
}
|
|
1074
|
-
|
|
1075
|
-
/* The chips the Work page adds to a row: outside PMOS and the person, Not before, Flagged, how often it moved, Looks done, the team task it advances. */
|
|
1076
|
-
function workChips(inst, item, o = {}) {
|
|
1077
|
-
const today = inst.data.today; const c = [];
|
|
1078
|
-
/* work the PM did not type in (work-shows-assigned): where it came from, with its link, and what the agent suggests */
|
|
1079
|
-
if (item.origin === 'jira' || item.origin === 'wbs') {
|
|
1080
|
-
const label = item.origin === 'jira' ? 'Jira ' + (item.key || '') : 'WBS' + (item.repo ? ' ' + item.repo : '') + (item.key ? ' ' + item.key : '');
|
|
1081
|
-
const attrs = { class: 'tag', 'data-pm-origin': item.origin, title: item.status || '' };
|
|
1082
|
-
c.push(item.url ? el('a', { ...attrs, href: item.url, target: '_blank', rel: 'noopener', onclick: (e) => e.stopPropagation() }, label.trim()) : el('span', attrs, label.trim()));
|
|
1083
|
-
// the agent's state is the row's first chip (itemRow), so quiet pages keep it in sight
|
|
1084
|
-
if (item.suggest && !item.agent) c.push(el('span', { class: 'chip2', 'data-pm-suggest': item.id }, c3ic('spark', 'sm'), COPY.agentSuggests(item.suggest)));
|
|
1085
|
-
} else if (item.origin === 'brief') {
|
|
1086
|
-
c.push(el('span', { class: 'tag', 'data-pm-origin': 'brief', title: item.why || '' }, c3ic('spark', 'sm'), COPY.suggested));
|
|
1087
|
-
if (item.why) c.push(el('span', { class: 'chip2', 'data-pm-why': item.id }, item.why));
|
|
1088
|
-
}
|
|
1089
|
-
if (item.kind === 'offline') c.push(el('span', { class: 'tag wk-off', 'data-pm-offline-tag': item.id }, COPY.offline), el('span', { class: 'chip2' }, c3ic('user', 'sm'), item.person || 'someone'));
|
|
1090
|
-
if (item.defer && item.defer > today) c.push(el('span', { class: 'tag wk-nb cal3-up', 'data-pm-notbefore': item.id }, COPY.notBeforeChip(dayLabel(item.defer))));
|
|
1091
|
-
if (item.flagged && !o.noFlag) c.push(el('span', { class: 'tag cal3-up', 'data-pm-flagged': item.id }, COPY.flagged));
|
|
1092
|
-
if (item.recurring) c.push(el('span', { class: 'chip2' }, c3ic('undo', 'sm'), COPY.repeats(item.recurring)));
|
|
1093
|
-
if (item.not_yet_count) c.push(el('span', { class: 'tag' }, COPY.moved(item.not_yet_count)));
|
|
1094
|
-
if (item.kind === 'offline' && item.evidence) c.push(el('span', { class: 'st warn', 'data-pm-looks-done': item.id }, c3ic('eye', 'sm'), COPY.looksDone));
|
|
1095
|
-
if (item.resolves) c.push(el('span', { class: 'chip2', title: RESOLVES_TIP, 'data-pm-resolves': item.resolves }, c3ic('init', 'sm'), COPY.advances(resolvesTitle(inst, item))));
|
|
1096
|
-
return c;
|
|
1097
|
-
}
|
|
1098
|
-
|
|
1099
|
-
/* The mockup's workRow(): li.nrow.wrow > .rv.l, .rv.r (made by the swipe), .ki, .nb (.tt, .chips, .xp > .xi), the .acts button and the .sg glyphs (line 3258). */
|
|
1100
|
-
function itemRow(inst, item, lens, o = {}) {
|
|
1101
|
-
const j = item.job && jobById(inst, item.job);
|
|
1102
|
-
const today = inst.data.today;
|
|
1103
|
-
const chips = [];
|
|
1104
|
-
/* An item with `mock_row` (the /c3.html demo mode's mockup rows) is drawn as the mockup draws a work row: agent move, effort, time, job, source, initiative. */
|
|
1105
|
-
const mock = item.mock_row === true;
|
|
1106
|
-
const rs = inst.runs.get(item.id);
|
|
1107
|
-
const agent = mock && item.agent_move && (item.ix || {}).move;
|
|
1108
|
-
const overdue = !!item.due && String(item.due).slice(0, 10) < today;
|
|
1109
|
-
if (rs && rs.phase === 'work') chips.push(el('span', { class: 'st c3strip', 'data-sxs': item.id }, el('span', { class: 'c3spin' }, c3ic('spark', 'sm')), rs.steps[Math.min(rs.i, rs.steps.length - 1)] + ' · ' + (Math.min(rs.i, rs.steps.length - 1) + 1) + ' of ' + rs.steps.length));
|
|
1110
|
-
else if (rs && rs.phase === 'done') chips.push(el('span', { class: 'st ok' }, c3ic('check', 'sm'), 'agent: result ready'));
|
|
1111
|
-
else if (inst.planning.has(item.id)) chips.push(el('span', { class: 'st' }, el('span', { class: 'c3spin' }, c3ic('spark', 'sm')), 'planning the steps'));
|
|
1112
|
-
const ac = !mock && agentChip(item);
|
|
1113
|
-
if (ac) chips.push(ac);
|
|
1114
|
-
if (item.waiting_on && !(ac && item.waiting_on === 'an agent')) {
|
|
1115
|
-
const since = item.waiting_since ? String(item.waiting_since).slice(0, 10) : '';
|
|
1116
|
-
chips.push(el('span', { class: 'chip2', 'data-pm-waiting-chip': item.id }, c3ic('wait', 'sm'), COPY.waitingSince(item.waiting_on, since ? dayLabel(since) : '', since ? ago(since, today) : '')));
|
|
1117
|
-
}
|
|
1118
|
-
chips.push(dueChip(inst, item));
|
|
1119
|
-
chips.push(...workChips(inst, item, { noFlag: o.noFlag }));
|
|
1120
|
-
if (mock && item.agent_move && !(rs && rs.phase === 'done')) chips.push(el('span', { class: 'chip2', style: 'gap:4px', title: 'Swipe right to let the agent act' }, c3ic('spark', 'sm'), 'agent move'));
|
|
1121
|
-
if (mock && item.mins) chips.push(el('span', { class: 'chip2', title: 'Effort' }, c3ic('clock', 'sm'), item.mins <= 2 ? 'under 2 min' : item.mins + ' min'));
|
|
1122
|
-
if (item.priority) chips.push(el('span', { class: 'fl ' + item.priority.toLowerCase() }, item.priority));
|
|
1123
|
-
if ((item.steps || []).length) { const dn = item.steps.filter((s) => s.done).length; const ag = item.steps.filter((s) => s.who !== 'you' && !s.done).length; chips.push(el('span', { class: 'chip2', title: 'Steps' }, c3ic('tree', 'sm'), dn + ' of ' + item.steps.length + ' steps' + (ag ? ' · agent can do ' + ag : ''))); }
|
|
1124
|
-
if (j) chips.push(el('span', { class: 'chip2 jc', title: j.want }, c3ic('target', 'sm'), mock && j.mock_name ? j.mock_name : j.want));
|
|
1125
|
-
if (mock && item.src) chips.push(el('span', { class: 'tag' }, item.src));
|
|
1126
|
-
if (mock && item.init) chips.push(el('span', { class: 'chip2' }, c3ic('init', 'sm'), item.init.length > 16 ? item.init.slice(0, 15) + '…' : item.init));
|
|
1127
|
-
const title = el('span', { class: 'tt', 'data-pm-title': item.id }, item.title);
|
|
1128
|
-
const spec = swipeSpec(inst, item, lens);
|
|
1129
|
-
const recL = itemCase(inst, item, lens).model.opts.find((q) => q.rec);
|
|
1130
|
-
const recSide = agent ? 'r' : (recL && /^(drop|keep|wait|defer|someday)/.test(recL.id) ? 'l' : 'r');
|
|
1131
|
-
/* the row icon (the mockup): user for work outside PMOS, flag when flagged, wait in Waiting, check otherwise */
|
|
1132
|
-
const icon = mock ? (KIND_ICON[item.kind] || 'check') : item.kind === 'offline' ? 'user' : item.flagged ? 'flag' : lens === 'waiting' ? 'wait' : 'check';
|
|
1133
|
-
const hot = overdue || item.flagged || item.priority === 'P1';
|
|
1134
|
-
/* the right side (mockup W8): Decide in Inbox, Nudge in Waiting, nothing in Someday, a Done check everywhere else */
|
|
1135
|
-
let right = null;
|
|
1136
|
-
if (lens === 'inbox') right = button({ label: COPY.decide, variant: 'ghost', size: 'sm', icon: 'next', attrs: { 'data-pm-decide': item.id }, onClick: (e) => { e.stopPropagation(); if (row.__exp) row.__exp.toggle(); } });
|
|
1137
|
-
else if (lens === 'waiting') right = c3ib(COPY.nudge, 'out', { 'data-pm-nudge': item.id, onClick: (e) => { e.stopPropagation(); say({ text: COPY.nudged(item.waiting_on || 'them'), timeout: 4000 }); } }, 'sm');
|
|
1138
|
-
else if (lens !== 'someday') right = c3ib(COPY.doneBtn, 'check', { 'data-pm-done': item.id, onClick: (e) => { e.stopPropagation(); doneAct(inst, item, row, 'Done.'); } }, 'sm');
|
|
1139
|
-
/* the agent line (Initiative Driver): one line under the title when the agent filed a proposal for this task */
|
|
1140
|
-
const dn = inst.drv && !item.done ? inst.drv.m.workNote({ item, props: inst.drv.targets[item.id] || [], ws: inst.drv.ws, mode: inst.drv.mode, done: () => load(inst) }) : null;
|
|
1141
|
-
const agentLine = dn ? el('div', { class: 'dim drv-small drv-sub', 'data-drv-line': item.id }, dn) : null;
|
|
1142
|
-
const row = el('li', { class: 'nrow wrow', 'data-row': '', 'data-id': item.id, 'data-w': '1', 'data-pm-item': item.id, 'data-lens': lens },
|
|
1143
|
-
el('span', { class: 'ki' + (hot ? ' hot' : ''), title: item.kind === 'offline' ? 'Happens outside PMOS' : item.priority || '' }, c3ic(icon)),
|
|
1144
|
-
el('div', { class: 'nb' }, title, agentLine, mock && item.left ? fuseBar(item.left) : null, chips.filter(Boolean).length ? el('div', { class: 'chips' }, chips.filter(Boolean)) : null),
|
|
1145
|
-
right ? el('div', { class: 'acts' }, right) : el('span'),
|
|
1146
|
-
el('span', { class: 'sg', title: agent ? 'Drag right: the agent acts. Drag left: reply.' : 'Drag right: ' + spec.right.label + '. Drag left: ' + spec.left.label + '.' },
|
|
1147
|
-
el('span', { class: 'g l' + (recSide === 'l' ? ' y' : '') }, c3ic(spec.left.icon)), el('span', { class: 'g r' + (recSide === 'r' ? ' y' : '') }, c3ic(spec.right.icon))));
|
|
1148
|
-
const xp = expandRow(inst, row, item.id, () => caseFile(inst, item, lens));
|
|
1149
|
-
row.querySelector('.nb').append(xp);
|
|
1150
|
-
row.__item = item;
|
|
1151
|
-
attachSwipe(row, {
|
|
1152
|
-
onRight: () => spec.right.fn(row), onLeft: () => spec.left.fn(row),
|
|
1153
|
-
labelRight: spec.right.label, labelLeft: spec.left.label, iconRight: spec.right.icon, iconLeft: spec.left.icon,
|
|
1154
|
-
});
|
|
1155
|
-
row.addEventListener('keydown', (e) => {
|
|
1156
|
-
if (e.target !== row || e.metaKey || e.ctrlKey || e.altKey) return;
|
|
1157
|
-
/* the mockup's e and n keys act on the Briefing's rows only (its key handler tests S.tab === 'brief'); on a Work row they do nothing. j / k move. */
|
|
1158
|
-
if (e.key === 'j' || e.key === 'k') {
|
|
1159
|
-
e.preventDefault();
|
|
1160
|
-
const all = [...inst.root.querySelectorAll('.nrow.wrow[data-pm-item]')]; const at = all.indexOf(row);
|
|
1161
|
-
const nx = all[at + (e.key === 'j' ? 1 : -1)]; if (nx) nx.focus();
|
|
1162
|
-
}
|
|
1163
|
-
});
|
|
1164
|
-
return row;
|
|
1165
|
-
}
|
|
1166
|
-
|
|
1167
|
-
/* ── Focus: the right-hand column of every view (console3-work-parity R2, R3; Flow today removed by console3-deck-flow-fixes) ── */
|
|
1168
|
-
|
|
1169
|
-
/* One Focus row (the mockup's focusHTML row): target icon, title, progress, the reason, the open items, and Accept / Edit / Not today. A row that
|
|
1170
|
-
* has a job opens the job's sheet (R3): the whole row, or its job chip for the keyboard. */
|
|
1171
|
-
function focusRow(inst, f, pinned) {
|
|
1172
|
-
const editing = inst.focEdit.has(f.key);
|
|
1173
|
-
const input = editing ? el('input', { type: 'text', 'aria-label': COPY.editTitle, 'data-pm-focus-input': f.key, autocomplete: 'off' }) : null;
|
|
1174
|
-
if (input) input.value = f.title;
|
|
1175
|
-
const save = () => focusAccept(inst, { ...f, title: (input && input.value.trim()) || f.title });
|
|
1176
|
-
const cancel = () => { inst.focEdit.delete(f.key); draw(inst); };
|
|
1177
|
-
const edit = () => { inst.focEdit.add(f.key); draw(inst); later(inst, () => { const i = inst.root.querySelector('[data-pm-focus-input="' + f.key + '"]'); if (i) i.focus(); }, 30); };
|
|
1178
|
-
if (input) input.addEventListener('keydown', (e) => { if (e.key === 'Enter' && !e.isComposing) save(); else if (e.key === 'Escape') cancel(); });
|
|
1179
|
-
const job = f.job && jobById(inst, f.job);
|
|
1180
|
-
const refs = (f.item_ids || []).map((id) => itemById(inst, id)).filter((i) => i && !i.done && i.title !== f.title); // a one-item job does not list itself
|
|
1181
|
-
const total = job ? job.total || 0 : (f.item_ids || []).length; const done = job ? job.done || 0 : 0;
|
|
1182
|
-
const btns = editing ? [pill(COPY.save, null, { class: 'pill', 'data-pm-focus-save': f.key, onclick: save }), pill(COPY.cancel, null, { 'data-pm-focus-cancel': f.key, onclick: cancel })]
|
|
1183
|
-
: pinned ? [pill(COPY.edit, null, { 'data-pm-focus-edit': f.key, onclick: edit }), pill(COPY.unpin, null, { 'data-pm-focus-clear': f.key, onclick: () => focusClear(inst, f) }),
|
|
1184
|
-
pill(COPY.notToday, null, { 'data-pm-focus-dismiss': f.key, onclick: () => focusDismiss(inst, f) })]
|
|
1185
|
-
: [pill(COPY.accept, 'check', { class: 'pill', 'data-pm-focus-accept': f.key, onclick: () => focusAccept(inst, f) }), pill(COPY.edit, null, { 'data-pm-focus-edit': f.key, onclick: edit }),
|
|
1186
|
-
pill(COPY.notToday, null, { 'data-pm-focus-dismiss': f.key, onclick: () => focusDismiss(inst, f) })];
|
|
1187
|
-
const pfill = el('i'); pfill.style.setProperty('--wl-w', (total ? Math.round((done / total) * 100) : 0) + '%');
|
|
1188
|
-
const openJob = () => openJobSheet(inst, job);
|
|
1189
|
-
const li = el('li', { class: 'nrow wkfr', 'data-pm-focus-card': f.key, 'data-pm-focus-state': pinned ? 'accepted' : 'suggested', 'data-row': '' },
|
|
1190
|
-
el('span', { class: 'ki' + (pinned ? ' hot' : '') }, c3ic('target')),
|
|
1191
|
-
el('div', { class: 'nb' },
|
|
1192
|
-
editing ? el('span', { class: 'form' }, input) : el('span', { class: 'tt', title: f.why || '', 'data-pm-focus-title': f.key }, f.title),
|
|
1193
|
-
el('div', { class: 'chips' }, el('div', { class: 'pbar wkpb' }, pfill),
|
|
1194
|
-
el('span', { class: 'mono dim wk-s' }, COPY.progress(done, total)),
|
|
1195
|
-
pinned ? el('span', { class: 'tag cal3-up wk-on' }, COPY.focusPinned) : null,
|
|
1196
|
-
job ? pill(job.mock_name || job.want, 'target', { class: 'pill wkjob', title: COPY.jobSheet, 'data-pm-focus-job': job.id, onclick: (e) => { e.stopPropagation(); openJob(); } }) : null),
|
|
1197
|
-
f.why ? el('div', { class: 'dim wk-s wkfc-why' }, COPY.why(f.why)) : null,
|
|
1198
|
-
refs.length ? el('div', { class: 'chips' }, refs.map((i) => el('span', { class: 'chip2' }, i.title))) : null,
|
|
1199
|
-
el('div', { class: 'chips2 wkq wkfr-b' }, btns)),
|
|
1200
|
-
el('span'));
|
|
1201
|
-
return li;
|
|
1202
|
-
}
|
|
1203
|
-
|
|
1204
|
-
function focusSection(inst) {
|
|
1205
|
-
const F = inst.data.focus || { suggestions: [], accepted: [], dismissed: [] };
|
|
1206
|
-
const acc = F.accepted || []; const sug = (F.suggestions || []).slice(0, 3); const hidden = F.dismissed || [];
|
|
1207
|
-
const n = acc.length + sug.length;
|
|
1208
|
-
const restore = async () => {
|
|
1209
|
-
for (const k of hidden) await press(inst, API + '/focus/clear', { key: k }, { quiet: true });
|
|
1210
|
-
say({ text: COPY.broughtBack, timeout: 2500 });
|
|
1211
|
-
await load(inst);
|
|
1212
|
-
};
|
|
1213
|
-
const foot = hidden.length ? el('div', { class: 'fold', 'data-pm-focus-hidden': '' }, COPY.markedNot(hidden.length), ' ', pill(COPY.bringBack2, null, { 'data-pm-focus-restore': '', onclick: restore })) : null;
|
|
1214
|
-
const add = c3ib(COPY.newJob, 'plus', { 'data-pm-job-add-toggle': '', onClick: () => openNewJob(inst) }, 'sm');
|
|
1215
|
-
return el('section', { class: 'card sect wkfoc', 'data-pm-focus': '' },
|
|
1216
|
-
el('div', { class: 'sh2' }, el('h2', null, c3ic('target', 'sm'), COPY.focus, ' ', el('span', { class: 'bdg g' }, String(n))), el('span', { class: 'r' }, add)),
|
|
1217
|
-
n ? el('ul', { class: 'list', role: 'list' }, ...acc.map((f) => focusRow(inst, f, true)), ...sug.map((f) => focusRow(inst, f, false)))
|
|
1218
|
-
: el('div', { class: 'fold', 'data-pm-focus-none': '' }, c3ic('check', 'sm'), COPY.focusNone),
|
|
1219
|
-
foot);
|
|
1220
|
-
}
|
|
1221
|
-
|
|
1222
|
-
/* ── Upcoming: Next 7 days by day, then a Later card (console3-work-parity R6) ──────────────────────────────────────── */
|
|
1223
|
-
|
|
1224
|
-
const legendEl = () => el('span', { class: 'fl2', 'data-pm-legend': '' }, COPY.legend.map((w, k) => el('span', null, ['• ', '× '][k] + w)));
|
|
1225
|
-
|
|
1226
|
-
function upcomingMain(inst, list) {
|
|
1227
|
-
const today = inst.data.today;
|
|
1228
|
-
const at = (i) => { const a = arrives(i, today); return a ? Math.max(1, daysBetween(today, a)) : 99; };
|
|
1229
|
-
const near = list.filter((i) => at(i) <= 7); const far = list.filter((i) => at(i) > 7);
|
|
1230
|
-
const days = [];
|
|
1231
|
-
for (let n = 1; n <= 7; n++) {
|
|
1232
|
-
const d = addIso(today, n); const its = near.filter((i) => at(i) === n);
|
|
1233
|
-
days.push(el('div', { class: 'wkday', 'data-pm-day': d },
|
|
1234
|
-
el('h3', { class: 'wkdayh' }, n === 1 ? COPY.tomorrowHead + ' ' : null, el('span', { class: 'dim' }, dayLabel(d))),
|
|
1235
|
-
its.length ? el('ul', { class: 'list', role: 'list' }, its.map((i) => itemRow(inst, i, 'upcoming'))) : el('div', { class: 'dim wkday-none' }, COPY.clear)));
|
|
1236
|
-
}
|
|
1237
|
-
const nextSec = sect(el('div', { class: 'sh2' }, el('h2', null, c3ic('cal', 'sm'), COPY.sect.next7, ' ', el('span', { class: 'bdg g' }, String(near.length))), legendEl()), el('div', { class: 'wkdays' }, days));
|
|
1238
|
-
nextSec.setAttribute('data-pm-list', 'upcoming');
|
|
1239
|
-
const laterSec = sect(el('div', { class: 'sh2' }, el('h2', null, c3ic('moon', 'sm'), COPY.sect.later, ' ', el('span', { class: 'bdg g' }, String(far.length))), el('span', { class: 'dim wk-s' }, COPY.beyond)),
|
|
1240
|
-
far.length ? el('ul', { class: 'list', role: 'list' }, far.map((i) => itemRow(inst, i, 'upcoming'))) : el('ul', { class: 'list' }, el('li', { class: 'fold' }, c3ic('check', 'sm'), COPY.nothingLater)));
|
|
1241
|
-
laterSec.setAttribute('data-pm-day', 'later');
|
|
1242
|
-
return [nextSec, laterSec];
|
|
1243
|
-
}
|
|
1244
|
-
|
|
1245
|
-
/* ── Today: Overdue, Due today and Flagged, each its own card (console3-work-parity R5) ─────────────────────────────── */
|
|
1246
|
-
|
|
1247
|
-
function todayMain(inst, list) {
|
|
1248
|
-
const today = inst.data.today; const dayOf = (i) => (i.due ? String(i.due).slice(0, 10) : '');
|
|
1249
|
-
const byDue = (a, b) => (dayOf(a) < dayOf(b) ? -1 : dayOf(a) > dayOf(b) ? 1 : String(a.time || '') < String(b.time || '') ? -1 : String(a.time || '') > String(b.time || '') ? 1 : 0);
|
|
1250
|
-
const over = list.filter((i) => dayOf(i) && dayOf(i) < today).sort(byDue);
|
|
1251
|
-
const due = list.filter((i) => dayOf(i) === today).sort(byDue);
|
|
1252
|
-
const flag = list.filter((i) => !over.includes(i) && !due.includes(i));
|
|
1253
|
-
if (!list.length) {
|
|
1254
|
-
const sec = sect(el('div', { class: 'sh2' }, el('h2', null, c3ic('sun', 'sm'), labelOf('today'), ' ', el('span', { class: 'bdg g' }, '0'))), el('ul', { class: 'list' }, el('li', { class: 'fold' }, c3ic('check', 'sm'), COPY.emptyView.today)));
|
|
1255
|
-
sec.setAttribute('data-pm-list', 'today');
|
|
1256
|
-
return [sec];
|
|
1257
|
-
}
|
|
1258
|
-
let first = true;
|
|
1259
|
-
return [['overdue', 'alert', COPY.sect.overdue, over], ['due', 'sun', COPY.sect.dueToday, due], ['flagged', 'flag', COPY.sect.flagged, flag]].filter((g) => g[3].length).map(([key, ic, title, its]) => {
|
|
1260
|
-
const sec = sect(el('div', { class: 'sh2' }, el('h2', null, c3ic(ic, 'sm'), title, ' ', el('span', { class: 'bdg g' }, String(its.length))), first ? legendEl() : null),
|
|
1261
|
-
el('ul', { class: 'list', role: 'list' }, its.map((i) => itemRow(inst, i, 'today', { noFlag: key === 'flagged' }))));
|
|
1262
|
-
first = false;
|
|
1263
|
-
sec.setAttribute('data-pm-list', 'today'); sec.setAttribute('data-pm-sect', key);
|
|
1264
|
-
return sec;
|
|
1265
|
-
});
|
|
1266
|
-
}
|
|
1267
|
-
|
|
1268
|
-
/* ── Review: a weekly pass, one item at a time (PRD R7) ────────────────────────────────────────────────────────────── */
|
|
1269
|
-
|
|
1270
|
-
function reviewMain(inst) {
|
|
1271
|
-
const today = inst.data.today; const q = shown(inst, 'review'); const R = inst.rv;
|
|
1272
|
-
const inQ = new Set(q.map((i) => i.id));
|
|
1273
|
-
if (!R.ids) { R.ids = q.map((i) => i.id); R.handled = new Set(); R.changing = false; }
|
|
1274
|
-
q.forEach((i) => { if (!R.ids.includes(i.id)) R.ids.push(i.id); });
|
|
1275
|
-
const curId = R.ids.find((id) => !R.handled.has(id) && inQ.has(id)) || null;
|
|
1276
|
-
const total = R.ids.length; const doneN = R.ids.filter((id) => R.handled.has(id) || !inQ.has(id)).length;
|
|
1277
|
-
const restart = () => { R.ids = null; draw(inst); };
|
|
1278
|
-
if (!curId) {
|
|
1279
|
-
return el('section', { class: 'card sect wkrv', 'data-pm-review-done': '' }, el('p', { class: 'wkrv-t' }, total ? COPY.reviewDone : labelOf('review')),
|
|
1280
|
-
el('p', { class: 'wk-s' }, total ? COPY.reviewDoneText(total) : COPY.reviewNone),
|
|
1281
|
-
q.length ? el('div', { class: 'wkq' }, pill(COPY.again, 'undo', { 'data-pm-review-again': '', onclick: restart })) : null);
|
|
1282
|
-
}
|
|
1283
|
-
const item = q.find((i) => i.id === curId);
|
|
1284
|
-
const next = () => { R.handled.add(curId); R.changing = false; draw(inst); };
|
|
1285
|
-
const place = workPlace(item, today);
|
|
1286
|
-
const upNext = R.ids.filter((id) => id !== curId && !R.handled.has(id) && inQ.has(id)).slice(0, 2).map((id) => (q.find((i) => i.id === id) || {}).title).filter(Boolean);
|
|
1287
|
-
return el('section', { class: 'card sect wkrv', 'data-pm-review': curId },
|
|
1288
|
-
el('div', { class: 'wkrv-p' }, el('span', { 'data-pm-review-progress': '' }, (doneN + 1) + ' of ' + total), el('span', null, COPY.reviewHead)),
|
|
1289
|
-
el('progress', { class: 'wk-bar', value: String(doneN), max: String(Math.max(1, total)), 'aria-label': doneN + ' of ' + total + ' reviewed' }), // Review's progress bar
|
|
1290
|
-
el('p', { class: 'wkrv-t', 'data-pm-title': curId }, item.title),
|
|
1291
|
-
el('div', { class: 'chips' }, el('span', { class: 'tag' }, COPY.untouched(untouchedDays(item, today))), el('span', { class: 'tag' }, COPY.livesIn(labelOf(place))),
|
|
1292
|
-
item.waiting_on ? el('span', { class: 'chip2' }, c3ic('wait', 'sm'), COPY.waitingOn(item.waiting_on)) : null, ...workChips(inst, item)),
|
|
1293
|
-
R.changing ? el('div', { class: 'wkrv-x' }, editForm(inst, item), el('div', { class: 'wkq' }, pill(COPY.next, 'next', { class: 'pill pri', 'data-pm-review-next': curId, onclick: next })))
|
|
1294
|
-
: el('div', { class: 'wkq' },
|
|
1295
|
-
pill(COPY.keep, 'check', { class: 'pill pri', 'data-pm-review-keep': curId, onclick: async () => { if (await act(inst, null, { route: '/keep', body: { id: curId }, text: COPY.kept, leave: false })) { R.handled.add(curId); draw(inst); } } }),
|
|
1296
|
-
pill(COPY.change, 'edit', { 'data-pm-review-change': curId, onclick: () => { R.changing = true; draw(inst); } }),
|
|
1297
|
-
pill(COPY.drop, 'trash', { 'data-pm-review-drop': curId, onclick: async () => { if (await dropAct(inst, item, null)) { R.handled.add(curId); draw(inst); } } })),
|
|
1298
|
-
upNext.length ? el('p', { class: 'dim wk-s' }, COPY.upNext + upNext.join(' · ')) : null);
|
|
1299
|
-
}
|
|
1300
|
-
|
|
1301
|
-
/* ── jobs ────────────────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
1302
|
-
|
|
1303
|
-
function jobEditField(inst, job, key) {
|
|
1304
|
-
const lab = key === 'mock_name' ? 'Job' : key === 'when' ? 'When' : key === 'want' ? 'I want' : 'So';
|
|
1305
|
-
const input = el('input', { type: 'text', 'aria-label': lab, 'data-pm-job-edit': job.id + ':' + key, autocomplete: 'off' });
|
|
1306
|
-
input.value = job[key] || '';
|
|
1307
|
-
input.addEventListener('change', async () => {
|
|
1308
|
-
const v = input.value.trim(); if (!v) { input.value = job[key] || ''; return; }
|
|
1309
|
-
const old = job[key] || '';
|
|
1310
|
-
const r = await press(inst, JOBS + '/edit', { id: job.id, fields: { [key]: v } });
|
|
1311
|
-
if (r) say({ text: 'Saved', timeout: 7000, actionLabel: COPY.undo, onAction: async () => { await press(inst, JOBS + '/edit', { id: job.id, fields: { [key]: old } }); } });
|
|
1312
|
-
});
|
|
1313
|
-
return field(lab, input);
|
|
1314
|
-
}
|
|
1315
|
-
|
|
1316
|
-
/* The mockup's c3jall(): "All N items, across every view", grouped by view (line 4657). */
|
|
1317
|
-
function jobAll(inst, job) {
|
|
1318
|
-
const its = (inst.data.items || []).filter((i) => i.job === job.id);
|
|
1319
|
-
if (!its.length) return el('div', { class: 'dim mono', style: small }, 'No item uses this job yet.');
|
|
1320
|
-
const G = {};
|
|
1321
|
-
its.forEach((i) => { const l = i.done ? 'done' : lensOfItem(inst, i.id); (G[l] = G[l] || []).push(i); });
|
|
1322
|
-
return el('div', { class: 'c3all', 'data-pm-job-all': job.id }, el('div', { class: 'hd dim mono' }, 'All ' + its.length + ' items, across every view'),
|
|
1323
|
-
...[...VIEWS, 'done'].filter((l) => G[l]).map((l) => el('div', null, el('span', { class: 'tag' }, l === 'done' ? 'Done' : labelOf(l)), el('span', null, ...G[l].map((i) => el('span', { class: i.done ? 'dn' : '' }, i.title))))));
|
|
1324
|
-
}
|
|
1325
|
-
|
|
1326
|
-
/* The job's case file (mockup C3.cases.job, line 4660): the words, the count, Keep / Delete and move / Delete and leave, slide to confirm. */
|
|
1327
|
-
function jobCase(inst, j, close) {
|
|
1328
|
-
const its = (inst.data.items || []).filter((i) => i.job === j.id);
|
|
1329
|
-
const done = its.filter((i) => i.done).length;
|
|
1330
|
-
const others = (inst.data.jobs || []).filter((q) => q.id !== j.id); const near = others[0];
|
|
1331
|
-
const nm = (q) => q.mock_name || q.want;
|
|
1332
|
-
const del = (reassign) => async () => { const r = await press(inst, JOBS + '/delete', { id: j.id, ...(reassign ? { reassign_to: reassign } : {}) }); if (r) { say({ text: COPY.reassigned(r.reassigned || 0), timeout: 4000 }); close(); } };
|
|
1333
|
-
const model = { id: 'job:' + j.id, sit: COPY.jobLine(j), conf: 90, cta: 'Slide to keep it',
|
|
1334
|
-
chg: [['target', done + ' of ' + its.length + ' done', 'count across every view', 'ok'], ['info', 'Change the words below. They save at once and you can undo for 7 seconds.', '']],
|
|
1335
|
-
opts: [{ id: 'keep', l: 'Keep it', rec: 1, fx: [fx('check', 'Nothing changes', 'ok')] },
|
|
1336
|
-
{ id: 'mv', l: near ? 'Delete it and move its ' + its.length + ' item' + (its.length === 1 ? '' : 's') + ' to "' + nm(near) + '"' : 'Delete it', rec: 0, fx: [fx('trash', 'The job is gone', 'warn'), fx('target', its.length + ' items change job', 'warn')] },
|
|
1337
|
-
{ id: 'nj', l: 'Delete it and leave its items without a job', rec: 0, fx: [fx('trash', 'The job is gone', 'warn'), fx('alert', 'The items have no job', '')] }] };
|
|
1338
|
-
const run = { keep: () => { say({ text: 'Kept.', timeout: 2500 }); close(); }, mv: del(near && near.id), nj: del(null) };
|
|
1339
|
-
// a job carries no confidence figure: never show a made-up percentage
|
|
1340
|
-
const root = renderCase(model, { noConf: true, onConfirm: ({ option }) => { if (run[option.id]) run[option.id](); } });
|
|
1341
|
-
root.setAttribute('data-pm-case', j.id);
|
|
1342
|
-
const sit = root.querySelector('.sit');
|
|
1343
|
-
sit.after(el('div', { class: 'c3jf' }, j.mock_name ? jobEditField(inst, j, 'mock_name') : null, jobEditField(inst, j, 'when'), jobEditField(inst, j, 'want'), jobEditField(inst, j, 'so')), jobAll(inst, j));
|
|
1344
|
-
return root;
|
|
1345
|
-
}
|
|
1346
|
-
|
|
1347
|
-
/* The "+ New job" draft (mockup c3jdraft, line 4678): one line in, the agent-style draft of the four fields out, then "Slide to create". */
|
|
1348
|
-
function jobNewCase(inst, st, close) {
|
|
1349
|
-
const x = st.line || 'keep the week calm';
|
|
1350
|
-
const d = st.draft;
|
|
1351
|
-
const inputs = ['when', 'want', 'so'].map((k) => el('input', { type: 'text', 'aria-label': k === 'when' ? 'When' : k === 'want' ? 'I want' : 'So', 'data-pm-job-new': k, value: d[k], autocomplete: 'off' }));
|
|
1352
|
-
const val = (k) => inputs[['when', 'want', 'so'].indexOf(k)].value.trim();
|
|
1353
|
-
const demo = DEMO(); // demo: the mockup's draft also names the job (its "Job" field); the server has no name field
|
|
1354
|
-
const nameIn = demo ? el('input', { type: 'text', 'aria-label': 'Job', 'data-pm-job-new': 'name', value: x.charAt(0).toUpperCase() + x.slice(1).replace(/\.$/, ''), autocomplete: 'off' }) : null;
|
|
1355
|
-
const model = { id: 'job:new', sit: 'The agent drafted this from your line. Change anything, then create it. It has no items yet.', conf: 70, cta: 'Slide to create',
|
|
1356
|
-
chg: [['spark', 'Drafted by the agent', 'assumption', 'warn']],
|
|
1357
|
-
opts: [{ id: 'mk', l: 'Create the job', rec: 1, fx: [fx('target', 'Items can now be filed under it', 'ok')] }, { id: 'no', l: 'Not now', rec: 0, fx: [] }] };
|
|
1358
|
-
const root = renderCase(model, { noConf: !demo, onConfirm: async ({ option }) => {
|
|
1359
|
-
if (option.id === 'no') { say({ text: 'Dropped the draft.', timeout: 2500 }); close(); return; }
|
|
1360
|
-
const line = 'when ' + val('when') + ', I want ' + val('want') + ', so ' + val('so');
|
|
1361
|
-
const r = await press(inst, JOBS + '/add', nameIn ? { line, name: nameIn.value.trim() } : { line });
|
|
1362
|
-
if (r) { say({ text: 'Job created. Add work to it by saying which job it serves.', timeout: 3000 }); close(); await load(inst); }
|
|
1363
|
-
} });
|
|
1364
|
-
root.querySelector('.sit').after(el('div', { class: 'c3jf' }, nameIn ? field('Job', nameIn) : null, ...['when', 'want', 'so'].map((k, i) => field(k === 'when' ? 'When' : k === 'want' ? 'I want' : 'So', inputs[i]))));
|
|
1365
|
-
return root;
|
|
1366
|
-
}
|
|
1367
|
-
|
|
1368
|
-
/* The job's sheet (console3-work-parity R3): a Focus row opens it. The case file lives in the sheet, so a redraw of the page does not dispose it. */
|
|
1369
|
-
function openJobSheet(inst, job) {
|
|
1370
|
-
let h = null;
|
|
1371
|
-
const body = jobCase(inst, job, () => h && h.close());
|
|
1372
|
-
h = openSheet({ title: COPY.jobSheet, icon: 'target', body, onClose: () => { try { body.c3case.dispose(); } catch { /* already gone */ } } });
|
|
1373
|
-
}
|
|
1374
|
-
|
|
1375
|
-
/* The New job button of the Focus section: one line in, the draft of the three fields out, then "Slide to create", all in a sheet. */
|
|
1376
|
-
function openNewJob(inst) {
|
|
1377
|
-
let h = null; let case2 = null;
|
|
1378
|
-
const holder = el('div', { 'data-pm-job-new-sheet': '' });
|
|
1379
|
-
const close = () => h && h.close();
|
|
1380
|
-
const input = el('input', { type: 'text', placeholder: 'What are you trying to get done? One line', 'aria-label': 'New job', autocomplete: 'off', 'data-pm-add': JOBS + '/add' });
|
|
1381
|
-
const go = () => {
|
|
1382
|
-
const x = (input.value || '').trim() || 'keep the week calm';
|
|
1383
|
-
const st = { line: x, draft: { when: 'it comes up', want: 'a clear way to ' + x.toLowerCase().replace(/^to /, '').replace(/\.$/, ''), so: 'the outcome is not left to chance' } };
|
|
1384
|
-
case2 = jobNewCase(inst, st, close);
|
|
1385
|
-
holder.replaceChildren(case2);
|
|
1386
|
-
later(inst, () => { const i = holder.querySelector('[data-pm-job-new="name"], [data-pm-job-new="when"]'); if (i) i.focus(); }, 30);
|
|
1387
|
-
};
|
|
1388
|
-
input.addEventListener('keydown', (e) => { if (e.key === 'Enter' && !e.isComposing) go(); });
|
|
1389
|
-
holder.append(el('div', { class: 'form' }, input, c3ib('Draft it', 'spark', { 'data-pm-job-draft': '', onClick: go }, 'pri')));
|
|
1390
|
-
h = openSheet({ title: COPY.newJob, icon: 'target', body: holder, onClose: () => { try { if (case2) case2.c3case.dispose(); } catch { /* already gone */ } } });
|
|
1391
|
-
later(inst, () => input.focus(), 30);
|
|
1392
|
-
}
|
|
1393
|
-
|
|
1394
|
-
/* ── Done (c3-work-agent amendment 18): what the PM finished in the last 30 days, by day, with how it closed and Reopen ── */
|
|
1395
|
-
|
|
1396
|
-
const localDay = (iso) => { const d = new Date(iso); return Number.isNaN(d.getTime()) ? '' : d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0') + '-' + String(d.getDate()).padStart(2, '0'); };
|
|
1397
|
-
/* Days between the day an item was done and today: 0 = today. */
|
|
1398
|
-
const doneAgo = (inst, i) => daysBetween(localDay(i.done_at), inst.data.today);
|
|
1399
|
-
function doneItems(inst) {
|
|
1400
|
-
if (!inst.data) return [];
|
|
1401
|
-
return (inst.data.items || []).filter((i) => i.done && i.done_at && localDay(i.done_at) && doneAgo(inst, i) <= DONE_DAYS && !inst.hidden.has(i.id))
|
|
1402
|
-
.sort((a, b) => String(b.done_at).localeCompare(String(a.done_at)));
|
|
1403
|
-
}
|
|
1404
|
-
/* How it closed: what the agent did wins (it posted, or did the approved step), else what the done press said. */
|
|
1405
|
-
const DONE_HOW_IC = { you: 'check', agent: 'spark', posted: 'out', step: 'spark', confirmed: 'eye' };
|
|
1406
|
-
function howOf(item) {
|
|
1407
|
-
const a = item.agent;
|
|
1408
|
-
if (a && a.state === 'sent') return a.draft && a.draft.step ? 'step' : 'posted';
|
|
1409
|
-
return DONE_HOW_IC[item.done_how] ? item.done_how : 'you';
|
|
1410
|
-
}
|
|
1411
|
-
|
|
1412
|
-
function doneRow(inst, item) {
|
|
1413
|
-
const today = inst.data.today;
|
|
1414
|
-
const how = howOf(item);
|
|
1415
|
-
const was = workPlace({ ...item, done: false }, today);
|
|
1416
|
-
const chips = [el('span', { class: 'st ok', 'data-pm-done-at': item.id }, c3ic('check', 'sm'), COPY.doneAt(doneAgo(inst, item) <= 0 ? hhmm(item.done_at) : dayLabel(localDay(item.done_at)))),
|
|
1417
|
-
el('span', { class: 'chip2', 'data-pm-done-how': how }, c3ic(DONE_HOW_IC[how], 'sm'), COPY.how[how])];
|
|
1418
|
-
if (item.origin === 'jira' || item.origin === 'wbs') {
|
|
1419
|
-
const label = (item.origin === 'jira' ? 'Jira ' + (item.key || '') : 'WBS' + (item.key ? ' ' + item.key : '')).trim();
|
|
1420
|
-
chips.push(item.url ? el('a', { class: 'tag', href: item.url, target: '_blank', rel: 'noopener' }, label) : el('span', { class: 'tag' }, label));
|
|
1421
|
-
} else if (item.origin === 'brief') chips.push(el('span', { class: 'tag' }, COPY.suggested));
|
|
1422
|
-
if (item.kind === 'offline' && item.person) chips.push(el('span', { class: 'chip2' }, c3ic('user', 'sm'), item.person));
|
|
1423
|
-
if (item.resolves) chips.push(el('span', { class: 'chip2', title: RESOLVES_TIP }, c3ic('init', 'sm'), resolvesTitle(inst, item)));
|
|
1424
|
-
const row = el('li', { class: 'nrow wrow wk-done-row', 'data-pm-done-item': item.id });
|
|
1425
|
-
const reopen = pill(COPY.reopen, 'undo', { 'data-pm-reopen': item.id, title: COPY.backTo(labelOf(was)),
|
|
1426
|
-
onclick: (e) => { e.stopPropagation(); act(inst, row, { route: '/reopen', body: { id: item.id }, text: COPY.reopened(labelOf(was)), undo: undoBy(inst, '/done', { id: item.id, ...(item.done_how ? { how: item.done_how } : {}) }) }); } });
|
|
1427
|
-
row.append(el('span', { class: 'ki' }, c3ic('check')),
|
|
1428
|
-
el('div', { class: 'nb' }, el('span', { class: 'tt', 'data-pm-title': item.id }, item.title),
|
|
1429
|
-
item.outcome ? el('div', { class: 'wk-done-out', 'data-pm-done-outcome': item.id }, c3ic('reply', 'sm'), item.outcome) : null,
|
|
1430
|
-
el('div', { class: 'chips' }, chips)),
|
|
1431
|
-
el('div', { class: 'acts' }, reopen));
|
|
1432
|
-
return row;
|
|
1433
|
-
}
|
|
1434
|
-
|
|
1435
|
-
function doneMain(inst) {
|
|
1436
|
-
const all = doneItems(inst);
|
|
1437
|
-
if (!all.length) {
|
|
1438
|
-
const sec = sect(el('div', { class: 'sh2' }, el('h2', null, c3ic('todo', 'sm'), labelOf('done'), ' ', el('span', { class: 'bdg g' }, '0'))),
|
|
1439
|
-
el('ul', { class: 'list' }, el('li', { class: 'fold', 'data-pm-done-empty': '' }, c3ic('check', 'sm'), COPY.emptyView.done)));
|
|
1440
|
-
sec.setAttribute('data-pm-list', 'done');
|
|
1441
|
-
return [sec];
|
|
1442
|
-
}
|
|
1443
|
-
const g = { today: [], yday: [], week: [], older: [] };
|
|
1444
|
-
all.forEach((i) => { const n = doneAgo(inst, i); (n <= 0 ? g.today : n === 1 ? g.yday : n <= 7 ? g.week : g.older).push(i); });
|
|
1445
|
-
const week = all.filter((i) => doneAgo(inst, i) <= 7).length;
|
|
1446
|
-
const out = [el('div', { class: 'fold wk-done-sum', 'data-pm-done-sum': '' }, c3ic('check', 'sm'), COPY.doneSum(week, all.length))];
|
|
1447
|
-
let first = true;
|
|
1448
|
-
[['today', 'sun'], ['yday', 'clock'], ['week', 'cal'], ['older', 'moon']].filter(([k]) => g[k].length).forEach(([k, ic]) => {
|
|
1449
|
-
const sec = sect(el('div', { class: 'sh2' }, el('h2', null, c3ic(ic, 'sm'), COPY.doneSect[k], ' ', el('span', { class: 'bdg g' }, String(g[k].length))),
|
|
1450
|
-
first ? el('span', { class: 'dim wk-sm' }, COPY.doneLegend) : null),
|
|
1451
|
-
el('ul', { class: 'list', role: 'list' }, g[k].map((i) => doneRow(inst, i))));
|
|
1452
|
-
first = false;
|
|
1453
|
-
sec.setAttribute('data-pm-list', 'done'); sec.setAttribute('data-pm-sect', k);
|
|
1454
|
-
out.push(sec);
|
|
1455
|
-
});
|
|
1456
|
-
return out;
|
|
1457
|
-
}
|
|
1458
|
-
|
|
1459
|
-
/* ── the page ────────────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
1460
|
-
|
|
1461
|
-
/* The mockup's workHead() calbar: the .seg view bar with a count on every view (line 3281). */
|
|
1462
|
-
function lensBar(inst) {
|
|
1463
|
-
const seg = el('div', { class: 'seg', role: 'group', 'aria-label': 'Work view', 'data-pm-lenses': '' },
|
|
1464
|
-
LENSES.map(([id, label]) => {
|
|
1465
|
-
const n = inst.data ? countOf(inst, id) : 0;
|
|
1466
|
-
const b = el('button', { type: 'button', 'aria-pressed': String(inst.lens === id), 'data-lens': id }, c3ic(WLI[id], 'sm'), label, n ? el('span', { class: 'bdg g' }, String(n)) : null);
|
|
1467
|
-
b.addEventListener('click', () => { inst.lens = id; if (inst.ctx.onLens) inst.ctx.onLens(id); draw(inst); }); // onLens: the page's deck follows the lens (demo)
|
|
1468
|
-
/* every view shows its count, also 0 */
|
|
1469
|
-
const badge = b.querySelector('.bdg') || b.appendChild(el('span', { class: 'bdg g' }, '0'));
|
|
1470
|
-
badge.setAttribute('data-pm-count', id);
|
|
1471
|
-
return b;
|
|
1472
|
-
}));
|
|
1473
|
-
return [seg];
|
|
1474
|
-
}
|
|
1475
|
-
|
|
1476
|
-
/* A .card.sect with an .sh2 title row and a ul.list of rows (line 3262). */
|
|
1477
|
-
function sect(head, rows) { return el('section', { class: 'card sect' }, head, rows); }
|
|
1478
|
-
|
|
1479
|
-
const FOCUS_ATTRS = ['data-pm-edit', 'data-pm-step-add', 'data-pm-job-edit', 'data-pm-agent-reply', 'data-pm-job-new', 'data-pm-outcome', 'data-pm-wait-on', 'data-pm-focus-input'];
|
|
1480
|
-
|
|
1481
|
-
/* What the briefing tells this page: how many decisions wait in Briefing (the header says so), and the drafts section that Review carries (decision 1). */
|
|
1482
|
-
function briefRead(inst, b) {
|
|
1483
|
-
const decide = ((b && b.cards) || []).filter((c) => c && (c.move || c.tag === 'Critical'));
|
|
1484
|
-
const n = b && Array.isArray(b.needs) && b.needs.length ? b.needs.length : decide.length;
|
|
1485
|
-
const rv = b && b.review ? b.review : null;
|
|
1486
|
-
const sig = JSON.stringify([n, rv]);
|
|
1487
|
-
if (sig === inst.briefSig) return;
|
|
1488
|
-
inst.briefSig = sig; inst.decisions = n;
|
|
1489
|
-
inst.draftsHost.replaceChildren(...(rv ? [reviewSection(rv)] : []));
|
|
1490
|
-
if (inst.data && insts.get(inst.host) === inst) draw(inst);
|
|
1491
|
-
}
|
|
1492
|
-
|
|
1493
|
-
function draw(inst) {
|
|
1494
|
-
if (inst.lens !== inst.prevLens) { if (inst.lens === 'review') inst.rv.ids = null; inst.prevLens = inst.lens; } // a fresh Review pass each time the view is opened
|
|
1495
|
-
/* keep the focus: a field the PM is typing in, or the row they were on, is found again after the redraw */
|
|
1496
|
-
const a = document.activeElement; let keep = null;
|
|
1497
|
-
if (a && inst.root.contains(a) && a !== document.body) {
|
|
1498
|
-
const at = FOCUS_ATTRS.find((k) => a.hasAttribute && a.hasAttribute(k));
|
|
1499
|
-
if (at) keep = { sel: '[' + at + '="' + a.getAttribute(at) + '"]' };
|
|
1500
|
-
else if (a.matches && a.matches('.nrow[data-pm-item]')) keep = { sel: '[data-pm-item="' + a.getAttribute('data-pm-item') + '"]' };
|
|
1501
|
-
}
|
|
1502
|
-
disposeCases(inst);
|
|
1503
|
-
inst.bar.replaceChildren(...lensBar(inst));
|
|
1504
|
-
const d = inst.data;
|
|
1505
|
-
if (!d) { inst.body.replaceChildren(el('p', { class: 'dim mono', style: small }, COPY.loading)); return; }
|
|
1506
|
-
const lens = inst.lens;
|
|
1507
|
-
const list = lens === 'review' ? [] : shown(inst, lens);
|
|
1508
|
-
const go = inst.ctx.go;
|
|
1509
|
-
const lh = el('div', { class: 'lh', 'data-pm-lens-head': lens },
|
|
1510
|
-
el('span', { class: 'ki' }, c3ic(WLI[lens])),
|
|
1511
|
-
el('div', { class: 'wk-min' }, el('b', null, COPY.lens[lens]),
|
|
1512
|
-
el('div', { class: 'dim' }, COPY.lensSub[lens] + (inst.decisions ? COPY.decisions(inst.decisions) : ''),
|
|
1513
|
-
inst.decisions && go ? [' ', pill(COPY.openBriefing, 'next', { 'data-pm-open-briefing': '', onclick: () => go('brief') })] : null)));
|
|
1514
|
-
const empty = el('li', { class: 'fold' }, c3ic('check', 'sm'), COPY.emptyView[lens] || COPY.empty);
|
|
1515
|
-
let main;
|
|
1516
|
-
if (lens === 'review') main = [reviewMain(inst), inst.draftsHost];
|
|
1517
|
-
else if (lens === 'upcoming') main = upcomingMain(inst, list);
|
|
1518
|
-
else if (lens === 'today') main = todayMain(inst, list);
|
|
1519
|
-
else if (lens === 'done') main = doneMain(inst);
|
|
1520
|
-
else {
|
|
1521
|
-
const sec = sect(el('div', { class: 'sh2' }, el('h2', null, c3ic(WLI[lens], 'sm'), COPY.sect[lens], ' ', el('span', { class: 'bdg g' }, String(list.length))), legendEl()),
|
|
1522
|
-
el('ul', { class: 'list', role: 'list' }, list.length ? list.map((i) => itemRow(inst, i, lens)) : empty));
|
|
1523
|
-
sec.setAttribute('data-pm-list', lens);
|
|
1524
|
-
main = [sec];
|
|
1525
|
-
if (lens === 'inbox') {
|
|
1526
|
-
const to = go ? pill(COPY.initiatives, 'next', { 'data-pm-go-init': '', onclick: () => go('init') }) : COPY.initiatives;
|
|
1527
|
-
main.push(el('div', { class: 'fold', 'data-pm-inbox-note': '' }, COPY.inboxNote + ' ', to, COPY.inboxNoteEnd));
|
|
1528
|
-
}
|
|
1529
|
-
}
|
|
1530
|
-
/* The mockup's vWork() body: .calbody > .lh + .brief.sbb > .bcols > .bcol.l (the view) and .bcol.r (Focus). The PM removed the mockup's Flow today card (console3-deck-flow-fixes). */
|
|
1531
|
-
inst.body.replaceChildren(lh, el('div', { class: 'brief sbb' }, el('div', { class: 'bcols' }, el('div', { class: 'bcol l' }, ...main), el('div', { class: 'bcol r' }, focusSection(inst)))));
|
|
1532
|
-
if (keep) { const n = inst.root.querySelector(keep.sel); if (n && n.focus) { try { n.focus({ preventScroll: true }); } catch { /* not focusable */ } } }
|
|
1533
|
-
}
|