@phis/ui 0.7.4 → 0.7.7
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/components/controls/phi-form-control.d.ts +3 -1
- package/components/controls/phi-form-control.js +5 -4
- package/components/controls/phi-options-provider.d.ts +14 -1
- package/components/controls/phi-options-provider.js +73 -2
- package/components/forms/auth-admin-settings-labels.d.ts +1 -1
- package/components/forms/auth-admin-settings-labels.js +2 -2
- package/components/forms/form-descriptor-contract.d.ts +1 -1
- package/components/forms/form-descriptor-contract.js +1 -1
- package/components/forms/form-descriptor-runtime-client.d.ts +4 -1
- package/components/forms/form-descriptor-runtime-client.js +33 -11
- package/components/forms/form-media-limits.d.ts +12 -0
- package/components/forms/form-media-limits.js +14 -0
- package/components/forms/form-provider-registry.d.ts +8 -0
- package/components/forms/form-record-title.d.ts +14 -0
- package/components/forms/form-record-title.js +38 -0
- package/components/forms/form-widget-config.d.ts +3 -0
- package/components/forms/form-widget-config.js +2 -0
- package/components/forms/phi-form-widget.d.ts +1 -1
- package/components/forms/phi-form-widget.js +4 -0
- package/components/overlays/phi-overlay-container-client.js +8 -8
- package/components/overlays/phi-overlay-title.d.ts +7 -0
- package/components/overlays/phi-overlay-title.js +21 -0
- package/components/tables/client/phi-table-binding.d.ts +3 -1
- package/components/tables/client/phi-table-binding.js +90 -49
- package/components/tables/client/phi-table-filter-options.d.ts +27 -0
- package/components/tables/client/phi-table-filter-options.js +35 -0
- package/components/widgets/accessible-areas.d.ts +1 -1
- package/components/widgets/accessible-areas.js +1 -1
- package/components/widgets/client/shared/phi-choice-controller.js +22 -15
- package/components/widgets/client/shared/phi-rendered-value.d.ts +10 -0
- package/components/widgets/client/shared/phi-rendered-value.js +49 -1
- package/components/widgets/client/shared/phi-table-provider.d.ts +10 -1
- package/components/widgets/client/shared/phi-table-provider.js +22 -0
- package/components/widgets/label-sets/admin-users.d.ts +15 -0
- package/components/widgets/label-sets/admin-users.js +31 -0
- package/constants/core-data-provider-keys.d.ts +7 -0
- package/constants/core-data-provider-keys.js +7 -0
- package/constants/phi-base-role-metadata.d.ts +2 -2
- package/constants/phi-base-role-metadata.js +1 -1
- package/constants/runtime-module-ownership.js +3 -0
- package/forms.d.ts +1 -1
- package/forms.js +1 -1
- package/gateway/capability-media-limits.d.ts +10 -0
- package/gateway/capability-media-limits.js +40 -0
- package/gateway/server-capabilities.js +4 -0
- package/helpers/preset-tree-contract-check.d.ts +3 -2
- package/helpers/preset-tree-contract-check.js +60 -0
- package/helpers/record-title.d.ts +7 -0
- package/helpers/record-title.js +25 -0
- package/helpers/record-widget.d.ts +15 -0
- package/helpers/record-widget.js +57 -0
- package/package.json +2 -2
- package/plugins/runtime-modules/accounting/client-data-providers.d.ts +7 -0
- package/plugins/runtime-modules/accounting/client-data-providers.js +9 -0
- package/plugins/runtime-modules/accounting/data-providers.d.ts +63 -0
- package/plugins/runtime-modules/accounting/data-providers.js +127 -0
- package/plugins/runtime-modules/accounting/definition.d.ts +54 -2
- package/plugins/runtime-modules/accounting/definition.js +5 -3
- package/plugins/runtime-modules/accounting/ids.d.ts +20 -0
- package/plugins/runtime-modules/accounting/ids.js +27 -0
- package/plugins/runtime-modules/accounting/module.d.ts +52 -0
- package/plugins/runtime-modules/accounting/presets.js +23 -4
- package/plugins/runtime-modules/accounting/services/products-table.d.ts +93 -0
- package/plugins/runtime-modules/accounting/services/products-table.js +158 -0
- package/plugins/runtime-modules/accounting/trees/accounting-products-label-set.d.ts +86 -0
- package/plugins/runtime-modules/accounting/trees/accounting-products-label-set.js +123 -0
- package/plugins/runtime-modules/accounting/trees/phi-default-accounting-products-page-tree.d.ts +21 -0
- package/plugins/runtime-modules/accounting/trees/phi-default-accounting-products-page-tree.js +435 -0
- package/plugins/runtime-modules/area-definitions.js +2 -2
- package/plugins/runtime-modules/asset/media-asset-field.d.ts +15 -0
- package/plugins/runtime-modules/asset/media-asset-field.js +21 -0
- package/plugins/runtime-modules/asset/media-asset-form-control.d.ts +4 -0
- package/plugins/runtime-modules/asset/media-asset-form-control.js +10 -5
- package/plugins/runtime-modules/asset/media-assets-field.d.ts +8 -0
- package/plugins/runtime-modules/asset/media-assets-field.js +10 -0
- package/plugins/runtime-modules/asset/media-assets-form-control.d.ts +5 -0
- package/plugins/runtime-modules/asset/media-assets-form-control.js +15 -6
- package/plugins/runtime-modules/auth/admin-settings-forms.js +1 -1
- package/plugins/runtime-modules/builder/clients/inspector-config-field.js +11 -6
- package/plugins/runtime-modules/client-manifests/accounting.js +5 -1
- package/plugins/runtime-modules/core/cards.js +2 -2
- package/plugins/runtime-modules/core/client-data-providers.js +5 -0
- package/plugins/runtime-modules/core/data-providers.js +14 -0
- package/plugins/runtime-modules/core/services/site-members-options.d.ts +27 -0
- package/plugins/runtime-modules/core/services/site-members-options.js +55 -0
- package/plugins/runtime-modules/core/widgets/cascader/client.js +13 -12
- package/plugins/runtime-modules/core/widgets/checkbox-group/client.js +5 -4
- package/plugins/runtime-modules/core/widgets/form/config.d.ts +5 -0
- package/plugins/runtime-modules/core/widgets/form/config.js +3 -0
- package/plugins/runtime-modules/core/widgets/multi-select/client.js +6 -4
- package/plugins/runtime-modules/core/widgets/record/actions.d.ts +20 -0
- package/plugins/runtime-modules/core/widgets/record/actions.js +77 -0
- package/plugins/runtime-modules/core/widgets/record/client.js +71 -8
- package/plugins/runtime-modules/core/widgets/record/config.d.ts +66 -1
- package/plugins/runtime-modules/core/widgets/record/config.js +71 -2
- package/plugins/runtime-modules/core/widgets/table/client.js +33 -29
- package/plugins/runtime-modules/core/widgets/table/config.js +5 -1
- package/plugins/runtime-modules/groups/data-providers.js +1 -1
- package/plugins/runtime-modules/groups/definition.js +1 -1
- package/plugins/runtime-modules/groups/page-visibility.d.ts +1 -1
- package/plugins/runtime-modules/groups/page-visibility.js +1 -1
- package/plugins/runtime-modules/groups/presets.js +1 -1
- package/plugins/runtime-modules/groups/services/options.js +1 -1
- package/plugins/runtime-modules/groups/services/table.js +1 -1
- package/plugins/runtime-modules/groups/trees/phi-default-app-groups-page-tree.js +2 -2
- package/plugins/runtime-modules/user-management/addon-roles.d.ts +60 -4
- package/plugins/runtime-modules/user-management/addon-roles.js +92 -8
- package/plugins/runtime-modules/user-management/addresses.d.ts +1 -1
- package/plugins/runtime-modules/user-management/controller/client.js +1 -1
- package/plugins/runtime-modules/user-management/data-providers.js +1 -0
- package/plugins/runtime-modules/user-management/forms.js +22 -0
- package/plugins/runtime-modules/user-management/presets.js +2 -2
- package/plugins/runtime-modules/user-management/services/options.d.ts +4 -0
- package/plugins/runtime-modules/user-management/services/options.js +14 -6
- package/plugins/runtime-modules/user-management/services/table.js +12 -3
- package/plugins/runtime-modules/user-management/trees/phi-default-admin-users-page-tree.js +9 -4
- package/types/access.d.ts +1 -1
- package/types/access.js +7 -7
- package/types/core-widget-placements.d.ts +7 -0
- package/types/form-descriptor.d.ts +1 -1
- package/types/record-widget.d.ts +35 -0
- package/types/server-capabilities.d.ts +1 -1
- package/types/table-widget.d.ts +20 -0
- package/types/table-widget.js +44 -0
package/types/access.js
CHANGED
|
@@ -21,35 +21,35 @@ export const PHI_VIEWER_ACCESS_SITE_ADMIN = {
|
|
|
21
21
|
providerId: PHI_CORE_ROLE_PROVIDER_ID,
|
|
22
22
|
allowedRoleFlags: PhiBaseRole.Admin,
|
|
23
23
|
};
|
|
24
|
-
export const
|
|
24
|
+
export const PHI_VIEWER_ACCESS_SITE_MAINTENANCE = {
|
|
25
25
|
access: "roles",
|
|
26
26
|
providerId: PHI_CORE_ROLE_PROVIDER_ID,
|
|
27
|
-
allowedRoleFlags: PhiBaseRole.
|
|
27
|
+
allowedRoleFlags: PhiBaseRole.Maintainer,
|
|
28
28
|
};
|
|
29
29
|
export const PHI_VIEWER_ACCESS_STRUCTURE_AUTHORING = {
|
|
30
30
|
access: "roles",
|
|
31
31
|
providerId: PHI_CORE_ROLE_PROVIDER_ID,
|
|
32
|
-
allowedRoleFlags: PhiBaseRole.
|
|
32
|
+
allowedRoleFlags: PhiBaseRole.Maintainer | PhiBaseRole.Builder,
|
|
33
33
|
};
|
|
34
34
|
export const PHI_VIEWER_ACCESS_CONTENT_EDITING = {
|
|
35
35
|
access: "roles",
|
|
36
36
|
providerId: PHI_CORE_ROLE_PROVIDER_ID,
|
|
37
|
-
allowedRoleFlags: PhiBaseRole.
|
|
37
|
+
allowedRoleFlags: PhiBaseRole.Maintainer | PhiBaseRole.Author | PhiBaseRole.Publisher,
|
|
38
38
|
};
|
|
39
39
|
export const PHI_VIEWER_ACCESS_PUBLISHING = {
|
|
40
40
|
access: "roles",
|
|
41
41
|
providerId: PHI_CORE_ROLE_PROVIDER_ID,
|
|
42
|
-
allowedRoleFlags: PhiBaseRole.
|
|
42
|
+
allowedRoleFlags: PhiBaseRole.Maintainer | PhiBaseRole.Publisher,
|
|
43
43
|
};
|
|
44
44
|
export const PHI_VIEWER_ACCESS_SUPPORT = {
|
|
45
45
|
access: "roles",
|
|
46
46
|
providerId: PHI_CORE_ROLE_PROVIDER_ID,
|
|
47
|
-
allowedRoleFlags: PhiBaseRole.
|
|
47
|
+
allowedRoleFlags: PhiBaseRole.Maintainer | PhiBaseRole.Supporter,
|
|
48
48
|
};
|
|
49
49
|
export const PHI_VIEWER_ACCESS_ACCOUNTING = {
|
|
50
50
|
access: "roles",
|
|
51
51
|
providerId: PHI_CORE_ROLE_PROVIDER_ID,
|
|
52
|
-
allowedRoleFlags: PhiBaseRole.
|
|
52
|
+
allowedRoleFlags: PhiBaseRole.Maintainer | PhiBaseRole.Accountant,
|
|
53
53
|
};
|
|
54
54
|
function asSubject(viewer) {
|
|
55
55
|
return {
|
|
@@ -12,6 +12,7 @@ import type { PhiMediaKindValue } from "./media";
|
|
|
12
12
|
import type { PhiCollectionProviderQuery } from "./collection-provider";
|
|
13
13
|
import type { PhiProviderResourceSource } from "./runtime-data-provider";
|
|
14
14
|
import type { PhiFormId } from "./form-id";
|
|
15
|
+
import type { PhiFormWidgetTitleFromRecord } from "../components/forms/form-record-title";
|
|
15
16
|
import type { PhiLinkTarget } from "./references";
|
|
16
17
|
import type { PhiMediaImageSourceConfig } from "./media";
|
|
17
18
|
import type { PhiViewerAccessPolicy } from "./access";
|
|
@@ -175,6 +176,10 @@ export type PhiRecordWidgetPlacement = PhiWidgetPlacementBase & {
|
|
|
175
176
|
source?: PhiRecordWidgetConfig["source"];
|
|
176
177
|
openActionKey?: PhiRecordWidgetConfig["openActionKey"];
|
|
177
178
|
presentation?: Partial<PhiRecordWidgetPresentation>;
|
|
179
|
+
/** Provider row actions of the source, run on the record shown by their key on `action/activate`. */
|
|
180
|
+
actions?: PhiRecordWidgetConfig["actions"];
|
|
181
|
+
/** A title from the record shown, announced on `recordTitle`, for the Overlay's `title` (TABLES.md). */
|
|
182
|
+
titleFromRecord?: PhiRecordWidgetConfig["titleFromRecord"];
|
|
178
183
|
};
|
|
179
184
|
/**
|
|
180
185
|
* Where a file goes: the Add-on, its table and the slot. What the slot takes is the Add-on's schema
|
|
@@ -292,6 +297,8 @@ export type PhiFormWidgetPlacement = PhiWidgetPlacementBase & {
|
|
|
292
297
|
source?: PhiProviderResourceSource | null;
|
|
293
298
|
/** Absent is a single-record form; the Form Widget's config says why that is an answer. */
|
|
294
299
|
openActionKey?: string;
|
|
300
|
+
/** A title from the record `source` reads, announced on `recordTitle`, for the Overlay's `title` (FORMS.md). */
|
|
301
|
+
titleFromRecord?: PhiFormWidgetTitleFromRecord | null;
|
|
295
302
|
};
|
|
296
303
|
export type PhiCmsCollectionViewMode = "grid" | "masonry" | "stack";
|
|
297
304
|
export type PhiCmsCollectionFilterControl = "select" | "multi-select" | "cascader";
|
|
@@ -2,7 +2,7 @@ import type { PhiCmsConfigField } from "./cms-plugins";
|
|
|
2
2
|
import type { PhiRuntimeModuleId } from "./cms-plugins";
|
|
3
3
|
import type { PhiFormProviderKey } from "@phis/contracts/forms";
|
|
4
4
|
import type { PhiFormSubmitCategory, PhiFormSubmitMethod, PhiFormSubmitTransport } from "./form-submit-route";
|
|
5
|
-
export { PHI_FORM_DEFAULT_SUBMIT_LABEL, PHI_FORM_DESCRIPTOR_SCHEMA_VERSION, PHI_FORM_GRID_TRACKS, type PhiFormDescriptor, type PhiFormFieldDescriptor, type PhiFormFieldPlacementDescriptor, type PhiFormGridRange, type PhiFormLabelSetKey, type PhiFormLayoutDescriptor, type PhiFormLogicalAlignment, type PhiFormOptionDescriptor, type PhiFormProviderKey, type PhiFormResponsiveGridRange, type PhiFormSubmitDescriptor, type PhiFormSuccessDescriptor, type PhiFormTextDescriptor, type PhiFormValidationRuleDescriptor, } from "@phis/contracts/forms";
|
|
5
|
+
export { PHI_FORM_DEFAULT_SUBMIT_LABEL, PHI_FORM_DESCRIPTOR_SCHEMA_VERSION, PHI_FORM_GRID_TRACKS, type PhiFormDescriptor, type PhiFormErrorTemplateDescriptor, type PhiFormErrorTextDescriptor, type PhiFormFieldDescriptor, type PhiFormFieldPlacementDescriptor, type PhiFormGridRange, type PhiFormLabelSetKey, type PhiFormLayoutDescriptor, type PhiFormLogicalAlignment, type PhiFormOptionDescriptor, type PhiFormProviderKey, type PhiFormResponsiveGridRange, type PhiFormSubmitDescriptor, type PhiFormSuccessDescriptor, type PhiFormTextDescriptor, type PhiFormValidationRuleDescriptor, } from "@phis/contracts/forms";
|
|
6
6
|
export type PhiFormHandlerPhase = "submit" | "confirm" | "preview";
|
|
7
7
|
export type PhiFormHandlerCredentialPolicy = "none" | "site-session" | "auth-link";
|
|
8
8
|
export type PhiFormFieldTypeProviderDescriptor = {
|
package/types/record-widget.d.ts
CHANGED
|
@@ -34,6 +34,38 @@ export type PhiRecordWidgetPresentation = {
|
|
|
34
34
|
columns: number;
|
|
35
35
|
fields: readonly PhiRecordFieldDefinition[];
|
|
36
36
|
};
|
|
37
|
+
/**
|
|
38
|
+
* A Provider action of the record's own resource, run on the record shown (TABLES.md, "The record
|
|
39
|
+
* Widget").
|
|
40
|
+
*
|
|
41
|
+
* The Table's row action without what drawing it takes: the record Widget draws no button -- a press
|
|
42
|
+
* arrives on its `action/activate` input as the action's key, from a Command Toolbar in the dialog's
|
|
43
|
+
* footer or any Control beside it, and that Control carries the words and the icon. What stays is what
|
|
44
|
+
* running it takes: which action, whether it is the danger a destructive one must be drawn as, and the
|
|
45
|
+
* question to ask first where showing the record is not question enough.
|
|
46
|
+
*/
|
|
47
|
+
export type PhiRecordWidgetAction = {
|
|
48
|
+
/** The action's key in the resource's `actions`; its scope is `row`. */
|
|
49
|
+
key: string;
|
|
50
|
+
/** `danger` for an action whose intent is `destructive`, which is also how its question is drawn. */
|
|
51
|
+
mode?: "normal" | "danger";
|
|
52
|
+
/** A question before it runs, `%1` the record's identity -- for a press that is not answer enough. */
|
|
53
|
+
confirm?: {
|
|
54
|
+
title: string;
|
|
55
|
+
description?: string;
|
|
56
|
+
okText?: string;
|
|
57
|
+
cancelText?: string;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* The dialog's title from the record shown: `template` with `%1` once, the value of `field` (dotted for a
|
|
62
|
+
* nested one) standing there, announced on `recordTitle` after every read (`helpers/record-title.ts`).
|
|
63
|
+
* The sentence is the placement's own, already in the reader's language like the field labels.
|
|
64
|
+
*/
|
|
65
|
+
export type PhiRecordWidgetTitleFromRecord = {
|
|
66
|
+
template: string;
|
|
67
|
+
field: string;
|
|
68
|
+
};
|
|
37
69
|
/**
|
|
38
70
|
* **Which record to show arrives as a signal.** The Widget does not know the table it belongs to and
|
|
39
71
|
* does not read a store: a row action carries a row identity onto the bus, and whoever listens on that
|
|
@@ -45,5 +77,8 @@ export type PhiRecordWidgetConfig = {
|
|
|
45
77
|
/** The row action whose signal opens a record -- `view` in every first-party table so far. */
|
|
46
78
|
openActionKey: string;
|
|
47
79
|
presentation: PhiRecordWidgetPresentation;
|
|
80
|
+
/** What may be done to the record shown, each run when its key arrives on `action/activate`. */
|
|
81
|
+
actions: readonly PhiRecordWidgetAction[];
|
|
82
|
+
titleFromRecord: PhiRecordWidgetTitleFromRecord | null;
|
|
48
83
|
signalRoutes?: PhiSignalRouteSet | null;
|
|
49
84
|
};
|
|
@@ -5,7 +5,7 @@ export declare const PHI_CORE_SERVER_CAPABILITY: {
|
|
|
5
5
|
readonly ResourceLinksV1: "@phis/server/resource-links:v1";
|
|
6
6
|
readonly SupportV1: "@phis/server/support:v1";
|
|
7
7
|
};
|
|
8
|
-
export type { PhiCapabilityDescriptor, PhiCapabilityId, PhiCapabilityProvider, PhiCapabilityProviderId, PhiCapabilitySnapshot, PhiCapabilityState, } from "@phis/contracts/server-capabilities";
|
|
8
|
+
export type { PhiAddonMediaLimits, PhiCapabilityDescriptor, PhiCapabilityId, PhiCapabilityProvider, PhiCapabilityProviderId, PhiCapabilitySnapshot, PhiCapabilityState, } from "@phis/contracts/server-capabilities";
|
|
9
9
|
import type { PhiCapabilityId, PhiCapabilityProviderId, PhiCapabilityState } from "@phis/contracts/server-capabilities";
|
|
10
10
|
export type PhiRuntimeModuleServerBinding = {
|
|
11
11
|
providerId: PhiCapabilityProviderId;
|
package/types/table-widget.d.ts
CHANGED
|
@@ -51,6 +51,13 @@ export type PhiTableQuery = {
|
|
|
51
51
|
* same rows draws the same values and must mean the same thing by `datetime` as the table does.
|
|
52
52
|
*/
|
|
53
53
|
export type PhiTableValueRenderer = "text" | "email" | "date" | "datetime" | "badge" | "tags" | "link" | "code" | "json" | "switch" | "checkbox" | "icon"
|
|
54
|
+
/**
|
|
55
|
+
* A small picture from a Site-relative address the Provider answers ready to load -- an image variant
|
|
56
|
+
* the server built with its cache revision (phis-server `resolvePhiMediaVariantUrl`, the `icon`
|
|
57
|
+
* variant for a list), never an Asset id put together here. Drawn at a fixed square box, fitted whole,
|
|
58
|
+
* lazily; any other address draws nothing. Bound to a `string` field.
|
|
59
|
+
*/
|
|
60
|
+
| "image"
|
|
54
61
|
/**
|
|
55
62
|
* An amount of money, `{ currency, minor }` -- the payment contract's `PhisPaymentMoney`, with `minor`
|
|
56
63
|
* an integer string or a safe integer of minor units -- written in the reader's language with the
|
|
@@ -80,6 +87,12 @@ export type PhiTableColumnDefinition = {
|
|
|
80
87
|
* Control's node `iconFieldKey`.
|
|
81
88
|
*/
|
|
82
89
|
iconFieldKey?: string;
|
|
90
|
+
/**
|
|
91
|
+
* A picture field drawn ahead of this column's own value, as `iconFieldKey` draws a named icon: the
|
|
92
|
+
* declared `string` field holding the Site-relative address the `image` renderer draws -- a product's
|
|
93
|
+
* icon beside its title. It stands for the value beside it, so it is decorative (empty `alt`).
|
|
94
|
+
*/
|
|
95
|
+
imageFieldKey?: string;
|
|
83
96
|
/**
|
|
84
97
|
* An icon for the column heading itself, from the same icon vocabulary as everything else
|
|
85
98
|
* (`antd:info-circle`, `@phis/ui/widgets:table`).
|
|
@@ -658,6 +671,13 @@ export declare function readPhiTableQuery(value: unknown): PhiTableQuery | null;
|
|
|
658
671
|
export declare function readPhiTableFilters(value: unknown): PhiTableQuery["filters"] | null;
|
|
659
672
|
export declare function readPhiTableProviderQueryResult(value: unknown): PhiTableProviderQueryResult | null;
|
|
660
673
|
export declare function readPhiTableProviderMutationResult(value: unknown): PhiTableProviderMutationResult | null;
|
|
674
|
+
/**
|
|
675
|
+
* Whether a Provider action may be asked for as stated: declared by the resource, with the row or the
|
|
676
|
+
* selection its scope needs, and a value of the type it declares. The one check every Widget that runs a
|
|
677
|
+
* Provider action makes before the Provider Client is called -- the Table's Binding and the record
|
|
678
|
+
* Widget alike -- answered as the error the Widget shows, or null.
|
|
679
|
+
*/
|
|
680
|
+
export declare function checkPhiTableProviderActionRequest(resource: Pick<PhiTableProviderResourceDescriptor, "resourceKey" | "actions"> | null | undefined, request: Pick<PhiTableProviderActionMutationRequest, "actionKey" | "rowIdentity" | "selectedRowIdentities" | "actionValue">): PhiTableProviderError | null;
|
|
661
681
|
/**
|
|
662
682
|
* The choices a row offers for a field that declares `rowOptionsPath`, or null when the row offers none.
|
|
663
683
|
* A generic reader: an entry without a string value and a string label is dropped, not repaired.
|
package/types/table-widget.js
CHANGED
|
@@ -149,6 +149,40 @@ export function readPhiTableProviderMutationResult(value) {
|
|
|
149
149
|
message: value.message,
|
|
150
150
|
};
|
|
151
151
|
}
|
|
152
|
+
/**
|
|
153
|
+
* Whether a Provider action may be asked for as stated: declared by the resource, with the row or the
|
|
154
|
+
* selection its scope needs, and a value of the type it declares. The one check every Widget that runs a
|
|
155
|
+
* Provider action makes before the Provider Client is called -- the Table's Binding and the record
|
|
156
|
+
* Widget alike -- answered as the error the Widget shows, or null.
|
|
157
|
+
*/
|
|
158
|
+
export function checkPhiTableProviderActionRequest(resource, request) {
|
|
159
|
+
const action = resource?.actions?.find((candidate) => candidate.key === request.actionKey);
|
|
160
|
+
if (!action) {
|
|
161
|
+
return new PhiTableProviderError("action-not-declared", `Table action "${request.actionKey}" is not declared by resource "${resource?.resourceKey ?? "unknown"}".`);
|
|
162
|
+
}
|
|
163
|
+
const hasRow = request.rowIdentity != null;
|
|
164
|
+
const hasSelection = (request.selectedRowIdentities?.length ?? 0) > 0;
|
|
165
|
+
if ((action.scope === "row" && !hasRow) || (action.scope === "selection" && !hasSelection)) {
|
|
166
|
+
return new PhiTableProviderError("action-scope-invalid", `Table action "${request.actionKey}" requires ${action.scope} identity context.`);
|
|
167
|
+
}
|
|
168
|
+
const value = request.actionValue;
|
|
169
|
+
const valueValid = action.valueType === undefined || action.valueType === "none"
|
|
170
|
+
? value === undefined || value === null
|
|
171
|
+
: action.valueType === "string"
|
|
172
|
+
? typeof value === "string"
|
|
173
|
+
: action.valueType === "number"
|
|
174
|
+
? typeof value === "number" && Number.isFinite(value)
|
|
175
|
+
: action.valueType === "boolean"
|
|
176
|
+
? typeof value === "boolean"
|
|
177
|
+
: action.valueType === "string[]"
|
|
178
|
+
? Array.isArray(value) && value.every((entry) => typeof entry === "string")
|
|
179
|
+
: action.valueType === "number[]"
|
|
180
|
+
? Array.isArray(value) && value.every((entry) => typeof entry === "number" && Number.isFinite(entry))
|
|
181
|
+
: isPhiRecord(value);
|
|
182
|
+
return valueValid
|
|
183
|
+
? null
|
|
184
|
+
: new PhiTableProviderError("action-value-invalid", `Table action "${request.actionKey}" received an incompatible value.`);
|
|
185
|
+
}
|
|
152
186
|
/**
|
|
153
187
|
* The choices a row offers for a field that declares `rowOptionsPath`, or null when the row offers none.
|
|
154
188
|
* A generic reader: an entry without a string value and a string label is dropped, not repaired.
|
|
@@ -312,6 +346,15 @@ export function validatePhiTableWidgetBinding(config, resource) {
|
|
|
312
346
|
errors.push(`Table column "${column.key}" icon field "${column.iconFieldKey}" must be an icon field.`);
|
|
313
347
|
}
|
|
314
348
|
}
|
|
349
|
+
if (column.imageFieldKey !== undefined) {
|
|
350
|
+
const imageField = fieldsByKey.get(column.imageFieldKey);
|
|
351
|
+
if (!imageField) {
|
|
352
|
+
errors.push(`Table column "${column.key}" references undeclared image field "${column.imageFieldKey}".`);
|
|
353
|
+
}
|
|
354
|
+
else if (imageField.type !== "string") {
|
|
355
|
+
errors.push(`Table column "${column.key}" image field "${column.imageFieldKey}" must be a string field.`);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
315
358
|
if (column.editor && field?.type === "json") {
|
|
316
359
|
errors.push(`Table column "${column.key}" cannot use an implicit JSON editor.`);
|
|
317
360
|
}
|
|
@@ -331,6 +374,7 @@ export function validatePhiTableWidgetBinding(config, resource) {
|
|
|
331
374
|
(column.renderer === "switch" && field?.type === "boolean") ||
|
|
332
375
|
(column.renderer === "checkbox" && field?.type === "boolean") ||
|
|
333
376
|
(column.renderer === "icon" && field?.type === "icon") ||
|
|
377
|
+
(column.renderer === "image" && field?.type === "string") ||
|
|
334
378
|
((column.renderer === "date" || column.renderer === "datetime") && field?.type === column.renderer) ||
|
|
335
379
|
(column.renderer === "json" && field?.type === "json") ||
|
|
336
380
|
(column.renderer === "tags" && (field?.type === "json" || field?.type === "enum[]")) ||
|