@visns-studio/visns-components 4.6.5 → 4.6.7
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.
|
@@ -73,6 +73,7 @@ const renderValue = (field, data) => {
|
|
|
73
73
|
};
|
|
74
74
|
|
|
75
75
|
const GenericDynamic = ({
|
|
76
|
+
buttons,
|
|
76
77
|
data,
|
|
77
78
|
fetchData,
|
|
78
79
|
label,
|
|
@@ -85,7 +86,6 @@ const GenericDynamic = ({
|
|
|
85
86
|
type,
|
|
86
87
|
userProfile,
|
|
87
88
|
}) => {
|
|
88
|
-
const toastId = useRef(null);
|
|
89
89
|
const [activeForm, setActiveForm] = useState({});
|
|
90
90
|
const [activeFormKey, setActiveFormKey] = useState(0);
|
|
91
91
|
|
|
@@ -372,6 +372,30 @@ const GenericDynamic = ({
|
|
|
372
372
|
setActiveFormKey(key);
|
|
373
373
|
};
|
|
374
374
|
|
|
375
|
+
const handleCustomButton = async (s) => {
|
|
376
|
+
let payload = {};
|
|
377
|
+
switch (s.type) {
|
|
378
|
+
case 'save':
|
|
379
|
+
if (s.payload?.length > 0) {
|
|
380
|
+
s.payload.forEach((p) => {
|
|
381
|
+
if (data[p]) {
|
|
382
|
+
payload[p] = data[p];
|
|
383
|
+
}
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
const res = await Download(s.url, s.method, payload);
|
|
388
|
+
|
|
389
|
+
if (res.data) {
|
|
390
|
+
saveAs(res.data);
|
|
391
|
+
}
|
|
392
|
+
break;
|
|
393
|
+
default:
|
|
394
|
+
console.info(s, 'default');
|
|
395
|
+
break;
|
|
396
|
+
}
|
|
397
|
+
};
|
|
398
|
+
|
|
375
399
|
const handleAddNewForm = async (showToast = true) => {
|
|
376
400
|
try {
|
|
377
401
|
if (activeForm && activeForm.id) {
|
|
@@ -845,6 +869,21 @@ const GenericDynamic = ({
|
|
|
845
869
|
)}
|
|
846
870
|
</div>
|
|
847
871
|
<div className={styles.polActions}>
|
|
872
|
+
{buttons.length > 0 &&
|
|
873
|
+
buttons.map((button, buttonKey) => (
|
|
874
|
+
<button
|
|
875
|
+
className={button.className}
|
|
876
|
+
key={`button-${buttonKey}`}
|
|
877
|
+
onClick={(e) => {
|
|
878
|
+
e.preventDefault();
|
|
879
|
+
|
|
880
|
+
handleCustomButton(button);
|
|
881
|
+
}}
|
|
882
|
+
>
|
|
883
|
+
{button.label}
|
|
884
|
+
</button>
|
|
885
|
+
))}
|
|
886
|
+
|
|
848
887
|
{multiple && templateStatus && (
|
|
849
888
|
<button className="btn" onClick={handleAddNewForm}>
|
|
850
889
|
Add New Form
|
package/package.json
CHANGED