@visns-studio/visns-components 3.6.7 → 3.6.8
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.
|
@@ -74,6 +74,7 @@ const GenericDynamic = ({
|
|
|
74
74
|
primaryKey,
|
|
75
75
|
setData,
|
|
76
76
|
setting,
|
|
77
|
+
templateStatus = true,
|
|
77
78
|
type,
|
|
78
79
|
}) => {
|
|
79
80
|
const toastId = useRef(null);
|
|
@@ -266,13 +267,14 @@ const GenericDynamic = ({
|
|
|
266
267
|
}
|
|
267
268
|
};
|
|
268
269
|
|
|
269
|
-
const handleDownloadForm = async (item,
|
|
270
|
+
const handleDownloadForm = async (item, label, data) => {
|
|
270
271
|
// Show loading toast and keep its ID
|
|
271
272
|
const toastId = toast.loading('Downloading form...');
|
|
272
273
|
|
|
273
274
|
try {
|
|
274
275
|
const res = await Download(setting.download, 'POST', {
|
|
275
276
|
data: item,
|
|
277
|
+
dynamicData: data,
|
|
276
278
|
label: label,
|
|
277
279
|
});
|
|
278
280
|
|
|
@@ -391,28 +393,30 @@ const GenericDynamic = ({
|
|
|
391
393
|
useEffect(() => {
|
|
392
394
|
if (data[type] && data[type].length > 0) {
|
|
393
395
|
if (multiple) {
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
if (
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
396
|
+
if (templateStatus) {
|
|
397
|
+
// Retrieve the last form of the specified type
|
|
398
|
+
let lastForm = data[type][data[type].length - 1];
|
|
399
|
+
|
|
400
|
+
if (lastForm && typeof lastForm === 'object') {
|
|
401
|
+
Object.entries(lastForm).forEach(([key, field]) => {
|
|
402
|
+
if (field && field.required) {
|
|
403
|
+
if (
|
|
404
|
+
field.required === 'yes' ||
|
|
405
|
+
field.required === 'no'
|
|
406
|
+
) {
|
|
407
|
+
lastForm[key].required =
|
|
408
|
+
field.required === 'yes';
|
|
409
|
+
}
|
|
406
410
|
}
|
|
407
|
-
}
|
|
408
|
-
});
|
|
411
|
+
});
|
|
409
412
|
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
+
// Update the active form with the modified lastForm
|
|
414
|
+
setActiveForm(lastForm);
|
|
415
|
+
setActiveFormKey(data[type].length - 1);
|
|
416
|
+
}
|
|
413
417
|
}
|
|
414
418
|
} else {
|
|
415
|
-
if (activeForm.length === 0) {
|
|
419
|
+
if (activeForm.length === 0 && templateStatus) {
|
|
416
420
|
setActiveForm(data[type]);
|
|
417
421
|
setActiveFormKey(0);
|
|
418
422
|
}
|
|
@@ -438,6 +442,7 @@ const GenericDynamic = ({
|
|
|
438
442
|
<thead>
|
|
439
443
|
<tr className="grid-headers">
|
|
440
444
|
<th>ID</th>
|
|
445
|
+
<th>Form</th>
|
|
441
446
|
<th>Created By</th>
|
|
442
447
|
<th>Created At</th>
|
|
443
448
|
<th>Updated By</th>
|
|
@@ -464,7 +469,8 @@ const GenericDynamic = ({
|
|
|
464
469
|
);
|
|
465
470
|
}}
|
|
466
471
|
>
|
|
467
|
-
<td>
|
|
472
|
+
<td>{item.id}</td>
|
|
473
|
+
<td>{item.form_label}</td>
|
|
468
474
|
<td>{item.created_by}</td>
|
|
469
475
|
<td>
|
|
470
476
|
{item.created_at
|
|
@@ -494,7 +500,8 @@ const GenericDynamic = ({
|
|
|
494
500
|
onClick={() =>
|
|
495
501
|
handleDownloadForm(
|
|
496
502
|
item,
|
|
497
|
-
|
|
503
|
+
label,
|
|
504
|
+
data
|
|
498
505
|
)
|
|
499
506
|
}
|
|
500
507
|
>
|
|
@@ -642,7 +649,7 @@ const GenericDynamic = ({
|
|
|
642
649
|
)}
|
|
643
650
|
</div>
|
|
644
651
|
<div className="polActions">
|
|
645
|
-
{multiple && (
|
|
652
|
+
{multiple && templateStatus && (
|
|
646
653
|
<button className="btn" onClick={handleAddNewForm}>
|
|
647
654
|
Add New Form
|
|
648
655
|
</button>
|
package/package.json
CHANGED