@visns-studio/visns-components 3.7.9 → 3.7.10
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.
|
@@ -47,6 +47,7 @@ const renderValue = (field, data) => {
|
|
|
47
47
|
const [table, key] = field.dynamicfield.split('::');
|
|
48
48
|
|
|
49
49
|
if (table && key) {
|
|
50
|
+
console.info(table, key, data);
|
|
50
51
|
switch (table) {
|
|
51
52
|
case 'opportunities':
|
|
52
53
|
return data[table][key];
|
|
@@ -77,6 +78,7 @@ const GenericDynamic = ({
|
|
|
77
78
|
fetchData,
|
|
78
79
|
label,
|
|
79
80
|
multiple = true,
|
|
81
|
+
originalData = {},
|
|
80
82
|
primaryKey,
|
|
81
83
|
setData,
|
|
82
84
|
setting,
|
|
@@ -84,7 +86,7 @@ const GenericDynamic = ({
|
|
|
84
86
|
type,
|
|
85
87
|
}) => {
|
|
86
88
|
const toastId = useRef(null);
|
|
87
|
-
const [activeForm, setActiveForm] = useState(
|
|
89
|
+
const [activeForm, setActiveForm] = useState({});
|
|
88
90
|
const [activeFormKey, setActiveFormKey] = useState(0);
|
|
89
91
|
|
|
90
92
|
const handleChange = (e) => {
|
|
@@ -256,7 +258,7 @@ const GenericDynamic = ({
|
|
|
256
258
|
setActiveFormKey(key);
|
|
257
259
|
};
|
|
258
260
|
|
|
259
|
-
const handleAddNewForm = async () => {
|
|
261
|
+
const handleAddNewForm = async (showToast = true) => {
|
|
260
262
|
try {
|
|
261
263
|
if (activeForm && activeForm.id) {
|
|
262
264
|
await CustomFetch(setting.save, 'POST', {
|
|
@@ -274,7 +276,9 @@ const GenericDynamic = ({
|
|
|
274
276
|
form_name: type,
|
|
275
277
|
});
|
|
276
278
|
if (res.data.error === '') {
|
|
277
|
-
|
|
279
|
+
if (showToast) {
|
|
280
|
+
toast.success('Form added successfully');
|
|
281
|
+
}
|
|
278
282
|
fetchData();
|
|
279
283
|
}
|
|
280
284
|
} catch (err) {
|
|
@@ -438,17 +442,25 @@ const GenericDynamic = ({
|
|
|
438
442
|
}
|
|
439
443
|
}
|
|
440
444
|
} else {
|
|
441
|
-
setActiveForm(
|
|
445
|
+
setActiveForm({});
|
|
446
|
+
}
|
|
447
|
+
}, [data, type]);
|
|
448
|
+
|
|
449
|
+
useEffect(() => {
|
|
450
|
+
if (data[type] && data[type].length > 0) {
|
|
451
|
+
} else {
|
|
442
452
|
if (multiple && templateStatus) {
|
|
443
|
-
|
|
453
|
+
if (activeForm.hasOwnProperty('id') === false) {
|
|
454
|
+
handleAddNewForm(false);
|
|
455
|
+
}
|
|
444
456
|
}
|
|
445
457
|
}
|
|
446
|
-
}, [
|
|
458
|
+
}, [activeForm]);
|
|
447
459
|
|
|
448
460
|
return (
|
|
449
461
|
<>
|
|
450
462
|
<div className="formSplit">
|
|
451
|
-
{multiple &&
|
|
463
|
+
{multiple && (
|
|
452
464
|
<>
|
|
453
465
|
<div className="gridtxt__header">
|
|
454
466
|
<span>Form List</span>
|
|
@@ -519,7 +531,7 @@ const GenericDynamic = ({
|
|
|
519
531
|
handleDownloadForm(
|
|
520
532
|
item,
|
|
521
533
|
label,
|
|
522
|
-
|
|
534
|
+
originalData
|
|
523
535
|
)
|
|
524
536
|
}
|
|
525
537
|
>
|
|
@@ -609,7 +621,7 @@ const GenericDynamic = ({
|
|
|
609
621
|
inputClass={''}
|
|
610
622
|
inputValue={renderValue(
|
|
611
623
|
field,
|
|
612
|
-
|
|
624
|
+
originalData
|
|
613
625
|
)}
|
|
614
626
|
onChange={
|
|
615
627
|
handleChange
|
|
@@ -643,7 +655,7 @@ const GenericDynamic = ({
|
|
|
643
655
|
inputClass={''}
|
|
644
656
|
inputValue={renderValue(
|
|
645
657
|
field,
|
|
646
|
-
|
|
658
|
+
originalData
|
|
647
659
|
)}
|
|
648
660
|
onChange={
|
|
649
661
|
handleChange
|
package/package.json
CHANGED