@fieldia/core 0.23.0 → 0.25.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 +211 -3
- package/package.json +1 -1
- package/schema/page.schema.json +1051 -325
- package/src/index.d.mts +9 -2
- package/src/index.d.ts +9 -2
- package/src/index.js +31 -1
- package/src/index.js.map +1 -1
- package/src/index.mjs +12 -2
- package/src/index.mjs.map +1 -1
- package/src/lib/format/actions.d.mts +31 -1
- package/src/lib/format/actions.d.ts +31 -1
- package/src/lib/format/actions.js +1 -0
- package/src/lib/format/actions.js.map +1 -1
- package/src/lib/format/actions.mjs +1 -0
- package/src/lib/format/actions.mjs.map +1 -1
- package/src/lib/format/autofill-group.d.mts +12 -0
- package/src/lib/format/autofill-group.d.ts +12 -0
- package/src/lib/format/autofill-group.js +23 -0
- package/src/lib/format/autofill-group.js.map +1 -0
- package/src/lib/format/autofill-group.mjs +19 -0
- package/src/lib/format/autofill-group.mjs.map +1 -0
- package/src/lib/format/autofill.d.mts +14 -0
- package/src/lib/format/autofill.d.ts +14 -0
- package/src/lib/format/autofill.js +54 -0
- package/src/lib/format/autofill.js.map +1 -0
- package/src/lib/format/autofill.mjs +48 -0
- package/src/lib/format/autofill.mjs.map +1 -0
- package/src/lib/format/bulk-edit.d.mts +18 -0
- package/src/lib/format/bulk-edit.d.ts +18 -0
- package/src/lib/format/bulk-edit.js +26 -0
- package/src/lib/format/bulk-edit.js.map +1 -0
- package/src/lib/format/bulk-edit.mjs +21 -0
- package/src/lib/format/bulk-edit.mjs.map +1 -0
- package/src/lib/format/duplicate-kinds.d.mts +10 -0
- package/src/lib/format/duplicate-kinds.d.ts +10 -0
- package/src/lib/format/duplicate-kinds.js +14 -0
- package/src/lib/format/duplicate-kinds.js.map +1 -0
- package/src/lib/format/duplicate-kinds.mjs +10 -0
- package/src/lib/format/duplicate-kinds.mjs.map +1 -0
- package/src/lib/format/duplicates.d.mts +22 -0
- package/src/lib/format/duplicates.d.ts +22 -0
- package/src/lib/format/duplicates.js +24 -0
- package/src/lib/format/duplicates.js.map +1 -0
- package/src/lib/format/duplicates.mjs +21 -0
- package/src/lib/format/duplicates.mjs.map +1 -0
- package/src/lib/format/field.d.mts +291 -34
- package/src/lib/format/field.d.ts +291 -34
- package/src/lib/format/field.js +19 -4
- package/src/lib/format/field.js.map +1 -1
- package/src/lib/format/field.mjs +17 -2
- package/src/lib/format/field.mjs.map +1 -1
- package/src/lib/format/import-fields.d.mts +18 -0
- package/src/lib/format/import-fields.d.ts +18 -0
- package/src/lib/format/import-fields.js +26 -0
- package/src/lib/format/import-fields.js.map +1 -0
- package/src/lib/format/import-fields.mjs +21 -0
- package/src/lib/format/import-fields.mjs.map +1 -0
- package/src/lib/format/layout.d.mts +7357 -3127
- package/src/lib/format/layout.d.ts +7357 -3127
- package/src/lib/format/layout.js +108 -32
- package/src/lib/format/layout.js.map +1 -1
- package/src/lib/format/layout.mjs +107 -32
- package/src/lib/format/layout.mjs.map +1 -1
- package/src/lib/format/layout.types.d.mts +5 -2
- package/src/lib/format/layout.types.d.ts +5 -2
- package/src/lib/format/page.d.mts +1080 -106
- package/src/lib/format/page.d.ts +1080 -106
- package/src/lib/format/page.js +25 -0
- package/src/lib/format/page.js.map +1 -1
- package/src/lib/format/page.mjs +26 -1
- package/src/lib/format/page.mjs.map +1 -1
- package/src/lib/format/phone.d.mts +27 -0
- package/src/lib/format/phone.d.ts +27 -0
- package/src/lib/format/phone.js +43 -0
- package/src/lib/format/phone.js.map +1 -0
- package/src/lib/format/phone.mjs +39 -0
- package/src/lib/format/phone.mjs.map +1 -0
- package/src/lib/format/references.d.mts +39 -0
- package/src/lib/format/references.d.ts +39 -0
- package/src/lib/format/references.js +263 -20
- package/src/lib/format/references.js.map +1 -1
- package/src/lib/format/references.mjs +263 -20
- package/src/lib/format/references.mjs.map +1 -1
- package/src/lib/format/slots-options.d.mts +26 -0
- package/src/lib/format/slots-options.d.ts +26 -0
- package/src/lib/format/slots-options.js +35 -0
- package/src/lib/format/slots-options.js.map +1 -0
- package/src/lib/format/slots-options.mjs +31 -0
- package/src/lib/format/slots-options.mjs.map +1 -0
- package/src/lib/format/translate.js +8 -4
- package/src/lib/format/translate.js.map +1 -1
- package/src/lib/format/translate.mjs +8 -4
- package/src/lib/format/translate.mjs.map +1 -1
- package/src/lib/format/upgrade.d.mts +8 -3
- package/src/lib/format/upgrade.d.ts +8 -3
- package/src/lib/format/upgrade.js +8 -3
- package/src/lib/format/upgrade.js.map +1 -1
- package/src/lib/format/upgrade.mjs +8 -3
- package/src/lib/format/upgrade.mjs.map +1 -1
- package/src/lib/format/version.d.mts +2 -2
- package/src/lib/format/version.d.ts +2 -2
- package/src/lib/format/version.js +2 -2
- package/src/lib/format/version.js.map +1 -1
- package/src/lib/format/version.mjs +2 -2
- package/src/lib/format/version.mjs.map +1 -1
- package/src/lib/format/zoned.d.mts +8 -0
- package/src/lib/format/zoned.d.ts +8 -0
- package/src/lib/format/zoned.js +36 -0
- package/src/lib/format/zoned.js.map +1 -0
- package/src/lib/format/zoned.mjs +33 -0
- package/src/lib/format/zoned.mjs.map +1 -0
- package/src/lib/record/check.d.mts +6 -1
- package/src/lib/record/check.d.ts +6 -1
- package/src/lib/record/check.js +12 -4
- package/src/lib/record/check.js.map +1 -1
- package/src/lib/record/check.mjs +12 -4
- package/src/lib/record/check.mjs.map +1 -1
- package/src/lib/record/data-source.d.mts +309 -3
- package/src/lib/record/data-source.d.ts +309 -3
- package/src/lib/record/data-source.js +16 -0
- package/src/lib/record/data-source.js.map +1 -1
- package/src/lib/record/data-source.mjs +15 -0
- package/src/lib/record/data-source.mjs.map +1 -1
- package/src/lib/record/form.d.mts +116 -25
- package/src/lib/record/form.d.ts +116 -25
- package/src/lib/record/form.js +457 -78
- package/src/lib/record/form.js.map +1 -1
- package/src/lib/record/form.mjs +457 -78
- package/src/lib/record/form.mjs.map +1 -1
- package/src/lib/record/input-rules.d.mts +51 -9
- package/src/lib/record/input-rules.d.ts +51 -9
- package/src/lib/record/input-rules.js +119 -20
- package/src/lib/record/input-rules.js.map +1 -1
- package/src/lib/record/input-rules.mjs +118 -19
- package/src/lib/record/input-rules.mjs.map +1 -1
- package/src/lib/record/inputs.js +4 -2
- package/src/lib/record/inputs.js.map +1 -1
- package/src/lib/record/inputs.mjs +4 -2
- package/src/lib/record/inputs.mjs.map +1 -1
- package/src/lib/record/limits.d.mts +1 -1
- package/src/lib/record/limits.d.ts +1 -1
- package/src/lib/record/limits.js +4 -2
- package/src/lib/record/limits.js.map +1 -1
- package/src/lib/record/limits.mjs +4 -2
- package/src/lib/record/limits.mjs.map +1 -1
- package/src/lib/record/locales/ar.js +3 -2
- package/src/lib/record/locales/ar.js.map +1 -1
- package/src/lib/record/locales/ar.mjs +3 -2
- package/src/lib/record/locales/ar.mjs.map +1 -1
- package/src/lib/record/locales/de.js +3 -2
- package/src/lib/record/locales/de.js.map +1 -1
- package/src/lib/record/locales/de.mjs +3 -2
- package/src/lib/record/locales/de.mjs.map +1 -1
- package/src/lib/record/locales/fr.js +3 -2
- package/src/lib/record/locales/fr.js.map +1 -1
- package/src/lib/record/locales/fr.mjs +3 -2
- package/src/lib/record/locales/fr.mjs.map +1 -1
- package/src/lib/record/memory-data-source.d.mts +20 -2
- package/src/lib/record/memory-data-source.d.ts +20 -2
- package/src/lib/record/memory-data-source.js +153 -35
- package/src/lib/record/memory-data-source.js.map +1 -1
- package/src/lib/record/memory-data-source.mjs +154 -36
- package/src/lib/record/memory-data-source.mjs.map +1 -1
- package/src/lib/record/memory-duplicates.d.mts +19 -0
- package/src/lib/record/memory-duplicates.d.ts +19 -0
- package/src/lib/record/memory-duplicates.js +78 -0
- package/src/lib/record/memory-duplicates.js.map +1 -0
- package/src/lib/record/memory-duplicates.mjs +74 -0
- package/src/lib/record/memory-duplicates.mjs.map +1 -0
- package/src/lib/record/memory-schedules.d.mts +45 -0
- package/src/lib/record/memory-schedules.d.ts +45 -0
- package/src/lib/record/memory-schedules.js +81 -0
- package/src/lib/record/memory-schedules.js.map +1 -0
- package/src/lib/record/memory-schedules.mjs +78 -0
- package/src/lib/record/memory-schedules.mjs.map +1 -0
- package/src/lib/record/messages.d.mts +3 -1
- package/src/lib/record/messages.d.ts +3 -1
- package/src/lib/record/messages.js +3 -2
- package/src/lib/record/messages.js.map +1 -1
- package/src/lib/record/messages.mjs +3 -2
- package/src/lib/record/messages.mjs.map +1 -1
- package/src/lib/record/periods.d.mts +47 -0
- package/src/lib/record/periods.d.ts +47 -0
- package/src/lib/record/periods.js +86 -0
- package/src/lib/record/periods.js.map +1 -0
- package/src/lib/record/periods.mjs +79 -0
- package/src/lib/record/periods.mjs.map +1 -0
- package/src/lib/record/rules.js +5 -6
- package/src/lib/record/rules.js.map +1 -1
- package/src/lib/record/rules.mjs +5 -6
- package/src/lib/record/rules.mjs.map +1 -1
- package/src/lib/record/run.d.mts +75 -9
- package/src/lib/record/run.d.ts +75 -9
- package/src/lib/record/run.js +169 -26
- package/src/lib/record/run.js.map +1 -1
- package/src/lib/record/run.mjs +170 -27
- package/src/lib/record/run.mjs.map +1 -1
- package/src/lib/record/search.d.mts +13 -3
- package/src/lib/record/search.d.ts +13 -3
- package/src/lib/record/search.js +11 -4
- package/src/lib/record/search.js.map +1 -1
- package/src/lib/record/search.mjs +11 -4
- package/src/lib/record/search.mjs.map +1 -1
- package/src/lib/record/waits.d.mts +32 -0
- package/src/lib/record/waits.d.ts +32 -0
- package/src/lib/record/waits.js +89 -0
- package/src/lib/record/waits.js.map +1 -0
- package/src/lib/record/waits.mjs +85 -0
- package/src/lib/record/waits.mjs.map +1 -0
- package/src/lib/record/zones.d.mts +57 -0
- package/src/lib/record/zones.d.ts +57 -0
- package/src/lib/record/zones.js +147 -0
- package/src/lib/record/zones.js.map +1 -0
- package/src/lib/record/zones.mjs +132 -0
- package/src/lib/record/zones.mjs.map +1 -0
- package/src/runtime.d.mts +19 -9
- package/src/runtime.d.ts +19 -9
- package/src/runtime.js +37 -2
- package/src/runtime.js.map +1 -1
- package/src/runtime.mjs +9 -2
- package/src/runtime.mjs.map +1 -1
|
@@ -10,13 +10,20 @@ const hotkeys_1 = require("./hotkeys");
|
|
|
10
10
|
const head_checks_1 = require("./head-checks");
|
|
11
11
|
const section_checks_1 = require("./section-checks");
|
|
12
12
|
const pattern_1 = require("./pattern");
|
|
13
|
+
const bulk_edit_1 = require("./bulk-edit");
|
|
14
|
+
const duplicate_kinds_1 = require("./duplicate-kinds");
|
|
15
|
+
const import_fields_1 = require("./import-fields");
|
|
16
|
+
const zones_1 = require("../record/zones");
|
|
13
17
|
const messages_1 = require("../record/messages");
|
|
18
|
+
const autofill_group_1 = require("./autofill-group");
|
|
14
19
|
const has = (record, key) => Object.prototype.hasOwnProperty.call(record, key);
|
|
15
20
|
/** The kinds of field an expression can give a value to: the rest hold records, lines or files. */
|
|
16
21
|
const EXPRESSIBLE = new Set(['char', 'text', 'html', 'integer', 'float', 'monetary', 'boolean', 'date', 'datetime', 'selection', 'json']);
|
|
17
22
|
const EXPRESSIBLE_WORDS = 'text, numbers, yes or no, dates, choices and json can';
|
|
18
23
|
/** The kinds of field a list's filter bar can list the values of. */
|
|
19
24
|
const LISTS_ITS_VALUES = new Set(['selection', 'many2one', 'many2many', 'boolean', 'char', 'integer']);
|
|
25
|
+
/** Kinds of field a list's card shows as its picture: a picture held, or text holding a picture's address. */
|
|
26
|
+
const PICTURES = new Set(['image', 'binary', 'char']);
|
|
20
27
|
/** What a calendar's start and end can be: a day, or a day and a time. */
|
|
21
28
|
const CALENDAR_TIMES = new Set(['date', 'datetime']);
|
|
22
29
|
/** What a record's words on a calendar can be. */
|
|
@@ -41,11 +48,15 @@ class ReferenceCheck {
|
|
|
41
48
|
/** The ids of the tabs and wizard steps a step can go to, and where each goTo and show names one. */
|
|
42
49
|
places = new Set();
|
|
43
50
|
goingTo = [];
|
|
51
|
+
/** The names of the slots the layout places. */
|
|
52
|
+
slots = new Set();
|
|
44
53
|
constructor(page, line) {
|
|
45
54
|
this.page = page;
|
|
46
55
|
this.line = line;
|
|
47
56
|
}
|
|
48
57
|
run() {
|
|
58
|
+
if (this.page.timeZone !== undefined)
|
|
59
|
+
this.checkZone(this.page.timeZone, 'timeZone');
|
|
49
60
|
this.checkFields(this.page.fields, 'fields', this.line?.name, this.line?.parent);
|
|
50
61
|
this.walkRoot(this.page.layout, 'layout');
|
|
51
62
|
(0, head_checks_1.checkHead)(this.page.layout, 'layout', {
|
|
@@ -61,9 +72,46 @@ class ReferenceCheck {
|
|
|
61
72
|
});
|
|
62
73
|
if (this.page.on)
|
|
63
74
|
this.checkEvents(this.page.on, 'on');
|
|
75
|
+
if (this.page.botCheck !== undefined && !this.line)
|
|
76
|
+
this.checkBotCheck(this.page);
|
|
77
|
+
if (this.page.duplicates !== undefined && !this.line)
|
|
78
|
+
this.checkDuplicates(this.page);
|
|
64
79
|
this.checkGoingTo();
|
|
65
80
|
return this.issues;
|
|
66
81
|
}
|
|
82
|
+
/** A bot check: on a page of responses, its captcha drawn in a slot the page places. */
|
|
83
|
+
checkBotCheck(page) {
|
|
84
|
+
const check = page.botCheck;
|
|
85
|
+
if (page.data.kind !== 'responses')
|
|
86
|
+
return this.report('botCheck', 'a bot check is for a page of responses that anyone may send; a record’s page is behind the app’s own sign-in');
|
|
87
|
+
const captcha = check?.captcha;
|
|
88
|
+
if (typeof captcha === 'string' && !this.slots.has(captcha))
|
|
89
|
+
this.report('botCheck.captcha', `no slot "${captcha}" on this page to draw the captcha in: place { "type": "slot", "id": "${captcha}", "name": "${captcha}" } where it goes`);
|
|
90
|
+
}
|
|
91
|
+
/** Possible duplicates: asked of a record's own page, by fields records can be compared by, each named once. */
|
|
92
|
+
checkDuplicates(page) {
|
|
93
|
+
const given = page.duplicates?.fields;
|
|
94
|
+
const named = Array.isArray(given) ? given : [];
|
|
95
|
+
if (!named.length)
|
|
96
|
+
this.report('duplicates.fields', 'name the fields records are compared by: ["phone", "email"]');
|
|
97
|
+
if (page.data.kind !== 'record')
|
|
98
|
+
this.report('duplicates', 'duplicates are asked of records like the one typed: a page of responses keeps none to compare it with');
|
|
99
|
+
else if (page.layout.type === 'list')
|
|
100
|
+
this.report('duplicates', 'duplicates are asked as a record is typed, on its own page, not on a list of records');
|
|
101
|
+
named.forEach((name, i) => {
|
|
102
|
+
const at = `duplicates.fields[${i}]`;
|
|
103
|
+
if (named.indexOf(name) !== i)
|
|
104
|
+
return this.report(at, `"${name}" is named twice`);
|
|
105
|
+
const def = this.need(name, at);
|
|
106
|
+
if (def && !duplicate_kinds_1.DUPLICATE_KINDS.has(def.type))
|
|
107
|
+
this.report(at, `"${name}" is a ${def.type}; records are compared by words, a number, a date, a choice or a link`);
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
/** A time zone the browser knows, by its IANA name: a page's dates and times are never drawn on a clock it cannot read. */
|
|
111
|
+
checkZone(zone, path) {
|
|
112
|
+
if (!(0, zones_1.isTimeZone)(zone))
|
|
113
|
+
this.report(path, `${JSON.stringify(zone)} is not a time zone this browser knows: name one as the IANA does, such as "Africa/Cairo"`);
|
|
114
|
+
}
|
|
67
115
|
/** Each step's goTo and show names a tab or a wizard step of this page. */
|
|
68
116
|
checkGoingTo() {
|
|
69
117
|
for (const { target, path } of this.goingTo) {
|
|
@@ -395,6 +443,14 @@ class ReferenceCheck {
|
|
|
395
443
|
if (pattern instanceof Error)
|
|
396
444
|
this.report(`${path}.pattern`, (0, messages_1.fill)(messages_1.MESSAGES.en.patternBroken, { label: def.label, problem: pattern.message }));
|
|
397
445
|
}
|
|
446
|
+
if (def.type === 'datetime' && def.timeZone !== undefined)
|
|
447
|
+
this.checkZone(def.timeZone, `${path}.timeZone`);
|
|
448
|
+
// A linked record's date and time, in a table of the records a many2many links to.
|
|
449
|
+
if (def.type === 'many2many' && def.fields) {
|
|
450
|
+
for (const [column, linked] of Object.entries(def.fields))
|
|
451
|
+
if (linked.type === 'datetime' && linked.timeZone !== undefined)
|
|
452
|
+
this.checkZone(linked.timeZone, `${path}.fields.${column}.timeZone`);
|
|
453
|
+
}
|
|
398
454
|
if (def.type === 'selection')
|
|
399
455
|
def.optionsFrom?.dependsOn?.forEach((other, i) => this.need(other, `${path}.optionsFrom.dependsOn[${i}]`, fields));
|
|
400
456
|
if (def.type === 'properties')
|
|
@@ -493,9 +549,7 @@ class ReferenceCheck {
|
|
|
493
549
|
walkList(list, path) {
|
|
494
550
|
if (this.page.data.kind !== 'record')
|
|
495
551
|
this.report('data', 'a list shows records: its data needs kind "record" and a model');
|
|
496
|
-
|
|
497
|
-
list.sort?.forEach((order, i) => this.need(order.field, `${path}.sort[${i}].field`));
|
|
498
|
-
list.searchFields?.forEach((name, i) => this.need(name, `${path}.searchFields[${i}]`));
|
|
552
|
+
this.checkListed(list, this.page.fields, path);
|
|
499
553
|
list.groupBy?.forEach((name, i) => this.need(name, `${path}.groupBy[${i}]`));
|
|
500
554
|
// A list's filters are about its own records: their fields are the page's, and there is no record to take a value from.
|
|
501
555
|
const walk = (item, at) => {
|
|
@@ -511,7 +565,11 @@ class ReferenceCheck {
|
|
|
511
565
|
list.filters?.forEach((filter, i) => {
|
|
512
566
|
this.claim(filter.id, `${path}.filters[${i}]`);
|
|
513
567
|
named.add(filter.id);
|
|
514
|
-
filter.filter
|
|
568
|
+
filter.filter?.forEach((item, j) => walk(item, `${path}.filters[${i}].filter[${j}]`));
|
|
569
|
+
// A period is of a date, or a date and time.
|
|
570
|
+
const dated = filter.period ? this.need(filter.period.field, `${path}.filters[${i}].period.field`) : undefined;
|
|
571
|
+
if (dated && dated.type !== 'date' && dated.type !== 'datetime')
|
|
572
|
+
this.report(`${path}.filters[${i}].period.field`, `"${filter.period?.field}" is a ${dated.type}; a period is of a date, or a date and time`);
|
|
515
573
|
});
|
|
516
574
|
list.defaultFilters?.forEach((id, i) => {
|
|
517
575
|
if (!named.has(id))
|
|
@@ -526,6 +584,54 @@ class ReferenceCheck {
|
|
|
526
584
|
if (list.calendar)
|
|
527
585
|
this.walkListCalendar(list, `${path}.calendar`);
|
|
528
586
|
this.checkListCells(list, path);
|
|
587
|
+
this.checkListRows(list, path);
|
|
588
|
+
}
|
|
589
|
+
/**
|
|
590
|
+
* A list's cards, gallery, columns people choose and rows' own rules: a
|
|
591
|
+
* card's fields the page's, its picture one that can hold a picture; the
|
|
592
|
+
* optional columns among the columns; a row's tones, bold and buttons
|
|
593
|
+
* reading the list's record (its fields, `id`, `user`); and the list
|
|
594
|
+
* opening on one thing.
|
|
595
|
+
*/
|
|
596
|
+
checkListRows(list, path) {
|
|
597
|
+
if (list.card)
|
|
598
|
+
this.checkListCard(list.card, `${path}.card`, this.page.fields);
|
|
599
|
+
for (const column of Object.keys(list.optionalColumns ?? {})) {
|
|
600
|
+
if (!list.columns.includes(column))
|
|
601
|
+
this.report(`${path}.optionalColumns.${column}`, `"${column}" is no column of this list: a person shows or hides its columns`);
|
|
602
|
+
}
|
|
603
|
+
// A column a person may hide, every one hidden at first: the list would open with no column but its own.
|
|
604
|
+
if (list.optionalColumns && list.columns.every((column) => list.optionalColumns?.[column] === 'hide'))
|
|
605
|
+
this.report(`${path}.optionalColumns`, 'every column starts hidden: show one at least, as the list opens');
|
|
606
|
+
if (list.gallery?.opens === 'gallery') {
|
|
607
|
+
if (list.map?.view && list.map.view !== 'list')
|
|
608
|
+
this.report(`${path}.gallery.opens`, 'the list opens on its map (map.view) and on its gallery: say one');
|
|
609
|
+
if (list.calendar?.opens === 'calendar')
|
|
610
|
+
this.report(`${path}.gallery.opens`, 'the list opens on its calendar and on its gallery: say one');
|
|
611
|
+
}
|
|
612
|
+
list.rowTones?.forEach((tone, i) => this.checkModifiers(tone, `${path}.rowTones[${i}]`, ['when']));
|
|
613
|
+
this.checkModifiers(list, path, ['rowBold']);
|
|
614
|
+
list.rowButtons?.forEach((button, i) => {
|
|
615
|
+
this.claim(button.id, `${path}.rowButtons[${i}]`);
|
|
616
|
+
this.checkPress(button, `${path}.rowButtons[${i}]`);
|
|
617
|
+
// Shown by a condition on each row's record.
|
|
618
|
+
this.checkModifiers(button, `${path}.rowButtons[${i}]`, ['invisible']);
|
|
619
|
+
});
|
|
620
|
+
}
|
|
621
|
+
/**
|
|
622
|
+
* What a list's card shows — a list page's, or a related list's of its own records' fields: its title, subtitle,
|
|
623
|
+
* status and lines each a field, its picture one that can hold a picture.
|
|
624
|
+
*/
|
|
625
|
+
checkListCard(card, at, fields) {
|
|
626
|
+
for (const key of ['title', 'subtitle', 'status'])
|
|
627
|
+
if (card[key] !== undefined)
|
|
628
|
+
this.need(card[key], `${at}.${key}`, fields);
|
|
629
|
+
if (card.image !== undefined) {
|
|
630
|
+
const def = this.need(card.image, `${at}.image`, fields);
|
|
631
|
+
if (def && !PICTURES.has(def.type))
|
|
632
|
+
this.report(`${at}.image`, `"${card.image}" is a ${def.type}; a card's picture is an image or binary field, or text holding a picture's address`);
|
|
633
|
+
}
|
|
634
|
+
card.fields?.forEach((line, i) => (Array.isArray(line) ? line : [line]).forEach((part, j) => this.need(typeof part === 'string' ? part : part.field, `${at}.fields[${i}]${Array.isArray(line) ? `[${j}]` : ''}${typeof part === 'string' ? '' : '.field'}`, fields)));
|
|
529
635
|
}
|
|
530
636
|
/**
|
|
531
637
|
* A list's calendar: when each record starts (a date, or a date and time)
|
|
@@ -570,22 +676,6 @@ class ReferenceCheck {
|
|
|
570
676
|
* the rows chosen need a box to choose one.
|
|
571
677
|
*/
|
|
572
678
|
checkListCells(list, path) {
|
|
573
|
-
for (const [column, cell] of Object.entries(list.cells ?? {})) {
|
|
574
|
-
const at = `${path}.cells.${column}`;
|
|
575
|
-
if (!list.columns.includes(column)) {
|
|
576
|
-
this.report(at, `"${column}" is no column of this list: its cells are for its columns`);
|
|
577
|
-
continue;
|
|
578
|
-
}
|
|
579
|
-
if (!cell.lead)
|
|
580
|
-
continue;
|
|
581
|
-
const def = this.need(cell.lead.field, `${at}.lead.field`);
|
|
582
|
-
if (def?.type !== 'selection')
|
|
583
|
-
continue;
|
|
584
|
-
const values = new Set(def.options.map((option) => String(option.value)));
|
|
585
|
-
for (const value of Object.keys(cell.lead.looks))
|
|
586
|
-
if (!values.has(value))
|
|
587
|
-
this.report(`${at}.lead.looks.${value}`, `"${value}" is no value of "${cell.lead.field}"`);
|
|
588
|
-
}
|
|
589
679
|
if (list.filterFields && list.search !== 'fields')
|
|
590
680
|
this.report(`${path}.filterFields`, 'the filter fields are for the "fields" search: add "search": "fields"');
|
|
591
681
|
list.filterFields?.forEach((name, i) => {
|
|
@@ -607,6 +697,86 @@ class ReferenceCheck {
|
|
|
607
697
|
}
|
|
608
698
|
if (list.choose === false && list.actions?.length)
|
|
609
699
|
this.report(`${path}.actions`, 'a list’s buttons act on the rows chosen: with "choose": false there is no way to choose one');
|
|
700
|
+
this.checkBulkEdit(list, path);
|
|
701
|
+
this.checkImport(list, path);
|
|
702
|
+
}
|
|
703
|
+
/**
|
|
704
|
+
* What a list shows of its records — a list page's, or a related list's of its own records' fields: its columns, its
|
|
705
|
+
* order and the fields its search looks in, each a field; each column's cells for a column of it, a sum, an average,
|
|
706
|
+
* the lowest and the highest of a number column (any column's count), a lead's icon by a field's values.
|
|
707
|
+
*/
|
|
708
|
+
checkListed(list, fields, path) {
|
|
709
|
+
list.columns.forEach((name, i) => this.need(name, `${path}.columns[${i}]`, fields));
|
|
710
|
+
list.sort?.forEach((order, i) => this.need(order.field, `${path}.sort[${i}].field`, fields));
|
|
711
|
+
list.searchFields?.forEach((name, i) => this.need(name, `${path}.searchFields[${i}]`, fields));
|
|
712
|
+
for (const [column, cell] of Object.entries(list.cells ?? {})) {
|
|
713
|
+
const at = `${path}.cells.${column}`;
|
|
714
|
+
if (!list.columns.includes(column)) {
|
|
715
|
+
this.report(at, `"${column}" is no column of this list: its cells are for its columns`);
|
|
716
|
+
continue;
|
|
717
|
+
}
|
|
718
|
+
const kind = has(fields, column) ? fields[column].type : undefined;
|
|
719
|
+
if (cell.total && cell.total !== 'count' && kind && kind !== 'integer' && kind !== 'float' && kind !== 'monetary') {
|
|
720
|
+
this.report(`${at}.total`, `"${column}" is a ${kind}; its total "${cell.total}" is of numbers — an integer, a float or an amount — and any column's is "count"`);
|
|
721
|
+
}
|
|
722
|
+
if (!cell.lead)
|
|
723
|
+
continue;
|
|
724
|
+
const def = this.need(cell.lead.field, `${at}.lead.field`, fields);
|
|
725
|
+
if (def?.type !== 'selection')
|
|
726
|
+
continue;
|
|
727
|
+
const values = new Set(def.options.map((option) => String(option.value)));
|
|
728
|
+
for (const value of Object.keys(cell.lead.looks))
|
|
729
|
+
if (!values.has(value))
|
|
730
|
+
this.report(`${at}.lead.looks.${value}`, `"${value}" is no value of "${cell.lead.field}"`);
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
/** A list's Edit: each field it names one value can set in many records, and rows to choose to set it on. */
|
|
734
|
+
checkBulkEdit(list, path) {
|
|
735
|
+
if (!list.bulkEdit)
|
|
736
|
+
return;
|
|
737
|
+
if (list.choose === false)
|
|
738
|
+
this.report(`${path}.bulkEdit`, 'Edit changes the rows chosen: with "choose": false there is no way to choose one');
|
|
739
|
+
if (list.bulkEdit === true) {
|
|
740
|
+
if (!list.columns.some((name) => (0, bulk_edit_1.bulkSettable)(this.page.fields[name])))
|
|
741
|
+
this.report(`${path}.bulkEdit`, 'Edit offers the columns one value can set, and none of these can: name the fields it offers');
|
|
742
|
+
return;
|
|
743
|
+
}
|
|
744
|
+
const named = list.bulkEdit;
|
|
745
|
+
named.forEach((name, i) => {
|
|
746
|
+
const at = `${path}.bulkEdit[${i}]`;
|
|
747
|
+
if (named.indexOf(name) !== i)
|
|
748
|
+
this.report(at, `"${name}" is offered twice`);
|
|
749
|
+
const def = this.need(name, at);
|
|
750
|
+
if (!def)
|
|
751
|
+
return;
|
|
752
|
+
if (!bulk_edit_1.BULK_KINDS.has(def.type))
|
|
753
|
+
this.report(at, `"${name}" is a ${def.type}; one value set in many records is words, a number, money, a yes or no, a date, a choice or a link`);
|
|
754
|
+
else if (def.readonly === true || def.compute)
|
|
755
|
+
this.report(at, `"${name}" is ${def.compute ? 'worked out from other fields' : 'read-only'}; Edit sets a field people can change`);
|
|
756
|
+
});
|
|
757
|
+
}
|
|
758
|
+
/** A list's Import: each field it names one a file's cell can fill, and at least one such field on the page. */
|
|
759
|
+
checkImport(list, path) {
|
|
760
|
+
if (!list.import)
|
|
761
|
+
return;
|
|
762
|
+
if (list.import === true) {
|
|
763
|
+
if (!Object.values(this.page.fields).some((def) => (0, import_fields_1.importable)(def)))
|
|
764
|
+
this.report(`${path}.import`, 'Import fills the fields a file’s cell can, and this page has none: words, a number, money, yes or no, a date, a choice or a link people can change');
|
|
765
|
+
return;
|
|
766
|
+
}
|
|
767
|
+
const named = list.import;
|
|
768
|
+
named.forEach((name, i) => {
|
|
769
|
+
const at = `${path}.import[${i}]`;
|
|
770
|
+
if (named.indexOf(name) !== i)
|
|
771
|
+
this.report(at, `"${name}" is offered twice`);
|
|
772
|
+
const def = this.need(name, at);
|
|
773
|
+
if (!def)
|
|
774
|
+
return;
|
|
775
|
+
if (!import_fields_1.IMPORT_KINDS.has(def.type))
|
|
776
|
+
this.report(at, `"${name}" is a ${def.type}; a file's cell fills words, a number, money, a yes or no, a date, a choice, or a link or links by name`);
|
|
777
|
+
else if (def.readonly === true || def.compute)
|
|
778
|
+
this.report(at, `"${name}" is ${def.compute ? 'worked out from other fields' : 'read-only'}; Import fills a field people can change`);
|
|
779
|
+
});
|
|
610
780
|
}
|
|
611
781
|
/** A list's map: where each record is, and the fields its pin and its card show, each of a type that can. */
|
|
612
782
|
walkListMap(map, path) {
|
|
@@ -802,6 +972,11 @@ class ReferenceCheck {
|
|
|
802
972
|
return this.checkValuesIn(node.text, `${path}.text`);
|
|
803
973
|
case 'map':
|
|
804
974
|
return this.walkMap(node, path);
|
|
975
|
+
case 'related':
|
|
976
|
+
return this.checkRelated(node, path);
|
|
977
|
+
case 'slot':
|
|
978
|
+
this.slots.add(node.name);
|
|
979
|
+
return;
|
|
805
980
|
default:
|
|
806
981
|
return;
|
|
807
982
|
}
|
|
@@ -823,6 +998,48 @@ class ReferenceCheck {
|
|
|
823
998
|
else
|
|
824
999
|
this.formNames.set(node.name, path);
|
|
825
1000
|
}
|
|
1001
|
+
/**
|
|
1002
|
+
* A related list: on a record's page, its columns, order, search, cells, card and rows' rules of its own records'
|
|
1003
|
+
* fields, its link to this record a link of theirs to this model where its fields name it, and its filter's
|
|
1004
|
+
* `valueFrom` this record's.
|
|
1005
|
+
*/
|
|
1006
|
+
checkRelated(node, path) {
|
|
1007
|
+
// The quick check reads no shapes: a part with nothing to go by is said here.
|
|
1008
|
+
if (typeof node.model !== 'string' || typeof node.field !== 'string' || !Array.isArray(node.columns) || !node.fields || typeof node.fields !== 'object') {
|
|
1009
|
+
return this.report(path, 'a related list needs the model of its records, their link to this record (field), their fields and its columns');
|
|
1010
|
+
}
|
|
1011
|
+
const model = this.page.data.kind === 'record' ? this.page.data.model : null;
|
|
1012
|
+
if (!model || this.line)
|
|
1013
|
+
this.report(path, 'a related list shows the records that point at a record: it belongs on a record’s page');
|
|
1014
|
+
const fields = node.fields;
|
|
1015
|
+
this.checkListed(node, fields, path);
|
|
1016
|
+
// On a phone its rows are cards, as a list's: of its own records' fields.
|
|
1017
|
+
if (node.card)
|
|
1018
|
+
this.checkListCard(node.card, `${path}.card`, fields);
|
|
1019
|
+
// Its rows' own rules, as a list's, each read on the row's record: its own fields, its id, the person, the context.
|
|
1020
|
+
const row = { fields };
|
|
1021
|
+
node.rowTones?.forEach((tone, i) => this.checkModifiers(tone, `${path}.rowTones[${i}]`, ['when'], row));
|
|
1022
|
+
this.checkModifiers(node, path, ['rowBold'], row);
|
|
1023
|
+
node.rowButtons?.forEach((button, i) => {
|
|
1024
|
+
this.claim(button.id, `${path}.rowButtons[${i}]`);
|
|
1025
|
+
this.checkPress(button, `${path}.rowButtons[${i}]`);
|
|
1026
|
+
this.checkModifiers(button, `${path}.rowButtons[${i}]`, ['invisible'], row);
|
|
1027
|
+
});
|
|
1028
|
+
const link = has(fields, node.field) ? fields[node.field] : undefined;
|
|
1029
|
+
if (link && model && (link.type !== 'many2one' || link.relation !== model)) {
|
|
1030
|
+
this.report(`${path}.field`, `"${node.field}" ${link.type === 'many2one' ? `links to ${link.relation}` : `is a ${link.type}`}; the records listed point at this one by a many2one to ${model}`);
|
|
1031
|
+
}
|
|
1032
|
+
for (const [name, def] of Object.entries(fields)) {
|
|
1033
|
+
if (def.type === 'monetary' && def.currencyField !== undefined)
|
|
1034
|
+
this.checkCurrency(def.currencyField, `${path}.fields.${name}.currencyField`, fields, undefined, fields);
|
|
1035
|
+
if (def.type === 'datetime' && def.timeZone !== undefined)
|
|
1036
|
+
this.checkZone(def.timeZone, `${path}.fields.${name}.timeZone`);
|
|
1037
|
+
}
|
|
1038
|
+
// Its filter is about its records, by their fields; what it compares with may be read from this record.
|
|
1039
|
+
node.filter?.forEach((item, i) => this.checkFilterItem(item, `${path}.filter[${i}]`, this.here()));
|
|
1040
|
+
if (node.viewAll && node.viewAll.page === this.page.id)
|
|
1041
|
+
this.report(`${path}.viewAll.page`, 'View all opens a list of the records related: this page is the record they point at');
|
|
1042
|
+
}
|
|
826
1043
|
walkTabs(node, path) {
|
|
827
1044
|
node.children.forEach((tab, i) => {
|
|
828
1045
|
const tabPath = `${path}.children[${i}]`;
|
|
@@ -959,6 +1176,23 @@ class ReferenceCheck {
|
|
|
959
1176
|
if (parts && parts !== 'json')
|
|
960
1177
|
this.report(`${path}.options.partsField`, `"${options['partsField']}" is a ${parts}; an address's parts are kept in a json field`);
|
|
961
1178
|
}
|
|
1179
|
+
/** Booking slots: on a date and time, its end written in another, asked again as the fields it depends on change. */
|
|
1180
|
+
checkSlots(node, def, path) {
|
|
1181
|
+
const options = node.options ?? {};
|
|
1182
|
+
if (def && def.type !== 'datetime')
|
|
1183
|
+
this.report(`${path}.widget`, `slots is for a datetime field; "${node.field}" is a ${def.type}`);
|
|
1184
|
+
const end = options['endField'];
|
|
1185
|
+
if (typeof end === 'string' && has(this.page.fields, end)) {
|
|
1186
|
+
const type = this.page.fields[end].type;
|
|
1187
|
+
if (end === node.field)
|
|
1188
|
+
this.report(`${path}.options.endField`, 'a booking ends in another field than the one it starts in');
|
|
1189
|
+
else if (type !== 'datetime')
|
|
1190
|
+
this.report(`${path}.options.endField`, `"${end}" is a ${type}; a booking's end is kept in a datetime field`);
|
|
1191
|
+
}
|
|
1192
|
+
const on = options['dependsOn'];
|
|
1193
|
+
if (Array.isArray(on))
|
|
1194
|
+
on.forEach((name, i) => typeof name === 'string' && this.need(name, `${path}.options.dependsOn[${i}]`));
|
|
1195
|
+
}
|
|
962
1196
|
/** A picker's own settings, on the kind of field each is for: a path on a link, Fieldia's own list on a choice, a button adding tags, a colour for each state. */
|
|
963
1197
|
checkPicker(node, def, path) {
|
|
964
1198
|
const options = node.options ?? {};
|
|
@@ -1004,6 +1238,13 @@ class ReferenceCheck {
|
|
|
1004
1238
|
node.tones?.forEach((tone, i) => this.checkModifiers(tone, `${path}.tones[${i}]`, ['when']));
|
|
1005
1239
|
node.placeholderWhen?.forEach((item, i) => this.checkModifiers(item, `${path}.placeholderWhen[${i}]`, ['when']));
|
|
1006
1240
|
this.checkModifiers(node, path, ['bold']);
|
|
1241
|
+
// What the browser fills its box in with: a box names what it holds, an address in parts only whose it is. (That
|
|
1242
|
+
// it is a purpose the standard lists is the format's check, `validatePage`, as other shapes are.)
|
|
1243
|
+
if (typeof node.autocomplete === 'string') {
|
|
1244
|
+
const problem = (0, autofill_group_1.autofillGroupProblem)(node.autocomplete, node.widget === 'address');
|
|
1245
|
+
if (problem)
|
|
1246
|
+
this.report(`${path}.autocomplete`, problem);
|
|
1247
|
+
}
|
|
1007
1248
|
if (def && node.totals) {
|
|
1008
1249
|
if (def.type !== 'one2many') {
|
|
1009
1250
|
this.report(`${path}.totals`, `totals only apply to one2many fields; "${node.field}" is a ${def.type}`);
|
|
@@ -1026,6 +1267,8 @@ class ReferenceCheck {
|
|
|
1026
1267
|
}
|
|
1027
1268
|
if (node.widget === 'address-search')
|
|
1028
1269
|
this.checkAddressSearch(node, def, path);
|
|
1270
|
+
if (node.widget === 'slots')
|
|
1271
|
+
this.checkSlots(node, def, path);
|
|
1029
1272
|
if (def)
|
|
1030
1273
|
this.checkPicker(node, def, path);
|
|
1031
1274
|
// The order lines load in: fields of its lines.
|