create-pmos 0.611.0 → 0.613.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 +105 -27
- package/payload/KIT-VERSION +2 -2
- 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/payload/state/log.md +1 -1
- package/workspace/briefing-premium-board-test.js +1 -1
- package/workspace/briefing-premium-calendar-2-test.js +3 -2
- package/workspace/briefing-premium-calendar-3-test.js +1 -1
- package/workspace/briefing-premium-calendar-test.js +1 -1
- package/workspace/briefing-premium-insights-test.js +1 -1
- package/workspace/briefing-premium-test.js +1 -1
- package/workspace/changelog.json +104 -0
- package/workspace/guide/layout.md +52 -18
- package/workspace/guide/programs.md +3 -3
- package/workspace/guide/routine.md +28 -13
- package/workspace/guide/settings-and-switches.md +1 -1
- package/workspace/lib/board-premium.js +12 -4
- package/workspace/lib/cos-chat.js +1 -0
- package/workspace/lib/doc-library.js +43 -12
- package/workspace/lib/doc-path.js +30 -0
- package/workspace/lib/engine/boards.js +4 -2
- package/workspace/lib/events-place.js +190 -38
- package/workspace/lib/events-stated.js +129 -0
- package/workspace/lib/initiative-chat.js +1 -0
- package/workspace/lib/insights-premium.js +13 -1
- package/workspace/lib/library-find.js +162 -0
- package/workspace/lib/library-items.js +196 -24
- package/workspace/lib/notes.js +3 -0
- package/workspace/lib/plan-items.js +17 -3
- package/workspace/lib/routes-artefacts.js +5 -2
- package/workspace/lib/routes-boards.js +6 -2
- package/workspace/lib/routes-doc-sheet.js +1 -0
- package/workspace/lib/routes-events-place.js +47 -10
- package/workspace/lib/routes-library.js +74 -8
- package/workspace/lib/routes-report-setups.js +13 -2
- package/workspace/lib/routine-reports.js +36 -4
- package/workspace/lib/status-when.js +36 -0
- package/workspace/lib/task-items.js +5 -3
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-vw-meet-test.js +2 -1
- package/workspace/premium-vw-notes-test.js +3 -2
- package/workspace/public/pm/artefact-kind.js +87 -0
- package/workspace/public/pm/bd-ini-panel.js +6 -6
- package/workspace/public/pm/bd-span.js +7 -1
- package/workspace/public/pm/bd-work.css +62 -0
- package/workspace/public/pm/bd-work.js +195 -68
- package/workspace/public/pm/cozy-bar.css +11 -0
- package/workspace/public/pm/cozy-bar.js +99 -0
- package/workspace/public/pm/cozy-day-pick.css +27 -0
- package/workspace/public/pm/cozy-day-pick.js +97 -0
- package/workspace/public/pm/cozy-ev.css +0 -4
- package/workspace/public/pm/cozy-events-view.js +165 -33
- package/workspace/public/pm/cozy-events.css +75 -3
- package/workspace/public/pm/cozy-events.js +86 -18
- package/workspace/public/pm/cozy-goals.css +172 -0
- package/workspace/public/pm/cozy-library.css +106 -17
- package/workspace/public/pm/cozy-nav.js +2 -3
- package/workspace/public/pm/cozy-pick.css +3 -0
- package/workspace/public/pm/cozy-pop-work.css +83 -24
- package/workspace/public/pm/cozy-pop-work.js +313 -72
- package/workspace/public/pm/cozy-popup.css +11 -2
- package/workspace/public/pm/cozy-popup.js +67 -9
- package/workspace/public/pm/cozy-routine-job.js +203 -0
- package/workspace/public/pm/cozy-routine-model.js +139 -31
- package/workspace/public/pm/cozy-routine-pop.js +164 -42
- package/workspace/public/pm/cozy-routine.css +61 -8
- package/workspace/public/pm/cozy-routine.js +207 -28
- package/workspace/public/pm/cozy-settings.js +1 -5
- package/workspace/public/pm/cozy-status-when.js +48 -0
- package/workspace/public/pm/cozy-viewer.js +19 -8
- package/workspace/public/pm/cozy-vw-mtg.css +39 -0
- package/workspace/public/pm/goals-model.js +205 -0
- package/workspace/public/pm/goals-open.js +124 -0
- package/workspace/public/pm/home-chat.js +4 -2
- package/workspace/public/pm/home-ini.js +8 -6
- package/workspace/public/pm/ini-edit.js +3 -1
- package/workspace/public/pm/ini-view-model.js +1 -1
- package/workspace/public/pm/library-model.js +170 -42
- package/workspace/public/pm/library-open.js +8 -5
- package/workspace/public/pm/page-chat.js +12 -2
- package/workspace/public/pm/pop-work-model.js +199 -41
- package/workspace/public/pm/premium-board.js +108 -43
- package/workspace/public/pm/premium-goals.js +213 -0
- package/workspace/public/pm/premium-library.js +376 -62
- package/workspace/public/pm/premium-shell.js +1 -1
- package/workspace/public/pm/premium-vw-mtg.js +79 -1
- package/workspace/public/pm/scope-chip.js +207 -0
- package/workspace/public/premium-events.html +3 -1
- package/workspace/public/premium-goals.html +37 -0
- package/workspace/public/premium-library.html +15 -7
- package/workspace/public/premium-routine.html +2 -0
- package/workspace/server.js +2 -1
- package/workspace/test-lists/doc-path.json +9 -0
- package/workspace/test-lists/goals-place.json +9 -0
- package/workspace/test-lists/status-when.json +9 -0
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
/* pm/cozy-routine.css — Routine (initiative routine-place, board 11) and a routine in the popup (board 10). One container: the page panel; the
|
|
2
2
|
* table is one card with a thin border; the setup is one grey box. Tokens are cozy.css's. */
|
|
3
3
|
.rt-page { gap: 14px; }
|
|
4
|
+
/* on a wide screen the page keeps one reading width and does not stretch (round 2) */
|
|
5
|
+
.rt-page > * { width: 100%; max-width: 1200px; }
|
|
6
|
+
.rt-pick:empty { display: none; }
|
|
7
|
+
.rt-seg .rt-n { margin-left: 6px; font-weight: var(--fw-strong); color: var(--cz-ink3); font-variant-numeric: tabular-nums; }
|
|
8
|
+
.rt-hid { margin: 0 0 10px; font-size: var(--fs-meta); color: var(--cz-ink3); }
|
|
9
|
+
.rt-hid button { all: unset; cursor: pointer; color: var(--cz-blue); font-weight: var(--fw-strong); }
|
|
10
|
+
.rt-hid button:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 2px; border-radius: 4px; }
|
|
4
11
|
.rt-bar { display: flex; align-items: center; gap: 12px; }
|
|
5
12
|
.rt-seg { display: inline-flex; gap: 2px; padding: 4px; border-radius: 999px; background: var(--cz-well); flex-wrap: wrap; }
|
|
6
13
|
.rt-seg button { all: unset; cursor: pointer; height: 30px; padding: 0 14px; border-radius: 999px; font-size: var(--fs-body); font-weight: var(--fw-strong); color: var(--cz-ink2); display: inline-flex; align-items: center; }
|
|
@@ -14,7 +21,18 @@
|
|
|
14
21
|
.rt-did span { flex: 1; min-width: 0; }
|
|
15
22
|
.rt-did em { font-style: normal; color: var(--cz-ink3); }
|
|
16
23
|
.rt-tbl { border-radius: 16px; background: var(--cz-card); box-shadow: inset 0 0 0 1px var(--cz-hair); overflow: hidden; font-size: var(--fs-body); color: var(--cz-ink); }
|
|
17
|
-
.rt-r { display: grid; grid-template-columns: 26px minmax(
|
|
24
|
+
.rt-r { display: grid; grid-template-columns: 26px minmax(180px, 1.3fr) 76px minmax(160px, 1fr) 196px 112px 44px 14px; align-items: center; column-gap: 12px; min-height: 46px; padding: 0 18px; box-shadow: inset 0 -1px 0 var(--cz-hair); }
|
|
25
|
+
.rt-tbl.multi .rt-r { grid-template-columns: 26px minmax(180px, 1.3fr) 76px 128px minmax(160px, 1fr) 196px 112px 44px 14px; }
|
|
26
|
+
/* the row is the way in: a small chevron shows on hover (round 3 item 5) */
|
|
27
|
+
.rt-r .go { color: var(--cz-ink3); display: grid; place-items: center; opacity: 0; }
|
|
28
|
+
.rt-r .go svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
|
|
29
|
+
.rt-r.rt-row:hover .go, .rt-r.rt-row:focus-visible .go { opacity: 1; }
|
|
30
|
+
/* one-time reports and loose drafts: one fold line at the end of Reports (round 3 item 1) */
|
|
31
|
+
.rt-r.rt-fold { display: block; min-height: 40px; padding: 0 18px; }
|
|
32
|
+
.rt-fold button { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; min-height: 40px; font-size: var(--fs-meta); color: var(--cz-ink3); }
|
|
33
|
+
.rt-fold button svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s; }
|
|
34
|
+
.rt-fold button[aria-expanded="true"] svg { transform: rotate(90deg); }
|
|
35
|
+
.rt-fold button:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 2px; border-radius: 4px; }
|
|
18
36
|
.rt-r:last-child { box-shadow: none; }
|
|
19
37
|
.rt-r.rt-h { min-height: 38px; background: var(--cz-well); font-size: var(--fs-meta); font-weight: var(--fw-strong); color: var(--cz-ink2); }
|
|
20
38
|
.rt-r.rt-g { min-height: 34px; font-size: var(--fs-meta); font-weight: var(--fw-strong); color: var(--cz-ink3); background: var(--cz-well); }
|
|
@@ -24,8 +42,10 @@
|
|
|
24
42
|
.rt-r .e { display: flex; justify-content: flex-end; align-items: center; }
|
|
25
43
|
.rt-r .ic { color: var(--cz-ink3); display: grid; place-items: center; }
|
|
26
44
|
.rt-r .ic svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
|
|
27
|
-
.rt-r .n { font-weight: var(--fw-strong);
|
|
28
|
-
|
|
45
|
+
.rt-r .n { font-weight: var(--fw-strong); }
|
|
46
|
+
/* nothing is cut off (round 2): a long name or sentence takes a second line, and only a third is cut */
|
|
47
|
+
.rt-r .n, .rt-r .c { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin: 6px 0; line-height: 1.35; }
|
|
48
|
+
.rt-r .c { color: var(--cz-ink2); }
|
|
29
49
|
.rt-r .w { color: var(--cz-risk); font-weight: var(--fw-strong); display: inline-flex; align-items: center; gap: 7px; }
|
|
30
50
|
.rt-r .w::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--cz-dot-risk); flex: none; }
|
|
31
51
|
.rt-r.off .n, .rt-r.off .c { color: var(--cz-ink3); }
|
|
@@ -43,7 +63,9 @@
|
|
|
43
63
|
.rt-toast.on { opacity: 1; }
|
|
44
64
|
@media (max-width: 760px) {
|
|
45
65
|
.rt-r { grid-template-columns: 22px minmax(0, 1fr) minmax(0, .8fr) 44px; padding: 0 12px; min-height: 52px; }
|
|
46
|
-
.rt-r .
|
|
66
|
+
.rt-r .go { display: none; }
|
|
67
|
+
.rt-tbl.multi .rt-r { grid-template-columns: 22px minmax(0, 1fr) minmax(0, .8fr) 44px; }
|
|
68
|
+
.rt-r .c.does, .rt-r .c.when, .rt-r.rt-h .does, .rt-r.rt-h .when, .rt-r .type, .rt-r .prod { display: none; }
|
|
47
69
|
.rt-seg { border-radius: 16px; }
|
|
48
70
|
}
|
|
49
71
|
.vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
|
|
@@ -96,7 +118,38 @@
|
|
|
96
118
|
.rp-box .rp-in { height: 28px; border-radius: 10px; border: 0; padding: 0 8px; font: inherit; font-size: var(--fs-meta); background: var(--cz-card); max-width: 170px; }
|
|
97
119
|
.rp-box p { margin: 12px 2px 0; font-size: var(--fs-meta); line-height: 1.45; color: var(--cz-ink3); }
|
|
98
120
|
.rp-box .rt-sw { justify-self: auto; }
|
|
99
|
-
/* a read, a job or your task in the popup
|
|
100
|
-
.
|
|
101
|
-
.
|
|
102
|
-
.
|
|
121
|
+
/* a read, a job, a service or your task in the popup (cozy-routine-job.js): Instruction and Last runs beside the Setup box */
|
|
122
|
+
.rj-sec { margin: 0 0 18px; }
|
|
123
|
+
.rj-sec h6 { margin: 0 0 6px; font-size: var(--fs-meta); font-weight: var(--fw-strong); color: var(--cz-ink3); }
|
|
124
|
+
.rj-ins { box-sizing: border-box; width: 100%; min-height: 96px; resize: vertical; border: 0; border-radius: 12px; padding: 10px 12px; font: inherit; font-size: var(--fs-body); line-height: 1.5; color: var(--cz-ink); background: var(--cz-well); }
|
|
125
|
+
.rj-ins:focus { outline: 2px solid var(--cz-ink3); outline-offset: 1px; }
|
|
126
|
+
.rj-act { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
|
|
127
|
+
.rj-act .rp-y { all: unset; cursor: pointer; flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--cz-ink); color: var(--cz-card); }
|
|
128
|
+
.rj-act .rp-y[disabled] { opacity: .5; cursor: default; }
|
|
129
|
+
.rj-hint { margin: 0; font-size: var(--fs-meta); line-height: 1.45; color: var(--cz-ink3); }
|
|
130
|
+
.rj-hint b { font-weight: var(--fw-strong); color: var(--cz-ink2); }
|
|
131
|
+
.rj-txt { margin: 0 0 6px; }
|
|
132
|
+
.rj-run { display: flex; gap: 12px; align-items: baseline; min-height: 32px; padding: 6px 0; box-shadow: inset 0 -1px 0 var(--cz-hair); font-size: var(--fs-meta); }
|
|
133
|
+
.rj-run span { flex: none; width: 110px; color: var(--cz-ink3); }
|
|
134
|
+
.rj-run em { font-style: normal; min-width: 0; overflow-wrap: anywhere; }
|
|
135
|
+
.rj-run.bad em { color: var(--cz-risk); }
|
|
136
|
+
.rj-undo, .rt-tundo { all: unset; cursor: pointer; font-weight: var(--fw-strong); text-decoration: underline; text-underline-offset: 2px; }
|
|
137
|
+
.rt-toast.on:has(.rt-tundo) { pointer-events: auto; }
|
|
138
|
+
.rj-act .rp-n { all: unset; cursor: pointer; flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--cz-card); box-shadow: inset 0 0 0 1px var(--cz-hair); color: var(--cz-ink); }
|
|
139
|
+
.rp-ins h6 { display: flex; align-items: center; gap: 4px; min-height: 32px; }
|
|
140
|
+
.rp-ins h6 .rp-ed { margin-left: 0; width: 28px; height: 28px; }
|
|
141
|
+
.rp-insx { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; color: var(--cz-ink2); }
|
|
142
|
+
/* ✕ on a proposed report: shown on hover, where the chevron is */
|
|
143
|
+
.rt-r .go .rt-drop { all: unset; cursor: pointer; width: 26px; height: 26px; margin: -6px; border-radius: 50%; display: grid; place-items: center; color: var(--cz-ink3); }
|
|
144
|
+
.rt-r .go .rt-drop:hover { background: var(--cz-well); color: var(--cz-ink); }
|
|
145
|
+
.rt-r .go:has(.rt-drop) { opacity: 0; }
|
|
146
|
+
.rt-r.rt-row:hover .go:has(.rt-drop), .rt-r .go:has(.rt-drop:focus-visible) { opacity: 1; }
|
|
147
|
+
.rp-hold ol { margin: 0; padding-left: 20px; font-size: var(--fs-body); line-height: 1.5; }
|
|
148
|
+
.rp-hold li { margin: 0 0 4px; color: var(--cz-ink2); }
|
|
149
|
+
.rp-hold li b { font-weight: var(--fw-strong); color: var(--cz-ink); }
|
|
150
|
+
/* PMOS reads and PMOS jobs fold to their heading while a program or project is picked */
|
|
151
|
+
.rt-gf { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; }
|
|
152
|
+
.rt-gf svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s; }
|
|
153
|
+
.rt-gf[aria-expanded="true"] svg { transform: rotate(90deg); }
|
|
154
|
+
.rt-gf em { font-style: normal; color: var(--cz-ink3); font-weight: var(--fw-regular); }
|
|
155
|
+
.rt-gf:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 2px; border-radius: 4px; }
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* pm/cozy-routine.js — Routine, the place (initiative routine-place, slice 8 of the six-place navigation; board 11 on Exploring 2; build plan
|
|
2
2
|
* /mnt/project-files/nav-structure/build-plan.md; done test planning/done-tests/routine-place.md).
|
|
3
3
|
*
|
|
4
|
-
* One table of everything that repeats: Routine, What it does, When, Next, and
|
|
4
|
+
* One table of everything that repeats: Routine, Type, Product (two products or more), What it does, When, Next, and the same switch on every row. Groups: Waits for you,
|
|
5
5
|
* Reports, PMOS reads, PMOS jobs, Your tasks (pm/cozy-routine-model.js). The kinds above it filter the table; PMOS remembers the choice on this
|
|
6
6
|
* computer. "PMOS did" is one line on top; a press opens the full log in the popup, each line with its Undo. + opens Ask PMOS about a new
|
|
7
7
|
* routine. A row opens the one popup (pm/cozy-routine-pop.js). It replaces the Scheduled work list of Settings › Connectors, which now goes here.
|
|
@@ -9,29 +9,38 @@
|
|
|
9
9
|
* READS GET /api/workspaces, then per product GET /api/report-setups/routine?ws and GET /api/autonomy?ws; once GET /api/refresh and
|
|
10
10
|
* GET /api/schedules?all=1. Every product is read: Routine has no product choice (slice 1).
|
|
11
11
|
* WRITES, each the PM's press: a report's switch → POST /api/report-setups/pause | resume; a read or a job → POST /api/refresh/source { id, on };
|
|
12
|
-
* your task → POST /api/schedules/update { id, enabled }; the
|
|
12
|
+
* your task → POST /api/schedules/update { id, enabled }; the switch of a proposed report (Waits for you) → /api/report-setups/confirm; Undo in the log →
|
|
13
13
|
* POST /api/autonomy/undo. Nothing here runs a routine or sends anything. */
|
|
14
14
|
import { pmGet, pmPost } from './http.js';
|
|
15
15
|
import { mountNav } from './cozy-nav.js';
|
|
16
16
|
import { mountLivePill } from './cozy-live-pill.js';
|
|
17
17
|
import * as VW from './cozy-viewer.js';
|
|
18
18
|
import * as POP from './cozy-popup.js';
|
|
19
|
-
import { KINDS, routineRows, routineGroups, didLine } from './cozy-routine-model.js';
|
|
19
|
+
import { KINDS, routineRows, routineGroups, didLine, kindCounts, productsOf, productName } from './cozy-routine-model.js';
|
|
20
|
+
import * as PK from './cozy-pick.js'; // the saved product pick of Work, Today and Goals
|
|
21
|
+
import { scopeChipHtml, openScope, scopeWords, whenNames, displayName } from './scope-chip.js'; // one chip for products, programs and projects (shared with Events)
|
|
20
22
|
import { atOf } from './cozy-evmodel.js';
|
|
21
|
-
import { openReport
|
|
23
|
+
import { openReport } from './cozy-routine-pop.js';
|
|
24
|
+
import { openJob, openNew } from './cozy-routine-job.js'; // reads, jobs, services and your tasks: manage them in the popup (round 3 item 3)
|
|
22
25
|
|
|
23
26
|
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]);
|
|
24
27
|
const svg = (d, n = 18) => `<svg viewBox="0 0 24 24" width="${n}" height="${n}" aria-hidden="true"><path d="${d}"/></svg>`;
|
|
25
28
|
const I = {
|
|
26
29
|
reports: 'M4 20V10M10 20V4M16 20v-8M22 20H2', reads: 'M2.5 12s3.5-6 9.5-6 9.5 6 9.5 6-3.5 6-9.5 6-9.5-6-9.5-6zM12 9.5a2.5 2.5 0 1 0 0 5a2.5 2.5 0 1 0 0-5',
|
|
27
30
|
jobs: 'M12 3l1.8 4.7L18.5 9.5l-4.7 1.8L12 16l-1.8-4.7L5.5 9.5l4.7-1.8z', tasks: 'M5 5h14v14H5zM8.5 12.5l2.5 2.5 4.5-5',
|
|
28
|
-
check: 'M5 12.5l4.5 4.5L19 7.5', chev: 'M9 6l6 6-6 6', undo: 'M9 14L4 9l5-5M4 9h10a6 6 0 0 1 0 12h-3',
|
|
31
|
+
check: 'M5 12.5l4.5 4.5L19 7.5', x: 'M6 6l12 12M18 6L6 18', chev: 'M9 6l6 6-6 6', undo: 'M9 14L4 9l5-5M4 9h10a6 6 0 0 1 0 12h-3',
|
|
29
32
|
};
|
|
30
33
|
const KIND_KEY = 'pmos.routine.kind';
|
|
31
34
|
const store = { get(k) { try { return localStorage.getItem(k); } catch { return null; } }, set(k, v) { try { localStorage.setItem(k, v); } catch { /* a private window */ } } };
|
|
32
|
-
const S = { ws: [], reports: [], refresh: [], tasks: [], done: [], kind: KINDS.some(([k]) => k === store.get(KIND_KEY)) ? store.get(KIND_KEY) : 'all', rows: [], busy: new Set(), read: false, err: '' };
|
|
35
|
+
const S = { ws: [], reports: [], refresh: [], tasks: [], done: [], kind: KINDS.some(([k]) => k === store.get(KIND_KEY)) ? store.get(KIND_KEY) : 'all', rows: [], busy: new Set(), gone: new Set(), read: false, err: '', pick: null, all: false, openG: new Set() };
|
|
33
36
|
const $ = (id) => document.getElementById(id);
|
|
34
|
-
|
|
37
|
+
/** A short line at the bottom. With `undo`, it carries an Undo button and stays 10 s, the time the undo has. */
|
|
38
|
+
const toast = (t, undo) => {
|
|
39
|
+
const el = $('toast'); if (!el) return;
|
|
40
|
+
el.textContent = t;
|
|
41
|
+
if (undo) { const b = document.createElement('button'); b.type = 'button'; b.className = 'rt-tundo'; b.textContent = 'Undo'; b.onclick = () => { undo(); el.classList.remove('on'); }; el.append(' ', b); }
|
|
42
|
+
el.classList.add('on'); clearTimeout(toast.t); toast.t = setTimeout(() => el.classList.remove('on'), undo ? 10000 : 4200);
|
|
43
|
+
};
|
|
35
44
|
const say = (t) => { const el = $('rtMsg'); if (el) el.textContent = t || ''; };
|
|
36
45
|
const enc = encodeURIComponent;
|
|
37
46
|
|
|
@@ -40,9 +49,28 @@ mountLivePill(document);
|
|
|
40
49
|
|
|
41
50
|
async function load() {
|
|
42
51
|
const w = await pmGet('/api/workspaces').catch(() => null);
|
|
43
|
-
|
|
52
|
+
// a product's display name, as Work shows it ("IDPF", not "pmos-idpf"); a work copy takes the name of its product
|
|
53
|
+
const raw = w && Array.isArray(w.workspaces) ? w.workspaces : [];
|
|
54
|
+
// the product a workspace is a copy of: a "⑂" work copy, or a linked git worktree of the same repository (a folder name such as "mainwt"
|
|
55
|
+
// never shows: the copy takes its product's name, and a product with no display name takes its repository's name)
|
|
56
|
+
const mainOf = (x) => {
|
|
57
|
+
const n = productName(x.name || x.id);
|
|
58
|
+
const up = (n !== (x.name || x.id) && raw.find((y) => y.name === n)) || (x.linked && x.repo_key && raw.find((y) => y !== x && !y.linked && y.repo_key === x.repo_key));
|
|
59
|
+
return up && up !== x ? up : null;
|
|
60
|
+
};
|
|
61
|
+
const own = displayName; // the chip's rule (pm/scope-chip.js), so the column and the chip agree
|
|
62
|
+
S.ws = raw.map((x) => { const m = mainOf(x); return { id: x.id, name: m ? own(m) : own(x), slug: x.name || x.id, main: m ? m.id : null }; });
|
|
63
|
+
const home = (raw.find((x) => x.home) || raw[0] || {}).id; // Horizon scan and Report finder are settings of the home product
|
|
44
64
|
const per = await Promise.all(S.ws.map((x) => Promise.all([pmGet('/api/report-setups/routine?ws=' + enc(x.id)).catch(() => null), pmGet('/api/autonomy?ws=' + enc(x.id)).catch(() => null)])));
|
|
45
|
-
const [rf, sc] = await Promise.all([pmGet('/api/refresh').catch(() => null), pmGet('/api/schedules?all=1').catch(() => null)
|
|
65
|
+
const [rf, sc, pk, scan, rs, pg] = await Promise.all([pmGet('/api/refresh').catch(() => null), pmGet('/api/schedules?all=1').catch(() => null), PK.readPick().catch(() => null),
|
|
66
|
+
home ? pmGet('/api/scan/portfolio?ws=' + enc(home)).catch(() => null) : null, home ? pmGet('/api/report-setups?ws=' + enc(home)).catch(() => null) : null, pmGet('/api/programs').catch(() => null)]);
|
|
67
|
+
// the two PMOS jobs whose schedule lives with their own setting: Horizon scan and Report finder (round 2 note 3)
|
|
68
|
+
S.jobs = {
|
|
69
|
+
scan: scan && scan.setting ? { cadence: scan.setting.cadence, was: scan.setting.cadence !== 'off' ? scan.setting.cadence : 'daily', when: scan.setting.cadence === 'off' ? 'Off' : String(scan.schedule || ''), on: scan.setting.cadence !== 'off' } : null,
|
|
70
|
+
finder: rs && rs.finder ? { when: rs.finder.cadence === 'off' ? 'Off' : rs.finder.cadence === 'weekly' ? 'Every week' : String(rs.finder.cadence), next: rs.finder.cadence === 'off' ? null : rs.finder.next_run || null, on: rs.finder.cadence !== 'off' } : null,
|
|
71
|
+
};
|
|
72
|
+
S.pick = pk; S.home = home;
|
|
73
|
+
S.programs = pg && pg.ok && Array.isArray(pg.programs) ? pg.programs : [];
|
|
46
74
|
S.reports = []; S.done = [];
|
|
47
75
|
per.forEach(([r, a], i) => {
|
|
48
76
|
const x = S.ws[i];
|
|
@@ -51,40 +79,139 @@ async function load() {
|
|
|
51
79
|
});
|
|
52
80
|
S.done.sort((a, b) => String(b.at || '').localeCompare(String(a.at || '')));
|
|
53
81
|
S.refresh = rf && rf.ok && Array.isArray(rf.rows) ? rf.rows : [];
|
|
54
|
-
|
|
82
|
+
const nameOf = new Map(S.ws.map((x) => [x.id, x.name]));
|
|
83
|
+
S.tasks = sc && Array.isArray(sc.schedules) ? sc.schedules.map((t) => (t && t.ws ? { ...t, wsName: nameOf.get(t.ws) || t.ws } : t)) : [];
|
|
55
84
|
S.err = !w ? 'PMOS is not answering. The table shows again when it is back.' : '';
|
|
56
85
|
S.read = true;
|
|
57
86
|
draw();
|
|
58
87
|
}
|
|
59
88
|
|
|
60
|
-
function kindsHtml() {
|
|
61
|
-
|
|
89
|
+
function kindsHtml(n) {
|
|
90
|
+
// each kind says how many it holds (round 2); All needs no number, and a kind with none says none (zero is silence)
|
|
91
|
+
return KINDS.map(([k, l]) => `<button type="button" data-kind="${k}" aria-pressed="${S.kind === k}"${k !== 'all' && n ? ` aria-label="${esc(l + ', ' + (n[k] || 0))}"` : ''}>${esc(l)}${k !== 'all' && n && n[k] ? `<span class="rt-n">${n[k]}</span>` : ''}</button>`).join('');
|
|
92
|
+
}
|
|
93
|
+
/* ── the chip (round 2, PR 3): the shared scope chip of Events (pm/scope-chip.js). Products is the saved pick of Work; Programs and Projects
|
|
94
|
+
* are this page's own (kept on this computer). A report is under a program or a project when its setup says so (lib/routine-reports.js
|
|
95
|
+
* about). Reads and PMOS jobs serve every product, so they always show. "Show all" shows everything on this page once, and leaves the
|
|
96
|
+
* saved pick and the page's own choice as they are. ── */
|
|
97
|
+
const SCOPE_KEY = 'pmos.routine.scope.v1';
|
|
98
|
+
S.sel = (() => { try { const v = JSON.parse(store.get(SCOPE_KEY) || '{}'); return { programs: Array.isArray(v.programs) ? v.programs : [], projects: Array.isArray(v.projects) ? v.projects : [] }; } catch { return { programs: [], projects: [] }; } })();
|
|
99
|
+
const onSet = () => { const P = S.pick; if (!P || S.all) return null; const on = P.products.filter((p) => p.on).map((p) => p.ws); return on.length && on.length < P.products.length ? new Set(on) : null; };
|
|
100
|
+
/** The product a workspace belongs to in the pick: a work copy ("pmos-idpf ⑂ initiative/x") counts as its product. */
|
|
101
|
+
function prodWs(id) {
|
|
102
|
+
const P = S.pick; if (!P || !id) return id;
|
|
103
|
+
if (P.products.some((p) => p.ws === id)) return id;
|
|
104
|
+
const w = S.ws.find((x) => x.id === id);
|
|
105
|
+
return w && w.main && P.products.some((p) => p.ws === w.main) ? w.main : id;
|
|
106
|
+
}
|
|
107
|
+
const inPick = (on) => (x) => !on || !x.ws || on.has(prodWs(x.ws));
|
|
108
|
+
/** A row's tokens for the chip: its product, its project and the programs that hold that project, or its program. */
|
|
109
|
+
function scopeOfRow(r) {
|
|
110
|
+
if (!r.ws) return null; // a read or a PMOS job: every product
|
|
111
|
+
const pw = prodWs(r.ws), out = ['p:' + pw];
|
|
112
|
+
const a = r.kind === 'reports' ? (reportOf(r) || {}).about : null;
|
|
113
|
+
if (a && a.level === 'program') out.push('g:' + a.id);
|
|
114
|
+
if (a && a.level === 'initiative') {
|
|
115
|
+
out.push('j:' + pw + '|' + a.id);
|
|
116
|
+
for (const g of S.programs) if ((g.members || []).some((m) => m && m.initiative === a.id && (!m.ws || m.ws === pw || prodWs(m.ws) === pw))) out.push('g:' + g.id);
|
|
117
|
+
}
|
|
118
|
+
return out;
|
|
119
|
+
}
|
|
120
|
+
/** The chip's Programs and Projects: only the ones a routine is under; a project says its product and its count of routines. */
|
|
121
|
+
function groupsOf(rows) {
|
|
122
|
+
const n = new Map(), name = new Map();
|
|
123
|
+
for (const r of rows) for (const t of r.scope || []) if (t[0] !== 'p') {
|
|
124
|
+
n.set(t, (n.get(t) || 0) + 1);
|
|
125
|
+
if (t.startsWith('j:') && !name.has(t)) name.set(t, String(r.name).split(' · ')[0]); // a ready-made report is "<project> · <kind>"
|
|
126
|
+
}
|
|
127
|
+
const wsName = (id) => (S.ws.find((x) => x.id === id) || {}).name || '';
|
|
128
|
+
const programs = [...n.keys()].filter((t) => t.startsWith('g:')).map((t) => { const g = S.programs.find((x) => 'g:' + x.id === t); return { id: t, name: (g && g.title) || t.slice(2), n: n.get(t) }; });
|
|
129
|
+
const projects = [...n.keys()].filter((t) => t.startsWith('j:')).map((t) => ({ id: t, name: name.get(t) || t.split('|')[1], product: wsName(t.slice(2).split('|')[0]), n: n.get(t) }));
|
|
130
|
+
return { programs, projects };
|
|
131
|
+
}
|
|
132
|
+
const extraOn = () => !S.all && (S.sel.programs.length > 0 || S.sel.projects.length > 0);
|
|
133
|
+
const inScope = (r) => !extraOn() || !r.scope || [...S.sel.programs, ...S.sel.projects].some((t) => r.scope.includes(t));
|
|
134
|
+
function drawPick(groups) {
|
|
135
|
+
const host = $('rtPick'); if (!host) return;
|
|
136
|
+
const P = S.pick && S.pick.products && S.pick.products.length ? S.pick : null;
|
|
137
|
+
const has = (P && P.products.length > 1) || groups.programs.length || groups.projects.length;
|
|
138
|
+
const shown = S.all && P ? { ...P, products: P.products.map((p) => ({ ...p, on: true })) } : P;
|
|
139
|
+
host.innerHTML = has ? scopeChipHtml(shown, S.all ? { programs: [], projects: [] } : S.sel, { id: 'rtPickBtn', groups }) : '';
|
|
140
|
+
const chip = $('rtPickBtn'); if (!chip) return;
|
|
141
|
+
chip.onclick = (e) => {
|
|
142
|
+
e.stopPropagation();
|
|
143
|
+
openScope(chip, { P: S.pick, groups, sel: S.sel, unit: 'routines', onApply: (next) => {
|
|
144
|
+
S.sel = { programs: next.programs || [], projects: next.projects || [] }; S.all = false;
|
|
145
|
+
store.set(SCOPE_KEY, S.sel.programs.length || S.sel.projects.length ? JSON.stringify(S.sel) : null);
|
|
146
|
+
draw();
|
|
147
|
+
} });
|
|
148
|
+
};
|
|
62
149
|
}
|
|
63
|
-
|
|
150
|
+
whenNames().then(() => draw()); // product display names (IDPF, not a folder name) arrive after the first draw
|
|
151
|
+
addEventListener('pp:changed', (e) => { if (e.detail && e.detail.ok) { S.pick = e.detail; S.all = false; draw(); } });
|
|
152
|
+
/** The fold line at the end of Reports: one-time reports and loose drafts, opened as plain rows. */
|
|
153
|
+
const foldHtml = (f) => `<div class="rt-r rt-fold" role="row"><button type="button" role="cell" data-once aria-expanded="${!!S.once}">${svg(I.chev, 14)}<span>${esc(f.words)}</span></button></div>`;
|
|
154
|
+
/** The Product cell: the product, or the first and +N when one report is in several. Empty for what serves every product. */
|
|
155
|
+
const prodWords = (r) => (r.wss && r.wss.length ? r.wss[0] + (r.wss.length > 1 ? ' +' + (r.wss.length - 1) : '') : '');
|
|
156
|
+
function rowHtml(r, multi) {
|
|
64
157
|
const busy = S.busy.has(r.key);
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
158
|
+
// round 3 item 1: the same switch on every row. A proposed routine's switch is off, and turning it on is the yes.
|
|
159
|
+
const label = r.proposed ? r.name + ': proposed by PMOS. Press to start it' : r.name + (r.on ? ': on. Press to pause it' : ': paused. Press to start it again');
|
|
160
|
+
const end = r.on === null ? '<span></span>'
|
|
161
|
+
: `<button type="button" class="rt-sw" role="switch" aria-checked="${r.on}" data-sw="${esc(r.key)}" aria-label="${esc(label)}" title="${r.proposed ? 'Proposed. Turn on to start it' : r.on ? 'On' : 'Paused'}"${busy ? ' disabled' : ''}></button>`;
|
|
162
|
+
const next = r.late || (r.group === 'once' && r.draft) ? `<span class="w">${esc(r.next)}</span>` : esc(r.next);
|
|
69
163
|
return `<div class="rt-r rt-row${r.off ? ' off' : ''}" role="row" tabindex="0" data-key="${esc(r.key)}" aria-label="${esc('Open ' + r.name)}">`
|
|
70
164
|
+ `<span class="ic" role="cell">${svg(I[r.kind], 17)}</span><span class="n" role="cell" title="${esc(r.name)}">${esc(r.name)}</span>`
|
|
165
|
+
+ `<span class="c type" role="cell">${esc(r.type || '')}</span>${multi ? `<span class="c prod" role="cell" title="${esc((r.wss || []).join(', '))}">${esc(prodWords(r))}</span>` : ''}`
|
|
71
166
|
+ `<span class="c does" role="cell" title="${esc(r.does)}">${esc(r.does)}</span><span class="c when" role="cell" title="${esc(r.when)}">${esc(r.when)}</span>`
|
|
72
|
-
+ `<span class="c" role="cell">${next}</span><span role="cell" class="e">${end}</span></div>`;
|
|
167
|
+
+ `<span class="c" role="cell">${next}</span><span role="cell" class="e">${end}</span>${r.proposed && r.kind === 'reports' ? `<span class="go" role="cell"><button type="button" class="rt-drop" data-drop="${esc(r.key)}" aria-label="${esc('Drop ' + r.name + '. PMOS stops proposing it')}" title="Drop this proposal">${svg(I.x, 14)}</button></span>` : `<span class="go" aria-hidden="true">${svg(I.chev, 14)}</span>`}</div>`;
|
|
73
168
|
}
|
|
74
169
|
function draw() {
|
|
75
|
-
|
|
170
|
+
const on = onSet();
|
|
171
|
+
const tag = (rows) => rows.map((r) => ({ ...r, scope: scopeOfRow(r) }));
|
|
172
|
+
const every = S.read ? tag(routineRows({ reports: S.reports, refresh: S.refresh, jobs: S.jobs, tasks: S.tasks, spaces: S.ws.flatMap((x) => [x.id, x.name]) })) : [];
|
|
173
|
+
const groups = groupsOf(every);
|
|
174
|
+
// drop a program or project that no routine is under any more, so the page never filters on one it cannot show
|
|
175
|
+
const known = new Set([...groups.programs, ...groups.projects].map((g) => g.id));
|
|
176
|
+
if (S.read) S.sel = { programs: S.sel.programs.filter((t) => known.has(t)), projects: S.sel.projects.filter((t) => known.has(t)) };
|
|
177
|
+
const mine = S.read ? tag(routineRows({ reports: S.reports.filter(inPick(on)), refresh: S.refresh, jobs: S.jobs, tasks: S.tasks.filter(inPick(on)), spaces: S.ws.flatMap((x) => [x.id, x.name]) })).filter(inScope) : [];
|
|
178
|
+
$('rtKinds').innerHTML = kindsHtml(S.read ? kindCounts(mine.filter((r) => r.group !== 'once' && (!r.unclear || S.unclear))) : null); // the routines, not the one-time reports
|
|
179
|
+
drawPick(groups);
|
|
76
180
|
const D = didLine(S.done);
|
|
77
181
|
$('rtDid').innerHTML = D ? `<button type="button" class="rt-did" data-did aria-label="${esc(D.text + ' Open the full log')}"><b aria-hidden="true">✦</b><span>${esc(D.text)} <em>${esc(D.sub)}</em></span>${svg(I.chev, 14)}</button>` : '';
|
|
78
182
|
if (!S.read) return;
|
|
79
|
-
S.rows =
|
|
80
|
-
|
|
183
|
+
S.rows = mine.filter((r) => !S.gone.has(r.key)); // a deleted task leaves at once; its delete is sent when the Undo has passed
|
|
184
|
+
// rows a PM cannot read are held back, counted in one grey line (round 3 item 2); one-time reports fold under Reports (item 1)
|
|
185
|
+
const unclear = mine.filter((r) => r.unclear && !S.unclear);
|
|
186
|
+
const G = routineGroups(S.rows.filter((r) => !unclear.includes(r)), S.kind);
|
|
187
|
+
const once = (S.kind === 'all' || S.kind === 'reports') ? mine.filter((r) => r.group === 'once' && !unclear.includes(r)) : [];
|
|
188
|
+
if (once.length) {
|
|
189
|
+
const nd = once.filter((r) => r.draft).length, no = once.length;
|
|
190
|
+
const words = (no === 1 ? 'One one-time report' : no + ' one-time reports') + (nd ? ' · ' + (nd === 1 ? 'one draft waits' : nd + ' drafts wait') : '');
|
|
191
|
+
const fold = { key: 'once', fold: true, words };
|
|
192
|
+
let g = G.find((x) => x.id === 'reports');
|
|
193
|
+
if (!g) { g = { id: 'reports', title: 'Reports', rows: [] }; const at = G.findIndex((x) => x.id !== 'wait'); G.splice(at < 0 ? G.length : at, 0, g); }
|
|
194
|
+
g.rows = g.rows.concat([fold], S.once ? once : []);
|
|
195
|
+
}
|
|
196
|
+
// a Product column only when the rows in view come from two products or more
|
|
197
|
+
const multi = productsOf(G.flatMap((g) => g.rows)).length > 1;
|
|
198
|
+
const hid = Math.max(0, routineGroups(every, S.kind).reduce((n, g) => n + g.rows.length, 0) - G.reduce((n, g) => n + g.rows.filter((r) => !r.fold && r.group !== 'once').length, 0));
|
|
199
|
+
// with a program or project picked, PMOS reads and PMOS jobs fold to their heading: they serve every product, so the picked
|
|
200
|
+
// work's own reports come first (design note on #1384). Pressing the heading opens the rows.
|
|
201
|
+
const shut = (g) => extraOn() && (g.id === 'reads' || g.id === 'jobs') && !S.openG.has(g.id) && g.rows.length > 0;
|
|
202
|
+
const head = (g) => shut(g) || (extraOn() && S.openG.has(g.id))
|
|
203
|
+
? `<div class="rt-r rt-g" role="row"><div role="rowheader"><button type="button" class="rt-gf" data-gfold="${esc(g.id)}" aria-expanded="${!shut(g)}" aria-label="${esc((shut(g) ? "Show " : "Fold ") + g.title)}">${svg(I.chev, 14)}<span>${esc(g.title)}</span>${shut(g) ? `<em>${g.rows.length}</em>` : ''}</button></div></div>`
|
|
204
|
+
: `<div class="rt-r rt-g" role="row"><div role="rowheader">${esc(g.title)}</div></div>`;
|
|
205
|
+
const unLine = unclear.length ? `<p class="rt-hid">${unclear.length === 1 ? 'One row is' : unclear.length + ' rows are'} hidden because their source is unclear. <button type="button" data-unclear>Show</button></p>` : '';
|
|
206
|
+
const only = extraOn() ? scopeWords(on ? S.pick : null, S.sel, groups) : '';
|
|
207
|
+
const hidLine = unLine + (hid ? `<p class="rt-hid">${only ? esc('Showing ' + only + ' only. ') + (hid === 1 ? 'One routine is' : hid + ' routines are') : hid === 1 ? 'One routine of another product is' : hid + ' routines of other products are'} not shown. <button type="button" data-showall>Show all</button></p>` : '');
|
|
81
208
|
const f = document.activeElement && document.activeElement.closest && document.activeElement.closest('[data-key],[data-sw],[data-yes]');
|
|
82
209
|
const fk = f ? (f.dataset.key || f.dataset.sw || f.dataset.yes) + (f.dataset.sw ? ':sw' : f.dataset.yes ? ':yes' : '') : '';
|
|
83
|
-
$('rtTable').innerHTML = S.err ? `<p class="rt-quiet">${esc(S.err)}</p>`
|
|
210
|
+
$('rtTable').innerHTML = hidLine + (S.err ? `<p class="rt-quiet">${esc(S.err)}</p>`
|
|
84
211
|
: !G.length ? `<p class="rt-quiet">${S.kind === 'all' ? 'Nothing repeats yet. Tell PMOS what to do on a schedule with +.' : 'Nothing of this kind repeats.'}</p>`
|
|
85
|
-
: `<div class="rt-tbl" role="table" aria-label="Routine"><div class="rt-r rt-h" role="row"><span role="columnheader"><span class="vh">Kind</span></span><span role="columnheader">Routine</span><span role="columnheader" class="does">What it does</span><span role="columnheader" class="when">When</span><span role="columnheader">Next</span><span role="columnheader"><span class="vh">On</span></span></div>`
|
|
86
|
-
+ G.map((g) =>
|
|
87
|
-
+ '<p class="rt-note">Everything that repeats, in one table. Press a row to open it. The switch pauses it.</p>';
|
|
212
|
+
: `<div class="rt-tbl${multi ? ' multi' : ''}" role="table" aria-label="Routine"><div class="rt-r rt-h" role="row"><span role="columnheader"><span class="vh">Kind</span></span><span role="columnheader">Routine</span><span role="columnheader" class="type">Type</span>${multi ? '<span role="columnheader" class="prod">Product</span>' : ''}<span role="columnheader" class="does">What it does</span><span role="columnheader" class="when">When</span><span role="columnheader">Next</span><span role="columnheader"><span class="vh">On</span></span></div>`
|
|
213
|
+
+ G.map((g) => head(g) + (shut(g) ? '' : g.rows.map((r) => (r.fold ? foldHtml(r) : rowHtml(r, multi))).join(''))).join('') + '</div>'
|
|
214
|
+
+ '<p class="rt-note">Everything that repeats, in one table. Press a row to open it. The switch pauses it.</p>');
|
|
88
215
|
if (fk) { const [k, x] = [fk.replace(/:(sw|yes)$/, ''), (/:(sw|yes)$/.exec(fk) || [])[1]]; const el = $('rtTable').querySelector(x === 'sw' ? `[data-sw="${CSS.escape(k)}"]` : x === 'yes' ? `[data-yes="${CSS.escape(k)}"]` : `[data-key="${CSS.escape(k)}"]`); if (el) el.focus(); }
|
|
89
216
|
}
|
|
90
217
|
|
|
@@ -98,22 +225,67 @@ async function press(key, fn) {
|
|
|
98
225
|
await load();
|
|
99
226
|
}
|
|
100
227
|
function flip(r) {
|
|
228
|
+
if (r.proposed) return yes(r);
|
|
101
229
|
return press(r.key, async () => {
|
|
102
230
|
const on = !r.on;
|
|
103
231
|
if (r.kind === 'reports') return said(await pmPost('/api/report-setups/' + (on ? 'resume' : 'pause'), { ws: r.ws || undefined, id: r.id }), r.name + (on ? ' is on.' : ' is paused. PMOS does not draft it until you turn it on.'));
|
|
104
232
|
if (r.kind === 'tasks') return said(await pmPost('/api/schedules/update', { id: r.id, enabled: on }), r.name + (on ? ' runs on its schedule again.' : ' is paused.'));
|
|
233
|
+
if (r.svc) return flipSvc(r, on);
|
|
105
234
|
return said(await pmPost('/api/refresh/source', { id: r.id, on }), r.name + (on ? ' is on.' : ' is paused. PMOS does not run it on its own.'));
|
|
106
235
|
});
|
|
107
236
|
}
|
|
237
|
+
/** One service of Your tools on or off, through the routes that exist: off is its own rhythm "only when you press read"; on follows Your
|
|
238
|
+
* tools again. When Your tools itself is off, turning one service on turns Your tools on and keeps the other services off. */
|
|
239
|
+
async function flipSvc(r, on) {
|
|
240
|
+
const tools = S.refresh.find((x) => x.id === r.parent) || { svcs: [] };
|
|
241
|
+
if (!on) return said(await pmPost('/api/refresh/source', { id: r.parent, svc: r.svc, schedule: { kind: 'manual' } }), r.name + ' is paused. PMOS reads it only when you press read.');
|
|
242
|
+
if (!tools.on) {
|
|
243
|
+
for (const v of tools.svcs || []) if (v.id !== r.svc && !(v.own && v.schedule && v.schedule.kind === 'manual')) await pmPost('/api/refresh/source', { id: r.parent, svc: v.id, schedule: { kind: 'manual' } });
|
|
244
|
+
const x = await pmPost('/api/refresh/source', { id: r.parent, on: true }); if (!(x && x.ok)) return said(x, '');
|
|
245
|
+
}
|
|
246
|
+
return said(await pmPost('/api/refresh/source', { id: r.parent, svc: r.svc, schedule: null }), r.name + ' is on.');
|
|
247
|
+
}
|
|
108
248
|
function yes(r) {
|
|
109
249
|
const rep = reportOf(r); if (!rep || !rep.act) return;
|
|
110
250
|
return press(r.key, async () => (rep.act.act === 'move'
|
|
111
251
|
? said(await pmPost('/api/report-setups/move', { ws: r.ws || undefined, id: r.id, to: rep.act.to }), 'Moved ' + r.name + ' to ' + rep.act.toName + '. It drafts there from now on.')
|
|
112
252
|
: said(await pmPost('/api/report-setups/confirm', { ws: r.ws || undefined, id: r.id }), 'Started ' + r.name + '. Its drafts follow the definition as it is.')));
|
|
113
253
|
}
|
|
114
|
-
|
|
254
|
+
/** A delete or a drop with Undo: the row leaves at once, and the POST is sent when its 10 s of Undo have passed (or when the page closes),
|
|
255
|
+
* so Undo needs no route of its own. */
|
|
256
|
+
const LATER = new Map();
|
|
257
|
+
function later(r, url, body, words) {
|
|
258
|
+
const send = async (keep) => {
|
|
259
|
+
const x = await pmPost(url, body, keep ? { keepalive: true } : undefined).catch(() => null);
|
|
260
|
+
LATER.delete(r.key);
|
|
261
|
+
if (keep) return;
|
|
262
|
+
if (!x || !x.ok) toast(said(x, ''));
|
|
263
|
+
await load(); S.gone.delete(r.key); draw();
|
|
264
|
+
};
|
|
265
|
+
LATER.set(r.key, { send, t: setTimeout(() => send(false), 10000) });
|
|
266
|
+
S.gone.add(r.key); draw();
|
|
267
|
+
toast(words, () => { const L = LATER.get(r.key); if (L) clearTimeout(L.t); LATER.delete(r.key); S.gone.delete(r.key); draw(); });
|
|
268
|
+
}
|
|
269
|
+
addEventListener('pagehide', () => { for (const L of [...LATER.values()]) { clearTimeout(L.t); L.send(true); } });
|
|
270
|
+
function drop(r) { later(r, '/api/report-setups/drop', { ws: r.ws || undefined, id: r.id }, r.name + ' is dropped. PMOS stops proposing it.'); }
|
|
271
|
+
|
|
272
|
+
/** What the popup reads for a row: its record, and for a service the rhythm it shares with Your tools. `fresh` finds the row again after a load. */
|
|
273
|
+
function rawOf(row, fresh) {
|
|
274
|
+
const r = fresh ? rowOf(row.key) || row : row;
|
|
275
|
+
if (r.kind === 'tasks') return { row: r, raw: S.tasks.find((t) => t && t.id === r.id) || {} };
|
|
276
|
+
if (r.svc) {
|
|
277
|
+
const tools = S.refresh.find((x) => x.id === r.parent) || {}, v = (tools.svcs || []).find((x) => x.id === r.svc) || {};
|
|
278
|
+
// repeatOpts reads a service as { svc, own, parent_text, kinds, every, schedule }
|
|
279
|
+
const own = { ...v, svc: v.id, parent: tools.id, own: !!v.own, parent_text: tools.schedule_text, kinds: tools.kinds, every: tools.every, schedule: v.own ? v.schedule : tools.schedule };
|
|
280
|
+
return { row: r, raw: tools, tools, own };
|
|
281
|
+
}
|
|
282
|
+
return { row: r, raw: S.refresh.find((x) => x.id === r.id) || {}, extra: (S.jobs && S.jobs[r.id]) || null };
|
|
283
|
+
}
|
|
284
|
+
const H = { VW, http: { pmGet, pmPost }, reload: () => load(), toast, raw: rawOf, flipSvc: (r, on) => flipSvc(r, on),
|
|
285
|
+
get ws() { return S.home || undefined; },
|
|
286
|
+
later: (r, url, body, words) => later(r, url, body, words) };
|
|
115
287
|
function open(r) {
|
|
116
|
-
if (r.kind === 'reports') { const rep = reportOf(r); if (rep) openReport(rep, H); return; }
|
|
288
|
+
if (r.kind === 'reports') { const rep = reportOf(r); if (rep) openReport({ ...rep, name: r.name, key: r.key, proposed: !!r.proposed, when: rep.when || r.when }, H); return; }
|
|
117
289
|
openJob(r, H);
|
|
118
290
|
}
|
|
119
291
|
|
|
@@ -138,7 +310,14 @@ document.addEventListener('click', (e) => {
|
|
|
138
310
|
const k = e.target.closest('[data-kind]');
|
|
139
311
|
if (k) { S.kind = k.dataset.kind; store.set(KIND_KEY, S.kind); draw(); return; }
|
|
140
312
|
if (e.target.closest('[data-did]')) { openLog(); return; }
|
|
141
|
-
if (e.target.closest('
|
|
313
|
+
if (e.target.closest('[data-showall]')) { S.all = true; draw(); return; }
|
|
314
|
+
if (e.target.closest('[data-unclear]')) { S.unclear = true; draw(); return; }
|
|
315
|
+
if (e.target.closest('[data-once]')) { S.once = !S.once; draw(); return; }
|
|
316
|
+
const gf = e.target.closest('[data-gfold]');
|
|
317
|
+
if (gf) { const id = gf.dataset.gfold; if (S.openG.has(id)) S.openG.delete(id); else S.openG.add(id); draw(); return; }
|
|
318
|
+
// + a new routine (round 3 item 4): the popup with an empty setup, and Ask PMOS asks "What should repeat?". A phone keeps the chat's sheet.
|
|
319
|
+
if (e.target.closest('#rtAdd')) { import('./page-chat.js').then((M) => (window.innerWidth > 760 ? openNew(H, M.targetOf({ id: 'routine-new', kind: 'routine', title: 'New routine' }, S.home)) : M.openCos({ here: 'Routine' }))); return; }
|
|
320
|
+
const d = e.target.closest('[data-drop]'); if (d) { const r = rowOf(d.dataset.drop); if (r) drop(r); return; }
|
|
142
321
|
const s = e.target.closest('[data-sw]'); if (s) { const r = rowOf(s.dataset.sw); if (r && !s.disabled) flip(r); return; }
|
|
143
322
|
const y = e.target.closest('[data-yes]'); if (y) { const r = rowOf(y.dataset.yes); if (r && !y.disabled) yes(r); return; }
|
|
144
323
|
const row = e.target.closest('[data-key]'); if (row && $('rtTable').contains(row)) { const r = rowOf(row.dataset.key); if (r) open(r); }
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* pm/cozy-settings.js — Settings (initiative premium-uncovered-features, E3; canvas EvSettings). A dialog over the page, its sections on the left:
|
|
2
|
-
* General Theme (this device; the place menu's Theme row moved here, feedback batch 16 item 5)
|
|
2
|
+
* General Theme (this device; the place menu's Theme row moved here, feedback batch 16 item 5). No "Viewer opens as": the popup is the one way (popup audit item 9)
|
|
3
3
|
* (this device), Product (which products Home reads: the Products card), Your day (when the end-of-day card shows:
|
|
4
4
|
* time.workEnd, POST /api/settings), Your impact (impact.on, POST /api/settings; canvas GmP1Switch, batch 16 item 7: the one switch
|
|
5
5
|
* for Adler's leaf, the impact log and the weekly check; the page hears `pmos:impact`), Agents write to Jira (fixed: only after Commit).
|
|
@@ -69,7 +69,6 @@ async function pmSend(method, path, body) {
|
|
|
69
69
|
const SECTIONS = [['general', 'General'], ['claude', 'PMOS'], ['connectors', 'Connectors'], ['workspaces', 'Workspaces'], ['updates', 'Updates']];
|
|
70
70
|
const SUBS = { adler: 'Adler', jl: 'Jev and Laya', workflows: 'Workflows' }; // General › Extras and Workspaces › Workflows: each opens as a sub-panel of its section (U4, U1)
|
|
71
71
|
const SRC = { calendar: 'Calendar', wispr: 'Wispr Flow', mail: 'Mail', slack: 'Slack', jira: 'Jira', confluence: 'Confluence', github: 'GitHub', drive: 'Google Drive', figma: 'Figma', website: 'Your websites' };
|
|
72
|
-
const VIEWER_KEY = 'pmos.cz.viewer';
|
|
73
72
|
const T = { el: null, sec: 'general', sub: '', ws: null, st: {}, src: null, con: {}, conn: [], set: null, prods: null, msg: '', busy: false, phase: '', say: '', back: null, fresh: null, reading: '', note: {}, info: false, fold: false, dir: null, q: '', cat: 'all', wait: null, dress: false, more: false, bday: false, dset: {}, wkOpen: new Set(), wkMore: new Set(), arc: false };
|
|
74
73
|
const cmpVer = (a, b) => { const x = String(a || '0').split('-')[0].split('.').map(Number), y = String(b || '0').split('-')[0].split('.').map(Number); for (let i = 0; i < 3; i++) if ((x[i] || 0) !== (y[i] || 0)) return (x[i] || 0) < (y[i] || 0) ? -1 : 1; return 0; };
|
|
75
74
|
const home = () => (T.ws && T.ws[0] ? T.st[T.ws[0].id] : null);
|
|
@@ -97,7 +96,6 @@ function general() {
|
|
|
97
96
|
if (T.sub === 'adler') return T.dress ? dressSec() : subHead('adler') + adlerSec();
|
|
98
97
|
if (T.sub === 'jl') return subHead('jl') + JL.html();
|
|
99
98
|
const theme = (() => { const t = store.get('pmos.c3.theme'); return t === 'light' || t === 'dark' ? t : 'auto'; })();
|
|
100
|
-
const vw = store.get(VIEWER_KEY) === 'popup' ? 'popup' : 'column';
|
|
101
99
|
const P = T.prods, on = P ? P.filter((x) => x.on) : null;
|
|
102
100
|
// the product the pages read (workspace grill W4): the page's own ?ws= first, then the pick; "No product" only when none is registered
|
|
103
101
|
const pageWs = (() => { try { return new URLSearchParams(location.search).get('ws') || ''; } catch { return ''; } })();
|
|
@@ -107,7 +105,6 @@ function general() {
|
|
|
107
105
|
const hours = []; for (let h = 13; h <= 23; h++) hours.push(h);
|
|
108
106
|
const upd = ready() ? `<div class="ev-card ev-upd">${adFace('needs-you')}<span class="ev-pill y">Update</span><p><b>PMOS ${esc(latest())} is ready.</b> <span class="ev-mut">${esc(firstLine())}</span></p><button type="button" class="ev-btn sm" data-ev-go="updates">What's new</button><button type="button" class="ev-btn sm dark" data-ev-upd="update">${appBehind() ? 'Restart to update' : 'Update'}</button></div>` : '';
|
|
109
107
|
return trow('Theme', 'Auto follows your computer', seg('Theme', 'theme', theme, [['light', 'Light'], ['dark', 'Dark'], ['auto', 'Auto']]))
|
|
110
|
-
+ trow('Viewer opens as', 'A column beside the chat, or a popup over it', seg('Viewer opens as', 'viewer', vw, [['column', 'Column'], ['popup', 'Popup']]))
|
|
111
108
|
+ trow('Product', 'Which products Today, Work and Goals read', `<button type="button" class="ev-pick" data-ev-products aria-haspopup="menu">${esc(pname)} ${svg(ICON.down, 14)}</button>`)
|
|
112
109
|
+ trow('Your day', 'When the end-of-day card shows', `<label class="ev-vh" for="evDay">Your day ends at</label><select id="evDay" class="ev-inp" data-ev-day>${hours.map((h) => `<option value="${h}"${h === end ? ' selected' : ''}>${pad(h)}:00</option>`).join('')}</select>`)
|
|
113
110
|
+ trow('Your impact', 'Adler’s sprout and your impact log. Only you see it. Nothing leaves PMOS.', sw(impactOn(), 'data-ev-impact', 'Your impact'))
|
|
@@ -630,7 +627,6 @@ async function press(e) {
|
|
|
630
627
|
T.msg = r && r.ok ? (on ? 'Your impact is on.' : 'Your impact is off. The leaf, the log and the weekly check are hidden.') : (r && r.error) || 'Not saved.';
|
|
631
628
|
draw(); return;
|
|
632
629
|
}
|
|
633
|
-
if (t.dataset.evSeg === 'viewer') { store.set(VIEWER_KEY, t.dataset.v); document.body.classList.toggle('ev-vw-popup', t.dataset.v === 'popup'); draw(); return; }
|
|
634
630
|
// the one product pick (batch 12 item 5): the same list as the chip on Home, Board and Insights, under this row
|
|
635
631
|
if ('evProducts' in t.dataset) {
|
|
636
632
|
const PP = await import('./cozy-pick.js'), P = await PP.readPick();
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/* pm/cozy-status-when.js — "When did this happen?" after a status pick (popup round 3 point 18). A person often moves a task days after the work
|
|
2
|
+
* moved, so the move can carry the real day apart from when it was recorded. One function for every place that moves a status (the popup's
|
|
3
|
+
* Work breakdown, and Work). The server checks the same limits (lib/status-when.js).
|
|
4
|
+
*
|
|
5
|
+
* whenLimits({ today, since }) → { min, max, yesterday } — never after today, never before since (the previous move's day); yesterday is
|
|
6
|
+
* null when it falls before since
|
|
7
|
+
* whenWords(state, happened, today) → the toast: "Done." on today, "Done on 14 Nov, noted today." on an earlier day
|
|
8
|
+
* askWhen(el, { today, since, onPick(iso) }) draws the line into el: When did this happen? [Today] [Yesterday] [Pick a date]. Today is
|
|
9
|
+
* preselected, so Enter saves it; Pick a date opens the app's own day field (pm/cozy-day-pick.js) inside the limits.
|
|
10
|
+
* Returns { save() } (saves the preselected day). Its presses stop at el. */
|
|
11
|
+
import { mountDay, localToday, dayText } from './cozy-day-pick.js';
|
|
12
|
+
|
|
13
|
+
const ms = (v) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(v || '')); return m ? Date.UTC(+m[1], +m[2] - 1, +m[3]) : null; };
|
|
14
|
+
const iso = (n) => new Date(n).toISOString().slice(0, 10);
|
|
15
|
+
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
16
|
+
|
|
17
|
+
export function whenLimits({ today = localToday(), since = null } = {}) {
|
|
18
|
+
const s = ms(since) != null ? String(since).slice(0, 10) : null;
|
|
19
|
+
const min = s && s <= today ? s : null;
|
|
20
|
+
const y = iso(ms(today) - 864e5);
|
|
21
|
+
return { min, max: today, yesterday: !min || y >= min ? y : null };
|
|
22
|
+
}
|
|
23
|
+
export function whenWords(state, happened, today = localToday()) {
|
|
24
|
+
if (!happened || happened >= today) return state + '.';
|
|
25
|
+
const d = new Date(ms(happened)), y = d.getUTCFullYear() !== +String(today).slice(0, 4) ? ' ' + d.getUTCFullYear() : '';
|
|
26
|
+
return state + ' on ' + d.getUTCDate() + ' ' + MON[d.getUTCMonth()] + y + ', noted today.';
|
|
27
|
+
}
|
|
28
|
+
export function askWhen(el, o = {}) {
|
|
29
|
+
const today = o.today || localToday(), L = whenLimits({ today, since: o.since });
|
|
30
|
+
const done = (v) => { if (o.onPick) o.onPick(v); };
|
|
31
|
+
el.classList.add('sw');
|
|
32
|
+
el.innerHTML = '<p class="sw-q" id="swQ">When did this happen?</p><div class="sw-ch" role="group" aria-labelledby="swQ">'
|
|
33
|
+
+ '<button type="button" class="sw-b" data-sw="today" aria-pressed="true">Today</button>'
|
|
34
|
+
+ (L.yesterday ? '<button type="button" class="sw-b" data-sw="yday" aria-pressed="false">Yesterday</button>' : '')
|
|
35
|
+
+ (L.min === today ? '' : '<button type="button" class="sw-b" data-sw="pick" aria-pressed="false" aria-expanded="false">Pick a date</button>') + '</div><div class="sw-day"></div>';
|
|
36
|
+
el.addEventListener('click', (e) => {
|
|
37
|
+
const b = e.target.closest('[data-sw]'); if (!b || !el.contains(b)) return;
|
|
38
|
+
e.stopPropagation();
|
|
39
|
+
if (b.dataset.sw === 'today') return done(today);
|
|
40
|
+
if (b.dataset.sw === 'yday') return done(L.yesterday);
|
|
41
|
+
el.querySelectorAll('[data-sw]').forEach((x) => x.setAttribute('aria-pressed', String(x === b)));
|
|
42
|
+
b.setAttribute('aria-expanded', 'true');
|
|
43
|
+
const box = el.querySelector('.sw-day');
|
|
44
|
+
if (!box.firstChild) mountDay(box, { label: 'Day', value: L.yesterday || today, min: L.min, max: today, today, open: true, onPick: done }).focus();
|
|
45
|
+
});
|
|
46
|
+
el.addEventListener('keydown', (e) => { if (e.key === 'Enter' && !e.target.closest('button, input, .sw-day')) { e.preventDefault(); e.stopPropagation(); done(today); } });
|
|
47
|
+
return { save: () => done(today), limits: L, text: (v) => dayText(v) };
|
|
48
|
+
}
|