@5minds/node-red-dashboard-2-processcube-dynamic-form 2.1.0-file-preview-ea90da-mdpynnv5 → 2.1.0-file-preview-1bee64-mdpzqcz2
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.
|
@@ -77,9 +77,7 @@
|
|
|
77
77
|
v-model="field.defaultValue"
|
|
78
78
|
/>
|
|
79
79
|
<p class="formkit-help">
|
|
80
|
-
{{
|
|
81
|
-
field.customForm ? JSON.parse(field.customForm).hint : undefined
|
|
82
|
-
}}
|
|
80
|
+
{{ getFieldHint(field) }}
|
|
83
81
|
</p>
|
|
84
82
|
</div>
|
|
85
83
|
<component
|
|
@@ -364,8 +362,39 @@ export default {
|
|
|
364
362
|
// This is now handled by computed properties automatically
|
|
365
363
|
},
|
|
366
364
|
|
|
365
|
+
// Safe method to get field hint for template use
|
|
366
|
+
getFieldHint(field) {
|
|
367
|
+
try {
|
|
368
|
+
if (field.customForm) {
|
|
369
|
+
let customForm;
|
|
370
|
+
if (typeof field.customForm === 'string') {
|
|
371
|
+
customForm = JSON.parse(field.customForm);
|
|
372
|
+
} else if (typeof field.customForm === 'object') {
|
|
373
|
+
customForm = field.customForm;
|
|
374
|
+
}
|
|
375
|
+
return customForm?.hint;
|
|
376
|
+
}
|
|
377
|
+
} catch (error) {
|
|
378
|
+
console.warn('Failed to parse customForm hint for field', field.id, error);
|
|
379
|
+
}
|
|
380
|
+
return undefined;
|
|
381
|
+
},
|
|
382
|
+
|
|
367
383
|
createComponent(field) {
|
|
368
|
-
|
|
384
|
+
// Safe parsing of customForm - handle both string and object cases
|
|
385
|
+
let customForm = {};
|
|
386
|
+
try {
|
|
387
|
+
if (field.customForm) {
|
|
388
|
+
if (typeof field.customForm === 'string') {
|
|
389
|
+
customForm = JSON.parse(field.customForm);
|
|
390
|
+
} else if (typeof field.customForm === 'object') {
|
|
391
|
+
customForm = field.customForm;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
} catch (error) {
|
|
395
|
+
console.warn('Failed to parse customForm for field', field.id, error);
|
|
396
|
+
customForm = {};
|
|
397
|
+
}
|
|
369
398
|
const { hint, placeholder, validation, customProperties = [] } = customForm;
|
|
370
399
|
const name = field.id;
|
|
371
400
|
const isReadOnly =
|
|
@@ -532,9 +561,11 @@ export default {
|
|
|
532
561
|
},
|
|
533
562
|
};
|
|
534
563
|
case 'select':
|
|
535
|
-
const selections =
|
|
536
|
-
|
|
537
|
-
|
|
564
|
+
const selections = customForm.entries
|
|
565
|
+
? customForm.entries.map((obj) => {
|
|
566
|
+
return { value: obj.key, label: obj.value };
|
|
567
|
+
})
|
|
568
|
+
: [];
|
|
538
569
|
return {
|
|
539
570
|
type: 'FormKit',
|
|
540
571
|
props: {
|
|
@@ -679,7 +710,7 @@ export default {
|
|
|
679
710
|
},
|
|
680
711
|
};
|
|
681
712
|
case 'file':
|
|
682
|
-
const multiple =
|
|
713
|
+
const multiple = customForm.multiple === 'true';
|
|
683
714
|
return {
|
|
684
715
|
type: 'FormKit',
|
|
685
716
|
props: {
|
|
@@ -701,9 +732,11 @@ export default {
|
|
|
701
732
|
},
|
|
702
733
|
};
|
|
703
734
|
case 'checkbox':
|
|
704
|
-
const options =
|
|
705
|
-
|
|
706
|
-
|
|
735
|
+
const options = customForm.entries
|
|
736
|
+
? customForm.entries.map((obj) => {
|
|
737
|
+
return { value: obj.key, label: obj.value };
|
|
738
|
+
})
|
|
739
|
+
: [];
|
|
707
740
|
return {
|
|
708
741
|
type: 'FormKit',
|
|
709
742
|
props: {
|
|
@@ -791,10 +824,10 @@ export default {
|
|
|
791
824
|
};
|
|
792
825
|
case 'header':
|
|
793
826
|
let typeToUse = 'h1';
|
|
794
|
-
if (
|
|
827
|
+
if (customForm.style === 'heading_2') {
|
|
795
828
|
typeToUse = 'h2';
|
|
796
829
|
}
|
|
797
|
-
if (
|
|
830
|
+
if (customForm.style === 'heading_3') {
|
|
798
831
|
typeToUse = 'h3';
|
|
799
832
|
}
|
|
800
833
|
return {
|
|
@@ -863,9 +896,11 @@ export default {
|
|
|
863
896
|
},
|
|
864
897
|
};
|
|
865
898
|
case 'radio':
|
|
866
|
-
const radioOptions =
|
|
867
|
-
|
|
868
|
-
|
|
899
|
+
const radioOptions = customForm.entries
|
|
900
|
+
? customForm.entries.map((obj) => {
|
|
901
|
+
return { value: obj.key, label: obj.value };
|
|
902
|
+
})
|
|
903
|
+
: [];
|
|
869
904
|
return {
|
|
870
905
|
type: 'FormKit',
|
|
871
906
|
props: {
|
|
@@ -890,7 +925,6 @@ export default {
|
|
|
890
925
|
},
|
|
891
926
|
};
|
|
892
927
|
case 'range':
|
|
893
|
-
const customForm = JSON.parse(field.customForm);
|
|
894
928
|
return {
|
|
895
929
|
type: 'v-slider',
|
|
896
930
|
props: {
|
|
@@ -938,7 +972,7 @@ export default {
|
|
|
938
972
|
},
|
|
939
973
|
};
|
|
940
974
|
case 'textarea':
|
|
941
|
-
const rows =
|
|
975
|
+
const rows = customForm.rows;
|
|
942
976
|
return {
|
|
943
977
|
type: 'FormKit',
|
|
944
978
|
props: {
|
|
@@ -1319,7 +1353,7 @@ export default {
|
|
|
1319
1353
|
|
|
1320
1354
|
const formFields = this.userTask.userTaskConfig.formFields;
|
|
1321
1355
|
const formFieldIds = formFields.map((ff) => ff.id);
|
|
1322
|
-
const initialValues = this.userTask.startToken
|
|
1356
|
+
const initialValues = this.userTask.startToken;
|
|
1323
1357
|
const finishedFormData = msg.payload.formData;
|
|
1324
1358
|
this.formIsFinished = !!msg.payload.formData;
|
|
1325
1359
|
if (this.formIsFinished) {
|
|
@@ -1334,7 +1368,19 @@ export default {
|
|
|
1334
1368
|
this.formData[field.id] = field.defaultValue;
|
|
1335
1369
|
|
|
1336
1370
|
if (field.type === 'confirm') {
|
|
1337
|
-
|
|
1371
|
+
let customForm = {};
|
|
1372
|
+
try {
|
|
1373
|
+
if (field.customForm) {
|
|
1374
|
+
if (typeof field.customForm === 'string') {
|
|
1375
|
+
customForm = JSON.parse(field.customForm);
|
|
1376
|
+
} else if (typeof field.customForm === 'object') {
|
|
1377
|
+
customForm = field.customForm;
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1380
|
+
} catch (error) {
|
|
1381
|
+
console.warn('Failed to parse customForm for confirm field', field.id, error);
|
|
1382
|
+
customForm = {};
|
|
1383
|
+
}
|
|
1338
1384
|
const confirmText = customForm.confirmButtonText ?? 'Confirm';
|
|
1339
1385
|
const declineText = customForm.declineButtonText ?? 'Decline';
|
|
1340
1386
|
this.actions = [
|