cabloy 5.1.64 → 5.1.66

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.
Files changed (173) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/cabloy-docs/.vitepress/config.mjs +1 -1
  3. package/cabloy-docs/backend/crud-workflow.md +33 -0
  4. package/cabloy-docs/backend/master-detail-workflow.md +149 -0
  5. package/cabloy-docs/frontend/bean-scene-authoring.md +1 -1
  6. package/cabloy-docs/frontend/cli.md +12 -1
  7. package/cabloy-docs/frontend/command-scene-authoring.md +12 -1
  8. package/cabloy-docs/frontend/component-guide.md +10 -0
  9. package/cabloy-docs/frontend/permission-formscene-action-visibility-guide.md +69 -7
  10. package/cabloy-docs/frontend/table-cell-cookbook.md +10 -0
  11. package/cabloy-docs/fullstack/backend-metadata-to-frontend-table-actions.md +83 -2
  12. package/cabloy-docs/reference/bean-scene-boilerplates.md +9 -4
  13. package/package.json +1 -1
  14. package/vona/packages-cli/cabloy-cli/package.json +1 -1
  15. package/vona/packages-cli/cabloy-cli/src/lib/local.helper.ts +38 -0
  16. package/vona/packages-cli/cli/package.json +1 -1
  17. package/vona/packages-cli/cli-set-api/cli/templates/tools/masterDetail/boilerplate/dto/<%=argv.detailDtoBaseName%>.tsx_ +18 -0
  18. package/vona/packages-cli/cli-set-api/cli/templates/tools/masterDetail/boilerplate/dto/<%=argv.detailDtoMutateName%>.tsx_ +17 -0
  19. package/vona/packages-cli/cli-set-api/cli/templates/tools/masterDetail/boilerplate/dto/<%=argv.detailDtoResItemName%>.tsx_ +60 -0
  20. package/vona/packages-cli/cli-set-api/cli/templates/tools/masterDetail/boilerplate/dto/<%=argv.detailDtoViewName%>.tsx_ +17 -0
  21. package/vona/packages-cli/cli-set-api/package.json +1 -1
  22. package/vona/packages-cli/cli-set-api/src/lib/bean/cli.create.bean.ts +2 -6
  23. package/vona/packages-cli/cli-set-api/src/lib/bean/cli.create.module.ts +3 -6
  24. package/vona/packages-cli/cli-set-api/src/lib/bean/cli.create.suite.ts +1 -1
  25. package/vona/packages-cli/cli-set-api/src/lib/bean/cli.create.test.ts +2 -6
  26. package/vona/packages-cli/cli-set-api/src/lib/bean/cli.init.asset.ts +2 -6
  27. package/vona/packages-cli/cli-set-api/src/lib/bean/cli.init.config.ts +2 -6
  28. package/vona/packages-cli/cli-set-api/src/lib/bean/cli.init.constant.ts +2 -6
  29. package/vona/packages-cli/cli-set-api/src/lib/bean/cli.init.error.ts +2 -6
  30. package/vona/packages-cli/cli-set-api/src/lib/bean/cli.init.lib.ts +2 -6
  31. package/vona/packages-cli/cli-set-api/src/lib/bean/cli.init.locale.ts +2 -6
  32. package/vona/packages-cli/cli-set-api/src/lib/bean/cli.init.main.ts +2 -6
  33. package/vona/packages-cli/cli-set-api/src/lib/bean/cli.init.monkey.ts +2 -6
  34. package/vona/packages-cli/cli-set-api/src/lib/bean/cli.init.static.ts +2 -6
  35. package/vona/packages-cli/cli-set-api/src/lib/bean/cli.init.types.ts +2 -6
  36. package/vona/packages-cli/cli-set-api/src/lib/bean/cli.tools.crud.ts +2 -6
  37. package/vona/packages-cli/cli-set-api/src/lib/bean/cli.tools.crudBasic.ts +2 -6
  38. package/vona/packages-cli/cli-set-api/src/lib/bean/cli.tools.crudStart.ts +2 -6
  39. package/vona/packages-cli/cli-set-api/src/lib/bean/cli.tools.masterDetail.ts +699 -0
  40. package/vona/packages-cli/cli-set-api/src/lib/bean/cli.tools.metadata.ts +1 -2
  41. package/vona/packages-cli/cli-set-api/src/lib/beans.ts +2 -0
  42. package/vona/packages-cli/cli-set-api/src/lib/command/tools.masterDetail.ts +78 -0
  43. package/vona/packages-cli/cli-set-api/src/lib/commands.ts +2 -0
  44. package/vona/packages-vona/vona/package.json +1 -1
  45. package/vona/packages-vona/vona-core/package.json +1 -1
  46. package/vona/packages-vona/vona-core/src/lib/mappedClass/type.ts +1 -0
  47. package/vona/packages-vona/vona-core/src/lib/mappedClass/utils.ts +36 -14
  48. package/vona/packages-vona/vona-mock/package.json +1 -1
  49. package/vona/pnpm-lock.yaml +29 -11
  50. package/vona/src/suite/a-training/modules/training-record/src/entity/record.tsx +1 -7
  51. package/vona/src/suite/a-training/modules/training-student/src/config/locale/en-us.ts +3 -0
  52. package/vona/src/suite/a-training/modules/training-student/src/config/locale/zh-cn.ts +3 -0
  53. package/vona/src/suite/a-training/modules/training-student/src/dto/detailRecordBase.tsx +8 -2
  54. package/vona/src/suite/a-training/modules/training-student/src/dto/detailRecordMutate.tsx +1 -15
  55. package/vona/src/suite/a-training/modules/training-student/src/dto/detailRecordResItem.tsx +27 -8
  56. package/vona/src/suite/a-training/modules/training-student/src/dto/detailRecordView.tsx +1 -12
  57. package/vona/src/suite/a-training/modules/training-student/src/dto/studentCreate.tsx +6 -4
  58. package/vona/src/suite/a-training/modules/training-student/src/dto/studentSelectReq.tsx +3 -6
  59. package/vona/src/suite/a-training/modules/training-student/src/dto/studentSummary.tsx +1 -1
  60. package/vona/src/suite/a-training/modules/training-student/src/dto/studentUpdate.tsx +14 -1
  61. package/vona/src/suite/a-training/modules/training-student/src/dto/studentView.tsx +14 -1
  62. package/vona/src/suite/a-training/modules/training-student/src/entity/student.tsx +1 -5
  63. package/vona/src/suite/a-training/modules/training-student/src/service/student.ts +9 -4
  64. package/vona/src/suite-vendor/a-vona/modules/a-core/package.json +1 -1
  65. package/vona/src/suite-vendor/a-vona/modules/a-openapiutils/package.json +1 -1
  66. package/vona/src/suite-vendor/a-vona/modules/a-openapiutils/src/lib/const/decorator.ts +3 -1
  67. package/vona/src/suite-vendor/a-vona/modules/a-openapiutils/src/lib/schema/makeSchemaLikes.ts +21 -17
  68. package/vona/src/suite-vendor/a-vona/modules/a-openapiutils/src/lib/utils.ts +44 -2
  69. package/vona/src/suite-vendor/a-vona/modules/a-orm/package.json +1 -1
  70. package/vona/src/suite-vendor/a-vona/modules/a-orm/src/lib/dto/dtoGet.ts +2 -2
  71. package/vona/src/suite-vendor/a-vona/modules/a-orm/src/lib/dto/dtoMutate.ts +8 -1
  72. package/vona/src/suite-vendor/a-vona/modules/a-orm/src/service/relations_.ts +32 -16
  73. package/vona/src/suite-vendor/a-vona/modules/a-web/package.json +1 -1
  74. package/vona/src/suite-vendor/a-vona/modules/a-web/src/lib/decorator/bean.ts +26 -5
  75. package/vona/src/suite-vendor/a-vona/package.json +1 -1
  76. package/zova/packages-cli/cli/package.json +3 -3
  77. package/zova/packages-cli/cli-set-front/cli/templates/create/component/boilerplateDetailsActionBulk/controller.tsx_ +31 -0
  78. package/zova/packages-cli/cli-set-front/cli/templates/rest/component.ts +24 -2
  79. package/zova/packages-cli/cli-set-front/cli/templates/rest/render.ts +4 -0
  80. package/zova/packages-cli/cli-set-front/package.json +2 -2
  81. package/zova/packages-cli/cli-set-front/src/lib/bean/cli.create.bean.ts +2 -6
  82. package/zova/packages-cli/cli-set-front/src/lib/bean/cli.create.mock.ts +2 -6
  83. package/zova/packages-cli/cli-set-front/src/lib/bean/cli.create.module.ts +3 -6
  84. package/zova/packages-cli/cli-set-front/src/lib/bean/cli.create.suite.ts +1 -1
  85. package/zova/packages-cli/cli-set-front/src/lib/bean/cli.init.asset.ts +2 -6
  86. package/zova/packages-cli/cli-set-front/src/lib/bean/cli.init.config.ts +2 -6
  87. package/zova/packages-cli/cli-set-front/src/lib/bean/cli.init.constant.ts +2 -6
  88. package/zova/packages-cli/cli-set-front/src/lib/bean/cli.init.error.ts +2 -6
  89. package/zova/packages-cli/cli-set-front/src/lib/bean/cli.init.icon.ts +2 -6
  90. package/zova/packages-cli/cli-set-front/src/lib/bean/cli.init.lib.ts +2 -6
  91. package/zova/packages-cli/cli-set-front/src/lib/bean/cli.init.locale.ts +2 -6
  92. package/zova/packages-cli/cli-set-front/src/lib/bean/cli.init.main.ts +2 -6
  93. package/zova/packages-cli/cli-set-front/src/lib/bean/cli.init.mainSys.ts +2 -6
  94. package/zova/packages-cli/cli-set-front/src/lib/bean/cli.init.monkey.ts +2 -6
  95. package/zova/packages-cli/cli-set-front/src/lib/bean/cli.init.monkeySys.ts +2 -6
  96. package/zova/packages-cli/cli-set-front/src/lib/bean/cli.init.types.ts +2 -6
  97. package/zova/packages-cli/cli-set-front/src/lib/bean/cli.openapi.config.ts +1 -4
  98. package/zova/packages-cli/cli-set-front/src/lib/bean/cli.openapi.generate.ts +2 -2
  99. package/zova/packages-cli/cli-set-front/src/lib/bean/cli.refactor.anotherRender.ts +2 -6
  100. package/zova/packages-cli/cli-set-front/src/lib/bean/cli.refactor.anotherStyle.ts +2 -6
  101. package/zova/packages-cli/cli-set-front/src/lib/bean/cli.refactor.componentEmits.ts +2 -6
  102. package/zova/packages-cli/cli-set-front/src/lib/bean/cli.refactor.componentGeneric.ts +2 -6
  103. package/zova/packages-cli/cli-set-front/src/lib/bean/cli.refactor.componentModel.ts +2 -6
  104. package/zova/packages-cli/cli-set-front/src/lib/bean/cli.refactor.componentProps.ts +2 -6
  105. package/zova/packages-cli/cli-set-front/src/lib/bean/cli.refactor.componentSlots.ts +2 -6
  106. package/zova/packages-cli/cli-set-front/src/lib/bean/cli.refactor.firstRender.ts +2 -6
  107. package/zova/packages-cli/cli-set-front/src/lib/bean/cli.refactor.firstStyle.ts +2 -6
  108. package/zova/packages-cli/cli-set-front/src/lib/bean/cli.refactor.pageParams.ts +2 -6
  109. package/zova/packages-cli/cli-set-front/src/lib/bean/cli.refactor.pageQuery.ts +2 -6
  110. package/zova/packages-cli/cli-set-front/src/lib/bean/cli.refactor.renameComponent.ts +2 -6
  111. package/zova/packages-cli/cli-set-front/src/lib/bean/cli.tools.metadata.ts +1 -2
  112. package/zova/packages-cli/cli-set-front/src/lib/common/cliCreateComponent.ts +2 -6
  113. package/zova/packages-cli/cli-set-front/src/lib/common/cliCreatePage.ts +2 -6
  114. package/zova/packages-zova/zova/package.json +2 -2
  115. package/zova/pnpm-lock.yaml +744 -884
  116. package/zova/src/suite/a-training/modules/training-student/package.json +2 -1
  117. package/zova/src/suite/cabloy-basic/modules/basic-app/src/bean/behavior.appModal.tsx +131 -13
  118. package/zova/src/suite/cabloy-basic/modules/basic-app/src/config/config.ts +15 -0
  119. package/zova/src/suite/cabloy-basic/modules/basic-app/src/service/appModal.ts +23 -5
  120. package/zova/src/suite/cabloy-basic/modules/basic-app/src/types/appModal.ts +30 -4
  121. package/zova/src/suite/cabloy-basic/modules/basic-details/package.json +6 -1
  122. package/zova/src/suite/cabloy-basic/modules/basic-details/src/.metadata/component/blockForm.ts +31 -0
  123. package/zova/src/suite/cabloy-basic/modules/basic-details/src/.metadata/component/blockTable.ts +31 -0
  124. package/zova/src/suite/cabloy-basic/modules/basic-details/src/.metadata/component/blockToolbarBulk.ts +31 -0
  125. package/zova/src/suite/cabloy-basic/modules/basic-details/src/.metadata/index.ts +204 -9
  126. package/zova/src/suite/cabloy-basic/modules/basic-details/src/bean/command.delete.tsx +47 -0
  127. package/zova/src/suite/cabloy-basic/modules/basic-details/src/bean/tableCell.actionDelete.tsx +52 -0
  128. package/zova/src/suite/cabloy-basic/modules/basic-details/src/bean/tableCell.actionOperationsRow.tsx +72 -0
  129. package/zova/src/suite/cabloy-basic/modules/basic-details/src/bean/tableCell.actionUpdate.tsx +73 -0
  130. package/zova/src/suite/cabloy-basic/modules/basic-details/src/bean/tableCell.actionView.tsx +64 -0
  131. package/zova/src/suite/cabloy-basic/modules/basic-details/src/bean/tableCell.lineNumber.tsx +30 -0
  132. package/zova/src/suite/cabloy-basic/modules/basic-details/src/component/actionCreate/controller.tsx +31 -7
  133. package/zova/src/suite/cabloy-basic/modules/basic-details/src/component/blockDetails/controller.tsx +28 -12
  134. package/zova/src/suite/cabloy-basic/modules/basic-details/src/component/blockForm/controller.tsx +53 -0
  135. package/zova/src/suite/cabloy-basic/modules/basic-details/src/component/blockTable/controller.tsx +49 -0
  136. package/zova/src/suite/cabloy-basic/modules/basic-details/src/component/{blockDetailsToolbarBulk → blockToolbarBulk}/controller.tsx +6 -4
  137. package/zova/src/suite/cabloy-basic/modules/basic-details/src/component/formFieldDetails/controller.tsx +24 -12
  138. package/zova/src/suite/cabloy-basic/modules/basic-details/src/config/locale/en-us.ts +5 -1
  139. package/zova/src/suite/cabloy-basic/modules/basic-details/src/config/locale/zh-cn.ts +5 -1
  140. package/zova/src/suite/cabloy-basic/modules/basic-details/src/index.ts +1 -0
  141. package/zova/src/suite/cabloy-basic/modules/basic-details/src/lib/index.ts +1 -0
  142. package/zova/src/suite/cabloy-basic/modules/basic-details/src/lib/utils.ts +12 -0
  143. package/zova/src/suite/cabloy-basic/modules/basic-details/src/service/detail.tsx +172 -0
  144. package/zova/src/suite/cabloy-basic/modules/basic-details/src/types/detail.ts +18 -0
  145. package/zova/src/suite/cabloy-basic/modules/basic-details/src/types/details.ts +11 -0
  146. package/zova/src/suite/cabloy-basic/modules/basic-details/src/types/dialogForm.ts +22 -0
  147. package/zova/src/suite/cabloy-basic/modules/basic-details/src/types/index.ts +2 -0
  148. package/zova/src/suite-vendor/a-cabloy/modules/rest-resource/package.json +1 -1
  149. package/zova/src/suite-vendor/a-cabloy/modules/rest-resource/src/page/entry/controller.tsx +1 -2
  150. package/zova/src/suite-vendor/a-cabloy/package.json +2 -2
  151. package/zova/src/suite-vendor/a-zova/modules/a-command/cli/command/boilerplate/{{sceneName}}.{{beanName}}.tsx_ +6 -1
  152. package/zova/src/suite-vendor/a-zova/modules/a-command/cli/commandBulk/boilerplate/{{sceneName}}.{{beanName}}.tsx_ +6 -1
  153. package/zova/src/suite-vendor/a-zova/modules/a-command/cli/commandDetailsRow/boilerplate/{{sceneName}}.{{beanName}}.tsx_ +20 -0
  154. package/zova/src/suite-vendor/a-zova/modules/a-command/cli/commandRow/boilerplate/{{sceneName}}.{{beanName}}.tsx_ +6 -1
  155. package/zova/src/suite-vendor/a-zova/modules/a-command/package.json +3 -2
  156. package/zova/src/suite-vendor/a-zova/modules/a-command/src/types/command.ts +2 -0
  157. package/zova/src/suite-vendor/a-zova/modules/a-form/package.json +1 -1
  158. package/zova/src/suite-vendor/a-zova/modules/a-form/src/component/form/controller.tsx +1 -0
  159. package/zova/src/suite-vendor/a-zova/modules/a-openapi/package.json +2 -2
  160. package/zova/src/suite-vendor/a-zova/modules/a-openapi/src/lib/schema.ts +20 -4
  161. package/zova/src/suite-vendor/a-zova/modules/a-openapi/src/types/action.ts +2 -1
  162. package/zova/src/suite-vendor/a-zova/modules/a-openapi/src/types/detail/detail.ts +10 -0
  163. package/zova/src/suite-vendor/a-zova/modules/a-openapi/src/types/detail/details.ts +4 -1
  164. package/zova/src/suite-vendor/a-zova/modules/a-openapi/src/types/detail/detailsActionRow.ts +24 -0
  165. package/zova/src/suite-vendor/a-zova/modules/a-openapi/src/types/detail/index.ts +2 -0
  166. package/zova/src/suite-vendor/a-zova/modules/a-openapi/src/types/permissions.ts +4 -0
  167. package/zova/src/suite-vendor/a-zova/modules/a-openapi/src/types/rest.ts +2 -0
  168. package/zova/src/suite-vendor/a-zova/modules/a-table/cli/detailsActionRow/boilerplate/{{sceneName}}.{{beanName}}.tsx_ +24 -0
  169. package/zova/src/suite-vendor/a-zova/modules/a-table/package.json +3 -2
  170. package/zova/src/suite-vendor/a-zova/modules/a-table/src/component/table/controller.tsx +5 -3
  171. package/zova/src/suite-vendor/a-zova/modules/a-zova/package.json +2 -2
  172. package/zova/src/suite-vendor/a-zova/package.json +6 -6
  173. package/zova/src/suite/cabloy-basic/modules/basic-details/src/.metadata/component/blockDetailsToolbarBulk.ts +0 -31
@@ -5,12 +5,11 @@ import { ZovaJsx } from 'zova-jsx';
5
5
  import { Controller } from 'zova-module-a-bean';
6
6
  import {
7
7
  IDetailsScope,
8
+ IFormMeta,
8
9
  IJsxRenderContextDetails,
9
- IPermissionHintDetailsActionBulk,
10
10
  IResourceBlockOptionsBase,
11
11
  IResourceRenderBlockOptionsBlock,
12
12
  ISchemaObjectExtensionField,
13
- TypeFormScene,
14
13
  } from 'zova-module-a-openapi';
15
14
  import { BeanControllerTableBase } from 'zova-module-a-table';
16
15
 
@@ -24,8 +23,9 @@ export interface ControllerBlockDetailsProps<
24
23
  TData extends {} = {},
25
24
  > extends IResourceBlockOptionsBase {
26
25
  blocks?: IResourceRenderBlockOptionsBlock[];
27
- formScene?: TypeFormScene;
26
+ formMeta?: IFormMeta;
28
27
  schemaRow?: ISchemaObjectExtensionField;
28
+ schemaForm?: ISchemaObjectExtensionField;
29
29
  getDetailItems?: () => TData[] | undefined;
30
30
  setDetailItems?: (detailItems: TData[]) => void;
31
31
  }
@@ -50,21 +50,24 @@ export class ControllerBlockDetails<TData extends {} = {}> extends BeanControlle
50
50
  return this.$props.getDetailItems?.() ?? [];
51
51
  }
52
52
 
53
+ set data(detailItems: TData[]) {
54
+ this.$props.setDetailItems?.(detailItems);
55
+ }
56
+
57
+ get formMeta() {
58
+ return this.$props.formMeta!;
59
+ }
60
+
53
61
  get formScene() {
54
- return this.$props.formScene!;
62
+ return this.formMeta.formScene!;
55
63
  }
56
64
 
57
65
  get schemaRow() {
58
66
  return this.$props.schemaRow!;
59
67
  }
60
68
 
61
- public checkPermission(permissionHint?: IPermissionHintDetailsActionBulk): boolean {
62
- const formScene = this.formScene;
63
- const formSceneHint = permissionHint?.formScene;
64
- if (!formSceneHint) return true;
65
- if (Array.isArray(formSceneHint) && formSceneHint.includes(formScene!)) return true;
66
- if (formSceneHint === formScene) return true;
67
- return false;
69
+ get schemaForm() {
70
+ return this.$props.schemaForm!;
68
71
  }
69
72
 
70
73
  private _prepareJsx() {
@@ -83,7 +86,20 @@ export class ControllerBlockDetails<TData extends {} = {}> extends BeanControlle
83
86
  }
84
87
 
85
88
  private _prepareJsxCelScope(): IDetailsScope {
86
- return {};
89
+ // eslint-disable-next-line
90
+ const self = this;
91
+ const $$details = this.$customRef(() => {
92
+ return {
93
+ get() {
94
+ return self;
95
+ },
96
+ set(_value) {},
97
+ };
98
+ }) as any;
99
+ return {
100
+ formMeta: this.formMeta,
101
+ $$details,
102
+ };
87
103
  }
88
104
 
89
105
  protected render() {
@@ -0,0 +1,53 @@
1
+ import type { IComponentOptions } from 'zova';
2
+ import type { IResourceBlockOptionsBase, IJsxRenderContextDetail } from 'zova-module-a-openapi';
3
+
4
+ import { BeanControllerBase, Use } from 'zova';
5
+ import { Controller } from 'zova-module-a-bean';
6
+ import { BeanControllerFormBase, ZForm } from 'zova-module-a-form';
7
+
8
+ declare module 'zova-module-a-openapi' {
9
+ export interface IResourceBlockRecord {
10
+ 'basic-details:blockForm'?: ControllerBlockFormProps;
11
+ }
12
+ }
13
+
14
+ export interface ControllerBlockFormProps extends IResourceBlockOptionsBase {}
15
+
16
+ @Controller()
17
+ export class ControllerBlockForm extends BeanControllerBase {
18
+ static $propsDefault = {};
19
+ static $componentOptions: IComponentOptions = { inheritAttrs: false, deepExtendDefault: true };
20
+
21
+ formRef: BeanControllerFormBase;
22
+
23
+ @Use({ injectionScope: 'host' })
24
+ $$renderContext: IJsxRenderContextDetail;
25
+
26
+ protected async __init__() {}
27
+
28
+ protected render() {
29
+ const { $$detail } = this.$$renderContext;
30
+ return (
31
+ <ZForm
32
+ class={this.$props.class}
33
+ controllerRef={ref => {
34
+ this.formRef = ref;
35
+ $$detail.formRef = ref;
36
+ }}
37
+ data={$$detail.formData}
38
+ schema={$$detail.formSchema}
39
+ schemaScene={$$detail.schemaScene}
40
+ formMeta={$$detail.formMeta}
41
+ formProvider={$$detail.formProvider}
42
+ formScope={$$detail.jsxCelScope}
43
+ onSubmitData={data => $$detail.submitData(data)}
44
+ onShowError={async ({ error }) => {
45
+ await this.$performCommand('basic-commands:alert', {
46
+ type: 'error',
47
+ text: error.message,
48
+ });
49
+ }}
50
+ ></ZForm>
51
+ );
52
+ }
53
+ }
@@ -0,0 +1,49 @@
1
+ import type { IComponentOptions } from 'zova';
2
+ import type { IResourceBlockOptionsBase, IJsxRenderContextDetails } from 'zova-module-a-openapi';
3
+
4
+ import { BeanControllerBase, Use } from 'zova';
5
+ import { Controller } from 'zova-module-a-bean';
6
+ import { BeanControllerTableBase, ZTable } from 'zova-module-a-table';
7
+
8
+ declare module 'zova-module-a-openapi' {
9
+ export interface IResourceBlockRecord {
10
+ 'basic-details:blockTable'?: ControllerBlockTableProps;
11
+ }
12
+ }
13
+
14
+ export interface ControllerBlockTableProps extends IResourceBlockOptionsBase {}
15
+
16
+ @Controller()
17
+ export class ControllerBlockTable<TData extends {} = {}> extends BeanControllerBase {
18
+ static $propsDefault = {};
19
+ static $componentOptions: IComponentOptions = { inheritAttrs: false, deepExtendDefault: true };
20
+
21
+ tableRef: BeanControllerTableBase<TData>;
22
+
23
+ @Use({ injectionScope: 'host' })
24
+ $$renderContext: IJsxRenderContextDetails;
25
+
26
+ protected async __init__() {}
27
+
28
+ protected render() {
29
+ const { $$details } = this.$$renderContext;
30
+ const data = ($$details.data as TData[]).filter(
31
+ item => (item as Record<string, any>).deleted !== true,
32
+ );
33
+ return (
34
+ <ZTable<TData>
35
+ class={this.$props.class}
36
+ controllerRef={ref => {
37
+ this.tableRef = ref;
38
+ $$details.tableRef = ref as unknown as BeanControllerTableBase<{}>;
39
+ }}
40
+ data={data}
41
+ schema={$$details.schemaRow}
42
+ tableScope={$$details.jsxCelScope}
43
+ getRowId={(_originalRow: TData, index: number) => {
44
+ return String(index);
45
+ }}
46
+ ></ZTable>
47
+ );
48
+ }
49
+ }
@@ -9,18 +9,20 @@ import { VNode } from 'vue';
9
9
  import { BeanControllerBase, Use } from 'zova';
10
10
  import { Controller } from 'zova-module-a-bean';
11
11
 
12
+ import { checkPermission } from '../../lib/utils.js';
13
+
12
14
  declare module 'zova-module-a-openapi' {
13
15
  export interface IResourceBlockRecord {
14
- 'basic-details:blockDetailsToolbarBulk'?: ControllerBlockDetailsToolbarBulkProps;
16
+ 'basic-details:blockToolbarBulk'?: ControllerBlockToolbarBulkProps;
15
17
  }
16
18
  }
17
19
 
18
- export interface ControllerBlockDetailsToolbarBulkProps extends IResourceBlockOptionsBase {
20
+ export interface ControllerBlockToolbarBulkProps extends IResourceBlockOptionsBase {
19
21
  actions?: IResourceRenderDetailsActionBulkOptionsAction[];
20
22
  }
21
23
 
22
24
  @Controller()
23
- export class ControllerBlockDetailsToolbarBulk extends BeanControllerBase {
25
+ export class ControllerBlockToolbarBulk extends BeanControllerBase {
24
26
  static $propsDefault = {};
25
27
  static $componentOptions: IComponentOptions = { inheritAttrs: false, deepExtendDefault: true };
26
28
 
@@ -46,7 +48,7 @@ export class ControllerBlockDetailsToolbarBulk extends BeanControllerBase {
46
48
  const domActions: VNode[] = [];
47
49
  actions.forEach((action, index) => {
48
50
  const permissionHint = action.options?.permission;
49
- if (!$$details.checkPermission(permissionHint)) return;
51
+ if (!checkPermission($$details.formScene, permissionHint)) return;
50
52
  const options = Object.assign({ key: index }, action.options);
51
53
  const domAction = $jsx.render(action.render!, options, $celScope, this.$$renderContext);
52
54
  if (!domAction) return;
@@ -14,7 +14,7 @@ import { VNode } from 'vue';
14
14
  import { BeanControllerBase, deepExtend } from 'zova';
15
15
  import { ZovaJsx } from 'zova-jsx';
16
16
  import { Controller } from 'zova-module-a-bean';
17
- import { ZFormField } from 'zova-module-a-form';
17
+ import { formMetaFromFormScene, ZFormField } from 'zova-module-a-form';
18
18
 
19
19
  declare module 'zova-module-a-openapi' {
20
20
  export interface IResourceFormFieldRecord {
@@ -22,7 +22,9 @@ declare module 'zova-module-a-openapi' {
22
22
  }
23
23
  }
24
24
 
25
- export interface IResourceFormFieldDetailsOptions extends IResourceFormFieldOptionsBase {}
25
+ export interface IResourceFormFieldDetailsOptions extends IResourceFormFieldOptionsBase {
26
+ // schemaRow?:
27
+ }
26
28
 
27
29
  export interface ControllerFormFieldDetailsProps extends IFormFieldComponentOptions {
28
30
  options?: IResourceFormFieldDetailsOptions;
@@ -60,19 +62,17 @@ export class ControllerFormFieldDetails extends BeanControllerBase {
60
62
  $$formField: ControllerFormField,
61
63
  ) {
62
64
  const { propsBucket } = formFieldRenderContext;
63
- // schema
64
- const schemaName = $$formField.property?.items?.$ref;
65
- if (!schemaName) {
66
- return <div>Should specify the detail schema</div>;
67
- }
68
- const schemaRow: ISchemaObjectExtensionField | undefined = this.$sdk.getSchema(
69
- schemaName!,
70
- ).data;
65
+ // schemaRow
66
+ const schemaRow = this._getSchemaRow($$formField);
71
67
  if (!schemaRow) return;
72
- // formScene
68
+ // schemaForm
69
+ const schemaForm = $$formField.property!.items;
70
+ if (!schemaForm) return;
71
+ // formMeta
73
72
  const formScene: TypeFormScene = propsBucket.readonly
74
73
  ? 'view'
75
74
  : $$formField.formMeta!.formScene!;
75
+ const formMeta = formMetaFromFormScene(formScene);
76
76
  // blocks
77
77
  const blocks = schemaRow?.rest?.blocks;
78
78
  if (!blocks || blocks.length === 0) return;
@@ -81,8 +81,9 @@ export class ControllerFormFieldDetails extends BeanControllerBase {
81
81
  const options = deepExtend(
82
82
  { key: index },
83
83
  {
84
- formScene,
84
+ formMeta,
85
85
  schemaRow,
86
+ schemaForm,
86
87
  getDetailItems: () => {
87
88
  return propsBucket.value;
88
89
  },
@@ -102,4 +103,15 @@ export class ControllerFormFieldDetails extends BeanControllerBase {
102
103
  });
103
104
  return <div>{domBlocks}</div>;
104
105
  }
106
+
107
+ private _getSchemaRow($$formField: ControllerFormField): ISchemaObjectExtensionField | undefined {
108
+ const fieldNameAux = `_${$$formField.name}`;
109
+ const propertyAux = $$formField.$$form.getFieldProperty(fieldNameAux);
110
+ // schema
111
+ const schemaName = propertyAux?.items?.$ref;
112
+ if (!schemaName) {
113
+ throw new Error(`Should specify the schemaRow of detail by auxiliary Field: ${fieldNameAux}`);
114
+ }
115
+ return this.$sdk.getSchema(schemaName!).data;
116
+ }
105
117
  }
@@ -1,3 +1,7 @@
1
1
  export default {
2
- Create: 'Create',
2
+ AddDetail: 'Add Detail',
3
+ EditDetail: 'Edit Detail',
4
+ Cancel: 'Cancel',
5
+ OK: 'OK',
6
+ DeleteConfirm: 'Are you sure you want to delete this detail?',
3
7
  };
@@ -1,3 +1,7 @@
1
1
  export default {
2
- Create: '创建',
2
+ AddDetail: '新增明细',
3
+ EditDetail: '编辑明细',
4
+ Cancel: '取消',
5
+ OK: '确认',
6
+ DeleteConfirm: '您确认要删除本明细吗?',
3
7
  };
@@ -1,3 +1,4 @@
1
+ export * from './lib/index.js';
1
2
  export * from './.metadata/locales.js';
2
3
  export * from './types/index.js';
3
4
  export * from './.metadata/index.js';
@@ -0,0 +1 @@
1
+ export * from './utils.js';
@@ -0,0 +1,12 @@
1
+ import { IPermissionHintDetailsActionBulk, TypeFormScene } from 'zova-module-a-openapi';
2
+
3
+ export function checkPermission(
4
+ formScene: TypeFormScene,
5
+ permissionHint?: IPermissionHintDetailsActionBulk,
6
+ ): boolean {
7
+ const formSceneHint = permissionHint?.formScene;
8
+ if (!formSceneHint) return true;
9
+ if (Array.isArray(formSceneHint) && formSceneHint.includes(formScene!)) return true;
10
+ if (formSceneHint === formScene) return true;
11
+ return false;
12
+ }
@@ -0,0 +1,172 @@
1
+ import { celEnvBase } from '@cabloy/utils';
2
+ import { classes } from 'typestyle';
3
+ import { VNode } from 'vue';
4
+ import { BeanBase, UseScope } from 'zova';
5
+ import { ZovaJsx } from 'zova-jsx';
6
+ import { Service } from 'zova-module-a-bean';
7
+ import {
8
+ BeanControllerFormBase,
9
+ formMetaFromFormScene,
10
+ TypeFormOnSubmitData,
11
+ } from 'zova-module-a-form';
12
+ import {
13
+ IDetailScope,
14
+ IFormMeta,
15
+ IFormProvider,
16
+ IJsxRenderContextDetail,
17
+ ISchemaObjectExtensionField,
18
+ ScopeModuleAOpenapi,
19
+ TypeFormScene,
20
+ TypeFormSchemaScene,
21
+ } from 'zova-module-a-openapi';
22
+ import { AppModalItem } from 'zova-module-basic-app';
23
+
24
+ import { IDialogFormOptions } from '../types/dialogForm.js';
25
+
26
+ @Service()
27
+ export class ServiceDetail<TData extends {} = {}> extends BeanBase {
28
+ private options: IDialogFormOptions<TData>;
29
+ private dialogInstance: AppModalItem | undefined;
30
+
31
+ formRef: BeanControllerFormBase<TData> | undefined;
32
+
33
+ formScene: TypeFormScene;
34
+ schemaScene: TypeFormSchemaScene;
35
+
36
+ formMeta: IFormMeta;
37
+ formProvider: IFormProvider;
38
+ formSchema?: ISchemaObjectExtensionField;
39
+ formData?: TData;
40
+
41
+ jsxZova: ZovaJsx;
42
+ jsxCelScope: IDetailScope;
43
+ jsxRenderContext: IJsxRenderContextDetail<TData>;
44
+
45
+ @UseScope()
46
+ $$scopeOpenapi: ScopeModuleAOpenapi;
47
+
48
+ protected async __init__(options: IDialogFormOptions<TData>) {
49
+ this.options = options;
50
+ this.formScene = options.formScene;
51
+ this.schemaScene = options.schemaScene;
52
+ this.formMeta = formMetaFromFormScene(this.formScene);
53
+ this.formProvider = this.$$scopeOpenapi.config.formProvider;
54
+ this.formSchema = options.schema;
55
+ this.formData = options.data;
56
+ // jsx
57
+ this._prepareJsx();
58
+ }
59
+
60
+ private _prepareJsx() {
61
+ const jsxCelEnv = celEnvBase.clone();
62
+ this.jsxZova = this.bean._newBeanSimple(
63
+ ZovaJsx,
64
+ false,
65
+ this.formProvider.components,
66
+ jsxCelEnv,
67
+ );
68
+ this.jsxCelScope = this._prepareJsxCelScope();
69
+ this.jsxRenderContext = {
70
+ app: this.app,
71
+ ctx: this.ctx,
72
+ $scene: 'detail',
73
+ $host: this,
74
+ $celScope: this.jsxCelScope,
75
+ $jsx: this.jsxZova,
76
+ $$detail: this,
77
+ };
78
+ }
79
+
80
+ private _prepareJsxCelScope(): IDetailScope {
81
+ // eslint-disable-next-line
82
+ const self = this;
83
+ const $$detail = this.$customRef(() => {
84
+ return {
85
+ get() {
86
+ return self;
87
+ },
88
+ set(_value) {},
89
+ };
90
+ }) as any;
91
+ return {
92
+ formMeta: this.formMeta,
93
+ $$detail,
94
+ };
95
+ }
96
+
97
+ private _renderBlocks() {
98
+ const blocks = this.formSchema?.rest?.blocks;
99
+ if (!blocks || blocks.length === 0) return;
100
+ const domBlocks: VNode[] = [];
101
+ blocks.forEach((block, index) => {
102
+ const options = Object.assign({ key: index }, block.options);
103
+ const domBlock = this.jsxZova.render(
104
+ block.render!,
105
+ options,
106
+ this.jsxCelScope,
107
+ this.jsxRenderContext,
108
+ );
109
+ if (!domBlock) return;
110
+ if (Array.isArray(domBlock)) {
111
+ domBlocks.push(...domBlock);
112
+ } else {
113
+ domBlocks.push(domBlock);
114
+ }
115
+ });
116
+ return domBlocks;
117
+ }
118
+
119
+ public closeDialog() {
120
+ if (this.dialogInstance) {
121
+ this.dialogInstance.close();
122
+ this.dialogInstance = undefined;
123
+ }
124
+ }
125
+
126
+ public submitData(data: TypeFormOnSubmitData<TData>) {
127
+ this.options.onSubmitData?.(data, this.dialogInstance!);
128
+ }
129
+
130
+ openDialogForm() {
131
+ const options = this.options;
132
+ this.dialogInstance = this.$appModal.dialog(
133
+ {
134
+ icon: options.icon,
135
+ title: options.title,
136
+ slotDefault: () => {
137
+ return <>{this._renderBlocks()}</>;
138
+ },
139
+ slotActions: () => {
140
+ const isSubmitting = this.formRef?.formState.isSubmitting;
141
+ return (
142
+ <>
143
+ {isSubmitting && <span class="loading loading-spinner text-primary"></span>}
144
+ <button
145
+ type="button"
146
+ class="btn btn-ghost"
147
+ onClick={() => {
148
+ this.closeDialog();
149
+ }}
150
+ >
151
+ {options.locale.Cancel()}
152
+ </button>
153
+ {this.formScene !== 'view' && (
154
+ <button
155
+ type="button"
156
+ class={classes('btn btn-primary', isSubmitting && 'btn-disabled')}
157
+ onClick={async () => {
158
+ if (isSubmitting) return;
159
+ await this.formRef?.submit();
160
+ }}
161
+ >
162
+ {options.locale.OK()}
163
+ </button>
164
+ )}
165
+ </>
166
+ );
167
+ },
168
+ },
169
+ options.dialogOptions,
170
+ );
171
+ }
172
+ }
@@ -0,0 +1,18 @@
1
+ import { IDetailScope } from 'zova-module-a-openapi';
2
+ import 'zova-module-a-form';
3
+ import 'zova-module-a-openapi';
4
+ import type { ServiceDetail } from '../service/detail.jsx';
5
+
6
+ declare module 'zova-module-a-openapi' {
7
+ export interface IJsxRenderContextDetail<TData extends {} = {}> {
8
+ $$detail: ServiceDetail<TData>;
9
+ }
10
+
11
+ export interface IDetailScope {
12
+ $$detail?: ServiceDetail;
13
+ }
14
+ }
15
+
16
+ declare module 'zova-module-a-form' {
17
+ export interface IFormScope extends IDetailScope {}
18
+ }
@@ -1,8 +1,19 @@
1
+ import 'zova-module-a-table';
1
2
  import 'zova-module-a-openapi';
3
+ import type { IDetailsScope } from 'zova-module-a-openapi';
4
+
2
5
  import { ControllerBlockDetails } from '../component/blockDetails/controller.jsx';
3
6
 
4
7
  declare module 'zova-module-a-openapi' {
5
8
  export interface IJsxRenderContextDetails<TData extends {} = {}> {
6
9
  $$details: ControllerBlockDetails<TData>;
7
10
  }
11
+
12
+ export interface IDetailsScope {
13
+ $$details?: ControllerBlockDetails<any>;
14
+ }
15
+ }
16
+
17
+ declare module 'zova-module-a-table' {
18
+ export interface ITableScope extends IDetailsScope {}
8
19
  }
@@ -0,0 +1,22 @@
1
+ import { TypeFormOnSubmitData } from 'zova-module-a-form';
2
+ import { IIconRecord } from 'zova-module-a-icon';
3
+ import { TypeFormScene, TypeFormSchemaScene } from 'zova-module-a-openapi';
4
+ import { AppModalItem, IModalDialogOptions } from 'zova-module-basic-app';
5
+
6
+ export interface IDialogFormOptions<TData extends {} = {}> {
7
+ locale: {
8
+ Cancel: () => string;
9
+ OK: () => string;
10
+ };
11
+ schema: any;
12
+ data: TData;
13
+ formScene: TypeFormScene;
14
+ schemaScene: TypeFormSchemaScene;
15
+ dialogOptions?: IModalDialogOptions;
16
+ icon?: keyof IIconRecord;
17
+ title: string;
18
+ onSubmitData?: (
19
+ data: TypeFormOnSubmitData<TData>,
20
+ dialogInstance: AppModalItem,
21
+ ) => void | Promise<void>;
22
+ }
@@ -1 +1,3 @@
1
1
  export * from './details.js';
2
+ export * from './dialogForm.js';
3
+ export * from './detail.js';
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zova-module-rest-resource",
3
- "version": "5.1.36",
3
+ "version": "5.1.37",
4
4
  "gitHead": "4dece229b6d3f4735930e833afcb4b95ec51bf86",
5
5
  "description": "",
6
6
  "keywords": [
@@ -52,8 +52,7 @@ export class ControllerPageEntry extends BeanControllerPageBase {
52
52
 
53
53
  protected async __init__() {
54
54
  this.formMeta = this.$computed(() => {
55
- const formScene = this.formScene;
56
- return { ...formMetaFromFormScene(formScene), formScene };
55
+ return formMetaFromFormScene(this.formScene);
57
56
  });
58
57
  this.formProvider = this.$computed(() => {
59
58
  return this.$$modelResource.formProvider;
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "zova-suite-a-cabloy",
3
- "version": "5.1.37",
3
+ "version": "5.1.38",
4
4
  "gitHead": "4dece229b6d3f4735930e833afcb4b95ec51bf86",
5
5
  "description": "",
6
6
  "author": "",
7
7
  "files": [],
8
8
  "type": "module",
9
9
  "dependencies": {
10
- "zova-module-rest-resource": "^5.1.36"
10
+ "zova-module-rest-resource": "^5.1.37"
11
11
  },
12
12
  "title": "a-cabloy"
13
13
  }
@@ -1,7 +1,12 @@
1
+ import type {
2
+ ICommandExecute,
3
+ ICommandOptionsBase,
4
+ NextCommandExecute,
5
+ } from 'zova-module-a-command';
1
6
  import type { IJsxRenderContextBase } from 'zova-module-a-openapi';
2
7
 
3
8
  import { BeanBase } from 'zova';
4
- import { Command, type ICommandExecute, type ICommandOptionsBase, type NextCommandExecute } from 'zova-module-a-command';
9
+ import { Command } from 'zova-module-a-command';
5
10
 
6
11
  export type TypeCommand<%=argv.beanNameCapitalize%>Result = unknown;
7
12
 
@@ -1,6 +1,11 @@
1
+ import type {
2
+ ICommandBulkOptionsBase,
3
+ ICommandExecute,
4
+ NextCommandExecute,
5
+ } from 'zova-module-a-command';
1
6
  import type { IJsxRenderContextBase } from 'zova-module-a-openapi';
2
7
 
3
- import { BeanCommandBulkBase, Command, type ICommandBulkOptionsBase, type ICommandExecute, type NextCommandExecute } from 'zova-module-a-command';
8
+ import { BeanCommandBulkBase, Command } from 'zova-module-a-command';
4
9
 
5
10
  export type TypeCommand<%=argv.beanNameCapitalize%>Result = unknown;
6
11
 
@@ -0,0 +1,20 @@
1
+ import type {
2
+ ICommandExecute,
3
+ ICommandDetailsRowOptionsBase,
4
+ NextCommandExecute,
5
+ } from 'zova-module-a-command';
6
+ import type { IJsxRenderContextBase } from 'zova-module-a-openapi';
7
+
8
+ import { BeanBase } from 'zova';
9
+ import { Command } from 'zova-module-a-command';
10
+
11
+ export type TypeCommand<%=argv.beanNameCapitalize%>Result = unknown;
12
+
13
+ export interface ICommandOptions<%=argv.beanNameCapitalize%> extends ICommandDetailsRowOptionsBase<TypeCommand<%=argv.beanNameCapitalize%>Result> {}
14
+
15
+ @Command<ICommandOptions<%=argv.beanNameCapitalize%>>()
16
+ export class Command<%=argv.beanNameCapitalize%> extends BeanBase implements ICommandExecute {
17
+ execute(_options: ICommandOptions<%=argv.beanNameCapitalize%>, _renderContext: IJsxRenderContextBase, next: NextCommandExecute) {
18
+ return next();
19
+ }
20
+ }
@@ -1,6 +1,11 @@
1
+ import type {
2
+ ICommandExecute,
3
+ ICommandRowOptionsBase,
4
+ NextCommandExecute,
5
+ } from 'zova-module-a-command';
1
6
  import type { IJsxRenderContextBase } from 'zova-module-a-openapi';
2
7
 
3
- import { BeanCommandRowBase, Command, type ICommandExecute, type ICommandRowOptionsBase, type NextCommandExecute } from 'zova-module-a-command';
8
+ import { BeanCommandRowBase, Command } from 'zova-module-a-command';
4
9
 
5
10
  export type TypeCommand<%=argv.beanNameCapitalize%>Result = unknown;
6
11