cabloy 5.1.168 → 5.1.169

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/.cabloy-version CHANGED
@@ -1 +1 @@
1
- 5.1.168
1
+ 5.1.169
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 5.1.169
4
+
5
+ ### Features
6
+
7
+ - Add a resource picker.
8
+
3
9
  ## 5.1.168
4
10
 
5
11
  ### Features
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cabloy",
3
- "version": "5.1.168",
3
+ "version": "5.1.169",
4
4
  "gitHead": "2c5c19284bab738e492856189acb6fad74b8a7b7",
5
5
  "description": "A Node.js fullstack framework",
6
6
  "keywords": [
@@ -567,8 +567,8 @@ importers:
567
567
  specifier: npm:@cabloy/zod@4.3.8
568
568
  version: '@cabloy/zod@4.3.8'
569
569
  zova:
570
- specifier: ^5.1.159
571
- version: 5.1.159(typescript@5.9.3)(vue@3.5.42(typescript@5.9.3))
570
+ specifier: ^5.1.160
571
+ version: 5.1.160(typescript@5.9.3)(vue@3.5.42(typescript@5.9.3))
572
572
  zova-jsx:
573
573
  specifier: ^1.1.89
574
574
  version: 1.1.89(typescript@5.9.3)
@@ -576,8 +576,8 @@ importers:
576
576
  specifier: ^5.1.22
577
577
  version: 5.1.22
578
578
  zova-module-a-bean:
579
- specifier: ^5.1.33
580
- version: 5.1.33
579
+ specifier: ^5.1.34
580
+ version: 5.1.34
581
581
  zova-module-a-behavior:
582
582
  specifier: ^5.1.26
583
583
  version: 5.1.26
@@ -603,8 +603,8 @@ importers:
603
603
  specifier: ^5.0.7
604
604
  version: 5.0.7
605
605
  zova-module-a-router:
606
- specifier: ^5.1.35
607
- version: 5.1.35
606
+ specifier: ^5.1.36
607
+ version: 5.1.36
608
608
  zova-module-a-routertabs:
609
609
  specifier: ^5.1.34
610
610
  version: 5.1.34
@@ -615,14 +615,14 @@ importers:
615
615
  specifier: ^5.1.35
616
616
  version: 5.1.35
617
617
  zova-module-a-table:
618
- specifier: ^5.1.40
619
- version: 5.1.40(vue@3.5.42(typescript@5.9.3))
618
+ specifier: ^5.1.41
619
+ version: 5.1.41(vue@3.5.42(typescript@5.9.3))
620
620
  zova-module-pay-mock:
621
621
  specifier: ^5.0.5
622
622
  version: 5.0.5
623
623
  zova-module-rest-resource:
624
- specifier: ^5.1.52
625
- version: 5.1.52
624
+ specifier: ^5.1.53
625
+ version: 5.1.53
626
626
 
627
627
  .zova-rest/cabloy-basic-web:
628
628
  dependencies:
@@ -9011,6 +9011,9 @@ packages:
9011
9011
  zova-module-a-bean@5.1.33:
9012
9012
  resolution: {integrity: sha512-GuBrUTDP5IAxHq2+bEBkDMOkgbtdiKI0IqvDnN/ipsxjqOlJMYTth8CzmRySLEc89DLk0369+uayWqywIpx61g==}
9013
9013
 
9014
+ zova-module-a-bean@5.1.34:
9015
+ resolution: {integrity: sha512-+HIOCNuaVfdCAxtdgiwc5XLWIG07G/z3gGGVuwosL3SZRSTdQBeoz08fGXvQ23ylZQe2HBBu7qNZJ4XKRg0Jcw==}
9016
+
9014
9017
  zova-module-a-behavior@5.1.26:
9015
9018
  resolution: {integrity: sha512-gvsonG3yIwH6mcEW/NNyaw9LCJK7WjKAW3pDYkhH+kipOe3TLPgmCQFz2FM0UZIwtopbRsR12exs7Sx26QqnAg==}
9016
9019
 
@@ -9062,9 +9065,15 @@ packages:
9062
9065
  zova-module-a-router@5.1.35:
9063
9066
  resolution: {integrity: sha512-uFHIXS1mEtYGqn8rsUxPXw20J1eZ60Me9irerpsr2v6tPLCC0E8QspeIXTzOO7jpnO660iuZYLGcIMp8GPh5Gw==}
9064
9067
 
9068
+ zova-module-a-router@5.1.36:
9069
+ resolution: {integrity: sha512-uVU4IECn7uPCVskHdle9J4bA/oMthCE/Uvnkm1zh102GIlfLojiPYIK9oDRGEI9kBD5bfZWtBz9wcbWfNf7DzA==}
9070
+
9065
9071
  zova-module-a-routerstack@5.1.27:
9066
9072
  resolution: {integrity: sha512-mSL3IPbk8IDXnfkXwljh8gmi+i7u2yuSmxLdDzGTJL9AFLKmdBYPnMh+pstLzKUPxaADPsfLKikJ35w0H8DSrQ==}
9067
9073
 
9074
+ zova-module-a-routerstack@5.1.28:
9075
+ resolution: {integrity: sha512-fDAxZ0460L+A4VHCTUCQTZ7DuEDYoaOe+OHErEL1iF6GaMvcos4dCHxWqjuqUlMXnjj/fSRrfF/g9iFrAkssoQ==}
9076
+
9068
9077
  zova-module-a-routertabs@5.1.34:
9069
9078
  resolution: {integrity: sha512-j8QS0bxpfQJidh/wUsA1N2FXhckoi5qq01nm2uKCY1CHLEFA19sccP41v6JjrN5N3sw90a3YTaMjbezO5bS9Lg==}
9070
9079
 
@@ -9086,6 +9095,9 @@ packages:
9086
9095
  zova-module-a-table@5.1.40:
9087
9096
  resolution: {integrity: sha512-R/vVUMVYt6lEno45fMfwyy+luQz+l0e2er9IfvorSlZ55kgnZOZj5lXGUCiYYBPgPwxJz3p42hHr7HZZpVu9sQ==}
9088
9097
 
9098
+ zova-module-a-table@5.1.41:
9099
+ resolution: {integrity: sha512-WWw51E+9TVLf1yx5BkW/98WrloxzpCbYugJuHp1BgNzIrjzxRYc8MKbuq/jgSkzVZev55SB2f+lU2J4aZQjBIA==}
9100
+
9089
9101
  zova-module-a-zod@5.1.37:
9090
9102
  resolution: {integrity: sha512-rXHN9rKbum9w3gDSnC/pIusG2d2FGJOcIauf8jrbT96f+Olk4Q3iV3t2V92mxiLCh9kMvBJPfcOgJFW7pRB5Fw==}
9091
9103
 
@@ -9104,8 +9116,8 @@ packages:
9104
9116
  zova-module-rest-resource@5.1.51:
9105
9117
  resolution: {integrity: sha512-rZy8oaQvtcXmqepkE+OWsXt0MUbBuL+NdY099FuG1eYrtl/nB5WMyvmtFVF5d5NRaz6q+otysFuyo8Q93aHfwA==}
9106
9118
 
9107
- zova-module-rest-resource@5.1.52:
9108
- resolution: {integrity: sha512-qQAPo/qsuz3ZkUV4x6NspnAvgJKfaoQb4TH/dWHHwcSWRcrra+0JdFYeSoXIDAtbYlFFBMi2jOq+S5qfVGYQQA==}
9119
+ zova-module-rest-resource@5.1.53:
9120
+ resolution: {integrity: sha512-hrxfwTOjcWdC2SeF01V3N4Nmo/tqv202A9kCJ4Z4fnoeRCsbMooD4cSyKjKFfCot2DQOtpEmKLE4l2r3V3DDfQ==}
9109
9121
 
9110
9122
  zova-suite-a-zova@5.1.155:
9111
9123
  resolution: {integrity: sha512-w4+mlwOJ3DF+Bl9N1hkZBbgNW0UouP3/Xaw8PtiNEpmmr/ScWj+/+l85RTr/q9F+Qw/hjDCWTLwy4GBukTiBag==}
@@ -9113,8 +9125,8 @@ packages:
9113
9125
  zova-suite-a-zova@5.1.157:
9114
9126
  resolution: {integrity: sha512-oMJHt3stq27tHnOMC8t3w0+QFoipL+wnc1tkhOi6q1MP3hz4g7S8aOSEvNA/3SAiI+Bq+wpeoSVqt/2ze4zVGw==}
9115
9127
 
9116
- zova-suite-a-zova@5.1.158:
9117
- resolution: {integrity: sha512-QBYPzzZl6PAASrTESQ+iNdCGJIhVKshgUWKElEDrs8K1EV+Ws+blobR+IAz55fRI5mttes4eA/qkDY/Ky7I+dA==}
9128
+ zova-suite-a-zova@5.1.159:
9129
+ resolution: {integrity: sha512-esr/oC88vxBCjYuD9DmeF+Qcr3F6czxUbvSPxCaChPnS2tHo5LjlPilTecwUOfvpD6FNEKNiZ2fh9Oi1ATxzWw==}
9118
9130
 
9119
9131
  zova@5.1.156:
9120
9132
  resolution: {integrity: sha512-LawJuQhiR+M+BdFkLYEz1wLz0zQa2IuZFAR0Vtq/dcNMX1Jus9g2iem/guNbavgeNP8aXRa+P4vCnaFynnWC/w==}
@@ -9122,8 +9134,8 @@ packages:
9122
9134
  zova@5.1.158:
9123
9135
  resolution: {integrity: sha512-lrsU/TlQvghdd3XRUuqeTIOsum7yv2Jm3NBeUqmcjixcDXxeAWRmH7i9g8MG+1Q8GJru6J6UYpD8mvxeTNKgcA==}
9124
9136
 
9125
- zova@5.1.159:
9126
- resolution: {integrity: sha512-0g4hrd9dNWzztQEfjgmHPTj4EUx7xulrkPZOo0uMMKmUCrQFP15TdjelKgr/H4S6+WpaLCtrg0D2+bPW1IhB6g==}
9137
+ zova@5.1.160:
9138
+ resolution: {integrity: sha512-WuyQiOVjNE7F6G3B2atcj5iJbU7M46NkmPvXIVnuwkv9hMsT6Edi01UZAEArcRva+niv04XKwTGHh2aWz5UiuQ==}
9127
9139
 
9128
9140
  zwitch@1.0.5:
9129
9141
  resolution: {integrity: sha512-V50KMwwzqJV0NpZIZFwfOD5/lyny3WlSzRiXgA0G7VUnRlqttta1L6UQIHzd6EuBY/cHGfwTIck7w1yH6Q5zUw==}
@@ -15561,6 +15573,10 @@ snapshots:
15561
15573
  dependencies:
15562
15574
  globby: 14.1.0
15563
15575
 
15576
+ zova-module-a-bean@5.1.34:
15577
+ dependencies:
15578
+ globby: 14.1.0
15579
+
15564
15580
  zova-module-a-behavior@5.1.26: {}
15565
15581
 
15566
15582
  zova-module-a-behaviors@5.1.22: {}
@@ -15646,8 +15662,12 @@ snapshots:
15646
15662
 
15647
15663
  zova-module-a-router@5.1.35: {}
15648
15664
 
15665
+ zova-module-a-router@5.1.36: {}
15666
+
15649
15667
  zova-module-a-routerstack@5.1.27: {}
15650
15668
 
15669
+ zova-module-a-routerstack@5.1.28: {}
15670
+
15651
15671
  zova-module-a-routertabs@5.1.34: {}
15652
15672
 
15653
15673
  zova-module-a-ssr@5.1.38:
@@ -15690,6 +15710,13 @@ snapshots:
15690
15710
  transitivePeerDependencies:
15691
15711
  - vue
15692
15712
 
15713
+ zova-module-a-table@5.1.41(vue@3.5.42(typescript@5.9.3)):
15714
+ dependencies:
15715
+ '@tanstack/table-core': 8.21.3
15716
+ '@tanstack/vue-table': 8.21.3(vue@3.5.42(typescript@5.9.3))
15717
+ transitivePeerDependencies:
15718
+ - vue
15719
+
15693
15720
  zova-module-a-zod@5.1.37:
15694
15721
  dependencies:
15695
15722
  '@cabloy/zod-errors-custom': link:packages-utils/zod-errors-custom
@@ -15735,7 +15762,7 @@ snapshots:
15735
15762
 
15736
15763
  zova-module-rest-resource@5.1.51: {}
15737
15764
 
15738
- zova-module-rest-resource@5.1.52: {}
15765
+ zova-module-rest-resource@5.1.53: {}
15739
15766
 
15740
15767
  zova-suite-a-zova@5.1.155(typescript@5.9.3)(vue@3.5.39(typescript@5.9.3)):
15741
15768
  dependencies:
@@ -15754,7 +15781,7 @@ snapshots:
15754
15781
  zova-module-a-meta: 5.1.22
15755
15782
  zova-module-a-model: 5.1.36(vue@3.5.39(typescript@5.9.3))
15756
15783
  zova-module-a-openapi: 5.1.53
15757
- zova-module-a-router: 5.1.34
15784
+ zova-module-a-router: 5.1.35
15758
15785
  zova-module-a-routerstack: 5.1.27
15759
15786
  zova-module-a-routertabs: 5.1.34
15760
15787
  zova-module-a-ssr: 5.1.38
@@ -15788,7 +15815,7 @@ snapshots:
15788
15815
  zova-module-a-meta: 5.1.22
15789
15816
  zova-module-a-model: 5.1.36(vue@3.5.42(typescript@5.9.3))
15790
15817
  zova-module-a-openapi: 5.1.53
15791
- zova-module-a-router: 5.1.34
15818
+ zova-module-a-router: 5.1.35
15792
15819
  zova-module-a-routerstack: 5.1.27
15793
15820
  zova-module-a-routertabs: 5.1.34
15794
15821
  zova-module-a-ssr: 5.1.38
@@ -15805,11 +15832,11 @@ snapshots:
15805
15832
  - typescript
15806
15833
  - vue
15807
15834
 
15808
- zova-suite-a-zova@5.1.158(typescript@5.9.3)(vue@3.5.42(typescript@5.9.3)):
15835
+ zova-suite-a-zova@5.1.159(typescript@5.9.3)(vue@3.5.42(typescript@5.9.3)):
15809
15836
  dependencies:
15810
15837
  zova-module-a-api: 5.1.22
15811
15838
  zova-module-a-app: 5.1.26
15812
- zova-module-a-bean: 5.1.33
15839
+ zova-module-a-bean: 5.1.34
15813
15840
  zova-module-a-behavior: 5.1.26
15814
15841
  zova-module-a-behaviors: 5.1.22
15815
15842
  zova-module-a-boundary: 5.1.22
@@ -15822,14 +15849,14 @@ snapshots:
15822
15849
  zova-module-a-meta: 5.1.22
15823
15850
  zova-module-a-model: 5.1.36(vue@3.5.42(typescript@5.9.3))
15824
15851
  zova-module-a-openapi: 5.1.53
15825
- zova-module-a-router: 5.1.35
15826
- zova-module-a-routerstack: 5.1.27
15852
+ zova-module-a-router: 5.1.36
15853
+ zova-module-a-routerstack: 5.1.28
15827
15854
  zova-module-a-routertabs: 5.1.34
15828
15855
  zova-module-a-ssr: 5.1.38
15829
15856
  zova-module-a-ssrhmr: 5.1.23
15830
15857
  zova-module-a-ssrserver: 5.1.26
15831
15858
  zova-module-a-style: 5.1.35
15832
- zova-module-a-table: 5.1.40(vue@3.5.42(typescript@5.9.3))
15859
+ zova-module-a-table: 5.1.41(vue@3.5.42(typescript@5.9.3))
15833
15860
  zova-module-a-zod: 5.1.37
15834
15861
  zova-module-a-zova: 5.1.104(typescript@5.9.3)(vue@3.5.42(typescript@5.9.3))
15835
15862
  transitivePeerDependencies:
@@ -15861,10 +15888,10 @@ snapshots:
15861
15888
  - typescript
15862
15889
  - vue
15863
15890
 
15864
- zova@5.1.159(typescript@5.9.3)(vue@3.5.42(typescript@5.9.3)):
15891
+ zova@5.1.160(typescript@5.9.3)(vue@3.5.42(typescript@5.9.3)):
15865
15892
  dependencies:
15866
15893
  zova-core: 5.1.89(patch_hash=144450bd7a567a6067e5857c0cf4c780981b7e90bc48745c09e1696a9b6f1b97)(typescript@5.9.3)
15867
- zova-suite-a-zova: 5.1.158(typescript@5.9.3)(vue@3.5.42(typescript@5.9.3))
15894
+ zova-suite-a-zova: 5.1.159(typescript@5.9.3)(vue@3.5.42(typescript@5.9.3))
15868
15895
  transitivePeerDependencies:
15869
15896
  - '@vue/composition-api'
15870
15897
  - debug
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zova",
3
- "version": "5.1.160",
3
+ "version": "5.1.161",
4
4
  "gitHead": "2c5c19284bab738e492856189acb6fad74b8a7b7",
5
5
  "description": "A vue3 framework with ioc",
6
6
  "keywords": [
@@ -46,7 +46,7 @@
46
46
  },
47
47
  "dependencies": {
48
48
  "zova-core": "^5.1.89",
49
- "zova-suite-a-zova": "^5.1.159"
49
+ "zova-suite-a-zova": "^5.1.160"
50
50
  },
51
51
  "devDependencies": {
52
52
  "clean-package": "^2.2.0",
@@ -41,8 +41,10 @@ export class ControllerRoutedDialog extends BeanControllerBase {
41
41
  if (!this.$$modelStack) return <div class="loading loading-spinner"></div>;
42
42
  const router = item.state.router;
43
43
  if (!router) return <div class="text-error">Router unavailable</div>;
44
+ const pageHostProviders = item.options.createPageHostProviders?.(item.state.context);
44
45
  const vnode = h(ZRouterViewStack, {
45
46
  pageHostProviders: {
47
+ ...pageHostProviders,
46
48
  [routedDialogContextKey]: item.state.context,
47
49
  },
48
50
  });
@@ -94,6 +94,9 @@ export interface IModalRoutedDialogOptions<
94
94
  title?: string;
95
95
  props?: TProps;
96
96
  session?: TSession;
97
+ createPageHostProviders?: (
98
+ context: IRoutedDialogContext<any, any, any>,
99
+ ) => Record<string, unknown>;
97
100
  onClose?: () => void;
98
101
  }
99
102
 
@@ -18,6 +18,7 @@ import { ZFormField, ZFormFieldPreset } from 'zova-module-a-form';
18
18
  import { $QueryEnsureLoaded } from 'zova-module-a-model';
19
19
  import { resolvePickerSelectionMax } from 'zova-module-basic-page';
20
20
  import { ZSelect, ZSelectProps } from 'zova-module-basic-select';
21
+ import { resourcePickerPageHostKey } from 'zova-module-rest-resource';
21
22
  import { ModelResource } from 'zova-module-rest-resource';
22
23
 
23
24
  import type { TypeResourcePickerSelectionMode } from '../../lib/resourcePicker.js';
@@ -26,6 +27,7 @@ import {
26
27
  normalizeResourcePickerIds,
27
28
  resolveResourcePickerValue,
28
29
  } from '../../lib/resourcePicker.js';
30
+ import { createResourcePickerPageHost } from '../../lib/resourcePickerPageHost.js';
29
31
 
30
32
  export type TypeResourcePickerMode = 'select' | 'routedDialog';
31
33
 
@@ -227,6 +229,9 @@ export class ControllerFormFieldResourcePicker extends BeanControllerBase {
227
229
  },
228
230
  props: options,
229
231
  session,
232
+ createPageHostProviders: dialog => ({
233
+ [resourcePickerPageHostKey]: createResourcePickerPageHost(dialog),
234
+ }),
230
235
  });
231
236
  const result = await handle.result;
232
237
  if (!result) return;
@@ -0,0 +1,64 @@
1
+ import type {
2
+ IResourceBlockOptionsBase,
3
+ IResourceRenderBlockOptionsBlock,
4
+ IResourceTableSelectionPayload,
5
+ } from 'zova-module-a-openapi';
6
+ import type { IRoutedDialogContext } from 'zova-module-basic-app';
7
+ import type {
8
+ IResourcePickerPageContext,
9
+ IResourcePickerPageHost,
10
+ } from 'zova-module-rest-resource';
11
+
12
+ import { deepExtend } from 'zova';
13
+
14
+ export function createResourcePickerPageHost(
15
+ dialog: IRoutedDialogContext<
16
+ IResourceTableSelectionPayload,
17
+ IResourcePickerPageContext['options'],
18
+ IResourcePickerPageContext['session']
19
+ >,
20
+ ): IResourcePickerPageHost {
21
+ const options = dialog.props;
22
+ const session = dialog.session;
23
+ if (!options || !session) {
24
+ throw new Error('resource picker requires dialog options and session');
25
+ }
26
+ return {
27
+ options,
28
+ session,
29
+ resolve: selection => dialog.resolve(selection),
30
+ cancel: () => dialog.cancel(),
31
+ prepareBlocks: (blocks, pickerContext) => {
32
+ if (!blocks) return;
33
+ return blocks.map(block => {
34
+ if (block.render !== 'basic-page:blockPage') return block;
35
+ return {
36
+ ...block,
37
+ options: deepExtend({}, block.options, {
38
+ actionPath: pickerContext.options.actionPath,
39
+ queryFixed: pickerContext.options.query,
40
+ selectionPolicy: 'always',
41
+ selectionMode: pickerContext.options.selectionMode,
42
+ selectionMax: pickerContext.options.selectionMax,
43
+ selectedIds: pickerContext.session.selectedIds,
44
+ selectedRows: pickerContext.session.selectedRows,
45
+ onSelectionChange: (selection: IResourceTableSelectionPayload) => {
46
+ pickerContext.session.selectedIds = [...selection.ids];
47
+ pickerContext.session.selectedRows = selection.rows.map(row => ({ ...row }));
48
+ },
49
+ blocks: [
50
+ ...((
51
+ block.options as IResourceBlockOptionsBase & {
52
+ blocks?: IResourceRenderBlockOptionsBlock[];
53
+ }
54
+ ).blocks ?? []),
55
+ {
56
+ render: 'basic-resource:blockResourcePickerActions',
57
+ },
58
+ ],
59
+ }),
60
+ };
61
+ });
62
+ },
63
+ };
64
+ }
@@ -0,0 +1,94 @@
1
+ import type { IResourceRenderBlockOptionsBlock } from 'zova-module-a-openapi';
2
+
3
+ import assert from 'node:assert/strict';
4
+ import test from 'node:test';
5
+
6
+ import { createResourcePickerPageHost } from '../../src/lib/resourcePickerPageHost.ts';
7
+
8
+ function createDialog() {
9
+ const resolved: unknown[] = [];
10
+ let cancelled = false;
11
+ const dialog = {
12
+ id: 1,
13
+ props: {
14
+ resource: 'training-student:student',
15
+ selectionMode: 'multiple' as const,
16
+ selectionMax: 2,
17
+ },
18
+ session: {
19
+ selectedIds: [1],
20
+ selectedRows: [{ id: 1, name: 'One' }],
21
+ },
22
+ resolve(value: unknown) {
23
+ resolved.push(value);
24
+ },
25
+ cancel() {
26
+ cancelled = true;
27
+ },
28
+ };
29
+ return {
30
+ dialog,
31
+ resolved,
32
+ get cancelled() {
33
+ return cancelled;
34
+ },
35
+ };
36
+ }
37
+
38
+ test('Basic picker host adapts only the Basic page block and preserves picker state', () => {
39
+ const { dialog } = createDialog();
40
+ const host = createResourcePickerPageHost(dialog);
41
+ const unrelated: IResourceRenderBlockOptionsBlock = {
42
+ render: 'other:block' as never,
43
+ options: { class: 'other' },
44
+ };
45
+ const basicPage: IResourceRenderBlockOptionsBlock = {
46
+ render: 'basic-page:blockPage' as never,
47
+ options: {
48
+ blocks: [{ render: 'basic-page:blockTable' as never }],
49
+ } as any,
50
+ };
51
+
52
+ const context = {
53
+ options: dialog.props,
54
+ session: dialog.session,
55
+ dialog: host,
56
+ };
57
+ const blocks = host.prepareBlocks([unrelated, basicPage], context)!;
58
+
59
+ assert.equal(blocks[0], unrelated);
60
+ assert.deepEqual(blocks[1].options, {
61
+ actionPath: undefined,
62
+ queryFixed: undefined,
63
+ selectionPolicy: 'always',
64
+ selectionMode: 'multiple',
65
+ selectionMax: 2,
66
+ selectedIds: [1],
67
+ selectedRows: [{ id: 1, name: 'One' }],
68
+ blocks: [
69
+ { render: 'basic-page:blockTable' },
70
+ { render: 'basic-resource:blockResourcePickerActions' },
71
+ ],
72
+ });
73
+
74
+ const onSelectionChange = (blocks[1].options as any).onSelectionChange as (
75
+ selection: any,
76
+ ) => void;
77
+ onSelectionChange({ ids: [2], rows: [{ id: 2, name: 'Two' }], count: 1 });
78
+ assert.deepEqual(dialog.session, {
79
+ selectedIds: [2],
80
+ selectedRows: [{ id: 2, name: 'Two' }],
81
+ });
82
+ });
83
+
84
+ test('Basic picker host forwards resolve and cancel', () => {
85
+ const { dialog, resolved, cancelled } = createDialog();
86
+ const host = createResourcePickerPageHost(dialog);
87
+ const selection = { ids: [1], rows: [{ id: 1 }], count: 1 };
88
+
89
+ host.resolve(selection);
90
+ host.cancel();
91
+
92
+ assert.deepEqual(resolved, [selection]);
93
+ assert.equal(cancelled, true);
94
+ });
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zova-module-rest-resource",
3
- "version": "5.1.53",
3
+ "version": "5.1.54",
4
4
  "gitHead": "4dece229b6d3f4735930e833afcb4b95ec51bf86",
5
5
  "description": "",
6
6
  "keywords": [
@@ -1 +1,43 @@
1
+ import type { TableIdentity } from 'table-identity';
2
+ import type {
3
+ IResourceRenderBlockOptionsBlock,
4
+ IResourceTableSelectionPayload,
5
+ ITableQuery,
6
+ } from 'zova-module-a-openapi';
7
+
1
8
  export const resourcePickerPageContextKey = '$resourcePickerPageContext';
9
+ export const resourcePickerPageHostKey = '$resourcePickerPageHost';
10
+
11
+ export interface IResourcePickerPageOptions extends Record<string, unknown> {
12
+ resource: string;
13
+ actionPath?: string;
14
+ query?: ITableQuery;
15
+ selectionMode: 'single' | 'multiple';
16
+ selectionMax?: number;
17
+ selectedIds?: readonly TableIdentity[];
18
+ }
19
+
20
+ export interface IResourcePickerPageSession {
21
+ selectedIds: TableIdentity[];
22
+ selectedRows: Record<string, unknown>[];
23
+ }
24
+
25
+ export interface IResourcePickerPageDialog {
26
+ resolve(value: IResourceTableSelectionPayload): void;
27
+ cancel(): void;
28
+ }
29
+
30
+ export interface IResourcePickerPageContext {
31
+ options: IResourcePickerPageOptions;
32
+ session: IResourcePickerPageSession;
33
+ dialog: IResourcePickerPageDialog;
34
+ }
35
+
36
+ export interface IResourcePickerPageHost extends IResourcePickerPageDialog {
37
+ options: IResourcePickerPageOptions;
38
+ session: IResourcePickerPageSession;
39
+ prepareBlocks(
40
+ blocks: IResourceRenderBlockOptionsBlock[] | undefined,
41
+ context: IResourcePickerPageContext,
42
+ ): IResourceRenderBlockOptionsBlock[] | undefined;
43
+ }
@@ -1,53 +1,25 @@
1
- import type { TableIdentity } from 'table-identity';
2
1
  import type { VNode } from 'vue';
3
- import type {
4
- IResourceBlockOptionsBase,
5
- IResourceRenderBlockOptionsBlock,
6
- IResourceTableSelectionPayload,
7
- ITableQuery,
8
- } from 'zova-module-a-openapi';
9
- import type { IRoutedDialogContext } from 'zova-module-basic-app';
10
2
 
11
3
  import { z } from 'zod';
12
4
  import { BeanControllerPageBase, deepExtend, Use, usePrepareArg } from 'zova';
13
5
  import { ZovaJsx } from 'zova-jsx';
14
6
  import { Controller } from 'zova-module-a-bean';
15
7
  import { $QueryEnsureLoaded } from 'zova-module-a-model';
16
- import { routedDialogContextKey } from 'zova-module-basic-app';
17
8
  import { ZPage } from 'zova-module-home-base';
18
9
 
10
+ import type {
11
+ IResourcePickerPageContext,
12
+ IResourcePickerPageHost,
13
+ } from '../../lib/resourcePicker.js';
19
14
  import type { ModelResource } from '../../model/resource.js';
20
15
 
21
16
  import { ZResourcePickerContext } from '../../.metadata/component/resourcePickerContext.js';
17
+ import { resourcePickerPageHostKey } from '../../lib/resourcePicker.js';
22
18
 
23
19
  export const ControllerPageResourcePickerSchemaParams = z.object({
24
20
  resource: z.string(),
25
21
  });
26
22
 
27
- export interface IResourcePickerPageOptions extends Record<string, unknown> {
28
- resource: string;
29
- actionPath?: string;
30
- query?: ITableQuery;
31
- selectionMode: 'single' | 'multiple';
32
- selectionMax?: number;
33
- selectedIds?: readonly TableIdentity[];
34
- }
35
-
36
- export interface IResourcePickerPageSession {
37
- selectedIds: TableIdentity[];
38
- selectedRows: Record<string, unknown>[];
39
- }
40
-
41
- export interface IResourcePickerPageContext {
42
- options: IResourcePickerPageOptions;
43
- session: IResourcePickerPageSession;
44
- dialog: IRoutedDialogContext<
45
- IResourceTableSelectionPayload,
46
- IResourcePickerPageOptions,
47
- IResourcePickerPageSession
48
- >;
49
- }
50
-
51
23
  @Controller()
52
24
  export class ControllerPageResourcePicker extends BeanControllerPageBase {
53
25
  jsxZova: ZovaJsx;
@@ -57,27 +29,27 @@ export class ControllerPageResourcePicker extends BeanControllerPageBase {
57
29
  return usePrepareArg(this.resource, true);
58
30
  }
59
31
 
60
- @Use({ name: routedDialogContextKey, injectionScope: 'host' })
61
- $$routedDialogContext: IRoutedDialogContext<
62
- IResourceTableSelectionPayload,
63
- IResourcePickerPageOptions,
64
- IResourcePickerPageSession
65
- >;
32
+ @Use({ name: resourcePickerPageHostKey, injectionScope: 'host' })
33
+ $$pickerHost: IResourcePickerPageHost | undefined;
66
34
 
67
35
  get resource() {
68
36
  return this.$params.resource;
69
37
  }
70
38
 
71
39
  get pickerContext(): IResourcePickerPageContext {
72
- const options = this.$$routedDialogContext.props;
73
- const session = this.$$routedDialogContext.session;
74
- if (!options || !session || options.resource !== this.resource) {
40
+ const host = this.$$pickerHost;
41
+ if (!host) {
42
+ throw new Error('resource picker requires a page host');
43
+ }
44
+ const options = host.options;
45
+ const session = host.session;
46
+ if (options.resource !== this.resource) {
75
47
  throw new Error('resource picker context does not match route resource');
76
48
  }
77
49
  return {
78
50
  options,
79
51
  session,
80
- dialog: this.$$routedDialogContext,
52
+ dialog: host,
81
53
  };
82
54
  }
83
55
 
@@ -91,7 +63,8 @@ export class ControllerPageResourcePicker extends BeanControllerPageBase {
91
63
  }
92
64
 
93
65
  public render() {
94
- const blocks = this._prepareBlocks(this.schemaRow?.rest?.blocks);
66
+ const pickerContext = this.pickerContext;
67
+ const blocks = this.$$pickerHost!.prepareBlocks(this.schemaRow?.rest?.blocks, pickerContext);
95
68
  if (!blocks || blocks.length === 0) return;
96
69
  const domBlocks: VNode[] = [];
97
70
  blocks.forEach((block, index) => {
@@ -102,43 +75,11 @@ export class ControllerPageResourcePicker extends BeanControllerPageBase {
102
75
  else domBlocks.push(domBlock);
103
76
  });
104
77
  return (
105
- <ZResourcePickerContext context={this.pickerContext}>
78
+ <ZResourcePickerContext context={pickerContext}>
106
79
  <ZPage>{domBlocks}</ZPage>
107
80
  </ZResourcePickerContext>
108
81
  );
109
82
  }
110
-
111
- private _prepareBlocks(blocks: IResourceRenderBlockOptionsBlock[] | undefined) {
112
- if (!blocks) return;
113
- return blocks.map(block => {
114
- if (block.render !== 'basic-page:blockPage') return block;
115
- const pickerContext = this.pickerContext;
116
- return {
117
- ...block,
118
- options: deepExtend({}, block.options, {
119
- actionPath: pickerContext.options.actionPath,
120
- queryFixed: pickerContext.options.query,
121
- selectionPolicy: 'always',
122
- selectionMode: pickerContext.options.selectionMode,
123
- selectionMax: pickerContext.options.selectionMax,
124
- selectedIds: pickerContext.session.selectedIds,
125
- selectedRows: pickerContext.session.selectedRows,
126
- onSelectionChange: (selection: IResourceTableSelectionPayload) => {
127
- pickerContext.session.selectedIds = [...selection.ids];
128
- pickerContext.session.selectedRows = selection.rows.map(row => ({ ...row }));
129
- },
130
- blocks: [
131
- ...((
132
- block.options as IResourceBlockOptionsBase & {
133
- blocks?: IResourceRenderBlockOptionsBlock[];
134
- }
135
- ).blocks ?? []),
136
- {
137
- render: 'basic-resource:blockResourcePickerActions',
138
- },
139
- ],
140
- }),
141
- };
142
- });
143
- }
144
83
  }
84
+
85
+ export type { IResourcePickerPageContext } from '../../lib/resourcePicker.js';
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zova-suite-a-cabloy",
3
- "version": "5.1.54",
3
+ "version": "5.1.55",
4
4
  "gitHead": "4dece229b6d3f4735930e833afcb4b95ec51bf86",
5
5
  "description": "",
6
6
  "author": "",
@@ -8,7 +8,7 @@
8
8
  "type": "module",
9
9
  "dependencies": {
10
10
  "zova-module-a-rbac": "^5.0.1",
11
- "zova-module-rest-resource": "^5.1.53"
11
+ "zova-module-rest-resource": "^5.1.54"
12
12
  },
13
13
  "title": "a-cabloy"
14
14
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zova-module-a-bean",
3
- "version": "5.1.34",
3
+ "version": "5.1.35",
4
4
  "gitHead": "09d901d17140a80ee0764211b441cda72fd94663",
5
5
  "description": "",
6
6
  "keywords": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zova-module-a-router",
3
- "version": "5.1.36",
3
+ "version": "5.1.37",
4
4
  "gitHead": "09d901d17140a80ee0764211b441cda72fd94663",
5
5
  "description": "router",
6
6
  "keywords": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zova-module-a-routerstack",
3
- "version": "5.1.28",
3
+ "version": "5.1.29",
4
4
  "gitHead": "09d901d17140a80ee0764211b441cda72fd94663",
5
5
  "description": "",
6
6
  "keywords": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zova-module-a-table",
3
- "version": "5.1.41",
3
+ "version": "5.1.42",
4
4
  "gitHead": "09d901d17140a80ee0764211b441cda72fd94663",
5
5
  "description": "",
6
6
  "keywords": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zova-suite-a-zova",
3
- "version": "5.1.159",
3
+ "version": "5.1.160",
4
4
  "gitHead": "2c5c19284bab738e492856189acb6fad74b8a7b7",
5
5
  "description": "zova",
6
6
  "license": "MIT",
@@ -10,7 +10,7 @@
10
10
  "dependencies": {
11
11
  "zova-module-a-api": "^5.1.22",
12
12
  "zova-module-a-app": "^5.1.26",
13
- "zova-module-a-bean": "^5.1.34",
13
+ "zova-module-a-bean": "^5.1.35",
14
14
  "zova-module-a-behavior": "^5.1.26",
15
15
  "zova-module-a-behaviors": "^5.1.22",
16
16
  "zova-module-a-boundary": "^5.1.22",
@@ -23,14 +23,14 @@
23
23
  "zova-module-a-meta": "^5.1.22",
24
24
  "zova-module-a-model": "^5.1.36",
25
25
  "zova-module-a-openapi": "^5.1.53",
26
- "zova-module-a-router": "^5.1.36",
27
- "zova-module-a-routerstack": "^5.1.28",
26
+ "zova-module-a-router": "^5.1.37",
27
+ "zova-module-a-routerstack": "^5.1.29",
28
28
  "zova-module-a-routertabs": "^5.1.34",
29
29
  "zova-module-a-ssr": "^5.1.38",
30
30
  "zova-module-a-ssrhmr": "^5.1.23",
31
31
  "zova-module-a-ssrserver": "^5.1.26",
32
32
  "zova-module-a-style": "^5.1.35",
33
- "zova-module-a-table": "^5.1.41",
33
+ "zova-module-a-table": "^5.1.42",
34
34
  "zova-module-a-zod": "^5.1.37",
35
35
  "zova-module-a-zova": "^5.1.104"
36
36
  },