@fieldia/core 0.20.0 → 0.22.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/README.md +116 -1
- package/package.json +1 -1
- package/schema/page.schema.json +173 -1
- package/src/index.d.mts +2 -2
- package/src/index.d.ts +2 -2
- package/src/index.js +3 -1
- package/src/index.js.map +1 -1
- package/src/index.mjs +2 -2
- package/src/index.mjs.map +1 -1
- package/src/lib/expression/parser.js +4 -4
- package/src/lib/expression/parser.js.map +1 -1
- package/src/lib/expression/parser.mjs +5 -5
- package/src/lib/expression/parser.mjs.map +1 -1
- package/src/lib/expression/tokenizer.d.mts +12 -0
- package/src/lib/expression/tokenizer.d.ts +12 -0
- package/src/lib/expression/tokenizer.js +21 -12
- package/src/lib/expression/tokenizer.js.map +1 -1
- package/src/lib/expression/tokenizer.mjs +20 -12
- package/src/lib/expression/tokenizer.mjs.map +1 -1
- package/src/lib/format/check-page.d.mts +3 -2
- package/src/lib/format/check-page.d.ts +3 -2
- package/src/lib/format/check-page.js +9 -4
- package/src/lib/format/check-page.js.map +1 -1
- package/src/lib/format/check-page.mjs +10 -5
- package/src/lib/format/check-page.mjs.map +1 -1
- package/src/lib/format/field.d.mts +101 -0
- package/src/lib/format/field.d.ts +101 -0
- package/src/lib/format/field.js +25 -2
- package/src/lib/format/field.js.map +1 -1
- package/src/lib/format/field.mjs +24 -1
- package/src/lib/format/field.mjs.map +1 -1
- package/src/lib/format/layout.d.mts +142 -17
- package/src/lib/format/layout.d.ts +142 -17
- package/src/lib/format/layout.js +18 -1
- package/src/lib/format/layout.js.map +1 -1
- package/src/lib/format/layout.mjs +17 -0
- package/src/lib/format/layout.mjs.map +1 -1
- package/src/lib/format/layout.types.d.mts +6 -2
- package/src/lib/format/layout.types.d.ts +6 -2
- package/src/lib/format/page.d.mts +87 -10
- package/src/lib/format/page.d.ts +87 -10
- package/src/lib/format/page.js +5 -1
- package/src/lib/format/page.js.map +1 -1
- package/src/lib/format/page.mjs +6 -2
- package/src/lib/format/page.mjs.map +1 -1
- package/src/lib/format/pattern.d.mts +10 -0
- package/src/lib/format/pattern.d.ts +10 -0
- package/src/lib/format/pattern.js +33 -0
- package/src/lib/format/pattern.js.map +1 -0
- package/src/lib/format/pattern.mjs +30 -0
- package/src/lib/format/pattern.mjs.map +1 -0
- package/src/lib/format/references.d.mts +7 -0
- package/src/lib/format/references.d.ts +7 -0
- package/src/lib/format/references.js +54 -0
- package/src/lib/format/references.js.map +1 -1
- package/src/lib/format/references.mjs +54 -0
- package/src/lib/format/references.mjs.map +1 -1
- package/src/lib/format/translate.js +6 -4
- package/src/lib/format/translate.js.map +1 -1
- package/src/lib/format/translate.mjs +6 -4
- package/src/lib/format/translate.mjs.map +1 -1
- package/src/lib/format/upgrade.d.mts +41 -0
- package/src/lib/format/upgrade.d.ts +41 -0
- package/src/lib/format/upgrade.js +41 -0
- package/src/lib/format/upgrade.js.map +1 -0
- package/src/lib/format/upgrade.mjs +37 -0
- package/src/lib/format/upgrade.mjs.map +1 -0
- package/src/lib/format/validate.d.mts +2 -1
- package/src/lib/format/validate.d.ts +2 -1
- package/src/lib/format/validate.js +4 -2
- package/src/lib/format/validate.js.map +1 -1
- package/src/lib/format/validate.mjs +4 -2
- package/src/lib/format/validate.mjs.map +1 -1
- package/src/lib/format/version.d.mts +16 -1
- package/src/lib/format/version.d.ts +16 -1
- package/src/lib/format/version.js +39 -2
- package/src/lib/format/version.js.map +1 -1
- package/src/lib/format/version.mjs +36 -1
- package/src/lib/format/version.mjs.map +1 -1
- package/src/lib/record/check.d.mts +13 -3
- package/src/lib/record/check.d.ts +13 -3
- package/src/lib/record/check.js +87 -17
- package/src/lib/record/check.js.map +1 -1
- package/src/lib/record/check.mjs +85 -17
- package/src/lib/record/check.mjs.map +1 -1
- package/src/lib/record/data-source.d.mts +224 -10
- package/src/lib/record/data-source.d.ts +224 -10
- package/src/lib/record/data-source.js +29 -0
- package/src/lib/record/data-source.js.map +1 -1
- package/src/lib/record/data-source.mjs +25 -0
- package/src/lib/record/data-source.mjs.map +1 -1
- package/src/lib/record/filter.js +14 -2
- package/src/lib/record/filter.js.map +1 -1
- package/src/lib/record/filter.mjs +14 -2
- package/src/lib/record/filter.mjs.map +1 -1
- package/src/lib/record/form.d.mts +186 -3
- package/src/lib/record/form.d.ts +186 -3
- package/src/lib/record/form.js +1036 -57
- package/src/lib/record/form.js.map +1 -1
- package/src/lib/record/form.mjs +1037 -60
- package/src/lib/record/form.mjs.map +1 -1
- package/src/lib/record/input-rules.d.mts +277 -0
- package/src/lib/record/input-rules.d.ts +277 -0
- package/src/lib/record/input-rules.js +724 -0
- package/src/lib/record/input-rules.js.map +1 -0
- package/src/lib/record/input-rules.mjs +705 -0
- package/src/lib/record/input-rules.mjs.map +1 -0
- package/src/lib/record/inputs.d.mts +25 -0
- package/src/lib/record/inputs.d.ts +25 -0
- package/src/lib/record/inputs.js +135 -9
- package/src/lib/record/inputs.js.map +1 -1
- package/src/lib/record/inputs.mjs +131 -9
- package/src/lib/record/inputs.mjs.map +1 -1
- package/src/lib/record/locales/ar.js +23 -2
- package/src/lib/record/locales/ar.js.map +1 -1
- package/src/lib/record/locales/ar.mjs +23 -2
- package/src/lib/record/locales/ar.mjs.map +1 -1
- package/src/lib/record/locales/de.js +23 -2
- package/src/lib/record/locales/de.js.map +1 -1
- package/src/lib/record/locales/de.mjs +23 -2
- package/src/lib/record/locales/de.mjs.map +1 -1
- package/src/lib/record/locales/fr.js +23 -2
- package/src/lib/record/locales/fr.js.map +1 -1
- package/src/lib/record/locales/fr.mjs +23 -2
- package/src/lib/record/locales/fr.mjs.map +1 -1
- package/src/lib/record/memory-data-source.d.mts +40 -3
- package/src/lib/record/memory-data-source.d.ts +40 -3
- package/src/lib/record/memory-data-source.js +171 -23
- package/src/lib/record/memory-data-source.js.map +1 -1
- package/src/lib/record/memory-data-source.mjs +171 -23
- package/src/lib/record/memory-data-source.mjs.map +1 -1
- package/src/lib/record/messages.d.mts +43 -0
- package/src/lib/record/messages.d.ts +43 -0
- package/src/lib/record/messages.js +23 -2
- package/src/lib/record/messages.js.map +1 -1
- package/src/lib/record/messages.mjs +23 -2
- package/src/lib/record/messages.mjs.map +1 -1
- package/src/lib/record/rules.js +3 -1
- package/src/lib/record/rules.js.map +1 -1
- package/src/lib/record/rules.mjs +3 -1
- package/src/lib/record/rules.mjs.map +1 -1
- package/src/lib/record/run.d.mts +53 -9
- package/src/lib/record/run.d.ts +53 -9
- package/src/lib/record/run.js +68 -21
- package/src/lib/record/run.js.map +1 -1
- package/src/lib/record/run.mjs +68 -21
- package/src/lib/record/run.mjs.map +1 -1
- package/src/lib/record/search.d.mts +8 -1
- package/src/lib/record/search.d.ts +8 -1
- package/src/lib/record/search.js +28 -8
- package/src/lib/record/search.js.map +1 -1
- package/src/lib/record/search.mjs +28 -8
- package/src/lib/record/search.mjs.map +1 -1
- package/src/lib/record/structures.d.mts +8 -3
- package/src/lib/record/structures.d.ts +8 -3
- package/src/lib/record/structures.js +51 -7
- package/src/lib/record/structures.js.map +1 -1
- package/src/lib/record/structures.mjs +48 -6
- package/src/lib/record/structures.mjs.map +1 -1
- package/src/lib/record/upload-to.d.mts +50 -0
- package/src/lib/record/upload-to.d.ts +50 -0
- package/src/lib/record/upload-to.js +117 -0
- package/src/lib/record/upload-to.js.map +1 -0
- package/src/lib/record/upload-to.mjs +114 -0
- package/src/lib/record/upload-to.mjs.map +1 -0
- package/src/lib/record/uploads.d.mts +152 -0
- package/src/lib/record/uploads.d.ts +152 -0
- package/src/lib/record/uploads.js +345 -0
- package/src/lib/record/uploads.js.map +1 -0
- package/src/lib/record/uploads.mjs +337 -0
- package/src/lib/record/uploads.mjs.map +1 -0
- package/src/lib/record/values.d.mts +6 -0
- package/src/lib/record/values.d.ts +6 -0
- package/src/lib/record/values.js.map +1 -1
- package/src/lib/record/values.mjs.map +1 -1
- package/src/runtime.d.mts +15 -8
- package/src/runtime.d.ts +15 -8
- package/src/runtime.js +48 -1
- package/src/runtime.js.map +1 -1
- package/src/runtime.mjs +12 -5
- package/src/runtime.mjs.map +1 -1
|
@@ -2,14 +2,18 @@ import { LANGUAGES } from './locales/all.mjs';
|
|
|
2
2
|
/** English: always here, and the words a language leaves out. */
|
|
3
3
|
const en = {
|
|
4
4
|
required: '{label} is required',
|
|
5
|
-
maxLength: '
|
|
5
|
+
maxLength: '{label} takes at most {max} characters',
|
|
6
6
|
pattern: '{label} is not in the expected format',
|
|
7
7
|
text: '{label} must be text',
|
|
8
8
|
number: '{label} must be a number',
|
|
9
9
|
integer: '{label} must be a whole number',
|
|
10
10
|
min: '{label} must be at least {min}',
|
|
11
11
|
max: '{label} must be at most {max}',
|
|
12
|
-
decimals: '
|
|
12
|
+
decimals: '{label} takes at most {digits} decimal places',
|
|
13
|
+
decimalsOne: '{label} takes at most 1 decimal place',
|
|
14
|
+
decimalsTwo: '{label} takes at most {digits} decimal places',
|
|
15
|
+
decimalsMany: '{label} takes at most {digits} decimal places',
|
|
16
|
+
digits: '{label} takes at most {n} digits',
|
|
13
17
|
boolean: '{label} must be yes or no',
|
|
14
18
|
dateFormat: 'Invalid date format (expected YYYY-MM-DD)',
|
|
15
19
|
dateInvalid: 'Invalid date (check month/day values)',
|
|
@@ -29,6 +33,9 @@ const en = {
|
|
|
29
33
|
fileType: '{label} must be {aTypes} file',
|
|
30
34
|
minFiles: 'Add at least {min} files to {label}',
|
|
31
35
|
maxFiles: 'Too many files for {label}: at most {max}',
|
|
36
|
+
notUploaded: '{name} was not uploaded: try again, or remove it',
|
|
37
|
+
notUploadedMany: '{n} files were not uploaded: try again, or remove them',
|
|
38
|
+
fileRefused: '{name} was not taken: {reason}',
|
|
32
39
|
minLength: '{label} must be at least {min} characters',
|
|
33
40
|
endsWith: '{label} must end with {ending}',
|
|
34
41
|
atLeast: 'Choose at least {min} for {label}',
|
|
@@ -51,6 +58,20 @@ const en = {
|
|
|
51
58
|
addressParts: 'Street address|Address line 2|City|State or region|Postcode|Country',
|
|
52
59
|
archiveConfirm: 'Are you sure that you want to archive this record?',
|
|
53
60
|
deleteConfirm: 'Are you sure you want to delete this record?',
|
|
61
|
+
mayNotEdit: 'You can read this record, but not change it.',
|
|
62
|
+
mayNotArchive: 'You cannot archive this record.',
|
|
63
|
+
mayNotDuplicate: 'You cannot duplicate this record.',
|
|
64
|
+
mayNotDelete: 'You cannot delete this record.',
|
|
65
|
+
theirsUnread: 'Their version could not be read, so yours was not saved over it. Try Keep mine again, or Reload.',
|
|
66
|
+
discardChanges: 'Discard your changes?',
|
|
67
|
+
recordReplaced: 'Another record is shown now: the rest of these steps did not run.',
|
|
68
|
+
overBy: '{label} is {over} characters over its {max}: shorten it to save',
|
|
69
|
+
overByOne: '{label} is 1 character over its {max}: shorten it to save',
|
|
70
|
+
postcode: '{label}: a postcode in {country} has {n} digits, like {example}',
|
|
71
|
+
urlScheme: 'Only a web address (http or https) can go here',
|
|
72
|
+
endBeforeStart: '{end} can’t be before {start}',
|
|
73
|
+
timeStep: '{label}: times go in steps of {step} minutes, like {example} or {next}',
|
|
74
|
+
patternBroken: 'The pattern of {label} is not a valid pattern: {problem}',
|
|
54
75
|
locale: 'en',
|
|
55
76
|
};
|
|
56
77
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.mjs","sourceRoot":"","sources":["../../../../../../libs/core/src/lib/record/messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"messages.mjs","sourceRoot":"","sources":["../../../../../../libs/core/src/lib/record/messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AA4H1C,iEAAiE;AACjE,MAAM,EAAE,GAAa;IACnB,QAAQ,EAAE,qBAAqB;IAC/B,SAAS,EAAE,wCAAwC;IACnD,OAAO,EAAE,uCAAuC;IAChD,IAAI,EAAE,sBAAsB;IAC5B,MAAM,EAAE,0BAA0B;IAClC,OAA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AA8B;IACrC,OAAO,EAAE,8BAA8B;IACvC,QAAQ,EAAE,+BAA+B;IACzC,QAAQ,EAAE,oCAAoC;IAC9C,YAAY,EAAE,qEAAqE;IACnF,cAAc,EAAE,oDAAoD;IACpE,aAAa,EAAE,8CAA8C;IAC7D,UAAU,EAAE,8CAA8C;IAC1D,aAAa,EAAE,iCAAiC;IAChD,eAAe,EAAE,mCAAmC;IACpD,YAAY,EAAE,gCAAgC;IAC9C,YAAY,EAAE,kGAAkG;IAChH,cAAc,EAAE,uBAAuB;IACvC,cAAc,EAAE,mEAAmE;IACnF,MAAM,EAAE,iEAAiE;IACzE,SAAS,EAAE,2DAA2D;IACtE,QAAQ,EAAE,iEAAiE;IAC3E,SAAS,EAAE,gDAAgD;IAC3D,cAAc,EAAE,+BAA+B;IAC/C,QAAQ,EAAE,wEAAwE;IAClF,aAAa,EAAE,0DAA0D;IACzE,MAAM,EAAE,IAAI;CACb,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,QAAQ,GAA6B,EAAE,EAAE,EAAE,GAAG,SAAS,EAAE,CAAC;AAEvE,kCAAkC;AAClC,MAAM,UAAU,IAAI,CAAC,QAAgB,EAAE,MAAuC;IAC5E,OAAO,QAAQ,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC,KAAK,EAAE,IAAY,EAAE,EAAE,CAAC,CAAC,IAAI,IAAI,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;AAClH,CAAC"}
|
package/src/lib/record/rules.js
CHANGED
|
@@ -5,6 +5,7 @@ exports.checkRules = checkRules;
|
|
|
5
5
|
const functions_1 = require("../expression/functions");
|
|
6
6
|
const modifier_1 = require("../expression/modifier");
|
|
7
7
|
const operations_1 = require("../expression/operations");
|
|
8
|
+
const input_rules_1 = require("./input-rules");
|
|
8
9
|
const messages_1 = require("./messages");
|
|
9
10
|
const values_1 = require("./values");
|
|
10
11
|
function compileRules(rules) {
|
|
@@ -38,7 +39,8 @@ function brokenAsk({ rule, pattern }, field, value, now) {
|
|
|
38
39
|
return { say: 'minLength', values: { min: rule.minLength } };
|
|
39
40
|
if (text !== null && rule.maxLength !== undefined && text.length > rule.maxLength)
|
|
40
41
|
return { say: 'maxLength', values: { max: rule.maxLength } };
|
|
41
|
-
|
|
42
|
+
// Its digits as 0-9, no direction marks, trimmed: "١١٥١١" is five digits.
|
|
43
|
+
if (pattern && (text !== null || (0, operations_1.isNumber)(value)) && !pattern.test(text !== null ? (0, input_rules_1.foldDigits)((0, input_rules_1.stripMarks)(text)).trim() : String(value)))
|
|
42
44
|
return { say: 'pattern' };
|
|
43
45
|
if (text !== null && rule.endsWith !== undefined && !text.trim().toLowerCase().endsWith(rule.endsWith.toLowerCase())) {
|
|
44
46
|
return { say: 'endsWith', values: { ending: rule.endsWith } };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rules.js","sourceRoot":"","sources":["../../../../../../libs/core/src/lib/record/rules.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"rules.js","sourceRoot":"","sources":["../../../../../../libs/core/src/lib/record/rules.ts"],"names":[],"mappings":";;AA0BA,oCAQC;AAWD,gCAgBC;AA1DD,uDAAmD;AACnD,qDAAgF;AAChF,yDAAoD;AACpD,+CAAuD;AACvD,yCAAiD;AACjD,qCAAwF;AAkBxF,SAAgB,YAAY,CAAC,KAAwC;IACnE,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAClC,IAAI;QACJ,IAAI,EAAE,IAAA,0BAAe,EAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC;QACxC,yDAAyD;QACzD,OAAO,EAAE,IAAI,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,IAAI,CA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AAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QAAE,OAAO,SAAS,CAAC;IACrF,OAAO,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC;AAC3E,CAAC;AAED;;;;GAIG;AACH,SAAS,MAAM,CAAC,KAAY,EAAE,IAAY,EAAE,GAAS;IACnD,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU;QAAE,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;IAClF,MAAM,KAAK,GAAG,IAAA,oBAAQ,EAAC,GAAG,CAAC,CAAC;IAC5B,OAAO,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAClD,CAAC"}
|
package/src/lib/record/rules.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { localDay } from '../expression/functions.mjs';
|
|
2
2
|
import { compileModifier } from '../expression/modifier.mjs';
|
|
3
3
|
import { isNumber } from '../expression/operations.mjs';
|
|
4
|
+
import { foldDigits, stripMarks } from './input-rules.mjs';
|
|
4
5
|
import { fill } from './messages.mjs';
|
|
5
6
|
import { isEmpty, lineKind } from './values.mjs';
|
|
6
7
|
export function compileRules(rules) {
|
|
@@ -34,7 +35,8 @@ function brokenAsk({ rule, pattern }, field, value, now) {
|
|
|
34
35
|
return { say: 'minLength', values: { min: rule.minLength } };
|
|
35
36
|
if (text !== null && rule.maxLength !== undefined && text.length > rule.maxLength)
|
|
36
37
|
return { say: 'maxLength', values: { max: rule.maxLength } };
|
|
37
|
-
|
|
38
|
+
// Its digits as 0-9, no direction marks, trimmed: "١١٥١١" is five digits.
|
|
39
|
+
if (pattern && (text !== null || isNumber(value)) && !pattern.test(text !== null ? foldDigits(stripMarks(text)).trim() : String(value)))
|
|
38
40
|
return { say: 'pattern' };
|
|
39
41
|
if (text !== null && rule.endsWith !== undefined && !text.trim().toLowerCase().endsWith(rule.endsWith.toLowerCase())) {
|
|
40
42
|
return { say: 'endsWith', values: { ending: rule.endsWith } };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rules.mjs","sourceRoot":"","sources":["../../../../../../libs/core/src/lib/record/rules.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAyB,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,IAAI,EAAiB,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAA6C,MAAM,UAAU,CAAC;AAkBxF,MAAM,UAAU,YAAY,CAAC,KAAwC;IACnE,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAClC,IAAI;QACJ,IAAI,EAAE,eAAe,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC;QACxC,yDAAyD;QACzD,OAAO,EAAE,IAAI,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,IAAI,CAAC,OAAO,IAAI,CAAC;QAChF,KAAK,EAAE,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC;KACrE,CAAC,CAAC,CAAC;AACN,CAAC;AAUD,iGAAiG;AACjG,M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AAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QAAE,OAAO,SAAS,CAAC;IACrF,OAAO,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC;AAC3E,CAAC;AAED;;;;GAIG;AACH,SAAS,MAAM,CAAC,KAAY,EAAE,IAAY,EAAE,GAAS;IACnD,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU;QAAE,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;IAClF,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;IAC5B,OAAO,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAClD,CAAC"}
|
package/src/lib/record/run.d.mts
CHANGED
|
@@ -120,7 +120,8 @@ export interface OpenResult {
|
|
|
120
120
|
export interface ActionHost {
|
|
121
121
|
open(request: OpenRequest): Promise<OpenResult>;
|
|
122
122
|
say(message: string, tone: Tone): void;
|
|
123
|
-
|
|
123
|
+
/** A question, answered Yes (true) or No; `how` says what kind, for a host that asks some differently. */
|
|
124
|
+
ask(message: string, how?: AskHow): Promise<boolean>;
|
|
124
125
|
/** Close the dialog or panel this form was opened in. */
|
|
125
126
|
close?(): void;
|
|
126
127
|
/** Show a tab by its id. The viewer then calls `form.shown(id)`, as for a tab a person picks. */
|
|
@@ -134,6 +135,14 @@ export interface ActionHost {
|
|
|
134
135
|
*/
|
|
135
136
|
post?(message: PostedMessage): boolean | void | Promise<boolean | void>;
|
|
136
137
|
}
|
|
138
|
+
/**
|
|
139
|
+
* How a question is asked. `discard`: its Yes lets go of the person's work not
|
|
140
|
+
* saved ("Discard your changes?"), so a host words Yes as Discard and puts the
|
|
141
|
+
* focus on Cancel: Enter keeps the work.
|
|
142
|
+
*/
|
|
143
|
+
export interface AskHow {
|
|
144
|
+
discard?: boolean;
|
|
145
|
+
}
|
|
137
146
|
/**
|
|
138
147
|
* Why a run stopped: a check found problems (`check`), a question was
|
|
139
148
|
* answered No (`no`), a save was refused (`save`), the app said stop or threw
|
|
@@ -183,6 +192,13 @@ export interface RunScope {
|
|
|
183
192
|
};
|
|
184
193
|
lines?: ChosenLines;
|
|
185
194
|
chain: readonly string[];
|
|
195
|
+
/**
|
|
196
|
+
* The record the run is on, as the form numbers each record it shows: set
|
|
197
|
+
* as it starts, and moved on by its own steps that show another (a `call`'s
|
|
198
|
+
* `{ record }`, Duplicate's copy, a reload). Shown another by anything else,
|
|
199
|
+
* the run stops: its steps are not for that record.
|
|
200
|
+
*/
|
|
201
|
+
generation?: number;
|
|
186
202
|
}
|
|
187
203
|
/** What a run reaches its form by: the form gives these. */
|
|
188
204
|
export interface RunForm {
|
|
@@ -200,13 +216,25 @@ export interface RunForm {
|
|
|
200
216
|
/** Write values the record holds where it is kept: no change to save. */
|
|
201
217
|
store(values: Values): void;
|
|
202
218
|
addLine(field: string, values: Values): void;
|
|
203
|
-
|
|
219
|
+
/** Check fields as sending does: what is still typed in a box read first, a name being looked up waited for. */
|
|
220
|
+
check(fields: readonly string[] | undefined): Stopped | null | Promise<Stopped | null>;
|
|
204
221
|
save(chain: readonly string[]): Promise<Stopped | null>;
|
|
205
|
-
/**
|
|
206
|
-
|
|
207
|
-
|
|
222
|
+
/** The number of the record shown now: each record shown — opened, loaded again, a new one — has its own. */
|
|
223
|
+
generation(): number;
|
|
224
|
+
/** Why a run stops whose record was replaced while it went on. */
|
|
225
|
+
gone(): Stopped;
|
|
226
|
+
/**
|
|
227
|
+
* Load the record again from its data source, once the form's one check let
|
|
228
|
+
* what is shown go; a new record cannot be. Each of these takes the run's
|
|
229
|
+
* `chain`: a step of a save's own beforeSave does not wait for that save.
|
|
230
|
+
*/
|
|
231
|
+
reload(chain: readonly string[]): Promise<Stopped | null>;
|
|
232
|
+
/** Reset the form, once its one check let what is shown go. */
|
|
233
|
+
reset(chain: readonly string[]): Stopped | null | Promise<Stopped | null>;
|
|
234
|
+
/** Close it through the host, once its one check let what is shown go. */
|
|
235
|
+
close(chain: readonly string[]): Stopped | null | Promise<Stopped | null>;
|
|
208
236
|
/** Go to a wizard's step; `undefined` when the target is none of its steps (a tab). */
|
|
209
|
-
goTo(target: string, chain: readonly string[]): Stopped | null | undefined
|
|
237
|
+
goTo(target: string, chain: readonly string[]): Stopped | null | undefined | Promise<Stopped | null | undefined>;
|
|
210
238
|
/** Run `show` of the host while `chain` is the run's, so a tab it shows knows who showed it. */
|
|
211
239
|
showing(chain: readonly string[], show: () => void): void;
|
|
212
240
|
host?: ActionHost;
|
|
@@ -214,8 +242,22 @@ export interface RunForm {
|
|
|
214
242
|
onAction?: OnAction;
|
|
215
243
|
/** The app answered a call. */
|
|
216
244
|
answered(request: ActionRequest, result: ActionResult | undefined): void;
|
|
217
|
-
/** Whether something changed since the record was loaded or saved. */
|
|
245
|
+
/** Whether something changed since the record was loaded or saved: a file still on its way is a change coming. */
|
|
218
246
|
changed(): boolean;
|
|
247
|
+
/**
|
|
248
|
+
* The form's one check, asked by a step before something that cannot be
|
|
249
|
+
* taken back — a copy made, the record archived, the page left for an
|
|
250
|
+
* address — whose way out passes the check only after: null to go on,
|
|
251
|
+
* else why the run stops. Every way out passes it anyway; asked first, it
|
|
252
|
+
* is not asked again.
|
|
253
|
+
*/
|
|
254
|
+
letGo(chain: readonly string[]): Stopped | null | Promise<Stopped | null>;
|
|
255
|
+
/**
|
|
256
|
+
* The record being deleted, by `remove`: a way out it takes meanwhile asks
|
|
257
|
+
* nothing, and once `done` says it is deleted, the person's work in it goes
|
|
258
|
+
* with it. Refused, their work stays.
|
|
259
|
+
*/
|
|
260
|
+
deleting<T>(remove: () => Promise<T>, done: (out: T) => boolean): Promise<T>;
|
|
219
261
|
/**
|
|
220
262
|
* The record's own operations through the data source, each only when the
|
|
221
263
|
* data source has it; without, the app's action of the step's name is called.
|
|
@@ -223,8 +265,8 @@ export interface RunForm {
|
|
|
223
265
|
archive?(archive: boolean): Promise<void>;
|
|
224
266
|
copy?(): Promise<RecordId>;
|
|
225
267
|
remove?(): Promise<void>;
|
|
226
|
-
/** Show another record in this form's place, loaded as a pager loads it; a new one for null. */
|
|
227
|
-
showRecord(id: RecordId | null): Promise<Stopped | null>;
|
|
268
|
+
/** Show another record in this form's place, loaded as a pager loads it, once the one check let this one go; a new one for null. */
|
|
269
|
+
showRecord(id: RecordId | null, chain: readonly string[]): Promise<Stopped | null>;
|
|
228
270
|
/** The record was archived (or brought back), copied, or deleted: told to the app. Deleted, the form leaves it unless a listener moved it on. */
|
|
229
271
|
told(event: {
|
|
230
272
|
archived: boolean;
|
|
@@ -237,6 +279,8 @@ export interface RunForm {
|
|
|
237
279
|
post(message: PostedMessage): Promise<boolean>;
|
|
238
280
|
/** A field's value as words in a posted message: a link's name, a choice's label. */
|
|
239
281
|
wordsOf(field: string): string;
|
|
282
|
+
/** Why the person may not archive, copy or delete the record, as its source told: their words to say; null when they may. */
|
|
283
|
+
barred?(right: 'archive' | 'duplicate' | 'delete'): string | null;
|
|
240
284
|
}
|
|
241
285
|
export declare const DONE: RunResult;
|
|
242
286
|
/** Steps run against one form. Expressions are read once and kept. */
|
package/src/lib/record/run.d.ts
CHANGED
|
@@ -120,7 +120,8 @@ export interface OpenResult {
|
|
|
120
120
|
export interface ActionHost {
|
|
121
121
|
open(request: OpenRequest): Promise<OpenResult>;
|
|
122
122
|
say(message: string, tone: Tone): void;
|
|
123
|
-
|
|
123
|
+
/** A question, answered Yes (true) or No; `how` says what kind, for a host that asks some differently. */
|
|
124
|
+
ask(message: string, how?: AskHow): Promise<boolean>;
|
|
124
125
|
/** Close the dialog or panel this form was opened in. */
|
|
125
126
|
close?(): void;
|
|
126
127
|
/** Show a tab by its id. The viewer then calls `form.shown(id)`, as for a tab a person picks. */
|
|
@@ -134,6 +135,14 @@ export interface ActionHost {
|
|
|
134
135
|
*/
|
|
135
136
|
post?(message: PostedMessage): boolean | void | Promise<boolean | void>;
|
|
136
137
|
}
|
|
138
|
+
/**
|
|
139
|
+
* How a question is asked. `discard`: its Yes lets go of the person's work not
|
|
140
|
+
* saved ("Discard your changes?"), so a host words Yes as Discard and puts the
|
|
141
|
+
* focus on Cancel: Enter keeps the work.
|
|
142
|
+
*/
|
|
143
|
+
export interface AskHow {
|
|
144
|
+
discard?: boolean;
|
|
145
|
+
}
|
|
137
146
|
/**
|
|
138
147
|
* Why a run stopped: a check found problems (`check`), a question was
|
|
139
148
|
* answered No (`no`), a save was refused (`save`), the app said stop or threw
|
|
@@ -183,6 +192,13 @@ export interface RunScope {
|
|
|
183
192
|
};
|
|
184
193
|
lines?: ChosenLines;
|
|
185
194
|
chain: readonly string[];
|
|
195
|
+
/**
|
|
196
|
+
* The record the run is on, as the form numbers each record it shows: set
|
|
197
|
+
* as it starts, and moved on by its own steps that show another (a `call`'s
|
|
198
|
+
* `{ record }`, Duplicate's copy, a reload). Shown another by anything else,
|
|
199
|
+
* the run stops: its steps are not for that record.
|
|
200
|
+
*/
|
|
201
|
+
generation?: number;
|
|
186
202
|
}
|
|
187
203
|
/** What a run reaches its form by: the form gives these. */
|
|
188
204
|
export interface RunForm {
|
|
@@ -200,13 +216,25 @@ export interface RunForm {
|
|
|
200
216
|
/** Write values the record holds where it is kept: no change to save. */
|
|
201
217
|
store(values: Values): void;
|
|
202
218
|
addLine(field: string, values: Values): void;
|
|
203
|
-
|
|
219
|
+
/** Check fields as sending does: what is still typed in a box read first, a name being looked up waited for. */
|
|
220
|
+
check(fields: readonly string[] | undefined): Stopped | null | Promise<Stopped | null>;
|
|
204
221
|
save(chain: readonly string[]): Promise<Stopped | null>;
|
|
205
|
-
/**
|
|
206
|
-
|
|
207
|
-
|
|
222
|
+
/** The number of the record shown now: each record shown — opened, loaded again, a new one — has its own. */
|
|
223
|
+
generation(): number;
|
|
224
|
+
/** Why a run stops whose record was replaced while it went on. */
|
|
225
|
+
gone(): Stopped;
|
|
226
|
+
/**
|
|
227
|
+
* Load the record again from its data source, once the form's one check let
|
|
228
|
+
* what is shown go; a new record cannot be. Each of these takes the run's
|
|
229
|
+
* `chain`: a step of a save's own beforeSave does not wait for that save.
|
|
230
|
+
*/
|
|
231
|
+
reload(chain: readonly string[]): Promise<Stopped | null>;
|
|
232
|
+
/** Reset the form, once its one check let what is shown go. */
|
|
233
|
+
reset(chain: readonly string[]): Stopped | null | Promise<Stopped | null>;
|
|
234
|
+
/** Close it through the host, once its one check let what is shown go. */
|
|
235
|
+
close(chain: readonly string[]): Stopped | null | Promise<Stopped | null>;
|
|
208
236
|
/** Go to a wizard's step; `undefined` when the target is none of its steps (a tab). */
|
|
209
|
-
goTo(target: string, chain: readonly string[]): Stopped | null | undefined
|
|
237
|
+
goTo(target: string, chain: readonly string[]): Stopped | null | undefined | Promise<Stopped | null | undefined>;
|
|
210
238
|
/** Run `show` of the host while `chain` is the run's, so a tab it shows knows who showed it. */
|
|
211
239
|
showing(chain: readonly string[], show: () => void): void;
|
|
212
240
|
host?: ActionHost;
|
|
@@ -214,8 +242,22 @@ export interface RunForm {
|
|
|
214
242
|
onAction?: OnAction;
|
|
215
243
|
/** The app answered a call. */
|
|
216
244
|
answered(request: ActionRequest, result: ActionResult | undefined): void;
|
|
217
|
-
/** Whether something changed since the record was loaded or saved. */
|
|
245
|
+
/** Whether something changed since the record was loaded or saved: a file still on its way is a change coming. */
|
|
218
246
|
changed(): boolean;
|
|
247
|
+
/**
|
|
248
|
+
* The form's one check, asked by a step before something that cannot be
|
|
249
|
+
* taken back — a copy made, the record archived, the page left for an
|
|
250
|
+
* address — whose way out passes the check only after: null to go on,
|
|
251
|
+
* else why the run stops. Every way out passes it anyway; asked first, it
|
|
252
|
+
* is not asked again.
|
|
253
|
+
*/
|
|
254
|
+
letGo(chain: readonly string[]): Stopped | null | Promise<Stopped | null>;
|
|
255
|
+
/**
|
|
256
|
+
* The record being deleted, by `remove`: a way out it takes meanwhile asks
|
|
257
|
+
* nothing, and once `done` says it is deleted, the person's work in it goes
|
|
258
|
+
* with it. Refused, their work stays.
|
|
259
|
+
*/
|
|
260
|
+
deleting<T>(remove: () => Promise<T>, done: (out: T) => boolean): Promise<T>;
|
|
219
261
|
/**
|
|
220
262
|
* The record's own operations through the data source, each only when the
|
|
221
263
|
* data source has it; without, the app's action of the step's name is called.
|
|
@@ -223,8 +265,8 @@ export interface RunForm {
|
|
|
223
265
|
archive?(archive: boolean): Promise<void>;
|
|
224
266
|
copy?(): Promise<RecordId>;
|
|
225
267
|
remove?(): Promise<void>;
|
|
226
|
-
/** Show another record in this form's place, loaded as a pager loads it; a new one for null. */
|
|
227
|
-
showRecord(id: RecordId | null): Promise<Stopped | null>;
|
|
268
|
+
/** Show another record in this form's place, loaded as a pager loads it, once the one check let this one go; a new one for null. */
|
|
269
|
+
showRecord(id: RecordId | null, chain: readonly string[]): Promise<Stopped | null>;
|
|
228
270
|
/** The record was archived (or brought back), copied, or deleted: told to the app. Deleted, the form leaves it unless a listener moved it on. */
|
|
229
271
|
told(event: {
|
|
230
272
|
archived: boolean;
|
|
@@ -237,6 +279,8 @@ export interface RunForm {
|
|
|
237
279
|
post(message: PostedMessage): Promise<boolean>;
|
|
238
280
|
/** A field's value as words in a posted message: a link's name, a choice's label. */
|
|
239
281
|
wordsOf(field: string): string;
|
|
282
|
+
/** Why the person may not archive, copy or delete the record, as its source told: their words to say; null when they may. */
|
|
283
|
+
barred?(right: 'archive' | 'duplicate' | 'delete'): string | null;
|
|
240
284
|
}
|
|
241
285
|
export declare const DONE: RunResult;
|
|
242
286
|
/** Steps run against one form. Expressions are read once and kept. */
|
package/src/lib/record/run.js
CHANGED
|
@@ -113,6 +113,7 @@ function createRunner(form) {
|
|
|
113
113
|
...(step.values ? { values: readMap(step.values) } : {}),
|
|
114
114
|
...(step.filter ? { filter: (0, filter_1.resolveFilter)(step.filter, form.reading().context) } : {}),
|
|
115
115
|
};
|
|
116
|
+
const on = form.generation();
|
|
116
117
|
let result;
|
|
117
118
|
try {
|
|
118
119
|
result = await host.open(request);
|
|
@@ -122,6 +123,9 @@ function createRunner(form) {
|
|
|
122
123
|
}
|
|
123
124
|
if (!result.saved)
|
|
124
125
|
return { reason: 'closed' };
|
|
126
|
+
// Its answers are for the record that opened it: another shown meanwhile takes none of them.
|
|
127
|
+
if (form.generation() !== on)
|
|
128
|
+
return form.gone();
|
|
125
129
|
if (step.into)
|
|
126
130
|
form.write(into(step.into, result));
|
|
127
131
|
if (!step.then)
|
|
@@ -170,6 +174,7 @@ function createRunner(form) {
|
|
|
170
174
|
};
|
|
171
175
|
if (!form.onAction)
|
|
172
176
|
return null;
|
|
177
|
+
const on = form.generation();
|
|
173
178
|
let answer;
|
|
174
179
|
try {
|
|
175
180
|
answer = (await form.onAction(request)) ?? undefined;
|
|
@@ -180,9 +185,18 @@ function createRunner(form) {
|
|
|
180
185
|
form.answered(request, answer);
|
|
181
186
|
if (!answer)
|
|
182
187
|
return null;
|
|
188
|
+
// Answered for a record no longer shown: nothing of it is laid over the one shown now. Its words to the person are
|
|
189
|
+
// laid over no record, and are said still — a dialog's "Payment … posted", answered as it closed, as before.
|
|
190
|
+
if (form.generation() !== on) {
|
|
191
|
+
if (answer.say !== undefined) {
|
|
192
|
+
const said = typeof answer.say === 'string' ? { message: answer.say } : answer.say;
|
|
193
|
+
form.host?.say(said.message, said.tone ?? 'info');
|
|
194
|
+
}
|
|
195
|
+
return form.gone();
|
|
196
|
+
}
|
|
183
197
|
// The server's record first, then what the app says over it.
|
|
184
198
|
if (answer.reload) {
|
|
185
|
-
const reloaded = await form.reload();
|
|
199
|
+
const reloaded = await ownMove(scope, () => form.reload(scope.chain));
|
|
186
200
|
if (reloaded)
|
|
187
201
|
return reloaded;
|
|
188
202
|
}
|
|
@@ -211,7 +225,7 @@ function createRunner(form) {
|
|
|
211
225
|
return stopped;
|
|
212
226
|
}
|
|
213
227
|
if (answer.record !== undefined) {
|
|
214
|
-
const moved = await form.showRecord(answer.record);
|
|
228
|
+
const moved = await ownMove(scope, () => form.showRecord(answer.record, scope.chain));
|
|
215
229
|
if (moved)
|
|
216
230
|
return moved;
|
|
217
231
|
}
|
|
@@ -249,20 +263,33 @@ function createRunner(form) {
|
|
|
249
263
|
const id = form.recordId();
|
|
250
264
|
if (id == null)
|
|
251
265
|
return cannot(`A new record cannot be ${name === 'duplicate' ? 'duplicated' : name === 'delete' ? 'deleted' : `${name}d`}: it is not saved yet`);
|
|
266
|
+
// Not when the record's source says this person may not: neither it nor the app is asked.
|
|
267
|
+
const barred = form.barred?.(name === 'unarchive' ? 'archive' : name);
|
|
268
|
+
if (barred)
|
|
269
|
+
return cannot(barred);
|
|
252
270
|
if (name === 'archive' || name === 'unarchive') {
|
|
253
271
|
if (!form.archive)
|
|
254
272
|
return instead(name, 'archive', scope);
|
|
273
|
+
// Loaded again once archived: the person's work is asked about before anything is.
|
|
274
|
+
const kept = await form.letGo(scope.chain);
|
|
275
|
+
if (kept)
|
|
276
|
+
return kept;
|
|
255
277
|
await form.archive(name === 'archive');
|
|
256
278
|
form.told({ archived: name === 'archive' }, id);
|
|
257
|
-
return form.reload();
|
|
279
|
+
return ownMove(scope, () => form.reload(scope.chain));
|
|
258
280
|
}
|
|
259
281
|
if (name === 'duplicate') {
|
|
260
|
-
// What was changed goes with the copy: it is saved first.
|
|
282
|
+
// What was changed goes with the copy: it is saved first. What that save could not take — changes Reload set
|
|
283
|
+
// aside, a change made while it ran — goes only when the person says so, before any copy is made; and a change
|
|
284
|
+
// made while the copy is made, before the copy shows.
|
|
261
285
|
if (form.changed()) {
|
|
262
286
|
const saved = await form.save(scope.chain);
|
|
263
287
|
if (saved)
|
|
264
288
|
return saved;
|
|
265
289
|
}
|
|
290
|
+
const kept = await form.letGo(scope.chain);
|
|
291
|
+
if (kept)
|
|
292
|
+
return kept;
|
|
266
293
|
if (!form.copy) {
|
|
267
294
|
const stopped = await instead(name, 'copy', scope);
|
|
268
295
|
const now = form.recordId();
|
|
@@ -271,22 +298,35 @@ function createRunner(form) {
|
|
|
271
298
|
return stopped;
|
|
272
299
|
}
|
|
273
300
|
const copied = await form.copy();
|
|
274
|
-
const moved = await form.showRecord(copied);
|
|
301
|
+
const moved = await ownMove(scope, () => form.showRecord(copied, scope.chain));
|
|
275
302
|
if (moved)
|
|
276
303
|
return moved;
|
|
277
304
|
form.told({ copied }, id);
|
|
278
305
|
return null;
|
|
279
306
|
}
|
|
307
|
+
// Deleted: what the person had not saved in it goes with it, unasked — they chose to delete it. Refused, it stays.
|
|
280
308
|
if (!form.remove) {
|
|
281
|
-
const stopped = await instead(name, 'delete', scope);
|
|
309
|
+
const stopped = await form.deleting(() => instead(name, 'delete', scope), (out) => !out);
|
|
282
310
|
if (!stopped)
|
|
283
|
-
|
|
311
|
+
told(scope, { deleted: true }, id);
|
|
284
312
|
return stopped;
|
|
285
313
|
}
|
|
286
|
-
|
|
287
|
-
form.
|
|
314
|
+
const remove = form.remove;
|
|
315
|
+
await form.deleting(() => remove(), () => true);
|
|
316
|
+
told(scope, { deleted: true }, id);
|
|
288
317
|
return null;
|
|
289
318
|
}
|
|
319
|
+
/** The record deleted, told: a pager moves on at once, and that move is this run's own. */
|
|
320
|
+
function told(scope, event, id) {
|
|
321
|
+
form.told(event, id);
|
|
322
|
+
scope.generation = form.generation();
|
|
323
|
+
}
|
|
324
|
+
/** A step of this run showing another record (or this one loaded again): the run goes on, on that one. */
|
|
325
|
+
async function ownMove(scope, move) {
|
|
326
|
+
const stopped = await move();
|
|
327
|
+
scope.generation = form.generation();
|
|
328
|
+
return stopped;
|
|
329
|
+
}
|
|
290
330
|
async function runStep(step, scope) {
|
|
291
331
|
switch (step.do) {
|
|
292
332
|
case 'set': {
|
|
@@ -316,10 +356,9 @@ function createRunner(form) {
|
|
|
316
356
|
case 'save':
|
|
317
357
|
return form.save(scope.chain);
|
|
318
358
|
case 'reset':
|
|
319
|
-
form.reset();
|
|
320
|
-
return null;
|
|
359
|
+
return form.reset(scope.chain);
|
|
321
360
|
case 'goTo': {
|
|
322
|
-
const stepped = form.goTo(step.target, scope.chain);
|
|
361
|
+
const stepped = await form.goTo(step.target, scope.chain);
|
|
323
362
|
if (stepped !== undefined)
|
|
324
363
|
return stepped;
|
|
325
364
|
const show = form.host?.show;
|
|
@@ -337,15 +376,12 @@ function createRunner(form) {
|
|
|
337
376
|
return call(step, scope);
|
|
338
377
|
case 'open':
|
|
339
378
|
return open(step, scope);
|
|
340
|
-
case 'close':
|
|
341
|
-
|
|
342
|
-
if (!close)
|
|
379
|
+
case 'close':
|
|
380
|
+
if (!form.host?.close)
|
|
343
381
|
return cannot('Nothing can close this form: it has no host, or was not opened in a dialog or panel');
|
|
344
|
-
close
|
|
345
|
-
return null;
|
|
346
|
-
}
|
|
382
|
+
return form.close(scope.chain);
|
|
347
383
|
case 'reload':
|
|
348
|
-
return form.reload();
|
|
384
|
+
return ownMove(scope, () => form.reload(scope.chain));
|
|
349
385
|
case 'openUrl': {
|
|
350
386
|
const openUrl = form.host?.openUrl;
|
|
351
387
|
if (!openUrl)
|
|
@@ -353,6 +389,12 @@ function createRunner(form) {
|
|
|
353
389
|
const url = read(step.url, false);
|
|
354
390
|
if (typeof url !== 'string' || !url.trim())
|
|
355
391
|
return cannot(`"${step.url}" gives no address to open`);
|
|
392
|
+
// In this tab, the page goes: the person's work is asked about first.
|
|
393
|
+
if (step.newTab === false) {
|
|
394
|
+
const kept = await form.letGo(scope.chain);
|
|
395
|
+
if (kept)
|
|
396
|
+
return kept;
|
|
397
|
+
}
|
|
356
398
|
openUrl.call(form.host, url.trim(), step.newTab ?? true);
|
|
357
399
|
return null;
|
|
358
400
|
}
|
|
@@ -366,13 +408,18 @@ function createRunner(form) {
|
|
|
366
408
|
}
|
|
367
409
|
}
|
|
368
410
|
async function runSteps(steps, scope) {
|
|
411
|
+
scope.generation ??= form.generation();
|
|
369
412
|
for (let at = 0; at < steps.length; at++) {
|
|
370
413
|
const step = steps[at];
|
|
371
414
|
let stopped;
|
|
372
415
|
try {
|
|
373
|
-
|
|
416
|
+
// The record it ran on was replaced by something else meanwhile: the rest is not for the one shown now.
|
|
417
|
+
if (form.generation() !== scope.generation)
|
|
418
|
+
stopped = form.gone();
|
|
419
|
+
else if (step.when !== undefined && !holds(step.when))
|
|
374
420
|
continue;
|
|
375
|
-
|
|
421
|
+
else
|
|
422
|
+
stopped = await runStep(step, scope);
|
|
376
423
|
}
|
|
377
424
|
catch (error) {
|
|
378
425
|
stopped = { reason: 'cannot', message: wordsOf(error), error };
|