@ibiz-template/model-helper 0.7.37-alpha.3 → 0.7.38-alpha.23

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.
@@ -0,0 +1,222 @@
1
+ import { DSLHelper } from '@ibiz/rt-model-api';
2
+ import { mergeAppMenu } from './merge-app-menu';
3
+ import { mergeDEDrControl } from './merge-de-drcontrol';
4
+ import { mergeAppDEUIActionGroup } from './merge-app-uiaction-group';
5
+ import { mergeTreeView } from './merge-treeview';
6
+ /**
7
+ * 子应用模型合并对象
8
+ *
9
+ * @author tony001
10
+ * @date 2024-09-26 16:09:56
11
+ * @export
12
+ * @class MergeSubModelHelper
13
+ */
14
+ export class MergeSubModelHelper {
15
+ constructor() {
16
+ /**
17
+ * dsl解析包
18
+ *
19
+ * @author tony001
20
+ * @date 2024-09-26 16:09:48
21
+ * @protected
22
+ */
23
+ this.dsl = new DSLHelper();
24
+ }
25
+ /**
26
+ * 合并应用主菜单
27
+ *
28
+ * @author tony001
29
+ * @date 2024-09-26 16:09:03
30
+ * @param {(IControl[] | undefined)} controls
31
+ * @param {ISubAppRef[]} subAppRefs
32
+ */
33
+ mergeAppMainMenu(view, controls, subAppRefs) {
34
+ const dstAppMenu = controls === null || controls === void 0 ? void 0 : controls.find(item => {
35
+ return item.controlType === 'APPMENU' && item.name === 'appmenu';
36
+ });
37
+ if (dstAppMenu) {
38
+ for (let i = 0; i < subAppRefs.length; i++) {
39
+ const srcAppMenu = subAppRefs[i].appMenuModel;
40
+ if (srcAppMenu) {
41
+ mergeAppMenu(dstAppMenu, srcAppMenu);
42
+ }
43
+ }
44
+ }
45
+ }
46
+ /**
47
+ * 合并扩展菜单
48
+ *
49
+ * @author tony001
50
+ * @date 2024-09-26 16:09:27
51
+ * @param {(IControl[] | undefined)} controls
52
+ * @param {ISubAppRef[]} subAppRefs
53
+ * @return {*} {void}
54
+ */
55
+ mergeSubAppExtendedMenu(view, controls, subAppRefs) {
56
+ if (view.viewType !== 'APPINDEXVIEW' || !controls)
57
+ return;
58
+ const dstAppMenus = controls.filter(item => {
59
+ return item.controlType === 'APPMENU' && item.name !== 'appmenu';
60
+ });
61
+ if (dstAppMenus && dstAppMenus.length > 0) {
62
+ for (let i = 0; i < dstAppMenus.length; i++) {
63
+ const dstAppMenu = dstAppMenus[i];
64
+ if (dstAppMenu && dstAppMenu.name) {
65
+ for (let j = 0; j < subAppRefs.length; j++) {
66
+ const srcAppMenu = ibiz.hub.getSubAppMenuModel(dstAppMenu.name, subAppRefs[j].appId);
67
+ if (srcAppMenu) {
68
+ mergeAppMenu(dstAppMenu, srcAppMenu);
69
+ }
70
+ }
71
+ }
72
+ }
73
+ }
74
+ }
75
+ /**
76
+ * 合并DRCtrl
77
+ *
78
+ * @author tony001
79
+ * @date 2024-09-26 16:09:01
80
+ * @param {IAppView} view
81
+ * @param {(IControl[] | undefined)} controls
82
+ * @param {ISubAppRef[]} subAppRefs
83
+ */
84
+ mergeSubAppDRCtrl(view, controls, subAppRefs) {
85
+ const dstDRCtrl = controls === null || controls === void 0 ? void 0 : controls.find(item => {
86
+ return item.controlType === 'DRBAR' || item.controlType === 'DRTAB';
87
+ });
88
+ if (dstDRCtrl) {
89
+ for (let i = 0; i < subAppRefs.length; i++) {
90
+ const srcDRCtrl = ibiz.hub.getSubAppDrControl(dstDRCtrl.uniqueTag, subAppRefs[i].appId);
91
+ if (srcDRCtrl) {
92
+ mergeDEDrControl(dstDRCtrl, srcDRCtrl);
93
+ }
94
+ }
95
+ }
96
+ }
97
+ /**
98
+ * 合并工具栏界面行为组项
99
+ *
100
+ * @author tony001
101
+ * @date 2024-09-26 16:09:23
102
+ * @param {IAppView} view
103
+ * @param {(IControl[] | undefined)} controls
104
+ * @param {ISubAppRef[]} subAppRefs
105
+ */
106
+ mergeSubAppToolbarActionGroup(view, controls, subAppRefs) {
107
+ if (!controls)
108
+ return;
109
+ const dstToolBar = controls.find(item => {
110
+ return item.controlType === 'TOOLBAR';
111
+ });
112
+ if (dstToolBar && dstToolBar.detoolbarItems) {
113
+ const dstToolBarItems = dstToolBar.detoolbarItems;
114
+ if (dstToolBarItems && dstToolBarItems.length > 0) {
115
+ for (let i = 0; i < dstToolBarItems.length; i++) {
116
+ const dstToolBarItem = dstToolBarItems[i];
117
+ if (dstToolBarItem &&
118
+ dstToolBarItem.uiactionGroup) {
119
+ const dstUIActionGroup = dstToolBarItem
120
+ .uiactionGroup;
121
+ if (dstUIActionGroup) {
122
+ for (let j = 0; j < subAppRefs.length; j++) {
123
+ const srcAppDEUIActionGroup = ibiz.hub.getSubAppDEUIActionGroups(dstUIActionGroup.uniqueTag, subAppRefs[j].appId);
124
+ if (srcAppDEUIActionGroup) {
125
+ mergeAppDEUIActionGroup(dstToolBarItems[i].uiactionGroup, srcAppDEUIActionGroup);
126
+ }
127
+ }
128
+ }
129
+ }
130
+ }
131
+ }
132
+ }
133
+ controls.forEach(control => {
134
+ if (control && control.controls) {
135
+ this.mergeSubAppToolbarActionGroup(view, control.controls, subAppRefs);
136
+ }
137
+ });
138
+ }
139
+ /**
140
+ * 合并树上下文菜单
141
+ *
142
+ * @author tony001
143
+ * @date 2024-09-26 16:09:02
144
+ * @param {IAppView} view
145
+ * @param {(IControl[] | undefined)} controls
146
+ * @param {ISubAppRef[]} subAppRefs
147
+ */
148
+ mergeSubAppTreeContextMenuActionGroup(view, controls, subAppRefs) {
149
+ var _a, _b;
150
+ if (!controls)
151
+ return;
152
+ const dstTree = controls.find(item => {
153
+ return item.controlType === 'TREEVIEW';
154
+ });
155
+ if (dstTree && dstTree.controls && dstTree.controls.length > 0) {
156
+ const dstContextMenus = (_a = dstTree.controls) === null || _a === void 0 ? void 0 : _a.filter(item => {
157
+ return item.controlType === 'CONTEXTMENU';
158
+ });
159
+ if (dstContextMenus && dstContextMenus.length > 0) {
160
+ for (let k = 0; k < dstContextMenus.length; k++) {
161
+ const dstContextMenu = dstContextMenus[k];
162
+ if (dstContextMenu && dstContextMenu.detoolbarItems) {
163
+ const dstContextMenuItems = dstContextMenu
164
+ .detoolbarItems;
165
+ if (dstContextMenuItems && dstContextMenuItems.length > 0) {
166
+ for (let i = 0; i < dstContextMenuItems.length; i++) {
167
+ const dstContextMenuItem = dstContextMenuItems[i];
168
+ if (dstContextMenuItem &&
169
+ dstContextMenuItem.uiactionGroup) {
170
+ const dstUIActionGroup = dstContextMenuItem.uiactionGroup;
171
+ if (dstUIActionGroup) {
172
+ for (let j = 0; j < subAppRefs.length; j++) {
173
+ const srcAppDEUIActionGroup = ibiz.hub.getSubAppDEUIActionGroups(dstUIActionGroup.uniqueTag, subAppRefs[j].appId);
174
+ if (srcAppDEUIActionGroup) {
175
+ mergeAppDEUIActionGroup(dstContextMenuItems[i]
176
+ .uiactionGroup, srcAppDEUIActionGroup);
177
+ const targetDeTreeNode = (_b = dstTree.detreeNodes) === null || _b === void 0 ? void 0 : _b.find(treeNode => {
178
+ return (treeNode.decontextMenu &&
179
+ treeNode.decontextMenu.modelId ===
180
+ dstContextMenu.modelId);
181
+ });
182
+ if (targetDeTreeNode) {
183
+ targetDeTreeNode.decontextMenu = dstContextMenu;
184
+ }
185
+ }
186
+ }
187
+ }
188
+ }
189
+ }
190
+ }
191
+ }
192
+ }
193
+ }
194
+ }
195
+ controls.forEach(control => {
196
+ if (control && control.controls) {
197
+ this.mergeSubAppTreeContextMenuActionGroup(view, control.controls, subAppRefs);
198
+ }
199
+ });
200
+ }
201
+ mergeSubAppTreeView(view, controls, subAppRefs) {
202
+ if (!controls)
203
+ return;
204
+ const dstTree = controls.find(item => {
205
+ return item.controlType === 'TREEVIEW';
206
+ });
207
+ if (dstTree) {
208
+ const ids = dstTree.id.split('.');
209
+ for (let i = 0; i < subAppRefs.length; i++) {
210
+ const srcTree = ibiz.hub.getSubAppControl(ids[1] + ids[2], subAppRefs[i].appId);
211
+ if (srcTree) {
212
+ mergeTreeView(dstTree, srcTree);
213
+ }
214
+ }
215
+ }
216
+ controls.forEach(control => {
217
+ if (control && control.controls) {
218
+ this.mergeSubAppTreeView(view, control.controls, subAppRefs);
219
+ }
220
+ });
221
+ }
222
+ }
@@ -0,0 +1,12 @@
1
+ import { IDETree } from '@ibiz/model-core';
2
+ /**
3
+ * 合并树部件
4
+ *
5
+ * @author tony001
6
+ * @date 2024-09-26 17:09:25
7
+ * @export
8
+ * @param {IDETree} dst
9
+ * @param {IDETree} source
10
+ */
11
+ export declare function mergeTreeView(dst: IDETree, source: IDETree): void;
12
+ //# sourceMappingURL=merge-treeview.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge-treeview.d.ts","sourceRoot":"","sources":["../../../src/utils/merge-model/merge-treeview.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI,CAiCjE"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * 合并树部件
3
+ *
4
+ * @author tony001
5
+ * @date 2024-09-26 17:09:25
6
+ * @export
7
+ * @param {IDETree} dst
8
+ * @param {IDETree} source
9
+ */
10
+ export function mergeTreeView(dst, source) {
11
+ if (!dst || !source)
12
+ return;
13
+ // 合并树节点
14
+ if (source.detreeNodes && source.detreeNodes.length > 0) {
15
+ if (!dst.detreeNodes) {
16
+ dst.detreeNodes = [];
17
+ }
18
+ source.detreeNodes.forEach(sourceNode => {
19
+ var _a;
20
+ const isExist = dst.detreeNodes.find(dstNode => {
21
+ return dstNode.id === sourceNode.id;
22
+ });
23
+ if (!isExist) {
24
+ (_a = dst.detreeNodes) === null || _a === void 0 ? void 0 : _a.push(sourceNode);
25
+ }
26
+ });
27
+ }
28
+ // 合并树节点关系
29
+ if (source.detreeNodeRSs && source.detreeNodeRSs.length > 0) {
30
+ if (!dst.detreeNodeRSs) {
31
+ dst.detreeNodeRSs = [];
32
+ }
33
+ source.detreeNodeRSs.forEach(sourceNodeRs => {
34
+ var _a;
35
+ const isExist = dst.detreeNodeRSs.find(dstNodeRs => {
36
+ return (dstNodeRs.parentDETreeNodeId === sourceNodeRs.parentDETreeNodeId &&
37
+ dstNodeRs.childDETreeNodeId === sourceNodeRs.childDETreeNodeId);
38
+ });
39
+ if (!isExist) {
40
+ (_a = dst.detreeNodeRSs) === null || _a === void 0 ? void 0 : _a.push(sourceNodeRs);
41
+ }
42
+ });
43
+ }
44
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ibiz-template/model-helper",
3
- "version": "0.7.37-alpha.3",
3
+ "version": "0.7.38-alpha.23",
4
4
  "description": "控制器包",
5
5
  "main": "out/index.js",
6
6
  "types": "out/index.d.ts",
@@ -33,13 +33,13 @@
33
33
  "author": "chitanda",
34
34
  "license": "MIT",
35
35
  "dependencies": {
36
- "@ibiz/model-core": "^0.1.53",
37
- "@ibiz/rt-model-api": "^0.2.44",
36
+ "@ibiz/model-core": "^0.1.58",
37
+ "@ibiz/rt-model-api": "0.2.52",
38
38
  "pluralize": "^8.0.0",
39
39
  "ramda": "^0.29.1"
40
40
  },
41
41
  "devDependencies": {
42
- "@ibiz-template/runtime": "^0.7.37-alpha.3",
42
+ "@ibiz-template/runtime": "^0.7.38-alpha.23",
43
43
  "@types/pluralize": "^0.0.33",
44
44
  "@types/ramda": "^0.29.10"
45
45
  },