@farris/jit-engine 1.3.329 → 1.3.331

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 (37) hide show
  1. package/README.md +12 -0
  2. package/lib/domstructure/devkit/viewmodel/component/component.js +221 -221
  3. package/lib/domstructure/devkit/viewmodel/component/component.js.map +1 -1
  4. package/lib/domstructure/devkit/viewmodel/viewmodel.js +135 -134
  5. package/lib/domstructure/devkit/viewmodel/viewmodel.js.map +1 -1
  6. package/lib/domstructure/ui/commands/toolbar.js +47 -45
  7. package/lib/domstructure/ui/commands/toolbar.js.map +1 -1
  8. package/lib/domstructure/ui/section/index.js +14 -14
  9. package/lib/domstructure/ui/section/section-html.js +6 -6
  10. package/lib/domstructure/ui/section/section.js +139 -137
  11. package/lib/domstructure/ui/section/section.js.map +1 -1
  12. package/lib/domstructure/ui/tabs/farris-tabs.js +98 -96
  13. package/lib/domstructure/ui/tabs/farris-tabs.js.map +1 -1
  14. package/lib/utility/config-hepler.js +73 -64
  15. package/lib/utility/config-hepler.js.map +1 -1
  16. package/lib/utility/declaration-trigger.js +304 -294
  17. package/lib/utility/declaration-trigger.js.map +1 -1
  18. package/lib/utility/devkit/component-parameter-collector/toolbar-collector.js +15 -10
  19. package/lib/utility/devkit/component-parameter-collector/toolbar-collector.js.map +1 -1
  20. package/lib/utility/devkit/devkit-creator.js +29 -28
  21. package/lib/utility/devkit/devkit-creator.js.map +1 -1
  22. package/lib/utility/devkit/external-component/external-component-creator.js +2 -1
  23. package/lib/utility/devkit/external-component/external-component-creator.js.map +1 -1
  24. package/lib/utility/devkit/form-file-executor.js +425 -416
  25. package/lib/utility/devkit/form-file-executor.js.map +1 -1
  26. package/lib/utility/devkit/toolbar/toolbar-item.js +2 -2
  27. package/lib/utility/devkit/toolbar/toolbar.js +2 -2
  28. package/lib/utility/devkit/toolbar/toolbaritem-state.js +2 -2
  29. package/lib/utility/template-generator/devkit/component-generator/component-events-parameter-generator.js +112 -112
  30. package/lib/utility/template-generator/devkit/component-generator/component-events-parameter-generator.js.map +1 -1
  31. package/lib/utility/template-generator/devkit/component-generator/component-farristabs-parameter-generator.js +210 -149
  32. package/lib/utility/template-generator/devkit/component-generator/component-farristabs-parameter-generator.js.map +1 -1
  33. package/lib/utility/template-generator/devkit/component-generator/component-section-parameter-generator.js +213 -161
  34. package/lib/utility/template-generator/devkit/component-generator/component-section-parameter-generator.js.map +1 -1
  35. package/lib/utility/template-generator/devkit/component-generator/component-toolbar-parameter-generator.js +219 -219
  36. package/lib/utility/template-generator/devkit/component-generator/component-toolbar-parameter-generator.js.map +1 -1
  37. package/package.json +1 -1
@@ -1,295 +1,305 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DeclarationTrigger = void 0;
4
- const toolhepler_1 = require("./toolhepler");
5
- const logger_helper_1 = require("./logger/logger-helper");
6
- const validate_result_1 = require("./validator/validate-result");
7
- const logger_level_1 = require("./logger/logger-level");
8
- class DeclarationTrigger {
9
- constructor() { }
10
- static getNewInstance() {
11
- return new DeclarationTrigger();
12
- }
13
- modifyComponentCommand(declarations, components, viewModels) {
14
- if (declarations && toolhepler_1.ToolHelper.isArray(declarations.events) == true && toolhepler_1.ToolHelper.isArray(components) == true) {
15
- declarations.events.forEach((declarationEvent) => {
16
- const declarationEventValidateResult = this.declarationEventValidate(declarationEvent);
17
- if (declarationEventValidateResult.success == false && declarationEventValidateResult.canContinue == false) {
18
- throw new Error(declarationEventValidateResult.errorMessage);
19
- }
20
- const isFieldEvent = this.isFieldEvent(declarationEvent);
21
- let declarationPath = isFieldEvent ? declarationEvent.fieldPath : declarationEvent.path;
22
- declarationPath = toolhepler_1.ToolHelper.convertNullToEmpty(declarationPath, declarationEvent.path);
23
- const declarationPathArray = declarationPath.split(".");
24
- if (declarationPathArray.length == 0) {
25
- const errorMessage = `declaration event has none path.the declaration event code is ${declarationEvent.code}`;
26
- logger_helper_1.LoggerHelper.log(errorMessage, logger_level_1.LoggerLevel.Error);
27
- throw new Error(errorMessage);
28
- }
29
- const componentId = declarationPathArray[0];
30
- let selectedComponent;
31
- if (!isFieldEvent) {
32
- selectedComponent = components.find((com) => {
33
- return com.id === componentId;
34
- });
35
- }
36
- else {
37
- selectedComponent = viewModels.find((com) => {
38
- return com.id === componentId;
39
- });
40
- }
41
- let findDom;
42
- if (declarationPathArray.length == 1) {
43
- findDom = selectedComponent;
44
- }
45
- else {
46
- findDom = this.rescureComponent(selectedComponent, 0, declarationPathArray, declarationEvent, isFieldEvent);
47
- }
48
- if (!findDom) {
49
- findDom = this.triggerValue;
50
- }
51
- if (!findDom) {
52
- logger_helper_1.LoggerHelper.log(`can not find element ,the code is :${declarationEvent.code}`, logger_level_1.LoggerLevel.Warning);
53
- }
54
- this.modifyComponentDeclaration(findDom, declarationEvent, isFieldEvent);
55
- });
56
- }
57
- }
58
- isFieldEvent(eventItem) {
59
- if (eventItem && eventItem.type == "fieldEvent") {
60
- return true;
61
- }
62
- return false;
63
- }
64
- rescureComponent(currentValue, pathIndex, declarationPathArray, declaration, isFieldEvent) {
65
- if (!currentValue || pathIndex >= declarationPathArray.length) {
66
- return;
67
- }
68
- const currentFindID = declarationPathArray[pathIndex];
69
- if (currentValue.id == currentFindID) {
70
- if (pathIndex < (declarationPathArray.length - 1)) {
71
- pathIndex = pathIndex + 1;
72
- const nextFindID = declarationPathArray[pathIndex];
73
- if (!isFieldEvent && (currentValue.type == "ToolBar" || toolhepler_1.ToolHelper.getClassName(currentValue) == "ToolBar" || (currentValue.type == "ToolBarItem" && currentValue.items && currentValue.items.length))) {
74
- if (currentValue.items && currentValue.items.length) {
75
- currentValue.items.forEach((content) => {
76
- if (content.id == nextFindID) {
77
- if (pathIndex != declarationPathArray.length - 1) {
78
- this.rescureComponent(content, pathIndex, declarationPathArray, declaration, isFieldEvent);
79
- }
80
- else {
81
- this.triggerValue = content;
82
- return content;
83
- }
84
- }
85
- });
86
- }
87
- }
88
- else if (!isFieldEvent && (currentValue.type == "TabToolbar" || toolhepler_1.ToolHelper.getClassName(currentValue) == "TabToolbar")) {
89
- if (currentValue.contents && currentValue.contents.length) {
90
- currentValue.contents.forEach((content) => {
91
- if (content.id == nextFindID) {
92
- if (pathIndex != declarationPathArray.length - 1) {
93
- this.rescureComponent(content, pathIndex, declarationPathArray, declaration, isFieldEvent);
94
- }
95
- else {
96
- this.triggerValue = content;
97
- return content;
98
- }
99
- }
100
- });
101
- }
102
- }
103
- else if (!isFieldEvent && (currentValue.componentType == "dataGrid")) {
104
- if (currentValue.template && currentValue.template.id == nextFindID) {
105
- if (pathIndex != declarationPathArray.length - 1) {
106
- this.rescureComponent(currentValue.template, pathIndex, declarationPathArray, declaration, isFieldEvent);
107
- }
108
- }
109
- else if (currentValue.contents && currentValue.contents.length) {
110
- currentValue.contents.forEach((content) => {
111
- if (content.id == nextFindID) {
112
- if (pathIndex != declarationPathArray.length - 1) {
113
- this.rescureComponent(content, pathIndex, declarationPathArray, declaration, isFieldEvent);
114
- }
115
- else {
116
- this.triggerValue = content;
117
- return content;
118
- }
119
- }
120
- });
121
- }
122
- }
123
- else if (!isFieldEvent && currentValue.componentType == "Frame") {
124
- if (currentValue.template && currentValue.template.id == nextFindID) {
125
- if (pathIndex != declarationPathArray.length - 1) {
126
- this.rescureComponent(currentValue.template, pathIndex, declarationPathArray, declaration, isFieldEvent);
127
- }
128
- }
129
- else if (currentValue.contents && currentValue.contents.length) {
130
- currentValue.contents.forEach((content) => {
131
- if (content.id == nextFindID) {
132
- if (pathIndex != declarationPathArray.length - 1) {
133
- this.rescureComponent(content, pathIndex, declarationPathArray, declaration, isFieldEvent);
134
- }
135
- else {
136
- this.triggerValue = content;
137
- return content;
138
- }
139
- }
140
- });
141
- }
142
- }
143
- else if (!isFieldEvent && (currentValue.contents && currentValue.contents.length)) {
144
- if (currentValue.type == "TabPage" && currentValue.toolbar && currentValue.toolbar.id == nextFindID) {
145
- this.rescureComponent(currentValue.toolbar, pathIndex, declarationPathArray, declaration, isFieldEvent);
146
- }
147
- else {
148
- currentValue.contents.forEach((content) => {
149
- if (content.id == nextFindID) {
150
- if (pathIndex != declarationPathArray.length - 1) {
151
- this.rescureComponent(content, pathIndex, declarationPathArray, declaration, isFieldEvent);
152
- }
153
- else {
154
- this.triggerValue = content;
155
- return content;
156
- }
157
- }
158
- });
159
- }
160
- }
161
- else if (isFieldEvent && toolhepler_1.ToolHelper.isArray(currentValue.fields, false)) {
162
- currentValue.fields.forEach((fieldItem) => {
163
- if (fieldItem.id == nextFindID) {
164
- if (pathIndex != declarationPathArray.length - 1) {
165
- this.rescureComponent(fieldItem, pathIndex, declarationPathArray, declaration, isFieldEvent);
166
- }
167
- else {
168
- this.triggerValue = fieldItem;
169
- return fieldItem;
170
- }
171
- }
172
- });
173
- }
174
- else {
175
- logger_helper_1.LoggerHelper.log("unknown declaration trigger,please call to administrator", logger_level_1.LoggerLevel.Warning);
176
- }
177
- }
178
- else {
179
- pathIndex = pathIndex + 1;
180
- const nextFindID = declarationPathArray[pathIndex];
181
- if (!isFieldEvent && currentValue.type == "ToolBar") {
182
- if (currentValue.items && currentValue.items.length) {
183
- currentValue.items.forEach((content) => {
184
- if (content.id == nextFindID) {
185
- this.triggerValue = content;
186
- return content;
187
- }
188
- });
189
- }
190
- }
191
- else {
192
- if (!isFieldEvent && (currentValue.contents && currentValue.contents.length)) {
193
- currentValue.contents.forEach((content) => {
194
- if (content.id == nextFindID) {
195
- this.triggerValue = content;
196
- return content;
197
- }
198
- });
199
- }
200
- else if (isFieldEvent && currentValue.fields && currentValue.fields.length) {
201
- currentValue.fields.forEach((fieldItem) => {
202
- if (fieldItem.id == nextFindID) {
203
- this.triggerValue = fieldItem;
204
- return fieldItem;
205
- }
206
- });
207
- }
208
- }
209
- }
210
- }
211
- }
212
- modifyComponentDeclaration(findDom, declaration, isFieldEvent) {
213
- if (findDom && declaration) {
214
- const declarationEvent = declaration.event;
215
- const declarationCode = declaration.code;
216
- const suffixDeclarationEvent = "DeclarationEvents";
217
- let generatedTriggerValue = `this.trigger('${declarationCode.trim()}');`;
218
- if (isFieldEvent) {
219
- generatedTriggerValue = `trigger:${declarationCode.trim()}`;
220
- }
221
- const generatedDeclarationEvent = `${declarationEvent}${suffixDeclarationEvent}`;
222
- let domEventValue = findDom[declarationEvent];
223
- if (declarationEvent == "onInit" || declarationEvent == "afterViewInit") {
224
- if (!findDom[generatedDeclarationEvent]) {
225
- findDom[generatedDeclarationEvent] = [];
226
- }
227
- findDom[generatedDeclarationEvent].push(generatedTriggerValue);
228
- }
229
- else if (declarationEvent == "lookupPicked" || declarationEvent == "lookupPicking") {
230
- if (!findDom[generatedDeclarationEvent]) {
231
- findDom[generatedDeclarationEvent] = [];
232
- }
233
- findDom[generatedDeclarationEvent].push(generatedTriggerValue);
234
- if (declarationEvent == "lookupPicking" && !findDom["lookupPicking"]) {
235
- findDom['lookupPicking'] = `${toolhepler_1.ToolHelper.toCamelCase(toolhepler_1.ToolHelper.tf(findDom["id"]))}LookupPicking`;
236
- findDom["isCreatedByDeclaration"] = true;
237
- }
238
- if (declarationEvent == "lookupPicked" && !findDom["lookupPicked"]) {
239
- findDom['lookupPicked'] = `${toolhepler_1.ToolHelper.toCamelCase(toolhepler_1.ToolHelper.tf(findDom["id"]))}LookupPicked`;
240
- findDom["isCreatedByDeclaration"] = true;
241
- }
242
- }
243
- else if (findDom.type == "ToolBarItem" || toolhepler_1.ToolHelper.getClassName(findDom) == "ToolBarItem") {
244
- if (!findDom[generatedDeclarationEvent]) {
245
- findDom[generatedDeclarationEvent] = [];
246
- }
247
- findDom[generatedDeclarationEvent].push(generatedTriggerValue);
248
- }
249
- else if (declarationEvent == "valueChange") {
250
- if (!findDom[generatedDeclarationEvent]) {
251
- findDom[generatedDeclarationEvent] = [];
252
- }
253
- findDom[generatedDeclarationEvent].push(generatedTriggerValue);
254
- }
255
- else {
256
- if (declarationEvent == "linkedLabelClick" && findDom["linkedLabelEnabled"] == false) {
257
- logger_helper_1.LoggerHelper.log(`${findDom["id"]} linkedLabelEnabled is false, so declaration event use this , not effective!`, logger_level_1.LoggerLevel.Warning);
258
- }
259
- else {
260
- if (domEventValue) {
261
- if (domEventValue.endsWith(";") == false) {
262
- if (!isFieldEvent && domEventValue.endsWith("()") == false) {
263
- domEventValue = domEventValue + "()";
264
- }
265
- domEventValue = domEventValue + ";" + generatedTriggerValue;
266
- }
267
- else {
268
- domEventValue = domEventValue + generatedTriggerValue;
269
- }
270
- findDom[declarationEvent] = domEventValue;
271
- }
272
- else {
273
- findDom[declarationEvent] = generatedTriggerValue;
274
- }
275
- }
276
- }
277
- }
278
- }
279
- declarationEventValidate(declarationEvent) {
280
- const validateResult = new validate_result_1.ValidateResult(true);
281
- if (!declarationEvent.path) {
282
- validateResult.setErrorMessage(`the declaration event has none path value.the declaration event code is ${declarationEvent.code}`);
283
- validateResult.setCanContinue(false);
284
- return validateResult;
285
- }
286
- if (!declarationEvent.event) {
287
- validateResult.setCanContinue(false);
288
- validateResult.setErrorMessage(`the declaration event has none event value.the declaration event code is ${declarationEvent.code}`);
289
- return validateResult;
290
- }
291
- return validateResult;
292
- }
293
- }
294
- exports.DeclarationTrigger = DeclarationTrigger;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DeclarationTrigger = void 0;
4
+ const toolhepler_1 = require("./toolhepler");
5
+ const logger_helper_1 = require("./logger/logger-helper");
6
+ const validate_result_1 = require("./validator/validate-result");
7
+ const logger_level_1 = require("./logger/logger-level");
8
+ class DeclarationTrigger {
9
+ constructor() { }
10
+ static getNewInstance() {
11
+ return new DeclarationTrigger();
12
+ }
13
+ modifyComponentCommand(declarations, components, toolbar, viewModels) {
14
+ if (declarations && toolhepler_1.ToolHelper.isArray(declarations.events) == true && toolhepler_1.ToolHelper.isArray(components) == true) {
15
+ declarations.events.forEach((declarationEvent) => {
16
+ const declarationEventValidateResult = this.declarationEventValidate(declarationEvent);
17
+ if (declarationEventValidateResult.success == false && declarationEventValidateResult.canContinue == false) {
18
+ throw new Error(declarationEventValidateResult.errorMessage);
19
+ }
20
+ const isFieldEvent = this.isFieldEvent(declarationEvent);
21
+ let declarationPath = isFieldEvent ? declarationEvent.fieldPath : declarationEvent.path;
22
+ declarationPath = toolhepler_1.ToolHelper.convertNullToEmpty(declarationPath, declarationEvent.path);
23
+ const declarationPathArray = declarationPath.split(".");
24
+ if (declarationPathArray.length == 0) {
25
+ const errorMessage = `declaration event has none path.the declaration event code is ${declarationEvent.code}`;
26
+ logger_helper_1.LoggerHelper.log(errorMessage, logger_level_1.LoggerLevel.Error);
27
+ throw new Error(errorMessage);
28
+ }
29
+ const componentId = declarationPathArray[0];
30
+ let selectedComponent;
31
+ if (!isFieldEvent) {
32
+ selectedComponent = components.find((com) => {
33
+ return com.id === componentId;
34
+ });
35
+ }
36
+ else {
37
+ selectedComponent = viewModels.find((com) => {
38
+ return com.id === componentId;
39
+ });
40
+ }
41
+ let findDom;
42
+ if (declarationPathArray.length == 1) {
43
+ findDom = selectedComponent;
44
+ }
45
+ else {
46
+ this.dealWithSpecialButton(selectedComponent, declarationPathArray, toolbar);
47
+ findDom = this.rescureComponent(selectedComponent, 0, declarationPathArray, declarationEvent, isFieldEvent);
48
+ }
49
+ if (!findDom) {
50
+ findDom = this.triggerValue;
51
+ }
52
+ if (!findDom) {
53
+ logger_helper_1.LoggerHelper.log(`can not find element ,the code is :${declarationEvent.code}`, logger_level_1.LoggerLevel.Warning);
54
+ }
55
+ this.modifyComponentDeclaration(findDom, declarationEvent, isFieldEvent);
56
+ });
57
+ }
58
+ }
59
+ isFieldEvent(eventItem) {
60
+ if (eventItem && eventItem.type == "fieldEvent") {
61
+ return true;
62
+ }
63
+ return false;
64
+ }
65
+ rescureComponent(currentValue, pathIndex, declarationPathArray, declaration, isFieldEvent) {
66
+ if (!currentValue || pathIndex >= declarationPathArray.length) {
67
+ return;
68
+ }
69
+ const currentFindID = declarationPathArray[pathIndex];
70
+ if (currentValue.id == currentFindID) {
71
+ if (pathIndex < (declarationPathArray.length - 1)) {
72
+ pathIndex = pathIndex + 1;
73
+ const nextFindID = declarationPathArray[pathIndex];
74
+ if (!isFieldEvent && (currentValue.type == "ToolBar" || toolhepler_1.ToolHelper.getClassName(currentValue) == "ToolBar" || (currentValue.type == "ToolBarItem" && currentValue.items && currentValue.items.length))) {
75
+ if (currentValue.items && currentValue.items.length) {
76
+ currentValue.items.forEach((content) => {
77
+ if (content.id == nextFindID) {
78
+ if (pathIndex != declarationPathArray.length - 1) {
79
+ this.rescureComponent(content, pathIndex, declarationPathArray, declaration, isFieldEvent);
80
+ }
81
+ else {
82
+ this.triggerValue = content;
83
+ return content;
84
+ }
85
+ }
86
+ });
87
+ }
88
+ }
89
+ else if (!isFieldEvent && (currentValue.type == "TabToolbar" || toolhepler_1.ToolHelper.getClassName(currentValue) == "TabToolbar")) {
90
+ if (currentValue.contents && currentValue.contents.length) {
91
+ currentValue.contents.forEach((content) => {
92
+ if (content.id == nextFindID) {
93
+ if (pathIndex != declarationPathArray.length - 1) {
94
+ this.rescureComponent(content, pathIndex, declarationPathArray, declaration, isFieldEvent);
95
+ }
96
+ else {
97
+ this.triggerValue = content;
98
+ return content;
99
+ }
100
+ }
101
+ });
102
+ }
103
+ }
104
+ else if (!isFieldEvent && (currentValue.componentType == "dataGrid")) {
105
+ if (currentValue.template && currentValue.template.id == nextFindID) {
106
+ if (pathIndex != declarationPathArray.length - 1) {
107
+ this.rescureComponent(currentValue.template, pathIndex, declarationPathArray, declaration, isFieldEvent);
108
+ }
109
+ }
110
+ else if (currentValue.contents && currentValue.contents.length) {
111
+ currentValue.contents.forEach((content) => {
112
+ if (content.id == nextFindID) {
113
+ if (pathIndex != declarationPathArray.length - 1) {
114
+ this.rescureComponent(content, pathIndex, declarationPathArray, declaration, isFieldEvent);
115
+ }
116
+ else {
117
+ this.triggerValue = content;
118
+ return content;
119
+ }
120
+ }
121
+ });
122
+ }
123
+ }
124
+ else if (!isFieldEvent && currentValue.componentType == "Frame") {
125
+ if (currentValue.template && currentValue.template.id == nextFindID) {
126
+ if (pathIndex != declarationPathArray.length - 1) {
127
+ this.rescureComponent(currentValue.template, pathIndex, declarationPathArray, declaration, isFieldEvent);
128
+ }
129
+ }
130
+ else if (currentValue.contents && currentValue.contents.length) {
131
+ currentValue.contents.forEach((content) => {
132
+ if (content.id == nextFindID) {
133
+ if (pathIndex != declarationPathArray.length - 1) {
134
+ this.rescureComponent(content, pathIndex, declarationPathArray, declaration, isFieldEvent);
135
+ }
136
+ else {
137
+ this.triggerValue = content;
138
+ return content;
139
+ }
140
+ }
141
+ });
142
+ }
143
+ }
144
+ else if (!isFieldEvent && (currentValue.contents && currentValue.contents.length)) {
145
+ if (currentValue.type == "TabPage" && currentValue.toolbar && currentValue.toolbar.id == nextFindID) {
146
+ this.rescureComponent(currentValue.toolbar, pathIndex, declarationPathArray, declaration, isFieldEvent);
147
+ }
148
+ else {
149
+ currentValue.contents.forEach((content) => {
150
+ if (content.id == nextFindID) {
151
+ if (pathIndex != declarationPathArray.length - 1) {
152
+ this.rescureComponent(content, pathIndex, declarationPathArray, declaration, isFieldEvent);
153
+ }
154
+ else {
155
+ this.triggerValue = content;
156
+ return content;
157
+ }
158
+ }
159
+ });
160
+ }
161
+ }
162
+ else if (isFieldEvent && toolhepler_1.ToolHelper.isArray(currentValue.fields, false)) {
163
+ currentValue.fields.forEach((fieldItem) => {
164
+ if (fieldItem.id == nextFindID) {
165
+ if (pathIndex != declarationPathArray.length - 1) {
166
+ this.rescureComponent(fieldItem, pathIndex, declarationPathArray, declaration, isFieldEvent);
167
+ }
168
+ else {
169
+ this.triggerValue = fieldItem;
170
+ return fieldItem;
171
+ }
172
+ }
173
+ });
174
+ }
175
+ else {
176
+ logger_helper_1.LoggerHelper.log("unknown declaration trigger,please call to administrator", logger_level_1.LoggerLevel.Warning);
177
+ }
178
+ }
179
+ else {
180
+ pathIndex = pathIndex + 1;
181
+ const nextFindID = declarationPathArray[pathIndex];
182
+ if (!isFieldEvent && currentValue.type == "ToolBar") {
183
+ if (currentValue.items && currentValue.items.length) {
184
+ currentValue.items.forEach((content) => {
185
+ if (content.id == nextFindID) {
186
+ this.triggerValue = content;
187
+ return content;
188
+ }
189
+ });
190
+ }
191
+ }
192
+ else {
193
+ if (!isFieldEvent && (currentValue.contents && currentValue.contents.length)) {
194
+ currentValue.contents.forEach((content) => {
195
+ if (content.id == nextFindID) {
196
+ this.triggerValue = content;
197
+ return content;
198
+ }
199
+ });
200
+ }
201
+ else if (isFieldEvent && currentValue.fields && currentValue.fields.length) {
202
+ currentValue.fields.forEach((fieldItem) => {
203
+ if (fieldItem.id == nextFindID) {
204
+ this.triggerValue = fieldItem;
205
+ return fieldItem;
206
+ }
207
+ });
208
+ }
209
+ }
210
+ }
211
+ }
212
+ }
213
+ modifyComponentDeclaration(findDom, declaration, isFieldEvent) {
214
+ if (findDom && declaration) {
215
+ const declarationEvent = declaration.event;
216
+ const declarationCode = declaration.code;
217
+ const suffixDeclarationEvent = "DeclarationEvents";
218
+ let generatedTriggerValue = `this.trigger('${declarationCode.trim()}');`;
219
+ if (isFieldEvent) {
220
+ generatedTriggerValue = `trigger:${declarationCode.trim()}`;
221
+ }
222
+ const generatedDeclarationEvent = `${declarationEvent}${suffixDeclarationEvent}`;
223
+ let domEventValue = findDom[declarationEvent];
224
+ if (declarationEvent == "onInit" || declarationEvent == "afterViewInit") {
225
+ if (!findDom[generatedDeclarationEvent]) {
226
+ findDom[generatedDeclarationEvent] = [];
227
+ }
228
+ findDom[generatedDeclarationEvent].push(generatedTriggerValue);
229
+ }
230
+ else if (declarationEvent == "lookupPicked" || declarationEvent == "lookupPicking") {
231
+ if (!findDom[generatedDeclarationEvent]) {
232
+ findDom[generatedDeclarationEvent] = [];
233
+ }
234
+ findDom[generatedDeclarationEvent].push(generatedTriggerValue);
235
+ if (declarationEvent == "lookupPicking" && !findDom["lookupPicking"]) {
236
+ findDom['lookupPicking'] = `${toolhepler_1.ToolHelper.toCamelCase(toolhepler_1.ToolHelper.tf(findDom["id"]))}LookupPicking`;
237
+ findDom["isCreatedByDeclaration"] = true;
238
+ }
239
+ if (declarationEvent == "lookupPicked" && !findDom["lookupPicked"]) {
240
+ findDom['lookupPicked'] = `${toolhepler_1.ToolHelper.toCamelCase(toolhepler_1.ToolHelper.tf(findDom["id"]))}LookupPicked`;
241
+ findDom["isCreatedByDeclaration"] = true;
242
+ }
243
+ }
244
+ else if (findDom.type == "ToolBarItem" || toolhepler_1.ToolHelper.getClassName(findDom) == "ToolBarItem") {
245
+ if (!findDom[generatedDeclarationEvent]) {
246
+ findDom[generatedDeclarationEvent] = [];
247
+ }
248
+ findDom[generatedDeclarationEvent].push(generatedTriggerValue);
249
+ }
250
+ else if (declarationEvent == "valueChange") {
251
+ if (!findDom[generatedDeclarationEvent]) {
252
+ findDom[generatedDeclarationEvent] = [];
253
+ }
254
+ findDom[generatedDeclarationEvent].push(generatedTriggerValue);
255
+ }
256
+ else {
257
+ if (declarationEvent == "linkedLabelClick" && findDom["linkedLabelEnabled"] == false) {
258
+ logger_helper_1.LoggerHelper.log(`${findDom["id"]} linkedLabelEnabled is false, so declaration event use this , not effective!`, logger_level_1.LoggerLevel.Warning);
259
+ }
260
+ else {
261
+ if (domEventValue) {
262
+ if (domEventValue.endsWith(";") == false) {
263
+ if (!isFieldEvent && domEventValue.endsWith("()") == false) {
264
+ domEventValue = domEventValue + "()";
265
+ }
266
+ domEventValue = domEventValue + ";" + generatedTriggerValue;
267
+ }
268
+ else {
269
+ domEventValue = domEventValue + generatedTriggerValue;
270
+ }
271
+ findDom[declarationEvent] = domEventValue;
272
+ }
273
+ else {
274
+ findDom[declarationEvent] = generatedTriggerValue;
275
+ }
276
+ }
277
+ }
278
+ }
279
+ }
280
+ declarationEventValidate(declarationEvent) {
281
+ const validateResult = new validate_result_1.ValidateResult(true);
282
+ if (!declarationEvent.path) {
283
+ validateResult.setErrorMessage(`the declaration event has none path value.the declaration event code is ${declarationEvent.code}`);
284
+ validateResult.setCanContinue(false);
285
+ return validateResult;
286
+ }
287
+ if (!declarationEvent.event) {
288
+ validateResult.setCanContinue(false);
289
+ validateResult.setErrorMessage(`the declaration event has none event value.the declaration event code is ${declarationEvent.code}`);
290
+ return validateResult;
291
+ }
292
+ return validateResult;
293
+ }
294
+ dealWithSpecialButton(selectedComponent, declarationPathArray, toolbar) {
295
+ if (toolbar.items && toolbar.items[selectedComponent.viewModel] && toolbar.items[selectedComponent.viewModel].length > 0) {
296
+ toolbar.items[selectedComponent.viewModel].forEach((item) => {
297
+ if (item.id == declarationPathArray.slice(-1)[0]) {
298
+ this.triggerValue = item;
299
+ }
300
+ });
301
+ }
302
+ }
303
+ }
304
+ exports.DeclarationTrigger = DeclarationTrigger;
295
305
  //# sourceMappingURL=declaration-trigger.js.map