@mistriwork/kit 1.0.0-rc.67 → 1.0.0-rc.69
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/dist/client/components/Chart.css +2 -5
- package/dist/client/components/appListModel.d.ts +6 -3
- package/dist/client/components/appListModel.js +9 -4
- package/dist/client/components/useBulkSelection.js +50 -4
- package/dist/client/copy/lists/components/useBulkSelection.d.ts +2 -0
- package/dist/client/copy/lists/components/useBulkSelection.js +2 -0
- package/dist/client/lumenLook.css +0 -9
- package/dist/client/shellMode.d.ts +8 -0
- package/package.json +3 -3
|
@@ -27,11 +27,8 @@
|
|
|
27
27
|
.chart-column-hit { fill: transparent; }
|
|
28
28
|
.chart-column-door:focus-visible .chart-column-hit { stroke: var(--focus); stroke-width: 2px; vector-effect: non-scaling-stroke; }
|
|
29
29
|
.chart-columns-legend { display: flex; flex-wrap: wrap; gap: var(--space-2h) 20px; max-width: none; }
|
|
30
|
-
/* A trend is
|
|
31
|
-
|
|
32
|
-
under it is a look's to show (Lumen's). */
|
|
33
|
-
.spark-host.good { --spark-ink: var(--status-good); }
|
|
34
|
-
.spark-host.bad { --spark-ink: var(--status-critical); }
|
|
30
|
+
/* A trend is neutral: the green or red of good and bad news belongs to the
|
|
31
|
+
change figure beside it alone. The wash under it is a look's to show (Lumen's). */
|
|
35
32
|
.spark-area { display: none; stroke: none; }
|
|
36
33
|
/* A donut's middle says what its figure counts, under it; each legend row ends with its share, in a column of its own
|
|
37
34
|
so the shares line up, the value beside it in the quieter ink. */
|
|
@@ -127,9 +127,12 @@ export declare function subtitleColumns(tableId: string, shown: readonly string[
|
|
|
127
127
|
with the row, so a cell edits the reference and says what it replaces (GridCellEditor.tsx). */
|
|
128
128
|
export declare function editedReferences(spec: Pick<ListSpec, 'table' | 'show' | 'editable' | 'presentation'>): string[];
|
|
129
129
|
/** The column a list's search box searches: the one its records are named by,
|
|
130
|
-
where a filter box can read it — not a
|
|
131
|
-
|
|
132
|
-
|
|
130
|
+
where a filter box can read it — not a column an API cannot filter by. A
|
|
131
|
+
record named by a template (`'{patient_id.name} · {kind}'`, the name read
|
|
132
|
+
through a reference) is searched by that name, `$label`, which the server
|
|
133
|
+
computes in the statement from every column the template reads, references
|
|
134
|
+
included, so the box finds a visit by its patient. The list draws that box
|
|
135
|
+
and its address says it as `search=` (publicAddress.ts), by this one rule. */
|
|
133
136
|
export declare function searchColumn(t: TableMeta | undefined): string | undefined;
|
|
134
137
|
/** The references a list draws — its `show`, its presentation's columns, or every column — by the path each is named from (referenceNames). */
|
|
135
138
|
export declare function listReferenceNames(spec: Pick<ListSpec, 'table' | 'show' | 'presentation'>): Record<string, string>;
|
|
@@ -115,14 +115,19 @@ export function editedReferences(spec) {
|
|
|
115
115
|
return over ? sharedEditedReferences(over, spec) : [];
|
|
116
116
|
}
|
|
117
117
|
/** The column a list's search box searches: the one its records are named by,
|
|
118
|
-
where a filter box can read it — not a
|
|
119
|
-
|
|
120
|
-
|
|
118
|
+
where a filter box can read it — not a column an API cannot filter by. A
|
|
119
|
+
record named by a template (`'{patient_id.name} · {kind}'`, the name read
|
|
120
|
+
through a reference) is searched by that name, `$label`, which the server
|
|
121
|
+
computes in the statement from every column the template reads, references
|
|
122
|
+
included, so the box finds a visit by its patient. The list draws that box
|
|
123
|
+
and its address says it as `search=` (publicAddress.ts), by this one rule. */
|
|
121
124
|
export function searchColumn(t) {
|
|
122
125
|
if (!t)
|
|
123
126
|
return undefined;
|
|
124
127
|
const label = recordLabel(t) === undefined ? labelColumn(t) : labelPath(t);
|
|
125
|
-
|
|
128
|
+
if (label === LABEL_SEGMENT)
|
|
129
|
+
return t.labelTemplate ? label : undefined;
|
|
130
|
+
return label && (!t.filterable || t.filterable.includes(label)) ? label : undefined;
|
|
126
131
|
}
|
|
127
132
|
/** The show clause that fetches the app's columns plus the keys a row needs to open. */
|
|
128
133
|
function showClause(spec) {
|
|
@@ -103,8 +103,8 @@ export function offeredBulk(table, actions, interactive, identity = sessionIdent
|
|
|
103
103
|
assign cannot edit the application, and that is the point. */
|
|
104
104
|
const grantedCommands = shell().app()?.grantedCommands ?? [];
|
|
105
105
|
const commandAllowed = (action) => interactive &&
|
|
106
|
-
|
|
107
|
-
action.command.targets === 'many' &&
|
|
106
|
+
/* `true` is one request for a command that names many records; `'each'` is the one-record command, run once per record. */
|
|
107
|
+
(action.bulk === 'each' ? action.command.targets !== 'many' : action.bulk === true && action.command.targets === 'many') &&
|
|
108
108
|
identity.mode === 'authenticated' &&
|
|
109
109
|
identity.appId === connection &&
|
|
110
110
|
grantedCommands.includes(action.command.id) &&
|
|
@@ -275,12 +275,58 @@ export function useBulkSelection({ table, keyed, actions = [], interactive = tru
|
|
|
275
275
|
const openCommand = (action) => {
|
|
276
276
|
if (running || commandForm || !availableCommands.includes(action))
|
|
277
277
|
return;
|
|
278
|
+
if (action.bulk === 'each')
|
|
279
|
+
return void runEach(action);
|
|
278
280
|
const targets = keyed.filter((record) => selection.includes(record.id)).map(({ key, label }) => ({ key, label }));
|
|
279
281
|
if (!targets.length)
|
|
280
282
|
return;
|
|
281
283
|
setReported(null);
|
|
282
284
|
setCommandRun({ action, targets, epoch: identity.epoch });
|
|
283
285
|
};
|
|
286
|
+
/* `bulk: 'each'`: the command runs once per selected record, in list order, each in its own transaction and each
|
|
287
|
+
answered on its own, so a refusal on one neither undoes nor stops the others (as a fixed action's bulk does). */
|
|
288
|
+
const runEach = async (action) => {
|
|
289
|
+
const runOne = commanding?.runEach;
|
|
290
|
+
if (!runOne)
|
|
291
|
+
return;
|
|
292
|
+
const targets = keyed.filter((record) => selection.includes(record.id));
|
|
293
|
+
if (!targets.length)
|
|
294
|
+
return;
|
|
295
|
+
const epoch = sessionIdentity().epoch;
|
|
296
|
+
const current = () => alive.current && sessionIdentity().epoch === epoch && (state.activeConnection ?? null) === connection;
|
|
297
|
+
setReported(null);
|
|
298
|
+
if (action.confirm) {
|
|
299
|
+
const yes = await new Promise((answer) => setAsking({ action, count: targets.length, skipped: 0, answer }));
|
|
300
|
+
if (alive.current)
|
|
301
|
+
setAsking(null);
|
|
302
|
+
if (!yes || !current())
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
setRunning({ label: action.label, done: 0, total: targets.length });
|
|
306
|
+
const outcomes = [];
|
|
307
|
+
let stopped = false;
|
|
308
|
+
for (const [at, record] of targets.entries()) {
|
|
309
|
+
if (!current()) {
|
|
310
|
+
stopped = true;
|
|
311
|
+
outcomes.push(...targets.slice(at).map(({ key, label }) => ({ key, label, kind: 'skipped', message: say('notRunTheList') })));
|
|
312
|
+
break;
|
|
313
|
+
}
|
|
314
|
+
const answer = await runOne(action, record.key);
|
|
315
|
+
outcomes.push({ key: record.key, label: record.label, kind: answer.kind, message: answer.message });
|
|
316
|
+
if (alive.current)
|
|
317
|
+
setRunning({ label: action.label, done: at + 1, total: targets.length });
|
|
318
|
+
}
|
|
319
|
+
if (!alive.current)
|
|
320
|
+
return;
|
|
321
|
+
setRunning(null);
|
|
322
|
+
const result = tally(outcomes, stopped);
|
|
323
|
+
setReported({ label: action.label, result });
|
|
324
|
+
if (result.counts.applied && current()) {
|
|
325
|
+
void client.invalidateQueries({ queryKey: ['run', connection] });
|
|
326
|
+
void client.invalidateQueries({ queryKey: ['count', connection] });
|
|
327
|
+
void client.invalidateQueries({ queryKey: ['when', table.id] });
|
|
328
|
+
}
|
|
329
|
+
};
|
|
284
330
|
const deselect = (keys) => {
|
|
285
331
|
const drop = new Set(keys.map(commandKeyText));
|
|
286
332
|
setSelected((current) => current.filter((id) => {
|
|
@@ -335,7 +381,7 @@ export function useBulkSelection({ table, keyed, actions = [], interactive = tru
|
|
|
335
381
|
setSetting(true);
|
|
336
382
|
}, children: say('setField') })), bulk.map((action) => (_jsx("button", { type: "button", className: "ghost", title: setSummary(action), disabled: busy, onClick: () => {
|
|
337
383
|
void run(action);
|
|
338
|
-
}, children: _jsx(ActionLabel, { action: action, count: selection.length }) }, action.label))), availableCommands.map((action) => (_jsx("button", { type: "button", className: "ghost", title: say('oneRequestForTheWhole'), disabled: busy, onClick: () => openCommand(action), children: _jsx(ActionLabel, { action: action, count: selection.length, noun: nounOf(table) }) }, `command:${action.command.id}:${action.label}`))), _jsx("button", { type: "button", className: "ghost queue-clear", disabled: Boolean(running), onClick: clear, children: say('clearSelection') }), running && (_jsx("span", { className: "queue-progress", role: "status", children: say('applying', { done: running.done, total: running.total }) }))] })), capped && (_jsx("p", { className: "queue-status", role: "status", children: say('selectionIsLimitedToRecords', { max: BULK_LIMIT }) })), _jsxs("div", { className: "queue-report", children: [_jsxs("div", { className: "queue-result", role: failed ? 'alert' : 'status', tabIndex: -1, ref: resultRef, hidden: !reported, children: [reported && _jsx("p", { children: reported.summary ?? bulkSummary(reported.label, reported.result) }), reported && !reported.summary && reported.result.outcomes.some((outcome) => outcome.kind !== 'applied') && (_jsx("ul", { children: reported.result.outcomes
|
|
384
|
+
}, children: _jsx(ActionLabel, { action: action, count: selection.length }) }, action.label))), availableCommands.map((action) => (_jsx("button", { type: "button", className: "ghost", title: action.bulk === 'each' ? say('eachOnItsOwn') : say('oneRequestForTheWhole'), disabled: busy, onClick: () => openCommand(action), children: _jsx(ActionLabel, { action: action, count: selection.length, noun: nounOf(table) }) }, `command:${action.command.id}:${action.label}`))), _jsx("button", { type: "button", className: "ghost queue-clear", disabled: Boolean(running), onClick: clear, children: say('clearSelection') }), running && (_jsx("span", { className: "queue-progress", role: "status", children: say('applying', { done: running.done, total: running.total }) }))] })), capped && (_jsx("p", { className: "queue-status", role: "status", children: say('selectionIsLimitedToRecords', { max: BULK_LIMIT }) })), _jsxs("div", { className: "queue-report", children: [_jsxs("div", { className: "queue-result", role: failed ? 'alert' : 'status', tabIndex: -1, ref: resultRef, hidden: !reported, children: [reported && _jsx("p", { children: reported.summary ?? bulkSummary(reported.label, reported.result) }), reported && !reported.summary && reported.result.outcomes.some((outcome) => outcome.kind !== 'applied') && (_jsx("ul", { children: reported.result.outcomes
|
|
339
385
|
.filter((outcome) => outcome.kind !== 'applied')
|
|
340
386
|
.map((outcome) => (_jsxs("li", { children: [outcome.label, ": ", outcome.message] }, bulkKey(table, outcome.key)))) }))] }), reported && !running && (_jsx("button", { type: "button", className: "ghost queue-dismiss", onClick: clear, children: say('common.dismiss') }))] })] }));
|
|
341
387
|
const dialogs = (_jsxs(_Fragment, { children: [setting && (_jsx(SetFieldDialog, { table: table, columns: fields, count: selection.length, row: selectedRecords[0]?.row, onApply: (column, value) => {
|
|
@@ -356,5 +402,5 @@ function Confirm({ asking, onAnswer }) {
|
|
|
356
402
|
answered.current = true;
|
|
357
403
|
onAnswer(yes);
|
|
358
404
|
};
|
|
359
|
-
return (_jsxs(Modal, { className: "confirm action-confirm", ariaLabel: `${action.label}?`, onClose: () => answer(false), children: [_jsxs("h2", { children: [action.label, "?"] }), _jsxs("p", { children: [say('applyToSelectedRecords', { count }), skipped ? say('willBeSkipped', { skipped: formatNumber(skipped) }) : '', "."] }), _jsx("p", { children: _jsx("strong", { children: setSummary(action) }) }), _jsxs("div", { className: "confirm-actions", children: [_jsx(Button, { intent: "secondary", onClick: () => answer(false), children: say('common.cancel') }), _jsx(Button, { intent: "primary", onClick: () => answer(true), children: action.label })] })] }));
|
|
405
|
+
return (_jsxs(Modal, { className: "confirm action-confirm", ariaLabel: `${action.label}?`, onClose: () => answer(false), children: [_jsxs("h2", { children: [action.label, "?"] }), _jsxs("p", { children: [say('applyToSelectedRecords', { count }), skipped ? say('willBeSkipped', { skipped: formatNumber(skipped) }) : '', "."] }), isUpdate(action) && (_jsx("p", { children: _jsx("strong", { children: setSummary(action) }) })), _jsxs("div", { className: "confirm-actions", children: [_jsx(Button, { intent: "secondary", onClick: () => answer(false), children: say('common.cancel') }), _jsx(Button, { intent: "primary", onClick: () => answer(true), children: action.label })] })] }));
|
|
360
406
|
}
|
|
@@ -4,6 +4,8 @@ export declare const say: import("../../../messages.js").RoomMessage<{
|
|
|
4
4
|
readonly selectedRecords: "Selected records";
|
|
5
5
|
readonly selected: "{selectionCount} selected";
|
|
6
6
|
readonly setField: "Set field…";
|
|
7
|
+
readonly notRunTheList: "Not run: the list is no longer current.";
|
|
8
|
+
readonly eachOnItsOwn: "Each record runs on its own: one that cannot be changed does not stop the others.";
|
|
7
9
|
readonly oneRequestForTheWhole: "One request for the whole selection: every record or none.";
|
|
8
10
|
readonly clearSelection: "Clear selection";
|
|
9
11
|
readonly applying: "Applying {done} of {total}…";
|
|
@@ -6,6 +6,8 @@ export const say = defineMessages({
|
|
|
6
6
|
selectedRecords: 'Selected records',
|
|
7
7
|
selected: '{selectionCount} selected',
|
|
8
8
|
setField: 'Set field…',
|
|
9
|
+
notRunTheList: 'Not run: the list is no longer current.',
|
|
10
|
+
eachOnItsOwn: 'Each record runs on its own: one that cannot be changed does not stop the others.',
|
|
9
11
|
oneRequestForTheWhole: 'One request for the whole selection: every record or none.',
|
|
10
12
|
clearSelection: 'Clear selection',
|
|
11
13
|
applying: 'Applying {done} of {total}…',
|
|
@@ -420,15 +420,6 @@
|
|
|
420
420
|
margin-top: auto;
|
|
421
421
|
padding-top: var(--space-3);
|
|
422
422
|
}
|
|
423
|
-
:root[data-look-stat='icon'] .dash-strip .spark-host:is(.good, .bad) {
|
|
424
|
-
--spark-ink: initial;
|
|
425
|
-
}
|
|
426
|
-
:root[data-look-stat='icon'] .dash-strip .spark-host.good {
|
|
427
|
-
--spark-ink: var(--status-good);
|
|
428
|
-
}
|
|
429
|
-
:root[data-look-stat='icon'] .dash-strip .spark-host.bad {
|
|
430
|
-
--spark-ink: var(--status-critical);
|
|
431
|
-
}
|
|
432
423
|
:root[data-look-stat='icon'] .dash-strip .spark {
|
|
433
424
|
height: 44px;
|
|
434
425
|
}
|
|
@@ -372,6 +372,14 @@ interface BulkCommands {
|
|
|
372
372
|
commandVersion: number;
|
|
373
373
|
key: Record<string, unknown>;
|
|
374
374
|
}>, enabled: boolean): boolean[];
|
|
375
|
+
/**
|
|
376
|
+
* One record of a selection run on its own, as one click on that record runs the command (`bulk: 'each'`): prepared
|
|
377
|
+
* for its revision, sent in its own transaction and answered alone. `uncertain` is an answer that did not arrive.
|
|
378
|
+
*/
|
|
379
|
+
runEach(action: AppCommandAction, key: Record<string, unknown>): Promise<{
|
|
380
|
+
kind: 'applied' | 'rejected' | 'uncertain';
|
|
381
|
+
message: string;
|
|
382
|
+
}>;
|
|
375
383
|
/** The command's form, which prepares, asks and sends once for the group. */
|
|
376
384
|
Form: ComponentType<{
|
|
377
385
|
action: AppCommandAction;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mistriwork/kit",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.69",
|
|
4
4
|
"description": "The shared React client both shells are drawn with: the walk and the address, Grid, Value, the record page, lists, filters and charts.",
|
|
5
5
|
"homepage": "https://mistriwork.dev",
|
|
6
6
|
"bugs": {
|
|
@@ -85,8 +85,8 @@
|
|
|
85
85
|
"./package.json": "./package.json"
|
|
86
86
|
},
|
|
87
87
|
"dependencies": {
|
|
88
|
-
"@mistriwork/engine": "1.0.0-rc.
|
|
89
|
-
"@mistriwork/ui": "1.0.0-rc.
|
|
88
|
+
"@mistriwork/engine": "1.0.0-rc.69",
|
|
89
|
+
"@mistriwork/ui": "1.0.0-rc.69",
|
|
90
90
|
"intl-messageformat": "12.1.2",
|
|
91
91
|
"qrcode-generator": "^2.0.4"
|
|
92
92
|
},
|