@antelopejs/interface-dms 0.14.7-next.992.ga290d49 → 0.14.7-next.996.g37a69a9
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/table-view/column-display.d.ts +6 -0
- package/dist/base/table-view/column-display.js.map +1 -1
- package/dist/base/table-view/internal/guards.d.ts +14 -1
- package/dist/base/table-view/internal/guards.js +26 -3
- package/dist/base/table-view/internal/guards.js.map +1 -1
- package/dist/base/types/guards.d.ts +18 -7
- package/dist/component-options/action-target.d.ts +20 -0
- package/dist/component-options/internal/action-target.d.ts +3 -1
- package/dist/component-options/internal/action-target.js +9 -1
- package/dist/component-options/internal/action-target.js.map +1 -1
- package/dist/page/internal/page-record.d.ts +2 -2
- package/dist/page/internal/page-record.js +9 -8
- package/dist/page/internal/page-record.js.map +1 -1
- package/docs/3.base/11.page-layouts.md +2 -0
- package/docs/3.base/12.table-row-actions.md +1 -1
- package/docs/3.base/2.types.md +13 -5
- package/package.json +2 -2
|
@@ -87,6 +87,12 @@ export declare namespace DefaultDisplays {
|
|
|
87
87
|
interface IdentityDisplayOptions {
|
|
88
88
|
/** Row field holding the avatar (an image value or a URL). */
|
|
89
89
|
avatarField?: string;
|
|
90
|
+
/**
|
|
91
|
+
* Frame of the avatar. `circle` (the default) crops the image round, as a
|
|
92
|
+
* person's photo; `square` draws it whole, contained in the rounded tile
|
|
93
|
+
* an icon gets, as a company's logo.
|
|
94
|
+
*/
|
|
95
|
+
avatarFrame?: "circle" | "square";
|
|
90
96
|
/** Icon drawn in a tile instead of an avatar. */
|
|
91
97
|
icon?: string;
|
|
92
98
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"column-display.js","sourceRoot":"","sources":["../../../src/base/table-view/column-display.ts"],"names":[],"mappings":";;;;;;;;;AAAA,sEAI+C;AAG/C,8DAAuD;AAEvD;;;;;;;;;;;;;;;GAeG;AACH;IAM8B,OAAO;IAFhB,eAAe,GA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UAAU,CAAC;OACf,eAAe,CAAiD;IAAhE,gBAAA,eAAe,kBAAiD,CAAA;IAE7E,oEAAoE;IAEpE,IAAa,YAAY,GAAzB,MAAa,YAAa,SAAQ,aAAoC;KAAG,CAAA;IAA5D,YAAY;QADxB,IAAA,QAAA,eAAe,EAAC,OAAO,CAAC;OACZ,YAAY,CAAgD;IAA5D,gBAAA,YAAY,eAAgD,CAAA;IAWzE;;;;OAIG;IAEH,IAAa,WAAW,GAAxB,MAAa,WAAY,SAAQ,aAAiC;KAAG,CAAA;IAAxD,WAAW;QADvB,IAAA,QAAA,eAAe,EAAC,QAAQ,CAAC;OACb,WAAW,CAA6C;IAAxD,gBAAA,WAAW,cAA6C,CAAA;IAOrE,wDAAwD;IAExD,IAAa,WAAW,GAAxB,MAAa,WAAY,SAAQ,aAAiC;KAAG,CAAA;IAAxD,WAAW;QADvB,IAAA,QAAA,eAAe,EAAC,MAAM,CAAC;OACX,WAAW,CAA6C;IAAxD,gBAAA,WAAW,cAA6C,CAAA;AACvE,CAAC,EAjUgB,eAAe,aAAf,eAAe,GAAf,eAAe,QAiU/B"}
|
|
@@ -11,6 +11,19 @@ interface GuardedActionParams {
|
|
|
11
11
|
restore: string[];
|
|
12
12
|
new: Parameters.NewParameters;
|
|
13
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* What each guarded action's route answers, as far as its after-write needs:
|
|
16
|
+
* a write reads its row back, a confirmation hands nothing on.
|
|
17
|
+
*/
|
|
18
|
+
interface GuardedActionAnswers {
|
|
19
|
+
edit: unknown;
|
|
20
|
+
delete: void;
|
|
21
|
+
archive: void;
|
|
22
|
+
restore: void;
|
|
23
|
+
new: {
|
|
24
|
+
_id: string;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
14
27
|
/** @internal */
|
|
15
28
|
export declare const guardedGetRoute: DataControllerCallback<Parameters.GetParameters, import("@antelopejs/interface-data-api/metadata").StoredRow, [RequestContext, Parameters.GetParameters]>;
|
|
16
29
|
/**
|
|
@@ -28,5 +41,5 @@ export declare const createGuardedConfirmRoute: <K extends "delete" | "archive"
|
|
|
28
41
|
*
|
|
29
42
|
* @internal
|
|
30
43
|
*/
|
|
31
|
-
export declare const createGuardedWriteRoute: <K extends "new" | "edit", O, R, Rest extends unknown[]>(baseRoute: DataControllerCallback<O, R, [RequestContext, GuardedActionParams[K], Validation.WrittenBody, ...Rest]>, actionName: K) => DataControllerCallback<O, R, [RequestContext, GuardedActionParams[K], Validation.WrittenBody, ...Rest]>;
|
|
44
|
+
export declare const createGuardedWriteRoute: <K extends "new" | "edit", O, R extends GuardedActionAnswers[K], Rest extends unknown[]>(baseRoute: DataControllerCallback<O, R, [RequestContext, GuardedActionParams[K], Validation.WrittenBody, ...Rest]>, actionName: K) => DataControllerCallback<O, R, [RequestContext, GuardedActionParams[K], Validation.WrittenBody, ...Rest]>;
|
|
32
45
|
export {};
|
|
@@ -117,6 +117,17 @@ const getIdField = (controller) => {
|
|
|
117
117
|
const meta = (0, interface_core_1.GetMetadata)(controller.constructor, meta_1.TableViewMeta);
|
|
118
118
|
return meta.options.rowIdKey || options_1.DEFAULT_ROW_ID_FIELD;
|
|
119
119
|
};
|
|
120
|
+
/**
|
|
121
|
+
* The row stored under the primary key `key`, read back for an after-write.
|
|
122
|
+
*
|
|
123
|
+
* @throws When no row is stored under `key`.
|
|
124
|
+
*/
|
|
125
|
+
const readWrittenRow = async (controller, key) => {
|
|
126
|
+
const row = await (0, data_functions_1.fetchRowForGuard)(controller, key, options_1.DEFAULT_ROW_ID_FIELD);
|
|
127
|
+
if (!row)
|
|
128
|
+
throw new Error("the written row could not be read back");
|
|
129
|
+
return row;
|
|
130
|
+
};
|
|
120
131
|
const ACTION_GUARD_CONFIGS = {
|
|
121
132
|
edit: {
|
|
122
133
|
invokeGuard: async (controller, ctx, params, body, guard) => {
|
|
@@ -124,7 +135,16 @@ const ACTION_GUARD_CONFIGS = {
|
|
|
124
135
|
const id = String(params.id);
|
|
125
136
|
const current = await (0, data_functions_1.fetchRowForGuard)(controller, id, idField);
|
|
126
137
|
(0, interface_api_util_1.assert)(current, 404, "Not Found");
|
|
127
|
-
|
|
138
|
+
const afterWrite = await guard.call(controller, ctx, {
|
|
139
|
+
id,
|
|
140
|
+
body,
|
|
141
|
+
current,
|
|
142
|
+
});
|
|
143
|
+
if (!afterWrite)
|
|
144
|
+
return undefined;
|
|
145
|
+
const { _id: key } = current;
|
|
146
|
+
(0, interface_api_util_1.assert)((0, type_check_1.isString)(key), 500, "Stored row has no primary key");
|
|
147
|
+
return async () => afterWrite(await readWrittenRow(controller, key));
|
|
128
148
|
},
|
|
129
149
|
},
|
|
130
150
|
delete: {
|
|
@@ -156,7 +176,10 @@ const ACTION_GUARD_CONFIGS = {
|
|
|
156
176
|
},
|
|
157
177
|
new: {
|
|
158
178
|
invokeGuard: async (controller, ctx, _params, body, guard) => {
|
|
159
|
-
|
|
179
|
+
const afterWrite = await guard.call(controller, ctx, { body });
|
|
180
|
+
if (!afterWrite)
|
|
181
|
+
return undefined;
|
|
182
|
+
return async (answer) => afterWrite(await readWrittenRow(controller, answer._id));
|
|
160
183
|
},
|
|
161
184
|
},
|
|
162
185
|
};
|
|
@@ -224,7 +247,7 @@ const createGuardedWriteRoute = (baseRoute, actionName) => {
|
|
|
224
247
|
const afterWrite = await config.invokeGuard(this, ctx, params, writtenBody, guard);
|
|
225
248
|
const result = await baseRoute.func.call(this, ctx, params, writtenBody, ...rest);
|
|
226
249
|
if (afterWrite)
|
|
227
|
-
await runAfterWrite(afterWrite, actionName);
|
|
250
|
+
await runAfterWrite(() => afterWrite(result), actionName);
|
|
228
251
|
return result;
|
|
229
252
|
},
|
|
230
253
|
args: baseRoute.args,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guards.js","sourceRoot":"","sources":["../../../../src/base/table-view/internal/guards.ts"],"names":[],"mappings":";;;AAAA,6DAAyE;AACzE,uEAA2E;AAC3E,+DAAyD;AACzD,uEAIwC;AACxC,0EAGmD;AACnD,gEA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face NewGuardArgs<T extends object = Record<string, unknown>> {
|
|
|
43
43
|
* notification comparing the two belongs here. It runs in the same request,
|
|
44
44
|
* on the same instance; a failure is logged and never fails the request, the
|
|
45
45
|
* write being done.
|
|
46
|
+
*
|
|
47
|
+
* `TWritten` lists what it receives. After a `new` or an `edit`, that is
|
|
48
|
+
* `[written]`: the row as stored once the write is done, loaded as the edit
|
|
49
|
+
* guard's `current` is, so a created row comes with its new id. After a
|
|
50
|
+
* `delete`, `archive` or `restore` it receives nothing: the guard already
|
|
51
|
+
* holds the ids.
|
|
46
52
|
*/
|
|
47
|
-
export type AfterWrite = () => void | Promise<void>;
|
|
53
|
+
export type AfterWrite<TWritten extends unknown[] = []> = (...written: TWritten) => void | Promise<void>;
|
|
48
54
|
/**
|
|
49
55
|
* Throws to refuse the action. A mutating guard (`edit`, `delete`, `archive`,
|
|
50
|
-
* `restore`, `new`) may return an {@link AfterWrite}
|
|
51
|
-
* ignored. It runs with the
|
|
52
|
-
* (`TController`), so a guard written as a
|
|
56
|
+
* `restore`, `new`) may return an {@link AfterWrite}, called with the
|
|
57
|
+
* arguments `TWritten` lists; what `get` returns is ignored. It runs with the
|
|
58
|
+
* data controller instance as `this` (`TController`), so a guard written as a
|
|
59
|
+
* `function` reaches its models.
|
|
53
60
|
*/
|
|
54
|
-
export type GuardFn<TArgs, TController = unknown> = (this: TController, ctx: RequestContext, args: TArgs) => void | AfterWrite | Promise<void | AfterWrite
|
|
61
|
+
export type GuardFn<TArgs, TController = unknown, TWritten extends unknown[] = []> = (this: TController, ctx: RequestContext, args: TArgs) => void | AfterWrite<TWritten> | Promise<void | AfterWrite<TWritten>>;
|
|
55
62
|
/**
|
|
56
63
|
* The guards of a table view. `T` is its data controller instance — the type
|
|
57
64
|
* `TableView()` infers from the controller — so it types both the row a
|
|
@@ -60,9 +67,13 @@ export type GuardFn<TArgs, TController = unknown> = (this: TController, ctx: Req
|
|
|
60
67
|
export interface TableViewGuards<T extends object = Record<string, unknown>> {
|
|
61
68
|
/** Runs after view authorization and loading, before response and presence acquisition. Not used by exports. */
|
|
62
69
|
get?: GuardFn<GetGuardArgs<T>, T>;
|
|
63
|
-
edit?: GuardFn<EditGuardArgs<T>, T
|
|
70
|
+
edit?: GuardFn<EditGuardArgs<T>, T, [written: T & {
|
|
71
|
+
_id: string;
|
|
72
|
+
}]>;
|
|
64
73
|
delete?: GuardFn<DeleteGuardArgs, T>;
|
|
65
74
|
archive?: GuardFn<BulkGuardArgs, T>;
|
|
66
75
|
restore?: GuardFn<BulkGuardArgs, T>;
|
|
67
|
-
new?: GuardFn<NewGuardArgs<T>, T
|
|
76
|
+
new?: GuardFn<NewGuardArgs<T>, T, [written: T & {
|
|
77
|
+
_id: string;
|
|
78
|
+
}]>;
|
|
68
79
|
}
|
|
@@ -197,6 +197,16 @@ export type ActionTarget = ({
|
|
|
197
197
|
* share link, a token).
|
|
198
198
|
*/
|
|
199
199
|
copy?: string;
|
|
200
|
+
/**
|
|
201
|
+
* Page of the dashboard opened once the request succeeded, after the
|
|
202
|
+
* success toast: a path starting with `/` (an absolute URL is refused
|
|
203
|
+
* when the target is serialized). Takes the tokens of `url`, plus
|
|
204
|
+
* `{{response.<field>}}`, a field of the JSON response (a dotted path
|
|
205
|
+
* reads a nested one). A field the response lacks leaves the user on
|
|
206
|
+
* the page, with a console warning.
|
|
207
|
+
* @example "/sales/invoices/{{response._id}}"
|
|
208
|
+
*/
|
|
209
|
+
redirect?: string;
|
|
200
210
|
successMessage: string;
|
|
201
211
|
} | {
|
|
202
212
|
type: "exportJob";
|
|
@@ -285,6 +295,16 @@ export type ActionTargetSerialized = ({
|
|
|
285
295
|
* share link, a token).
|
|
286
296
|
*/
|
|
287
297
|
copy?: string;
|
|
298
|
+
/**
|
|
299
|
+
* Page of the dashboard opened once the request succeeded, after the
|
|
300
|
+
* success toast: a path starting with `/` (an absolute URL is refused
|
|
301
|
+
* when the target is serialized). Takes the tokens of `url`, plus
|
|
302
|
+
* `{{response.<field>}}`, a field of the JSON response (a dotted path
|
|
303
|
+
* reads a nested one). A field the response lacks leaves the user on
|
|
304
|
+
* the page, with a console warning.
|
|
305
|
+
* @example "/sales/invoices/{{response._id}}"
|
|
306
|
+
*/
|
|
307
|
+
redirect?: string;
|
|
288
308
|
successMessage: string;
|
|
289
309
|
} | {
|
|
290
310
|
type: "exportJob";
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { ActionTarget, ActionTargetSerialized } from "../action-target";
|
|
2
2
|
/**
|
|
3
3
|
* An action target as the options carry it: a component target is serialized,
|
|
4
|
-
* every other kind is plain data already.
|
|
4
|
+
* every other kind is plain data already. Throws on an `api` target whose
|
|
5
|
+
* `redirect` is not a path of the dashboard (one leading `/`, so neither a
|
|
6
|
+
* scheme nor a protocol-relative `//host`).
|
|
5
7
|
*
|
|
6
8
|
* @internal
|
|
7
9
|
*/
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.serializeActionTarget = serializeActionTarget;
|
|
4
|
+
const DASHBOARD_PATH = /^\/(?![/\\])/;
|
|
4
5
|
/**
|
|
5
6
|
* An action target as the options carry it: a component target is serialized,
|
|
6
|
-
* every other kind is plain data already.
|
|
7
|
+
* every other kind is plain data already. Throws on an `api` target whose
|
|
8
|
+
* `redirect` is not a path of the dashboard (one leading `/`, so neither a
|
|
9
|
+
* scheme nor a protocol-relative `//host`).
|
|
7
10
|
*
|
|
8
11
|
* @internal
|
|
9
12
|
*/
|
|
@@ -13,6 +16,11 @@ function serializeActionTarget(target) {
|
|
|
13
16
|
target.type === "sidePanel") {
|
|
14
17
|
return { ...target, component: target.component.serializeSync() };
|
|
15
18
|
}
|
|
19
|
+
if (target.type === "api" &&
|
|
20
|
+
target.redirect !== undefined &&
|
|
21
|
+
!DASHBOARD_PATH.test(target.redirect)) {
|
|
22
|
+
throw new Error(`An "api" action target redirects to a path of the dashboard, starting with "/": "${target.redirect}" is not one`);
|
|
23
|
+
}
|
|
16
24
|
return target;
|
|
17
25
|
}
|
|
18
26
|
//# sourceMappingURL=action-target.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action-target.js","sourceRoot":"","sources":["../../../src/component-options/internal/action-target.ts"],"names":[],"mappings":";;;AAEA
|
|
1
|
+
{"version":3,"file":"action-target.js","sourceRoot":"","sources":["../../../src/component-options/internal/action-target.ts"],"names":[],"mappings":";;;AAEA,MAAM,cAAc,GAAG,cAAc,CAAC;AAEtC;;;;;;;GAOG;AACH,+BACE,MAAoB;IAEpB,IACE,MAAM,CAAC,IAAI,KAAK,QAAQ;QACxB,MAAM,CAAC,IAAI,KAAK,OAAO;QACvB,MAAM,CAAC,IAAI,KAAK,WAAW,EAC3B,CAAC;QACD,OAAO,EAAE,GAAG,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,aAAa,EAAE,EAAE,CAAC;IACpE,CAAC;IACD,IACE,MAAM,CAAC,IAAI,KAAK,KAAK;QACrB,MAAM,CAAC,QAAQ,KAAK,SAAS;QAC7B,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EACrC,CAAC;QACD,MAAM,IAAI,KAAK,CACb,oFAAoF,MAAM,CAAC,QAAQ,cAAc,CAClH,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -18,8 +18,8 @@ export declare function readPageRecord(layout: ComponentInfo | undefined, contex
|
|
|
18
18
|
/**
|
|
19
19
|
* A header button as the page's record leaves it: unchanged when the layout
|
|
20
20
|
* reads no record or the button does not act on it, left out (`undefined`)
|
|
21
|
-
* when the record was not found,
|
|
22
|
-
* otherwise.
|
|
21
|
+
* when the record was not found, the `{{record.X}}` of its target's `url`
|
|
22
|
+
* (and of an `api` target's `redirect`) filled in otherwise.
|
|
23
23
|
*
|
|
24
24
|
* @internal
|
|
25
25
|
*/
|
|
@@ -11,6 +11,7 @@ const targetUrl = (target) => {
|
|
|
11
11
|
const url = target?.url;
|
|
12
12
|
return (0, type_check_1.isString)(url) ? url : undefined;
|
|
13
13
|
};
|
|
14
|
+
const targetRedirect = (target) => target?.type === "api" ? target.redirect : undefined;
|
|
14
15
|
const isRecordNode = (value) => !!value && typeof value === "object";
|
|
15
16
|
function leafAt(record, path) {
|
|
16
17
|
const value = path
|
|
@@ -46,8 +47,7 @@ async function readPageRecord(layout, context) {
|
|
|
46
47
|
function isRecordBound(button) {
|
|
47
48
|
if (button.requiresRecord)
|
|
48
49
|
return true;
|
|
49
|
-
|
|
50
|
-
return !!url && NAMES_RECORD.test(url);
|
|
50
|
+
return [targetUrl(button.target), targetRedirect(button.target)].some((url) => !!url && NAMES_RECORD.test(url));
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
53
53
|
* A URL with its `{{record.X}}` tokens filled in, each value percent-encoded
|
|
@@ -63,8 +63,8 @@ function fillRecordTokens(url, record) {
|
|
|
63
63
|
/**
|
|
64
64
|
* A header button as the page's record leaves it: unchanged when the layout
|
|
65
65
|
* reads no record or the button does not act on it, left out (`undefined`)
|
|
66
|
-
* when the record was not found,
|
|
67
|
-
* otherwise.
|
|
66
|
+
* when the record was not found, the `{{record.X}}` of its target's `url`
|
|
67
|
+
* (and of an `api` target's `redirect`) filled in otherwise.
|
|
68
68
|
*
|
|
69
69
|
* @internal
|
|
70
70
|
*/
|
|
@@ -78,9 +78,10 @@ record) {
|
|
|
78
78
|
const { target } = button;
|
|
79
79
|
if (!target || !("url" in target) || !(0, type_check_1.isString)(target.url))
|
|
80
80
|
return button;
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
81
|
+
const filled = { ...target, url: fillRecordTokens(target.url, record) };
|
|
82
|
+
if (filled.type === "api" && filled.redirect !== undefined) {
|
|
83
|
+
filled.redirect = fillRecordTokens(filled.redirect, record);
|
|
84
|
+
}
|
|
85
|
+
return { ...button, target: filled };
|
|
85
86
|
}
|
|
86
87
|
//# sourceMappingURL=page-record.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page-record.js","sourceRoot":"","sources":["../../../src/page/internal/page-record.ts"],"names":[],"mappings":";;;;AAAA,gEAA6D;AAM7D,gEAIyC;AAEzC,MAAM,YAAY,GAAG,kCAAkC,CAAC;AACxD,MAAM,YAAY,GAAG,iBAAiB,CAAC;AACvC,MAAM,cAAc,GAAG,GAAG,CAAC;
|
|
1
|
+
{"version":3,"file":"page-record.js","sourceRoot":"","sources":["../../../src/page/internal/page-record.ts"],"names":[],"mappings":";;;;AAAA,gEAA6D;AAM7D,gEAIyC;AAEzC,MAAM,YAAY,GAAG,kCAAkC,CAAC;AACxD,MAAM,YAAY,GAAG,iBAAiB,CAAC;AACvC,MAAM,cAAc,GAAG,GAAG,CAAC;AAI3B,MAAM,SAAS,GAAG,CAChB,MAAwD,EACpC,EAAE;IACtB,MAAM,GAAG,GAAG,MAAM,EAAE,GAAG,CAAC;IACxB,OAAO,IAAA,qBAAQ,EAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC;AACzC,CAAC,CAAC;AAEF,MAAM,cAAc,GAAG,CAAC,MAAkC,EAAE,EAAE,CAC5D,MAAM,EAAE,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;AAEvD,MAAM,YAAY,GAAG,CAAC,KAAc,EAAoC,EAAE,CACxE,CAAC,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC;AAEvC,SAAS,MAAM,CACb,MAA6C,EAC7C,IAAY;IAEZ,MAAM,KAAK,GAAG,IAAI;SACf,KAAK,CAAC,cAAc,CAAC;SACrB,MAAM,CACL,CAAC,OAAO,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CA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|
```
|
|
179
179
|
|
|
180
|
+
An `api` button's `redirect` takes the `{{record.X}}` tokens too, filled in the same way, and a button whose `redirect` names one acts on the record. `{{response.<field>}}` is filled by the browser once the call answered: `redirect: "/sites/{{response._id}}?from={{record.address}}"`.
|
|
181
|
+
|
|
180
182
|
The record travels with the layout, so the header is drawn with it, on the server too, and never waits for it. Like an `availability`, it follows the page URL: the header asks for its buttons again when the route parameters or the query change, and once a write refreshed the page (`refreshPageBlocks()`, which a header button calls after a change, and a form once it saved). Its fields only shape the buttons; the route behind each one still checks the record on its own.
|
|
181
183
|
|
|
182
184
|
#### A record deleted under the page
|
|
@@ -78,7 +78,7 @@ A `new` or `edit` `ResourceForm` block over the controller submits to the same r
|
|
|
78
78
|
|
|
79
79
|
`RowActionConfig` (built-in actions) also takes `label`, `icon` and `confirm` (an `ActionConfirm`: a `ConfirmDialog`, or `{ from }`, a URL answering one for the row, on delete, archive and restore, for a single row); `BulkRowActionConfig` (delete, archive, restore) adds `successMessage`. `CustomRowAction` also takes `confirm`, `permission` (`ButtonPermission`: an action of the table by name, or an `Action`), `permissionId` (an absolute permission id, which wins over `permission`), `color`, `variant`, `showLabel`, `bulk` (`true` or `{ allMatching: true }`: offered on the selection bar, see below) and `deepLink` (a drawer, modal or side panel it opens is kept in the URL as `?record=<id>` (by default for a side panel, which `false` opts out of), or `?<tableId>.record=<id>` on a page with several table views). An action the caller fails the permission for is stripped per request like a custom button; it is only hidden, so the route its target calls must check the permission itself.
|
|
80
80
|
|
|
81
|
-
A bulk custom action sends the selected ids as a repeated `ids` query parameter, or `allMatching=true` with the table's filters, search and archive view after "Select all N matching". `resolveBulkRowIds(this, ctx, user)`, called from a route of the table's data controller, or `resolveBulkRowIds({ model, tableView }, ctx, user)` (`BulkRowSource`: the model the calling route is given, and the table's `TableViewMeta`) from any other route, a page's included, answers the ids the action covers: the selected ones, or every matching row read like the list reads them, refusing more than `MAX_BULK_MATCHING_ROWS` (413). Either way the caller needs the table's `list` permission (403 otherwise). `BULK_ALL_MATCHING_KEY` is the query flag. The `api` action target also takes `body` (the confirmation's field values merged in)
|
|
81
|
+
A bulk custom action sends the selected ids as a repeated `ids` query parameter, or `allMatching=true` with the table's filters, search and archive view after "Select all N matching". `resolveBulkRowIds(this, ctx, user)`, called from a route of the table's data controller, or `resolveBulkRowIds({ model, tableView }, ctx, user)` (`BulkRowSource`: the model the calling route is given, and the table's `TableViewMeta`) from any other route, a page's included, answers the ids the action covers: the selected ones, or every matching row read like the list reads them, refusing more than `MAX_BULK_MATCHING_ROWS` (413). Either way the caller needs the table's `list` permission (403 otherwise). `BULK_ALL_MATCHING_KEY` is the query flag. The `api` action target also takes `body` (the confirmation's field values merged in), `copy` (response field copied to the clipboard) and `redirect` (a dashboard path opened on success, taking `{{response.<field>}}` besides the tokens of `url`). `CustomButton` takes `placement` (`"toolbar"`, the default, or `"header"`: drawn in the page header, which the server adds it to); `rowActions.add` takes it too (`AddRowActionConfig`).
|
|
82
82
|
|
|
83
83
|
When several table views share a data controller, each read action of its routes is guarded by the permission ids of every mounted table view, each write action by the writing table view's (`TableViewMeta.actionPermissionIds(action)`; any one suffices). `TableViewMeta.componentBuilders` lists them, `writingComponentBuilders` the ones that write.
|
|
84
84
|
|
package/docs/3.base/2.types.md
CHANGED
|
@@ -151,7 +151,7 @@ import type { ActionTarget } from "@antelopejs/interface-dms/base/types/action-t
|
|
|
151
151
|
| `"external"` | `url: string`, `newTab?: boolean`; the same tokens as `page` |
|
|
152
152
|
| `"download"` | `url: string`, `filename?: string` (`DownloadActionTarget`); the same tokens as `page`, the file name taking them as written. Fetched with the user's session and saved under `filename`, else the server's `Content-Disposition` name, else the URL's last segment; a failure is toasted |
|
|
153
153
|
| `"quickAction"` | `id: string` (`category:id`, or the bare id) |
|
|
154
|
-
| `"api"` | `url: string`, `method?: "GET" \| "POST" \| "PUT" \| "DELETE" \| "PATCH"`, `body?`, `copy?`, `successMessage: string`; the same tokens as `page` |
|
|
154
|
+
| `"api"` | `url: string`, `method?: "GET" \| "POST" \| "PUT" \| "DELETE" \| "PATCH"`, `body?`, `copy?`, `redirect?: string`, `successMessage: string`; the same tokens as `page`. `redirect` is a dashboard path (starting with `/`, an absolute URL throws when the target is serialized) opened on success; it takes the tokens of `url` plus `{{response.<field>}}` (dotted paths allowed), and a field the response lacks leaves the user on the page |
|
|
155
155
|
| `"exportJob"` | `url: string`, `method?: "GET" \| "POST"`, `statusUrl?`, `downloadUrl?`, `labels?`; the same tokens as `page`, plus `{{job.id}}` in `statusUrl` and `downloadUrl` |
|
|
156
156
|
|
|
157
157
|
`SidePanelTargetOptions` sets the header the DMS draws above a `sidePanel` target's component: `title` (the action's label by default; `$`: an i18n key), `rowTitle`, the title while a row is open, an i18n key or a literal receiving the row's fields (`"{method} {path}"`), `positionLabel`, an i18n key receiving `{ index }` (from 1) and `{ total }` for the row's position among all the rows the table lists, its count rather than the page loaded (the DMS's "{index} of {total}" by default), and `deepLink`, which keeps the open row in the URL like the action's own `deepLink`. It is on by default for a side panel, `false` opting out (the action's own `deepLink` wins when set), and `notFound` (`SidePanelNotFoundTexts`: `title?`, `description?`), the state the panel draws with a close button when the row a link names answers 404. The panel is non-modal and docked on the right, one at a time with a module's side panels. It is meant for global, page-independent panels (an assistant dock): a detail or record panel opens in a `drawer`.
|
|
@@ -278,16 +278,24 @@ The imported `GuardFn` has this signature:
|
|
|
278
278
|
```typescript
|
|
279
279
|
import type { RequestContext } from "@antelopejs/interface-api";
|
|
280
280
|
|
|
281
|
-
type AfterWrite
|
|
281
|
+
type AfterWrite<TWritten extends unknown[] = []> = (
|
|
282
|
+
...written: TWritten
|
|
283
|
+
) => void | Promise<void>;
|
|
282
284
|
|
|
283
|
-
type GuardFn<
|
|
285
|
+
type GuardFn<
|
|
286
|
+
TArgs,
|
|
287
|
+
TController = unknown,
|
|
288
|
+
TWritten extends unknown[] = [],
|
|
289
|
+
> = (
|
|
284
290
|
this: TController,
|
|
285
291
|
ctx: RequestContext,
|
|
286
292
|
args: TArgs,
|
|
287
|
-
) => void | AfterWrite | Promise<void | AfterWrite
|
|
293
|
+
) => void | AfterWrite<TWritten> | Promise<void | AfterWrite<TWritten>>;
|
|
288
294
|
```
|
|
289
295
|
|
|
290
|
-
A mutating guard may return an `AfterWrite`: the table view runs it once the write succeeded, in the same request. It is where work comparing the row before the write (what the guard saw) with the row after belongs, such as a notification; a failure there is logged and does not fail the request, since the write is done. What a `get` guard returns is ignored.
|
|
296
|
+
A mutating guard may return an `AfterWrite`: the table view runs it once the write succeeded, in the same request. It is where work comparing the row before the write (what the guard saw) with the row after belongs, such as a notification or an audit entry; a failure there is logged and does not fail the request, since the write is done. What a `get` guard returns is ignored.
|
|
297
|
+
|
|
298
|
+
After a `new` or an `edit`, the `AfterWrite` receives `written`: the row as stored once the write is done, read back the way the edit guard's `current` is, so a created row comes with its new `_id`. `TableViewGuards<T>` types it as `T & { _id: string }`, through `AfterWrite<[written]>`; a bare `AfterWrite` takes no argument, and fits every guard. After a `delete`, `archive` or `restore` it receives nothing, since the guard already holds the ids.
|
|
291
299
|
|
|
292
300
|
`ctx` is the `RequestContext` from `@antelopejs/interface-api`. `this` is the data controller instance, typed as such in `TableViewGuards<T>` (`TController` is `T` there), so a guard written as a `function` reaches the properties declared with `@Model` without a cast.
|
|
293
301
|
|
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.996.g37a69a9",
|
|
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": "37a69a92434eb3ba671c1cbdb1a0bce5b16637ec",
|
|
136
136
|
"scripts": {
|
|
137
137
|
"build": "rimraf dist && antelopejs-tsc",
|
|
138
138
|
"typecheck": "antelopejs-tsc --noEmit",
|