@antelopejs/interface-dms 0.14.7-next.996.g37a69a9 → 0.14.7-next.998.gc2b0d73
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/base/data-types/default/relations.d.ts +35 -2
- package/dist/base/data-types/default/relations.js +12 -8
- package/dist/base/data-types/default/relations.js.map +1 -1
- package/dist/base/form-relation-options.d.ts +70 -0
- package/dist/base/form-relation-options.js +3 -0
- package/dist/base/form-relation-options.js.map +1 -0
- package/dist/base/form-schema.d.ts +6 -58
- package/dist/base/form-schema.js.map +1 -1
- package/docs/3.base/8.data-types.md +3 -0
- package/package.json +2 -2
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import type { ControllerClass } from "@antelopejs/interface-api";
|
|
3
3
|
import type { DecoratorTarget } from "@antelopejs/interface-core/decorators";
|
|
4
4
|
import { z } from "zod";
|
|
5
|
-
import type { FormContainerPageTexts } from "../../table-view/options";
|
|
5
|
+
import type { FormContainerPageTexts, TableViewTabFilter } from "../../table-view/options";
|
|
6
6
|
import { DataType } from "../core";
|
|
7
7
|
/** {@link FormComponents.RelationFilterBy}, `field` typed on the related row. */
|
|
8
8
|
export interface RelationFilterBy<T extends ControllerClass> {
|
|
@@ -65,6 +65,18 @@ export declare class RelationType<T extends ControllerClass> extends DataType {
|
|
|
65
65
|
* controller: declaring it otherwise throws at registration.
|
|
66
66
|
*/
|
|
67
67
|
filterBy?: RelationFilterBy<T>;
|
|
68
|
+
/**
|
|
69
|
+
* Lists only the related rows meeting a fixed condition, written like
|
|
70
|
+
* a tab's filter: `{ accessorKey: "isArchived", mode: "ne", value:
|
|
71
|
+
* "true" }` for the active rows of an `@ArchiveField` table. `mode` is
|
|
72
|
+
* one the related field's filter takes (`eq` or `ne` for an archive
|
|
73
|
+
* field, a compare mode such as `is` or `is_not` for a filterable
|
|
74
|
+
* column). `accessorKey` must be filterable on the related controller:
|
|
75
|
+
* declaring it otherwise throws at registration.
|
|
76
|
+
*/
|
|
77
|
+
filter?: TableViewTabFilter & {
|
|
78
|
+
accessorKey: keyof InstanceType<T> & string;
|
|
79
|
+
};
|
|
68
80
|
};
|
|
69
81
|
constructor(options: {
|
|
70
82
|
placeholder?: string;
|
|
@@ -116,6 +128,18 @@ export declare class RelationType<T extends ControllerClass> extends DataType {
|
|
|
116
128
|
* controller: declaring it otherwise throws at registration.
|
|
117
129
|
*/
|
|
118
130
|
filterBy?: RelationFilterBy<T>;
|
|
131
|
+
/**
|
|
132
|
+
* Lists only the related rows meeting a fixed condition, written like
|
|
133
|
+
* a tab's filter: `{ accessorKey: "isArchived", mode: "ne", value:
|
|
134
|
+
* "true" }` for the active rows of an `@ArchiveField` table. `mode` is
|
|
135
|
+
* one the related field's filter takes (`eq` or `ne` for an archive
|
|
136
|
+
* field, a compare mode such as `is` or `is_not` for a filterable
|
|
137
|
+
* column). `accessorKey` must be filterable on the related controller:
|
|
138
|
+
* declaring it otherwise throws at registration.
|
|
139
|
+
*/
|
|
140
|
+
filter?: TableViewTabFilter & {
|
|
141
|
+
accessorKey: keyof InstanceType<T> & string;
|
|
142
|
+
};
|
|
119
143
|
});
|
|
120
144
|
protected defaultInputComponent(): import("../../..").ComponentInfoSerialized<{
|
|
121
145
|
placeholder: string | undefined;
|
|
@@ -129,6 +153,9 @@ export declare class RelationType<T extends ControllerClass> extends DataType {
|
|
|
129
153
|
disabled?: keyof InstanceType<T> & string;
|
|
130
154
|
} | undefined;
|
|
131
155
|
filterBy: RelationFilterBy<T> | undefined;
|
|
156
|
+
filter: (TableViewTabFilter & {
|
|
157
|
+
accessorKey: keyof InstanceType<T> & string;
|
|
158
|
+
}) | undefined;
|
|
132
159
|
addForm: import("../../..").ComponentInfoSerialized<import("../..").FormPropsSerialized> | undefined;
|
|
133
160
|
addPermissionIds: string[] | undefined;
|
|
134
161
|
addFormTexts: FormContainerPageTexts | undefined;
|
|
@@ -146,6 +173,9 @@ export declare class RelationType<T extends ControllerClass> extends DataType {
|
|
|
146
173
|
disabled?: keyof InstanceType<T> & string;
|
|
147
174
|
} | undefined;
|
|
148
175
|
filterBy: RelationFilterBy<T> | undefined;
|
|
176
|
+
filter: (TableViewTabFilter & {
|
|
177
|
+
accessorKey: keyof InstanceType<T> & string;
|
|
178
|
+
}) | undefined;
|
|
149
179
|
addForm: import("../../..").ComponentInfoSerialized<import("../..").FormPropsSerialized> | undefined;
|
|
150
180
|
addPermissionIds: string[] | undefined;
|
|
151
181
|
addFormTexts: FormContainerPageTexts | undefined;
|
|
@@ -163,13 +193,16 @@ export declare class RelationType<T extends ControllerClass> extends DataType {
|
|
|
163
193
|
disabled?: keyof InstanceType<T> & string;
|
|
164
194
|
} | undefined;
|
|
165
195
|
filterBy: RelationFilterBy<T> | undefined;
|
|
196
|
+
filter: (TableViewTabFilter & {
|
|
197
|
+
accessorKey: keyof InstanceType<T> & string;
|
|
198
|
+
}) | undefined;
|
|
166
199
|
addForm: import("../../..").ComponentInfoSerialized<import("../..").FormPropsSerialized> | undefined;
|
|
167
200
|
addPermissionIds: string[] | undefined;
|
|
168
201
|
addFormTexts: FormContainerPageTexts | undefined;
|
|
169
202
|
}>;
|
|
170
203
|
private relationInput;
|
|
171
204
|
getValidation(): z.ZodType;
|
|
172
|
-
private
|
|
205
|
+
private assertFiltersFilterable;
|
|
173
206
|
decorateField(target: DecoratorTarget, key: PropertyKey, descriptor?: PropertyDescriptor): void;
|
|
174
207
|
}
|
|
175
208
|
/**
|
|
@@ -72,6 +72,7 @@ let RelationType = class RelationType extends core_1.DataType {
|
|
|
72
72
|
searchUrl: (0, relation_endpoints_1.selectUrl)(controller),
|
|
73
73
|
keyMapping: this.options.keyMapping,
|
|
74
74
|
filterBy: this.options.filterBy,
|
|
75
|
+
filter: this.options.filter,
|
|
75
76
|
addForm: addOptions?.addForm,
|
|
76
77
|
addPermissionIds: addOptions?.addPermissionIds,
|
|
77
78
|
addFormTexts: this.options.addForm,
|
|
@@ -80,17 +81,20 @@ let RelationType = class RelationType extends core_1.DataType {
|
|
|
80
81
|
getValidation() {
|
|
81
82
|
return this.options.multiple ? zod_1.z.array(zod_1.z.string()) : zod_1.z.string();
|
|
82
83
|
}
|
|
83
|
-
|
|
84
|
-
const field = this.options.filterBy?.field;
|
|
85
|
-
if (!field)
|
|
86
|
-
return;
|
|
84
|
+
assertFiltersFilterable(key) {
|
|
87
85
|
const { filters } = (0, interface_core_1.GetMetadata)(this.options.dataApiController, metadata_1.DataAPIMeta);
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
86
|
+
const fields = {
|
|
87
|
+
"filterBy.field": this.options.filterBy?.field,
|
|
88
|
+
"filter.accessorKey": this.options.filter?.accessorKey,
|
|
89
|
+
};
|
|
90
|
+
for (const [option, field] of Object.entries(fields)) {
|
|
91
|
+
if (!field || filters[field])
|
|
92
|
+
continue;
|
|
93
|
+
throw new Error(`Relation "${String(key)}": ${option} "${field}" is not filterable on ${this.options.dataApiController.name}; declare it filterable: true there.`);
|
|
94
|
+
}
|
|
91
95
|
}
|
|
92
96
|
decorateField(target, key, descriptor) {
|
|
93
|
-
this.
|
|
97
|
+
this.assertFiltersFilterable(key);
|
|
94
98
|
if (this.options.filterOnly) {
|
|
95
99
|
return;
|
|
96
100
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relations.js","sourceRoot":"","sources":["../../../../src/base/data-types/default/relations.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,+DAAyD;AAEzD,sEAA+E;AAC/E,6BAAwB;AACxB,mDAAmD;
|
|
1
|
+
{"version":3,"file":"relations.js","sourceRoot":"","sources":["../../../../src/base/data-types/default/relations.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,+DAAyD;AAEzD,sEAA+E;AAC/E,6BAAwB;AACxB,mDAAmD;AAKnD,kCAAqD;AACrD,6DAAoE;AACpE,qEAAkE;AAClE,uEAA+E;AAC/E,oDAA2D;AAQ3D,SAAS,oBAAoB,CAAC,QAAkB;IAC9C,OAAO,QAAQ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KAAK,EAClB,IAAI,CAAC,OAAO,CAAC,QAAQ,EACrB,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,EACtC,IAAI,CAAC,UAAU,EACf,IAAI,CACL,CAAC,MAAM,EAAE,GAAG,EAAE,UAAU,IAAI,EAAE,CAAC,CAAC;IACnC,CAAC;CACF,CAAA;;+BA/EY,oBAAoB;IADhC,IAAA,uBAAgB,EAAC,mBAAmB,CAAC;;GACzB,oBAAoB,CA+EhC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/** Options of the relation pickers `dms-input-relation` and `dms-input-cascader`. @packageDocumentation */
|
|
2
|
+
import type { ComponentInfoSerialized } from "../component";
|
|
3
|
+
import type { FormPropsSerialized } from "./form-types";
|
|
4
|
+
import type { FormContainerPageTexts, TableViewTabFilter } from "./table-view/options";
|
|
5
|
+
/**
|
|
6
|
+
* Narrows a relation picker to the related rows matching another field of
|
|
7
|
+
* the same form: the related table's `field` must equal the form's current
|
|
8
|
+
* value of `from` (a ticket's site among its customer's sites).
|
|
9
|
+
*/
|
|
10
|
+
export interface RelationFilterBy {
|
|
11
|
+
/**
|
|
12
|
+
* Field of the related table to match. It must be filterable there
|
|
13
|
+
* (`filterable: true` or `@Filter`): the search route honors only the
|
|
14
|
+
* filters the related controller declares.
|
|
15
|
+
*/
|
|
16
|
+
field: string;
|
|
17
|
+
/** Id of the form field whose value the related `field` must equal. */
|
|
18
|
+
from: string;
|
|
19
|
+
}
|
|
20
|
+
export interface RelationOptions {
|
|
21
|
+
placeholder?: string;
|
|
22
|
+
searchUrl: string;
|
|
23
|
+
/**
|
|
24
|
+
* Lists only the related rows matching another field of the form. The
|
|
25
|
+
* picker searches again when that field changes and clears a pick made
|
|
26
|
+
* for its previous value. While it is empty, every row is offered.
|
|
27
|
+
*/
|
|
28
|
+
filterBy?: RelationFilterBy;
|
|
29
|
+
/**
|
|
30
|
+
* Lists only the related rows meeting a fixed condition, sent like a tab's
|
|
31
|
+
* filter (`filter_<accessorKey>=<mode>:<value>`). Ignored outside a form
|
|
32
|
+
* (a filter's picker).
|
|
33
|
+
*/
|
|
34
|
+
filter?: TableViewTabFilter;
|
|
35
|
+
multiple?: boolean;
|
|
36
|
+
deselectable?: boolean;
|
|
37
|
+
keyMapping?: {
|
|
38
|
+
label?: string;
|
|
39
|
+
value?: string;
|
|
40
|
+
avatar?: string;
|
|
41
|
+
disabled?: string;
|
|
42
|
+
};
|
|
43
|
+
addForm?: ComponentInfoSerialized<FormPropsSerialized>;
|
|
44
|
+
/**
|
|
45
|
+
* The `add` permission of each TableView mounted on the related
|
|
46
|
+
* controller: the inline add form posts to their shared `new` route, which
|
|
47
|
+
* any one of them grants.
|
|
48
|
+
*/
|
|
49
|
+
addPermissionIds?: string[];
|
|
50
|
+
/**
|
|
51
|
+
* Title and description of the drawer the "add" entry opens.
|
|
52
|
+
* `$`-prefixed: i18n keys.
|
|
53
|
+
*/
|
|
54
|
+
addFormTexts?: FormContainerPageTexts;
|
|
55
|
+
}
|
|
56
|
+
export interface CascaderRelationKeyMapping {
|
|
57
|
+
label: string;
|
|
58
|
+
value: string;
|
|
59
|
+
parent: string;
|
|
60
|
+
disabled?: string;
|
|
61
|
+
}
|
|
62
|
+
export interface CascaderRelationOptions {
|
|
63
|
+
placeholder?: string;
|
|
64
|
+
searchUrl: string;
|
|
65
|
+
multiple?: boolean;
|
|
66
|
+
deselectable?: boolean;
|
|
67
|
+
keyMapping: CascaderRelationKeyMapping;
|
|
68
|
+
maxDepth?: number;
|
|
69
|
+
leafOnly?: boolean;
|
|
70
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form-relation-options.js","sourceRoot":"","sources":["../../src/base/form-relation-options.ts"],"names":[],"mappings":""}
|
|
@@ -4,10 +4,10 @@ import "../uploads";
|
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import "zod-to-json-schema";
|
|
6
6
|
import type { DefaultDataTypes } from "./data-types/default-types";
|
|
7
|
-
import type
|
|
7
|
+
import type * as RelationPickers from "./form-relation-options";
|
|
8
8
|
import type { AxeOrientation, EnumOption } from "./types";
|
|
9
9
|
import "./internal/form-block-schema";
|
|
10
|
-
import { FormBuilder, FormField, FormFieldOrGroup, FormFieldOrGroupSerialized, FormFunctions, FormProps,
|
|
10
|
+
import { FormBuilder, FormField, FormFieldOrGroup, FormFieldOrGroupSerialized, FormFunctions, FormProps, type SetFieldValueParams } from "./form-types";
|
|
11
11
|
export * from "./form-block-schema";
|
|
12
12
|
/** Options of {@link adaptFieldValidationSchema}. */
|
|
13
13
|
export interface FieldValidationOptions {
|
|
@@ -214,65 +214,13 @@ export declare namespace FormComponents {
|
|
|
214
214
|
multiple?: boolean;
|
|
215
215
|
deselectable?: boolean;
|
|
216
216
|
}
|
|
217
|
-
|
|
218
|
-
* Narrows a relation picker to the related rows matching another field of
|
|
219
|
-
* the same form: the related table's `field` must equal the form's current
|
|
220
|
-
* value of `from` (a ticket's site among its customer's sites).
|
|
221
|
-
*/
|
|
222
|
-
interface RelationFilterBy {
|
|
223
|
-
/**
|
|
224
|
-
* Field of the related table to match. It must be filterable there
|
|
225
|
-
* (`filterable: true` or `@Filter`): the search route honors only the
|
|
226
|
-
* filters the related controller declares.
|
|
227
|
-
*/
|
|
228
|
-
field: string;
|
|
229
|
-
/** Id of the form field whose value the related `field` must equal. */
|
|
230
|
-
from: string;
|
|
217
|
+
interface RelationFilterBy extends RelationPickers.RelationFilterBy {
|
|
231
218
|
}
|
|
232
|
-
interface RelationOptions {
|
|
233
|
-
placeholder?: string;
|
|
234
|
-
searchUrl: string;
|
|
235
|
-
/**
|
|
236
|
-
* Lists only the related rows matching another field of the form. The
|
|
237
|
-
* picker searches again when that field changes and clears a pick made
|
|
238
|
-
* for its previous value. While it is empty, every row is offered.
|
|
239
|
-
*/
|
|
240
|
-
filterBy?: RelationFilterBy;
|
|
241
|
-
multiple?: boolean;
|
|
242
|
-
deselectable?: boolean;
|
|
243
|
-
keyMapping?: {
|
|
244
|
-
label?: string;
|
|
245
|
-
value?: string;
|
|
246
|
-
avatar?: string;
|
|
247
|
-
disabled?: string;
|
|
248
|
-
};
|
|
249
|
-
addForm?: ComponentInfoSerialized<FormPropsSerialized>;
|
|
250
|
-
/**
|
|
251
|
-
* The `add` permission of each TableView mounted on the related
|
|
252
|
-
* controller: the inline add form posts to their shared `new` route, which
|
|
253
|
-
* any one of them grants.
|
|
254
|
-
*/
|
|
255
|
-
addPermissionIds?: string[];
|
|
256
|
-
/**
|
|
257
|
-
* Title and description of the drawer the "add" entry opens.
|
|
258
|
-
* `$`-prefixed: i18n keys.
|
|
259
|
-
*/
|
|
260
|
-
addFormTexts?: FormContainerPageTexts;
|
|
219
|
+
interface RelationOptions extends RelationPickers.RelationOptions {
|
|
261
220
|
}
|
|
262
|
-
interface CascaderRelationKeyMapping {
|
|
263
|
-
label: string;
|
|
264
|
-
value: string;
|
|
265
|
-
parent: string;
|
|
266
|
-
disabled?: string;
|
|
221
|
+
interface CascaderRelationKeyMapping extends RelationPickers.CascaderRelationKeyMapping {
|
|
267
222
|
}
|
|
268
|
-
interface CascaderRelationOptions {
|
|
269
|
-
placeholder?: string;
|
|
270
|
-
searchUrl: string;
|
|
271
|
-
multiple?: boolean;
|
|
272
|
-
deselectable?: boolean;
|
|
273
|
-
keyMapping: CascaderRelationKeyMapping;
|
|
274
|
-
maxDepth?: number;
|
|
275
|
-
leafOnly?: boolean;
|
|
223
|
+
interface CascaderRelationOptions extends RelationPickers.CascaderRelationOptions {
|
|
276
224
|
}
|
|
277
225
|
interface SliderOptions {
|
|
278
226
|
min?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-schema.js","sourceRoot":"","sources":["../../src/base/form-schema.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA,wBAAsB;AACtB,sBAAoB;AACpB,6BAAwB;AACxB,8BAA4B;AAC5B,4CAAkD;AAIlD,wCA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aAAd,cAAc,GAAd,cAAc,QAoe9B"}
|
|
@@ -324,10 +324,13 @@ declare customerId: string;
|
|
|
324
324
|
| `filterOnly` | `boolean` | Skip the join entirely: the raw scalar id stays in the list output and the funnel filter runs equality on it. A table cell, a card or a kanban card of that column then shows the id: lists draw the joined row only, they never read the ids by `?ids=`. |
|
|
325
325
|
| `addForm` | `{ displayName?: string; description?: string }` | Title and description of the drawer the picker's "add" entry opens ("New customer"). `$`-prefixed: i18n keys. Default to "New entry". |
|
|
326
326
|
| `filterBy` | `{ field, from }` | List only the target rows whose `field` equals the form's current value of the field `from`, e.g. `{ field: "customerId", from: "customerId" }` for a site among its customer's sites. `field` must be filterable on the target (`filterable: true` or `@Filter`); `decorateField` throws otherwise. |
|
|
327
|
+
| `filter` | `TableViewTabFilter` (`{ accessorKey, mode, value? }`) | List only the target rows meeting a fixed condition, written like a tab's filter, e.g. `{ accessorKey: "isArchived", mode: "ne", value: "true" }` for the active rows of an `@ArchiveField` table. `mode` is one the target field's filter takes: `eq` or `ne` for an archive field, a compare mode (`is`, `is_not`, `is_empty`, …) for a filterable column. `accessorKey` must be filterable on the target, as for `filterBy`. |
|
|
327
328
|
| `fallback` | `string` | Text used in place of an empty value. |
|
|
328
329
|
|
|
329
330
|
With `filterBy`, the picker sends the table filter syntax to the `select` endpoint (`filter_<field>=is:<value>`), which honors only the filters the target controller declares. It searches again when `from` changes and clears a pick made for its previous value; the pair a record loaded with is kept, and while `from` is empty every row is offered. It narrows what is offered only: a rule that must hold on save belongs to the module's routes.
|
|
330
331
|
|
|
332
|
+
With `filter`, the picker of a form sends `filter_<accessorKey>=<mode>:<value>` on every search, as a tab does, next to `filterBy`'s condition (both apply when they name the same field). The label read of the ids a record holds (`?ids=`) does not carry it, so a held row outside the condition keeps its label as long as the reader may see that row (an archived row stays hidden from a user without the `viewArchived` permission). A table filter's picker leaves it out and reaches every row.
|
|
333
|
+
|
|
331
334
|
When the target controller exposes a `new` endpoint and has form fields, the picker of an editable form field also carries an inline "add" form built from the target's `new` fields, plus the permission id of the target's `add` action. That form (the target's fields, its validation schema, its own relations' add forms) is the bulk of the component, so a table column's type, its filter and a read-only field leave it out: they read the related rows through the `select` route, and a filter only picks among them.
|
|
332
335
|
|
|
333
336
|
`CascaderRelationType<T>` is the same idea for a self-referencing table: the target's `select` endpoint returns a flat list, and the widget rebuilds the tree client-side. Its cell and its field name the picked row by its path, read by `?ids=` for the picked rows and then each level of their ancestors. Its `keyMapping` is required and adds `parent`, the field pointing at the parent row, which must itself carry `@Select()`, alongside the required `label` and `value`. It adds `maxDepth` and `leafOnly` to the relation options, and supports the same `filterOnly` behaviour. In a table cell it shows the path of the picked node ("Electronics / Audio"); a `multiple` one shows a badge per picked node, named by its own label with its path on hover, and folds those past three into `+N`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antelopejs/interface-dms",
|
|
3
|
-
"version": "0.14.7-next.
|
|
3
|
+
"version": "0.14.7-next.998.gc2b0d73",
|
|
4
4
|
"description": "Public AntelopeJS interfaces of the DMS: pages, components, permissions, tenancy, auth, notifications and HTML rendering.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"antelopejs",
|
|
@@ -132,7 +132,7 @@
|
|
|
132
132
|
"provenance": true,
|
|
133
133
|
"registry": "https://registry.npmjs.org/"
|
|
134
134
|
},
|
|
135
|
-
"gitHead": "
|
|
135
|
+
"gitHead": "c2b0d732c31c34545dcdb4a78b0e7d0a799c8ea0",
|
|
136
136
|
"scripts": {
|
|
137
137
|
"build": "rimraf dist && antelopejs-tsc",
|
|
138
138
|
"typecheck": "antelopejs-tsc --noEmit",
|