@visns-studio/visns-components 3.7.9 → 3.7.11
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) => {
|
|
@@ -103,20 +105,11 @@ const GenericDynamic = ({
|
|
|
103
105
|
updateField(prevState, name, newValue)
|
|
104
106
|
);
|
|
105
107
|
} else if (files && files[0]) {
|
|
108
|
+
const toastId = toast.loading('Uploading file...'); // Show loading toast
|
|
106
109
|
// Start the upload process and read the file if it's an image
|
|
107
110
|
Vapor.store(files[0], {
|
|
108
111
|
progress: (progress) => {
|
|
109
|
-
|
|
110
|
-
if (
|
|
111
|
-
toastId.current === null ||
|
|
112
|
-
!toast.isActive(toastId.current)
|
|
113
|
-
) {
|
|
114
|
-
toastId.current = toast(`File Upload in Progress`, {
|
|
115
|
-
progress,
|
|
116
|
-
});
|
|
117
|
-
} else {
|
|
118
|
-
toast.update(toastId.current, { progress });
|
|
119
|
-
}
|
|
112
|
+
console.info(`Upload Progress: ${progress}`);
|
|
120
113
|
},
|
|
121
114
|
}).then((response) => {
|
|
122
115
|
if (files[0].type.startsWith('image/')) {
|
|
@@ -154,7 +147,13 @@ const GenericDynamic = ({
|
|
|
154
147
|
})
|
|
155
148
|
);
|
|
156
149
|
}
|
|
157
|
-
toast.
|
|
150
|
+
toast.update(toastId, {
|
|
151
|
+
render: 'Upload successful!',
|
|
152
|
+
type: 'success',
|
|
153
|
+
isLoading: false,
|
|
154
|
+
autoClose: 5000,
|
|
155
|
+
closeButton: true,
|
|
156
|
+
});
|
|
158
157
|
});
|
|
159
158
|
} else {
|
|
160
159
|
newValue = value;
|
|
@@ -256,7 +255,7 @@ const GenericDynamic = ({
|
|
|
256
255
|
setActiveFormKey(key);
|
|
257
256
|
};
|
|
258
257
|
|
|
259
|
-
const handleAddNewForm = async () => {
|
|
258
|
+
const handleAddNewForm = async (showToast = true) => {
|
|
260
259
|
try {
|
|
261
260
|
if (activeForm && activeForm.id) {
|
|
262
261
|
await CustomFetch(setting.save, 'POST', {
|
|
@@ -274,7 +273,9 @@ const GenericDynamic = ({
|
|
|
274
273
|
form_name: type,
|
|
275
274
|
});
|
|
276
275
|
if (res.data.error === '') {
|
|
277
|
-
|
|
276
|
+
if (showToast) {
|
|
277
|
+
toast.success('Form added successfully');
|
|
278
|
+
}
|
|
278
279
|
fetchData();
|
|
279
280
|
}
|
|
280
281
|
} catch (err) {
|
|
@@ -438,17 +439,25 @@ const GenericDynamic = ({
|
|
|
438
439
|
}
|
|
439
440
|
}
|
|
440
441
|
} else {
|
|
441
|
-
setActiveForm(
|
|
442
|
+
setActiveForm({});
|
|
443
|
+
}
|
|
444
|
+
}, [data, type]);
|
|
445
|
+
|
|
446
|
+
useEffect(() => {
|
|
447
|
+
if (data[type] && data[type].length > 0) {
|
|
448
|
+
} else {
|
|
442
449
|
if (multiple && templateStatus) {
|
|
443
|
-
|
|
450
|
+
if (activeForm.hasOwnProperty('id') === false) {
|
|
451
|
+
handleAddNewForm(false);
|
|
452
|
+
}
|
|
444
453
|
}
|
|
445
454
|
}
|
|
446
|
-
}, [
|
|
455
|
+
}, [activeForm]);
|
|
447
456
|
|
|
448
457
|
return (
|
|
449
458
|
<>
|
|
450
459
|
<div className="formSplit">
|
|
451
|
-
{multiple &&
|
|
460
|
+
{multiple && (
|
|
452
461
|
<>
|
|
453
462
|
<div className="gridtxt__header">
|
|
454
463
|
<span>Form List</span>
|
|
@@ -519,7 +528,7 @@ const GenericDynamic = ({
|
|
|
519
528
|
handleDownloadForm(
|
|
520
529
|
item,
|
|
521
530
|
label,
|
|
522
|
-
|
|
531
|
+
originalData
|
|
523
532
|
)
|
|
524
533
|
}
|
|
525
534
|
>
|
|
@@ -609,7 +618,7 @@ const GenericDynamic = ({
|
|
|
609
618
|
inputClass={''}
|
|
610
619
|
inputValue={renderValue(
|
|
611
620
|
field,
|
|
612
|
-
|
|
621
|
+
originalData
|
|
613
622
|
)}
|
|
614
623
|
onChange={
|
|
615
624
|
handleChange
|
|
@@ -643,7 +652,7 @@ const GenericDynamic = ({
|
|
|
643
652
|
inputClass={''}
|
|
644
653
|
inputValue={renderValue(
|
|
645
654
|
field,
|
|
646
|
-
|
|
655
|
+
originalData
|
|
647
656
|
)}
|
|
648
657
|
onChange={
|
|
649
658
|
handleChange
|
package/package.json
CHANGED