@processmaker/screen-builder 3.8.10 → 3.8.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@processmaker/screen-builder",
3
- "version": "3.8.10",
3
+ "version": "3.8.12",
4
4
  "scripts": {
5
5
  "dev": "VITE_COVERAGE=true vite",
6
6
  "build": "vite build",
@@ -531,6 +531,7 @@ export default {
531
531
  const url = `?user_id=${this.userId}&status=ACTIVE&process_request_id=${requestId}&include_sub_tasks=1${timestamp}`;
532
532
  return this.$dataProvider
533
533
  .getTasks(url).then((response) => {
534
+ this.$emit("load-data-task", response);
534
535
  if (response.data.data.length > 0) {
535
536
  let task = response.data.data[0];
536
537
  if (task.process_request_id !== this.requestId) {
@@ -489,7 +489,7 @@ export default [
489
489
  varname: 'dynamic_panel',
490
490
  indexName: '',
491
491
  add: false,
492
- emptyStateMessage: 'No data available for this dynamic panel',
492
+ emptyStateMessage: 'No data available. Please configure an Index Name for this dynamic panel.',
493
493
  },
494
494
  },
495
495
  inspector: [
@@ -8,25 +8,13 @@ export default {
8
8
  };
9
9
  },
10
10
  methods: {
11
- loadFormDynamicPanelProperties({ properties, element }) {
12
- const variableName = element.config.settings.varname;
13
- const index = element.config.settings.indexName;
14
-
15
- // Add itemData to the properties of FormDynamicPanel
16
- properties[':itemData'] = `${variableName} && ${variableName}[${index}]`;
17
-
18
- // Add emptyStateMessage property if configured
19
- if (element.config.settings.emptyStateMessage) {
20
- properties[':emptyStateMessage'] = this.byRef(element.config.settings.emptyStateMessage);
21
- }
22
-
23
- // Add validationData for Mustache processing
24
- properties[':validationData'] = 'getValidationData()';
25
-
26
- this.registerVariable(element.config.settings.varname, element);
27
- },
28
- loadFormDynamicPanelItems({ element, node, definition }) {
29
- const nested = {
11
+ /**
12
+ * Builds the nested configuration for dynamic panel items
13
+ * @param {Object} element - The dynamic panel element
14
+ * @returns {Object} The nested configuration
15
+ */
16
+ buildNestedConfig(element) {
17
+ return {
30
18
  config: [
31
19
  {
32
20
  items: element.items,
@@ -35,21 +23,155 @@ export default {
35
23
  watchers: [],
36
24
  isMobile: false
37
25
  };
26
+ },
38
27
 
28
+ /**
29
+ * Creates expressions for value and loop context based on index availability
30
+ * @param {string} variableName - The variable name
31
+ * @param {string} index - The index name
32
+ * @returns {Object} Object containing valueExpression and loopContextExpression
33
+ */
34
+ buildExpressions(variableName, index) {
35
+ if (index && index.trim()) {
36
+ return {
37
+ valueExpression: `${variableName} && ${variableName}[${index}]`,
38
+ loopContextExpression: `'${variableName} && ${variableName}[${index}]'`
39
+ };
40
+ }
41
+
42
+ return {
43
+ valueExpression: variableName,
44
+ loopContextExpression: `'${variableName}'`
45
+ };
46
+ },
39
47
 
40
- const variableName = element.config.settings.varname;
41
- const index = element.config.settings.indexName;
42
-
43
- // Add nested component inside dynamic panel
44
- const child = this.createComponent("ScreenRenderer", {
48
+ /**
49
+ * Creates a ScreenRenderer component for the dynamic panel
50
+ * @param {Object} nested - The nested configuration
51
+ * @param {string} valueExpression - The value expression
52
+ * @param {string} loopContextExpression - The loop context expression
53
+ * @param {Object} definition - The definition object
54
+ * @returns {Object} The created component
55
+ */
56
+ createScreenRenderer(nested, valueExpression, loopContextExpression, definition) {
57
+ return this.createComponent("ScreenRenderer", {
45
58
  ":definition": this.byRef(nested),
46
- ":value": `${variableName} && ${variableName}[${index}]`,
47
- ":loop-context": `'${variableName} && ${variableName}[${index}]'`,
59
+ ":value": valueExpression,
60
+ ":loop-context": loopContextExpression,
48
61
  ":_parent": "getValidationData()",
49
62
  ":components": this.byRef(this.components),
50
63
  ":config-ref": this.byRef(this.configRef || definition.config),
51
64
  "@submit": "submitForm"
52
65
  });
66
+ },
67
+
68
+ /**
69
+ * Builds the itemData property based on variable name and index
70
+ * @param {string} variableName - The variable name
71
+ * @param {string} index - The index name
72
+ * @returns {string} The itemData expression
73
+ */
74
+ buildItemDataExpression(variableName, index) {
75
+ if (index && index.trim()) {
76
+ return `${variableName} && ${variableName}[${index}]`;
77
+ }
78
+ return variableName;
79
+ },
80
+
81
+ /**
82
+ * Gets a helpful empty state message based on whether index is configured
83
+ * @param {string} index - The index name
84
+ * @param {string} customMessage - Custom message from settings
85
+ * @returns {string} The appropriate empty state message
86
+ */
87
+ getEmptyStateMessage(index, customMessage) {
88
+ if (customMessage) {
89
+ return customMessage;
90
+ }
91
+
92
+ if (!index || !index.trim()) {
93
+ console.warn('FormDynamicPanel: No Index Name configured. The dynamic panel will not function properly without an index.');
94
+ return 'No data available. Please configure an Index Name for this dynamic panel.';
95
+ }
96
+
97
+ return 'No data available for this dynamic panel.';
98
+ },
99
+
100
+ /**
101
+ * Validates that required settings are present
102
+ * @param {Object} element - The dynamic panel element
103
+ * @returns {boolean} True if valid, false otherwise
104
+ */
105
+ validateElementSettings(element) {
106
+ if (!element.config || !element.config.settings) {
107
+ console.warn('FormDynamicPanel: Missing config or settings');
108
+ return false;
109
+ }
110
+
111
+ if (!element.config.settings.varname) {
112
+ console.warn('FormDynamicPanel: Missing varname setting');
113
+ return false;
114
+ }
115
+
116
+ return true;
117
+ },
118
+
119
+ /**
120
+ * Safely extracts settings from element with validation
121
+ * @param {Object} element - The dynamic panel element
122
+ * @returns {Object|null} Settings object or null if invalid
123
+ */
124
+ extractValidatedSettings(element) {
125
+ if (!this.validateElementSettings(element)) {
126
+ return null;
127
+ }
128
+
129
+ return {
130
+ variableName: element.config.settings.varname,
131
+ index: element.config.settings.indexName || '',
132
+ emptyStateMessage: element.config.settings.emptyStateMessage
133
+ };
134
+ },
135
+
136
+ /**
137
+ * Loads the properties for the FormDynamicPanel
138
+ * @param {Object} params - The parameters object
139
+ */
140
+ loadFormDynamicPanelProperties({ properties, element }) {
141
+ const settings = this.extractValidatedSettings(element);
142
+ if (!settings) {
143
+ return;
144
+ }
145
+
146
+ // Add itemData to the properties of FormDynamicPanel
147
+ properties[':itemData'] = this.buildItemDataExpression(settings.variableName, settings.index);
148
+
149
+ // Add emptyStateMessage property with helpful default
150
+ const emptyStateMessage = this.getEmptyStateMessage(settings.index, settings.emptyStateMessage);
151
+ properties[':emptyStateMessage'] = this.byRef(emptyStateMessage);
152
+
153
+ // Add validationData for Mustache processing
154
+ properties[':validationData'] = 'getValidationData()';
155
+
156
+ this.registerVariable(settings.variableName, element);
157
+ },
158
+ /**
159
+ * Loads the items for the FormDynamicPanel
160
+ * @param {Object} params - The parameters object
161
+ */
162
+ loadFormDynamicPanelItems({ element, node, definition }) {
163
+ const settings = this.extractValidatedSettings(element);
164
+ if (!settings) {
165
+ return;
166
+ }
167
+
168
+ const nested = this.buildNestedConfig(element);
169
+
170
+ // Build expressions based on index availability
171
+ const { valueExpression, loopContextExpression } = this.buildExpressions(settings.variableName, settings.index);
172
+
173
+ // Create and add the ScreenRenderer component
174
+ const child = this.createScreenRenderer(nested, valueExpression, loopContextExpression, definition);
53
175
  node.appendChild(child);
54
176
  }
55
177
  },