@sincpro/web-framework 2.1.0 → 2.2.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/dist/core/copy.d.ts +3 -1
- package/dist/core/copy.js +2 -2
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.js +2 -2
- package/dist/core/lines.d.ts +12 -4
- package/dist/core/lines.js +15 -3
- package/dist/core/related.d.ts +5 -1
- package/dist/core/related.js +13 -12
- package/dist/core/relation.d.ts +23 -1
- package/dist/core/relation.js +33 -1
- package/dist/react/useRelated.d.ts +5 -4
- package/dist/react/useRelated.js +14 -13
- package/dist/web/record/RelatedList.js +9 -6
- package/dist/web/record/edit.js +3 -2
- package/dist/web/record/record.js +1 -1
- package/package.json +7 -7
package/dist/core/copy.d.ts
CHANGED
|
@@ -48,7 +48,9 @@ export type FrameworkCopy = {
|
|
|
48
48
|
keep: string;
|
|
49
49
|
loading: string;
|
|
50
50
|
/** Under an embedded list the record holds only one page of. */
|
|
51
|
-
|
|
51
|
+
/** A relation that brought one page of its records: how many it shows, of how many — a
|
|
52
|
+
* floor when `exact` is false («at least 1000»). */
|
|
53
|
+
partial: (shown: number, total: number, exact?: boolean) => string;
|
|
52
54
|
/** The title of a record that does not exist yet, after the model's name. */
|
|
53
55
|
creating: (name: string) => string;
|
|
54
56
|
/** The list's button that opens the form of a new record. */
|
package/dist/core/copy.js
CHANGED
|
@@ -26,7 +26,7 @@ export const ENGLISH_FRAMEWORK_COPY = {
|
|
|
26
26
|
missing: (fields) => `Missing: ${fields.join(", ")}.`,
|
|
27
27
|
keep: "Keep draft",
|
|
28
28
|
loading: "Loading the record",
|
|
29
|
-
partial: (shown, total) => `Showing ${shown} of ${total}.`,
|
|
29
|
+
partial: (shown, total, exact = true) => `Showing ${shown} of ${exact ? "" : "at least "}${total}.`,
|
|
30
30
|
creating: (name) => (name ? `${name} · new` : "New"),
|
|
31
31
|
create: "New",
|
|
32
32
|
add: "Add",
|
|
@@ -96,7 +96,7 @@ export const SPANISH_FRAMEWORK_COPY = {
|
|
|
96
96
|
missing: (fields) => `Falta: ${fields.join(", ")}.`,
|
|
97
97
|
keep: "Guardar borrador",
|
|
98
98
|
loading: "Cargando el registro",
|
|
99
|
-
partial: (shown, total) => `Se muestran ${shown} de ${total}.`,
|
|
99
|
+
partial: (shown, total, exact = true) => `Se muestran ${shown} de ${exact ? "" : "al menos "}${total}.`,
|
|
100
100
|
creating: (name) => (name ? `${name} · nuevo` : "Nuevo"),
|
|
101
101
|
create: "Nuevo",
|
|
102
102
|
add: "Agregar",
|
package/dist/core/index.d.ts
CHANGED
|
@@ -13,12 +13,12 @@ export { type Advice, adviceAt, changesOf, computedLocally, creationOf, defaults
|
|
|
13
13
|
export { explain } from "./explain.js";
|
|
14
14
|
export { type FormLayout, formOf } from "./form.js";
|
|
15
15
|
export { type HistoryEntry, historyOf } from "./history.js";
|
|
16
|
-
export { addingOf, type AddingRule, blankLine, type Declared, editableLines, type LineAdding, lineFields, lineKey, linesAnswered, moved, sameLine, writtenInCell, } from "./lines.js";
|
|
16
|
+
export { addingOf, type AddingRule, blankLine, type Declared, editableLines, isReference, type LineAdding, lineFields, lineKey, linesAnswered, moved, sameLine, writtenInCell, } from "./lines.js";
|
|
17
17
|
export { defineList, type GroupLevel, isList, type ListDefinition, type ListSpec, type NamedFilter, scopeOf, } from "./list.js";
|
|
18
18
|
export { lookupOf, type LookupOption } from "./lookup.js";
|
|
19
19
|
export { detailOf, measuresOf, sumsOf } from "./measure.js";
|
|
20
20
|
export { BOOKKEEPING, defaultFields, type FieldView, sortKeyOf, textOf, viewOf, } from "./present.js";
|
|
21
21
|
export { type Related, relatedOf } from "./related.js";
|
|
22
|
-
export { entityFor, type RelationField, relationFieldOf, } from "./relation.js";
|
|
22
|
+
export { backReference, entityFor, relatedScope, type RelationField, relationFieldOf, } from "./relation.js";
|
|
23
23
|
export { type RecordSummary, summaryFieldsOf, summaryOf, } from "./summary.js";
|
|
24
24
|
export { placeOf, stepIn, type Trail } from "./trail.js";
|
package/dist/core/index.js
CHANGED
|
@@ -13,12 +13,12 @@ export { adviceAt, changesOf, computedLocally, creationOf, defaultsOf, errorAt,
|
|
|
13
13
|
export { explain } from "./explain.js";
|
|
14
14
|
export { formOf } from "./form.js";
|
|
15
15
|
export { historyOf } from "./history.js";
|
|
16
|
-
export { addingOf, blankLine, editableLines, lineFields, lineKey, linesAnswered, moved, sameLine, writtenInCell, } from "./lines.js";
|
|
16
|
+
export { addingOf, blankLine, editableLines, isReference, lineFields, lineKey, linesAnswered, moved, sameLine, writtenInCell, } from "./lines.js";
|
|
17
17
|
export { defineList, isList, scopeOf, } from "./list.js";
|
|
18
18
|
export { lookupOf } from "./lookup.js";
|
|
19
19
|
export { detailOf, measuresOf, sumsOf } from "./measure.js";
|
|
20
20
|
export { BOOKKEEPING, defaultFields, sortKeyOf, textOf, viewOf, } from "./present.js";
|
|
21
21
|
export { relatedOf } from "./related.js";
|
|
22
|
-
export { entityFor, relationFieldOf, } from "./relation.js";
|
|
22
|
+
export { backReference, entityFor, relatedScope, relationFieldOf, } from "./relation.js";
|
|
23
23
|
export { summaryFieldsOf, summaryOf, } from "./summary.js";
|
|
24
24
|
export { placeOf, stepIn } from "./trail.js";
|
package/dist/core/lines.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AnyRecord, Meta } from "@sincpro/criteria";
|
|
1
|
+
import type { AnyRecord, FieldMeta, Meta } from "@sincpro/criteria";
|
|
2
2
|
/** The key a line is drawn and found by: its identity, or a local one while it has none. */
|
|
3
3
|
export declare function lineKey(line: AnyRecord, identity: string): string;
|
|
4
4
|
/** `next` is `line` edited: it keeps the line's local key. */
|
|
@@ -6,10 +6,18 @@ export declare function sameLine<T extends AnyRecord>(line: AnyRecord, next: T):
|
|
|
6
6
|
/** What the server answered about the list it was sent, each line keeping its key by position. */
|
|
7
7
|
export declare function linesAnswered(sent: readonly AnyRecord[], answered: readonly AnyRecord[]): AnyRecord[];
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
9
|
+
* Whether a to-many holds other aggregates rather than parts of the record — sincpro_framework's
|
|
10
|
+
* `References[Invoice]`, or a foreign key declared `owned=False` (`reference: true` on its
|
|
11
|
+
* definition): listed and searched, never edited as lines, because nothing the record saves
|
|
12
|
+
* writes them.
|
|
11
13
|
*/
|
|
12
|
-
export declare function
|
|
14
|
+
export declare function isReference(field: FieldMeta | undefined): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* The lines a form can edit, or `null` when it holds only part of them — a list written back
|
|
17
|
+
* whole from one page would delete every line the page did not bring — or when they are not
|
|
18
|
+
* the record's to write (`isReference`): the record would save them and nothing would happen.
|
|
19
|
+
*/
|
|
20
|
+
export declare function editableLines(value: unknown, field?: FieldMeta): AnyRecord[] | null;
|
|
13
21
|
/** A blank line: the line model's defaults, never its identity — the server mints that. */
|
|
14
22
|
export declare function blankLine(defaults: AnyRecord, identity: string): AnyRecord;
|
|
15
23
|
/** The list with the line `key` moved before `before` (`null`: to the end). */
|
package/dist/core/lines.js
CHANGED
|
@@ -39,10 +39,22 @@ export function linesAnswered(sent, answered) {
|
|
|
39
39
|
return answered.map((line, i) => (sent[i] === undefined ? line : sameLine(sent[i], line)));
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
42
|
+
* Whether a to-many holds other aggregates rather than parts of the record — sincpro_framework's
|
|
43
|
+
* `References[Invoice]`, or a foreign key declared `owned=False` (`reference: true` on its
|
|
44
|
+
* definition): listed and searched, never edited as lines, because nothing the record saves
|
|
45
|
+
* writes them.
|
|
44
46
|
*/
|
|
45
|
-
export function
|
|
47
|
+
export function isReference(field) {
|
|
48
|
+
return field?.reference === true;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The lines a form can edit, or `null` when it holds only part of them — a list written back
|
|
52
|
+
* whole from one page would delete every line the page did not bring — or when they are not
|
|
53
|
+
* the record's to write (`isReference`): the record would save them and nothing would happen.
|
|
54
|
+
*/
|
|
55
|
+
export function editableLines(value, field) {
|
|
56
|
+
if (isReference(field))
|
|
57
|
+
return null;
|
|
46
58
|
if (Array.isArray(value))
|
|
47
59
|
return value;
|
|
48
60
|
const related = relatedOf(value);
|
package/dist/core/related.d.ts
CHANGED
|
@@ -6,7 +6,11 @@ import type { Count } from "@sincpro/criteria";
|
|
|
6
6
|
* `{items, count, cursor}` — so a tenant with a thousand members does not answer all of them;
|
|
7
7
|
* an older answer, or a domain declared by hand, sends a bare array. A screen that reads only
|
|
8
8
|
* `items` and counts them shows the first page and calls it the total (forge's console did:
|
|
9
|
-
* `count={repositories.length}`). This reads both shapes and keeps the real count
|
|
9
|
+
* `count={repositories.length}`). This reads both shapes and keeps the real count — a floor
|
|
10
|
+
* («at least 1000») when the backend stopped counting at its cap.
|
|
11
|
+
*
|
|
12
|
+
* Built on @sincpro/client-framework's `EntityCollection` (`isCollection`, `isPartial`,
|
|
13
|
+
* `totalOf`): a screen keeps this shape, with `count` always said.
|
|
10
14
|
*
|
|
11
15
|
* relatedOf({ items: [a, b], count: { value: 1000, exact: true }, cursor: "x" })
|
|
12
16
|
* -> { items: [a, b], count: { value: 1000, exact: true }, cursor: "x", partial: true }
|
package/dist/core/related.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
import { isCollection, isPartial, totalOf, } from "@sincpro/client-framework";
|
|
1
2
|
export function relatedOf(value) {
|
|
3
|
+
// The shapes, and what «partial» means, are @sincpro/client-framework's — the same rule as the
|
|
4
|
+
// backend's `is_partial` on every platform. Read without copying: a table reads this for every
|
|
5
|
+
// one2many cell of a page.
|
|
2
6
|
if (Array.isArray(value))
|
|
3
7
|
return {
|
|
4
8
|
items: value,
|
|
@@ -6,16 +10,13 @@ export function relatedOf(value) {
|
|
|
6
10
|
cursor: null,
|
|
7
11
|
partial: false,
|
|
8
12
|
};
|
|
9
|
-
if (
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
return { items: [], count: { value: 0, exact: true }, cursor: null, partial: false };
|
|
13
|
+
if (!isCollection(value))
|
|
14
|
+
return { items: [], count: { value: 0, exact: true }, cursor: null, partial: false };
|
|
15
|
+
const page = value;
|
|
16
|
+
return {
|
|
17
|
+
items: (page.items ?? []),
|
|
18
|
+
count: totalOf(page),
|
|
19
|
+
cursor: page.cursor ?? null,
|
|
20
|
+
partial: isPartial(page),
|
|
21
|
+
};
|
|
21
22
|
}
|
package/dist/core/relation.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Entity } from "@sincpro/client-framework";
|
|
2
|
-
import type { FieldMeta, Meta } from "@sincpro/criteria";
|
|
2
|
+
import type { AnyRecord, Criteria, FieldMeta, Meta } from "@sincpro/criteria";
|
|
3
3
|
/**
|
|
4
4
|
* Which record a field of a form is about, read from the model — so a form draws a many2one
|
|
5
5
|
* as a picker of the right entity without being told.
|
|
@@ -36,3 +36,25 @@ export declare function relationFieldOf(meta: Meta | null | undefined, name: str
|
|
|
36
36
|
* named by its own name (`sincpro-forge-auth.Tenant`) where the application keys it by alias.
|
|
37
37
|
*/
|
|
38
38
|
export declare function entityFor(entities: readonly Entity[], target: string, metaOf?: (key: string) => Meta | undefined): Entity | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* The field of the related records that points back at a record, and the value it holds for this
|
|
41
|
+
* one — what a list of them hides as a column and fills on a new one. `null` when the relation
|
|
42
|
+
* does not say. It reads the keys as @sincpro/client-framework's `relatedCriteria` asks by them.
|
|
43
|
+
*/
|
|
44
|
+
export declare function backReference(record: AnyRecord | null, field: FieldMeta | undefined, identity: string): {
|
|
45
|
+
field: string;
|
|
46
|
+
value: unknown;
|
|
47
|
+
} | null;
|
|
48
|
+
/** Whether a value can point a relation at a record: an empty key points at the orphans. */
|
|
49
|
+
export declare function isKeyValue(value: unknown): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* The criteria a relation of ONE record is listed with, over the related entity — or `null` while
|
|
52
|
+
* there is no key to ask by: the record or its definition has not arrived, or the record holds no
|
|
53
|
+
* value in that key yet (a new one, a business key not written). Never a question that would
|
|
54
|
+
* match every orphan.
|
|
55
|
+
*
|
|
56
|
+
* relatedScope(customer, meta.fields.invoices, "id", criteria)
|
|
57
|
+
* -> criteria AND customer_id = customer.id (identified_by)
|
|
58
|
+
* -> criteria AND customer_code = customer.code (parent_field / related_field)
|
|
59
|
+
*/
|
|
60
|
+
export declare function relatedScope<T extends AnyRecord>(record: AnyRecord | null, field: FieldMeta | undefined, identity: string, criteria?: Criteria<T>): Criteria<T> | null;
|
package/dist/core/relation.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { entityKeyOf, kindOf } from "@sincpro/client-framework";
|
|
1
|
+
import { entityKeyOf, kindOf, relatedCriteria } from "@sincpro/client-framework";
|
|
2
2
|
export function relationFieldOf(meta, name) {
|
|
3
3
|
if (!meta)
|
|
4
4
|
return undefined;
|
|
@@ -56,3 +56,35 @@ export function entityFor(entities, target, metaOf = () => undefined) {
|
|
|
56
56
|
entities.find((one) => namedBy(one, target)) ??
|
|
57
57
|
(ofKind.length === 1 ? ofKind[0] : undefined));
|
|
58
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* The field of the related records that points back at a record, and the value it holds for this
|
|
61
|
+
* one — what a list of them hides as a column and fills on a new one. `null` when the relation
|
|
62
|
+
* does not say. It reads the keys as @sincpro/client-framework's `relatedCriteria` asks by them.
|
|
63
|
+
*/
|
|
64
|
+
export function backReference(record, field, identity) {
|
|
65
|
+
const there = field?.related_field ?? field?.identified_by;
|
|
66
|
+
if (record === null || !there)
|
|
67
|
+
return null;
|
|
68
|
+
const here = field?.related_field ? (field.parent_field ?? identity) : identity;
|
|
69
|
+
return { field: there, value: record[here] };
|
|
70
|
+
}
|
|
71
|
+
/** Whether a value can point a relation at a record: an empty key points at the orphans. */
|
|
72
|
+
export function isKeyValue(value) {
|
|
73
|
+
return value !== null && value !== undefined && value !== "";
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The criteria a relation of ONE record is listed with, over the related entity — or `null` while
|
|
77
|
+
* there is no key to ask by: the record or its definition has not arrived, or the record holds no
|
|
78
|
+
* value in that key yet (a new one, a business key not written). Never a question that would
|
|
79
|
+
* match every orphan.
|
|
80
|
+
*
|
|
81
|
+
* relatedScope(customer, meta.fields.invoices, "id", criteria)
|
|
82
|
+
* -> criteria AND customer_id = customer.id (identified_by)
|
|
83
|
+
* -> criteria AND customer_code = customer.code (parent_field / related_field)
|
|
84
|
+
*/
|
|
85
|
+
export function relatedScope(record, field, identity, criteria) {
|
|
86
|
+
const back = backReference(record, field, identity);
|
|
87
|
+
if (record === null || field === undefined || back === null || !isKeyValue(back.value))
|
|
88
|
+
return null;
|
|
89
|
+
return relatedCriteria(field, record, identity, criteria);
|
|
90
|
+
}
|
|
@@ -8,10 +8,11 @@ import type { RecordReading } from "./useRecord.js";
|
|
|
8
8
|
* Context: sincpro_framework sends a one2many inside its record as ONE page (`RecordLines` draws
|
|
9
9
|
* it). A customer with forty thousand invoices, a tenant with a thousand members, the lines of a
|
|
10
10
|
* big order need more than that page: search in them, order them, walk them. The model says how
|
|
11
|
-
* to ask — the related aggregate's key that points back (`identified_by`)
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
11
|
+
* to ask — the related aggregate's key that points back (`identified_by`), or the two fields of a
|
|
12
|
+
* relation by a business key (`parent_field`, `related_field`) — so the relation is a criteria
|
|
13
|
+
* over the related entity (@sincpro/client-framework's `relatedCriteria`), answered by the server
|
|
14
|
+
* like any list. The relation's scope is AND-ed with everything else, so no search, filter or
|
|
15
|
+
* page can ever leave it.
|
|
15
16
|
*
|
|
16
17
|
* const facturas = useRelated(cliente, "invoices", invoicesEntity);
|
|
17
18
|
* <EntityList listing={facturas} embedded />
|
package/dist/react/useRelated.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {} from "@sincpro/client-framework";
|
|
3
|
+
import { relatedScope } from "../core/relation.js";
|
|
3
4
|
import { useListing } from "./useListing.js";
|
|
4
5
|
/**
|
|
5
6
|
* The records a relation of ONE record points to, as a live listing of the related entity.
|
|
@@ -7,27 +8,27 @@ import { useListing } from "./useListing.js";
|
|
|
7
8
|
* Context: sincpro_framework sends a one2many inside its record as ONE page (`RecordLines` draws
|
|
8
9
|
* it). A customer with forty thousand invoices, a tenant with a thousand members, the lines of a
|
|
9
10
|
* big order need more than that page: search in them, order them, walk them. The model says how
|
|
10
|
-
* to ask — the related aggregate's key that points back (`identified_by`)
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* to ask — the related aggregate's key that points back (`identified_by`), or the two fields of a
|
|
12
|
+
* relation by a business key (`parent_field`, `related_field`) — so the relation is a criteria
|
|
13
|
+
* over the related entity (@sincpro/client-framework's `relatedCriteria`), answered by the server
|
|
14
|
+
* like any list. The relation's scope is AND-ed with everything else, so no search, filter or
|
|
15
|
+
* page can ever leave it.
|
|
14
16
|
*
|
|
15
17
|
* const facturas = useRelated(cliente, "invoices", invoicesEntity);
|
|
16
18
|
* <EntityList listing={facturas} embedded />
|
|
17
19
|
*/
|
|
18
20
|
export function useRelated(record, name, related, options = {}) {
|
|
19
21
|
const field = record.meta?.fields[name];
|
|
20
|
-
const key = field?.identified_by ?? "";
|
|
21
22
|
const own = record.meta?.get_id || record.meta?.identity || "id";
|
|
22
|
-
const
|
|
23
|
-
|
|
23
|
+
const asked = relatedScope(record.record, field, own, options.criteria);
|
|
24
|
+
// No key to ask by yet — the record or its definition has not arrived, or the record is new: a
|
|
25
|
+
// question that matches nothing (an empty `in`), never one that would list every orphan. It is
|
|
26
|
+
// asked over the field that points back when the definition names it: the related entity has
|
|
27
|
+
// that one, and it may have no `id`.
|
|
28
|
+
const nothing = field?.related_field || field?.identified_by || "id";
|
|
29
|
+
const scope = asked ?? {
|
|
24
30
|
...options.criteria,
|
|
25
|
-
selection: {
|
|
26
|
-
all: [
|
|
27
|
-
...(options.criteria?.selection ? [options.criteria.selection] : []),
|
|
28
|
-
{ field: key, operator: "=", value: value },
|
|
29
|
-
],
|
|
30
|
-
},
|
|
31
|
+
selection: { field: nothing, operator: "in", value: [] },
|
|
31
32
|
};
|
|
32
33
|
return useListing(related, { pageSize: 10, ...options, criteria: scope });
|
|
33
34
|
}
|
|
@@ -3,6 +3,7 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
3
3
|
import {} from "@sincpro/client-framework";
|
|
4
4
|
import { frameworkCopy } from "../../core/copy.js";
|
|
5
5
|
import { defaultFields } from "../../core/present.js";
|
|
6
|
+
import { backReference, isKeyValue } from "../../core/relation.js";
|
|
6
7
|
import { useRelated } from "../../react/useRelated.js";
|
|
7
8
|
import { EntityList } from "../list/EntityList.js";
|
|
8
9
|
import { useRecordOpening } from "./opening.js";
|
|
@@ -26,22 +27,24 @@ import { useMemo } from "react";
|
|
|
26
27
|
export function RelatedList({ record, name, entity, pageSize, ...list }) {
|
|
27
28
|
const listing = useRelated(record, name, entity, pageSize === undefined ? {} : { pageSize });
|
|
28
29
|
const opening = useRecordOpening();
|
|
29
|
-
// Every row points back to THIS record: the column that says so is the same on all of them
|
|
30
|
-
|
|
30
|
+
// Every row points back to THIS record: the column that says so is the same on all of them —
|
|
31
|
+
// the same key `useRelated` scopes the list by, by identity or by a business key.
|
|
32
|
+
const identity = record.meta?.get_id || record.meta?.identity || "id";
|
|
33
|
+
const pointing = backReference(record.record, record.meta?.fields[name], identity);
|
|
34
|
+
const back = pointing?.field;
|
|
31
35
|
const own = list.columns;
|
|
32
36
|
const columns = useMemo(() => own ??
|
|
33
37
|
(listing.meta === null || !back
|
|
34
38
|
? undefined
|
|
35
39
|
: defaultFields(listing.meta).filter((field) => field !== back)), [own, listing.meta, back]);
|
|
36
40
|
const create = opening?.create;
|
|
37
|
-
// The value the rows point back with
|
|
38
|
-
const
|
|
39
|
-
const here = record.record === null ? undefined : record.record[identity];
|
|
41
|
+
// The value the rows point back with.
|
|
42
|
+
const here = pointing?.value;
|
|
40
43
|
const adding = create === undefined ||
|
|
41
44
|
entity.create === undefined ||
|
|
42
45
|
!back ||
|
|
43
46
|
record.isNew ||
|
|
44
|
-
here
|
|
47
|
+
!isKeyValue(here) ||
|
|
45
48
|
record.edit.state(name).readonly ? null : (_jsx(Button, { size: "sm", role: "secondary", onClick: () => create(entity, { [back]: here }, listing.reload), children: frameworkCopy().record.add }));
|
|
46
49
|
return (_jsx(EntityList, { listing: listing, embedded: true, ...list, ...(columns === undefined ? {} : { columns }), ...(adding === null && list.actions === undefined
|
|
47
50
|
? {}
|
package/dist/web/record/edit.js
CHANGED
|
@@ -75,8 +75,9 @@ export function RecordField({ record, name, as, bare = false, lines: look, list:
|
|
|
75
75
|
return bare ? lines : _jsx(FormSection, { title: view.label, children: lines });
|
|
76
76
|
}
|
|
77
77
|
if (as === undefined && relation?.field.type === "one2many" && target === undefined) {
|
|
78
|
-
// Editable when the record holds ALL its lines; a page of them stays read only
|
|
79
|
-
|
|
78
|
+
// Editable when the record holds ALL its lines; a page of them stays read only, and so do
|
|
79
|
+
// the records it only references — nothing it saves writes them.
|
|
80
|
+
const whole = editableLines(edit.values[name], relation.field);
|
|
80
81
|
const lines = whole === null ? (_jsx(RecordLines, { record: record.record ?? {}, meta: meta, name: name, locale: locale })) : (_jsx(RecordLinesEditor, { record: record, name: name, lines: whole, ...(look === undefined ? {} : { look }) }));
|
|
81
82
|
return bare ? lines : _jsx(FormSection, { title: view.label, children: lines });
|
|
82
83
|
}
|
|
@@ -60,5 +60,5 @@ export function RecordLines({ record, meta, name, columns, cells, locale, onOpen
|
|
|
60
60
|
const definition = meta?.fields[name]?.definition ?? describeRows(related.items);
|
|
61
61
|
const identity = definition.identity || "id";
|
|
62
62
|
const copy = frameworkCopy();
|
|
63
|
-
return (_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(List, { embedded: true, items: related.items, keyOf: (row) => String(row[identity]), present: "table", empty: { sentence: copy.list.empty }, ...(onOpen === undefined ? {} : { onOpen }), children: _jsx(List.Table, { columns: columnsOf(definition, columns, { locale, ...(cells ? { cells } : {}) }), ...(rowActions === undefined ? {} : { rowActions }) }) }), related.partial ? (_jsx("p", { className: "text-meta text-muted", children: copy.record.partial(related.items.length, related.count.value) })) : null] }));
|
|
63
|
+
return (_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(List, { embedded: true, items: related.items, keyOf: (row) => String(row[identity]), present: "table", empty: { sentence: copy.list.empty }, ...(onOpen === undefined ? {} : { onOpen }), children: _jsx(List.Table, { columns: columnsOf(definition, columns, { locale, ...(cells ? { cells } : {}) }), ...(rowActions === undefined ? {} : { rowActions }) }) }), related.partial ? (_jsx("p", { className: "text-meta text-muted", children: copy.record.partial(related.items.length, related.count.value, related.count.exact) })) : null] }));
|
|
64
64
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sincpro/web-framework",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "The web client of sincpro_framework: entities, lists and records bound to the metadata the server publishes, drawn with @sincpro/web-ui and arranged with @sincpro/web-composer.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -40,9 +40,9 @@
|
|
|
40
40
|
"@opentelemetry/resources": "^3.1.0",
|
|
41
41
|
"@opentelemetry/sdk-trace": "^3.1.0",
|
|
42
42
|
"@sentry/browser": "^11.11.0",
|
|
43
|
-
"@sincpro/client-framework": "^0.
|
|
44
|
-
"@sincpro/criteria": "^2.
|
|
45
|
-
"@sincpro/criteria-react": "^2.
|
|
43
|
+
"@sincpro/client-framework": "^0.6.0",
|
|
44
|
+
"@sincpro/criteria": "^2.1.0",
|
|
45
|
+
"@sincpro/criteria-react": "^2.1.0",
|
|
46
46
|
"@sincpro/web-composer": "^1.6.0",
|
|
47
47
|
"@sincpro/web-ui": "^2.1.0",
|
|
48
48
|
"react": ">=19",
|
|
@@ -72,9 +72,9 @@
|
|
|
72
72
|
"@opentelemetry/resources": "3.1.0",
|
|
73
73
|
"@opentelemetry/sdk-trace": "3.1.0",
|
|
74
74
|
"@sentry/browser": "11.11.0",
|
|
75
|
-
"@sincpro/client-framework": "^0.
|
|
76
|
-
"@sincpro/criteria": "^2.
|
|
77
|
-
"@sincpro/criteria-react": "^2.
|
|
75
|
+
"@sincpro/client-framework": "^0.6.0",
|
|
76
|
+
"@sincpro/criteria": "^2.1.0",
|
|
77
|
+
"@sincpro/criteria-react": "^2.1.0",
|
|
78
78
|
"@sincpro/web-composer": "^1.6.0",
|
|
79
79
|
"@sincpro/web-ui": "^2.1.0",
|
|
80
80
|
"@storybook/addon-a11y": "10.6.5",
|