@visns-studio/visns-components 4.6.6 → 4.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.
|
@@ -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
|
|
@@ -51,6 +51,7 @@ function useConfig(setting, tabs, filters, setRowsSelected, tableSetting) {
|
|
|
51
51
|
if (activeTabConfig) {
|
|
52
52
|
setConfig((currentConfig) => ({
|
|
53
53
|
...currentConfig,
|
|
54
|
+
id: activeTabConfig.id,
|
|
54
55
|
ajaxSetting: activeTabConfig.ajaxSetting,
|
|
55
56
|
form: activeTabConfig.form,
|
|
56
57
|
columns: activeTabConfig.columns,
|
|
@@ -209,12 +210,20 @@ function GenericIndex({ layout = 'full', setting, userProfile }) {
|
|
|
209
210
|
}
|
|
210
211
|
}, [rowsSelected, setting?.functions?.checkboxUpdate]);
|
|
211
212
|
|
|
212
|
-
const renderTable = useCallback(
|
|
213
|
-
|
|
213
|
+
const renderTable = useCallback(() => {
|
|
214
|
+
// Find the active subnav item with show: true
|
|
215
|
+
const activeSubnav = subnav.find((item) => item.show === true);
|
|
216
|
+
|
|
217
|
+
// Check if the config.id matches the active subnav id
|
|
218
|
+
if (
|
|
219
|
+
activeSubnav &&
|
|
220
|
+
activeSubnav.id === config.id &&
|
|
214
221
|
config.ajaxSetting &&
|
|
215
222
|
config.form &&
|
|
216
223
|
config.columns &&
|
|
217
|
-
config.settings
|
|
224
|
+
config.settings
|
|
225
|
+
) {
|
|
226
|
+
return (
|
|
218
227
|
<Table
|
|
219
228
|
{...config}
|
|
220
229
|
ref={gridRef}
|
|
@@ -224,9 +233,11 @@ function GenericIndex({ layout = 'full', setting, userProfile }) {
|
|
|
224
233
|
style={userProfile?.settings?.style || {}}
|
|
225
234
|
userProfile={userProfile}
|
|
226
235
|
/>
|
|
227
|
-
)
|
|
228
|
-
|
|
229
|
-
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
return null;
|
|
240
|
+
}, [config, subnav, windowHeight, userProfile, setConfig, setTotal]);
|
|
230
241
|
|
|
231
242
|
const renderContentBasedOnType = useCallback(() => {
|
|
232
243
|
switch (config.type) {
|
package/package.json
CHANGED