datastake-daf 0.6.101 → 0.6.102
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/dist/components/index.css +1 -1
- package/dist/components/index.js +2700 -207
- package/package.json +1 -1
- package/src/@daf/core/components/EditForm/components/AjaxSubGroup/index.js +0 -2
- package/src/@daf/core/components/PdfForm/components/AjaxSubGroup.js +106 -0
- package/src/@daf/core/components/PdfForm/components/ajaxSubGroupHandler.js +12 -0
- package/src/@daf/core/components/PdfForm/components/dataLinkGroupHandler.js +24 -15
- package/src/@daf/core/components/PdfForm/components/dataLinkHandler.js +51 -17
- package/src/@daf/core/components/PdfForm/index.js +208 -22
- package/src/@daf/core/components/PdfForm/storyConfig.js +464 -163
- package/src/@daf/core/components/PdfForm/style.scss +145 -3
- package/src/@daf/core/components/PdfForm/utils/fieldData.js +82 -3
- package/src/@daf/core/components/PdfForm/utils/fieldRenderer.js +14 -6
- package/src/@daf/core/components/_style.scss +1 -2
- package/src/index.js +0 -1
- package/src/@daf/core/components/ProgressTabs/ProgressTabs.stories.js +0 -118
- package/src/@daf/core/components/ProgressTabs/_index.scss +0 -100
- package/src/@daf/core/components/ProgressTabs/demo.jsx +0 -167
- package/src/@daf/core/components/ProgressTabs/index.jsx +0 -69
|
@@ -12,14 +12,26 @@ import './style.scss';
|
|
|
12
12
|
import { resolveDynamicLabel } from './utils.js';
|
|
13
13
|
import { findOptions } from '../../../../helpers/StringHelper.js';
|
|
14
14
|
import GroupInputsHandler from './components/groupInputsHandler.js';
|
|
15
|
+
import { handleAjaxSubGroupChildren } from './components/ajaxSubGroupHandler.js';
|
|
16
|
+
import { evaluateShowIfCondition } from './utils/fieldData.js';
|
|
15
17
|
|
|
16
18
|
const TreeNode = ({ nodeKey, config, value, level = 0, isLast = false, t, rootForm, allData, user, getApiBaseUrl = () => {}, getAppHeader = () => {}, app }) => {
|
|
17
|
-
|
|
19
|
+
if (config.showIf && !evaluateShowIfCondition(config.showIf, allData)) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const hasMetaComment = level <= 2 && allData?.meta?.[nodeKey]?.comment;
|
|
24
|
+
|
|
25
|
+
const originalHasChildren = determineHasChildren({ config, level });
|
|
26
|
+
const hasChildren = originalHasChildren || hasMetaComment;
|
|
27
|
+
|
|
18
28
|
const label = resolveDynamicLabel(config?.label, allData || value, nodeKey);
|
|
19
29
|
const nodeType = config?.type || 'field';
|
|
20
30
|
|
|
21
|
-
let renderNodeValue = () => renderValue({ value, hasChildren, config, user, getApiBaseUrl, getAppHeader, app });
|
|
22
|
-
|
|
31
|
+
let renderNodeValue = () => renderValue({ value, hasChildren: originalHasChildren, config, user, getApiBaseUrl, getAppHeader, app });
|
|
32
|
+
if(nodeKey === 'keyIncidents') {
|
|
33
|
+
console.log({config, value, hasChildren})
|
|
34
|
+
}
|
|
23
35
|
|
|
24
36
|
const renderChildren = () => {
|
|
25
37
|
if (!hasChildren) return null;
|
|
@@ -39,11 +51,27 @@ const TreeNode = ({ nodeKey, config, value, level = 0, isLast = false, t, rootFo
|
|
|
39
51
|
TreeNodeComponent: TreeNode
|
|
40
52
|
});
|
|
41
53
|
|
|
42
|
-
if (
|
|
54
|
+
if (config.type === 'ajaxSubGroup') {
|
|
55
|
+
const ajaxSubGroupChildren = handleAjaxSubGroupChildren({
|
|
56
|
+
config,
|
|
57
|
+
value,
|
|
58
|
+
allData,
|
|
59
|
+
level,
|
|
60
|
+
t,
|
|
61
|
+
rootForm,
|
|
62
|
+
user,
|
|
63
|
+
app,
|
|
64
|
+
getApiBaseUrl,
|
|
65
|
+
getAppHeader,
|
|
66
|
+
TreeNodeComponent: TreeNode
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
if (ajaxSubGroupChildren) {
|
|
70
|
+
children = ajaxSubGroupChildren;
|
|
71
|
+
}
|
|
72
|
+
} else if (sectionChildren) {
|
|
43
73
|
children = sectionChildren;
|
|
44
|
-
} else if (config.type === '
|
|
45
|
-
console.log({value})
|
|
46
|
-
} else if (config.type === 'dataLink' && config?.meta?.tableKeys && !config.inputs) {
|
|
74
|
+
} else if (config.type === 'dataLink') {
|
|
47
75
|
const singleDataLinkChildren = handleDataLinkWithTableKeys({
|
|
48
76
|
inputConfig: config,
|
|
49
77
|
inputKey: nodeKey,
|
|
@@ -64,11 +92,20 @@ const TreeNode = ({ nodeKey, config, value, level = 0, isLast = false, t, rootFo
|
|
|
64
92
|
}
|
|
65
93
|
} else if (config?.inputs) {
|
|
66
94
|
if (config.type === 'dataLinkGroup' || config.type === 'dataLink') {
|
|
67
|
-
const inputKeys = Object.keys(config.inputs)
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
95
|
+
const inputKeys = Object.keys(config.inputs)
|
|
96
|
+
.filter(inputKey => {
|
|
97
|
+
const inputConfig = config.inputs[inputKey];
|
|
98
|
+
// Check showIf condition for input
|
|
99
|
+
if (inputConfig?.showIf && !evaluateShowIfCondition(inputConfig.showIf, allData)) {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
return true;
|
|
103
|
+
})
|
|
104
|
+
.sort((a, b) => {
|
|
105
|
+
const positionA = config.inputs[a]?.position || 0;
|
|
106
|
+
const positionB = config.inputs[b]?.position || 0;
|
|
107
|
+
return positionA - positionB;
|
|
108
|
+
});
|
|
72
109
|
|
|
73
110
|
children = inputKeys.map((inputKey, index, array) => {
|
|
74
111
|
const inputConfig = config.inputs[inputKey];
|
|
@@ -153,11 +190,20 @@ const TreeNode = ({ nodeKey, config, value, level = 0, isLast = false, t, rootFo
|
|
|
153
190
|
if (arrayChildren) {
|
|
154
191
|
children = arrayChildren;
|
|
155
192
|
} else {
|
|
156
|
-
const inputKeys = Object.keys(config.inputs)
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
193
|
+
const inputKeys = Object.keys(config.inputs)
|
|
194
|
+
.filter(inputKey => {
|
|
195
|
+
const inputConfig = config.inputs[inputKey];
|
|
196
|
+
// Check showIf condition for input
|
|
197
|
+
if (inputConfig?.showIf && !evaluateShowIfCondition(inputConfig.showIf, allData)) {
|
|
198
|
+
return false;
|
|
199
|
+
}
|
|
200
|
+
return true;
|
|
201
|
+
})
|
|
202
|
+
.sort((a, b) => {
|
|
203
|
+
const positionA = config.inputs[a]?.position || 0;
|
|
204
|
+
const positionB = config.inputs[b]?.position || 0;
|
|
205
|
+
return positionA - positionB;
|
|
206
|
+
});
|
|
161
207
|
|
|
162
208
|
children = inputKeys.map((inputKey, index, array) => {
|
|
163
209
|
const inputConfig = config.inputs[inputKey];
|
|
@@ -208,6 +254,37 @@ const TreeNode = ({ nodeKey, config, value, level = 0, isLast = false, t, rootFo
|
|
|
208
254
|
}
|
|
209
255
|
}
|
|
210
256
|
|
|
257
|
+
// Ensure children is always an array before adding meta comment
|
|
258
|
+
if (!Array.isArray(children)) {
|
|
259
|
+
children = children ? [children] : [];
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// Add meta comment as a child if it exists
|
|
263
|
+
if (hasMetaComment) {
|
|
264
|
+
const commentChild = (
|
|
265
|
+
<TreeNode
|
|
266
|
+
key={`${nodeKey}-comment`}
|
|
267
|
+
nodeKey="comment"
|
|
268
|
+
config={{
|
|
269
|
+
label: "Comment",
|
|
270
|
+
type: "field",
|
|
271
|
+
meta: { isComment: true } // Add a marker to identify this as a comment
|
|
272
|
+
}}
|
|
273
|
+
value={allData.meta[nodeKey].comment}
|
|
274
|
+
level={level + 1}
|
|
275
|
+
isLast={children.length === 0} // This will be the last child if no other children
|
|
276
|
+
t={t}
|
|
277
|
+
rootForm={rootForm}
|
|
278
|
+
allData={allData}
|
|
279
|
+
user={user}
|
|
280
|
+
app={app}
|
|
281
|
+
getApiBaseUrl={getApiBaseUrl}
|
|
282
|
+
getAppHeader={getAppHeader}
|
|
283
|
+
/>
|
|
284
|
+
);
|
|
285
|
+
children.push(commentChild);
|
|
286
|
+
}
|
|
287
|
+
|
|
211
288
|
return (
|
|
212
289
|
<div className="tree-children">
|
|
213
290
|
{children}
|
|
@@ -221,7 +298,7 @@ const TreeNode = ({ nodeKey, config, value, level = 0, isLast = false, t, rootFo
|
|
|
221
298
|
};
|
|
222
299
|
}
|
|
223
300
|
return (
|
|
224
|
-
<div className={`tree-node level-${level} ${hasChildren ? 'parent' : 'leaf'} ${isLast ? 'last' : ''}`}>
|
|
301
|
+
<div className={`tree-node level-${level} ${hasChildren ? 'parent' : 'leaf'} ${isLast ? 'last' : ''} ${nodeKey === 'comment' ? 'comment-node' : ''}`}>
|
|
225
302
|
<div className="tree-node-content">
|
|
226
303
|
<div className="tree-indent">
|
|
227
304
|
{Array.from({ length: level }, (_, i) => (
|
|
@@ -230,7 +307,7 @@ const TreeNode = ({ nodeKey, config, value, level = 0, isLast = false, t, rootFo
|
|
|
230
307
|
</div>
|
|
231
308
|
|
|
232
309
|
<div className="tree-node-title">
|
|
233
|
-
<span className=
|
|
310
|
+
<span className={`tree-label ${nodeKey === 'comment' ? 'comment-label' : ''}`}>{label}{!hasChildren && renderNodeValue() && !label.endsWith('?') ? ':' : ''}</span>
|
|
234
311
|
<div className="tree-value-container">
|
|
235
312
|
{renderNodeValue()}
|
|
236
313
|
</div>
|
|
@@ -269,6 +346,11 @@ const PdfFormContent = ({
|
|
|
269
346
|
<div className="pdf-tree">
|
|
270
347
|
{Object.keys(form)
|
|
271
348
|
.filter(sectionKey => {
|
|
349
|
+
const section = form[sectionKey];
|
|
350
|
+
// Check if section should be shown based on showIf condition
|
|
351
|
+
if (section?.showIf && !evaluateShowIfCondition(section.showIf, data)) {
|
|
352
|
+
return false;
|
|
353
|
+
}
|
|
272
354
|
return !(sectionKey === 'id' || sectionKey === 'label' || sectionKey === 'position' || sectionKey === 'subTitle');
|
|
273
355
|
})
|
|
274
356
|
.sort((a, b) => {
|
|
@@ -321,11 +403,115 @@ const PdfForm = ({
|
|
|
321
403
|
getAppHeader = () => {},
|
|
322
404
|
app
|
|
323
405
|
}) => {
|
|
406
|
+
// Group objects under headers based on position
|
|
407
|
+
const organizeFormByHeaders = (formData) => {
|
|
408
|
+
const organizedSections = {};
|
|
409
|
+
|
|
410
|
+
Object.keys(formData).forEach((sectionKey) => {
|
|
411
|
+
const section = formData[sectionKey];
|
|
412
|
+
|
|
413
|
+
if (typeof section !== 'object' || !section.label) {
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
// Get all objects from this section and sort by position
|
|
418
|
+
const allObjects = Object.keys(section)
|
|
419
|
+
.filter(key => {
|
|
420
|
+
return !(key === 'id' || key === 'label' || key === 'position' || key === 'subTitle');
|
|
421
|
+
})
|
|
422
|
+
.map(key => ({
|
|
423
|
+
key,
|
|
424
|
+
...section[key]
|
|
425
|
+
}))
|
|
426
|
+
.sort((a, b) => {
|
|
427
|
+
const positionA = a.position || 0;
|
|
428
|
+
const positionB = b.position || 0;
|
|
429
|
+
return positionA - positionB;
|
|
430
|
+
});
|
|
431
|
+
|
|
432
|
+
// Identify headers and regular objects
|
|
433
|
+
const headers = allObjects.filter(obj => obj.type === 'header');
|
|
434
|
+
const nonHeaders = allObjects.filter(obj => obj.type !== 'header');
|
|
435
|
+
|
|
436
|
+
if (headers.length === 0) {
|
|
437
|
+
// No headers found, keep original structure
|
|
438
|
+
organizedSections[sectionKey] = section;
|
|
439
|
+
return;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
const organizedSection = {
|
|
443
|
+
...section,
|
|
444
|
+
// Keep the section-level properties
|
|
445
|
+
};
|
|
446
|
+
|
|
447
|
+
// Clear the section of its original objects
|
|
448
|
+
Object.keys(section).forEach(key => {
|
|
449
|
+
if (!(key === 'id' || key === 'label' || key === 'position' || key === 'subTitle')) {
|
|
450
|
+
delete organizedSection[key];
|
|
451
|
+
}
|
|
452
|
+
});
|
|
453
|
+
|
|
454
|
+
headers.forEach((header, index) => {
|
|
455
|
+
const headerPosition = header.position || 0;
|
|
456
|
+
const nextHeaderPosition = index < headers.length - 1
|
|
457
|
+
? (headers[index + 1].position || 0)
|
|
458
|
+
: Infinity;
|
|
459
|
+
|
|
460
|
+
// Find objects that belong under this header
|
|
461
|
+
const childrenObjects = nonHeaders.filter(obj => {
|
|
462
|
+
const objPosition = obj.position || 0;
|
|
463
|
+
return objPosition > headerPosition && objPosition < nextHeaderPosition;
|
|
464
|
+
});
|
|
465
|
+
|
|
466
|
+
// Create the header structure with children as inputs
|
|
467
|
+
const headerWithChildren = { ...header };
|
|
468
|
+
delete headerWithChildren.key; // Remove the key we added temporarily
|
|
469
|
+
|
|
470
|
+
if (childrenObjects.length > 0) {
|
|
471
|
+
headerWithChildren.inputs = {};
|
|
472
|
+
childrenObjects.forEach(child => {
|
|
473
|
+
const childKey = child.key;
|
|
474
|
+
const childData = { ...child };
|
|
475
|
+
delete childData.key; // Remove the temporary key
|
|
476
|
+
headerWithChildren.inputs[childKey] = childData;
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
organizedSection[header.key] = headerWithChildren;
|
|
481
|
+
});
|
|
482
|
+
|
|
483
|
+
// Add any remaining objects that don't fall under any header
|
|
484
|
+
const uncategorizedObjects = nonHeaders.filter(obj => {
|
|
485
|
+
const objPosition = obj.position || 0;
|
|
486
|
+
return !headers.some((header, index) => {
|
|
487
|
+
const headerPosition = header.position || 0;
|
|
488
|
+
const nextHeaderPosition = index < headers.length - 1
|
|
489
|
+
? (headers[index + 1].position || 0)
|
|
490
|
+
: Infinity;
|
|
491
|
+
return objPosition > headerPosition && objPosition < nextHeaderPosition;
|
|
492
|
+
});
|
|
493
|
+
});
|
|
494
|
+
|
|
495
|
+
uncategorizedObjects.forEach(obj => {
|
|
496
|
+
const objKey = obj.key;
|
|
497
|
+
const objData = { ...obj };
|
|
498
|
+
delete objData.key;
|
|
499
|
+
organizedSection[objKey] = objData;
|
|
500
|
+
});
|
|
501
|
+
|
|
502
|
+
organizedSections[sectionKey] = organizedSection;
|
|
503
|
+
});
|
|
504
|
+
|
|
505
|
+
return organizedSections;
|
|
506
|
+
};
|
|
507
|
+
|
|
508
|
+
const organizedForm = useMemo(() => organizeFormByHeaders(form), [form]);
|
|
509
|
+
|
|
324
510
|
const pdfConfig = useMemo(() => {
|
|
325
511
|
const sections = [];
|
|
326
512
|
|
|
327
|
-
Object.keys(
|
|
328
|
-
const section =
|
|
513
|
+
Object.keys(organizedForm).forEach((sectionKey) => {
|
|
514
|
+
const section = organizedForm[sectionKey];
|
|
329
515
|
|
|
330
516
|
if (typeof section !== 'object' || !section.label) {
|
|
331
517
|
return;
|
|
@@ -356,7 +542,7 @@ const PdfForm = ({
|
|
|
356
542
|
});
|
|
357
543
|
|
|
358
544
|
return sections;
|
|
359
|
-
}, [
|
|
545
|
+
}, [organizedForm, data, t, getApiBaseUrl, getAppHeader, app, formName, source, version]);
|
|
360
546
|
|
|
361
547
|
return (
|
|
362
548
|
<PdfView
|