@visns-studio/visns-components 5.3.13 → 5.4.0
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.
package/package.json
CHANGED
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"react-dom": "^17.0.0 || ^18.0.0"
|
|
79
79
|
},
|
|
80
80
|
"name": "@visns-studio/visns-components",
|
|
81
|
-
"version": "5.
|
|
81
|
+
"version": "5.4.0",
|
|
82
82
|
"description": "Various packages to assist in the development of our Custom Applications.",
|
|
83
83
|
"main": "src/index.js",
|
|
84
84
|
"files": [
|
|
@@ -321,6 +321,31 @@ function GenericDetail({
|
|
|
321
321
|
}
|
|
322
322
|
};
|
|
323
323
|
|
|
324
|
+
const handleCheckboxDelete = async () => {
|
|
325
|
+
try {
|
|
326
|
+
if (currentConfigRef.current.functions.checkboxDelete) {
|
|
327
|
+
const { data, method, message, url } =
|
|
328
|
+
currentConfigRef.current.functions.checkboxDelete;
|
|
329
|
+
if (!Object.keys(rowsSelected).length) {
|
|
330
|
+
toast.warning(message.warning);
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
const res = await CustomFetch(url, method, {
|
|
334
|
+
...data,
|
|
335
|
+
rows: rowsSelected,
|
|
336
|
+
});
|
|
337
|
+
if (res.data.error === '') {
|
|
338
|
+
toast.success(message.success);
|
|
339
|
+
gridRef.current.reload();
|
|
340
|
+
} else {
|
|
341
|
+
toast.error(message.error);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
} catch (error) {
|
|
345
|
+
console.error(error);
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
|
|
324
349
|
const handleReload = () => {
|
|
325
350
|
const min = 0;
|
|
326
351
|
const max = 999999999;
|
|
@@ -1509,6 +1534,7 @@ function GenericDetail({
|
|
|
1509
1534
|
<span>{formConfig.title}</span>
|
|
1510
1535
|
</div>
|
|
1511
1536
|
<Form
|
|
1537
|
+
key={`form-${activeTabConfig.id}`}
|
|
1512
1538
|
columnId={routeParams[urlParam]}
|
|
1513
1539
|
formSettings={formConfig.form}
|
|
1514
1540
|
formType="update"
|
|
@@ -1908,6 +1934,22 @@ function GenericDetail({
|
|
|
1908
1934
|
</button>
|
|
1909
1935
|
</div>
|
|
1910
1936
|
)}
|
|
1937
|
+
|
|
1938
|
+
{activeTabConfig.functions
|
|
1939
|
+
?.checkboxDelete && (
|
|
1940
|
+
<div className={styles.polActions}>
|
|
1941
|
+
<button
|
|
1942
|
+
className={styles.btn}
|
|
1943
|
+
onClick={
|
|
1944
|
+
handleCheckboxDelete
|
|
1945
|
+
}
|
|
1946
|
+
>
|
|
1947
|
+
{activeTabConfig.functions
|
|
1948
|
+
.checkboxDelete.label ||
|
|
1949
|
+
'Delete'}
|
|
1950
|
+
</button>
|
|
1951
|
+
</div>
|
|
1952
|
+
)}
|
|
1911
1953
|
</>
|
|
1912
1954
|
);
|
|
1913
1955
|
} else {
|
|
@@ -249,6 +249,52 @@ function GenericIndex({
|
|
|
249
249
|
tableData,
|
|
250
250
|
]);
|
|
251
251
|
|
|
252
|
+
const handleCheckboxDelete = async () => {
|
|
253
|
+
try {
|
|
254
|
+
const { data, method, message, url } = setting?.functions
|
|
255
|
+
?.checkboxDelete
|
|
256
|
+
? setting.functions.checkboxDelete
|
|
257
|
+
: config.form?.functions?.checkboxDelete;
|
|
258
|
+
|
|
259
|
+
if (!Object.keys(rowsSelectedRef.current).length) {
|
|
260
|
+
toast.warning(message.warning);
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// Create a map of selected rows with full data from tableData
|
|
265
|
+
const selectedRowsData = {};
|
|
266
|
+
Object.entries(rowsSelectedRef.current).forEach(([id, value]) => {
|
|
267
|
+
if (value) {
|
|
268
|
+
const fullRowData = tableData.find(
|
|
269
|
+
(row) => row.id === parseInt(id)
|
|
270
|
+
);
|
|
271
|
+
if (fullRowData) {
|
|
272
|
+
selectedRowsData[id] = fullRowData;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
const res = await CustomFetch(url, method, {
|
|
278
|
+
...data,
|
|
279
|
+
rows: selectedRowsData,
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
if (res.data.error === '') {
|
|
283
|
+
toast.success(message.success);
|
|
284
|
+
gridRef.current?.reload();
|
|
285
|
+
// Clear selections after successful delete
|
|
286
|
+
rowsSelectedRef.current = {};
|
|
287
|
+
} else {
|
|
288
|
+
toast.error(message.error);
|
|
289
|
+
}
|
|
290
|
+
} catch (err) {
|
|
291
|
+
console.error(err);
|
|
292
|
+
toast.error(
|
|
293
|
+
'An error occurred while processing the delete request'
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
|
|
252
298
|
const handleExport = async (e) => {
|
|
253
299
|
try {
|
|
254
300
|
if (e) {
|
|
@@ -464,34 +510,48 @@ function GenericIndex({
|
|
|
464
510
|
|
|
465
511
|
<div className={styles.grid}>{renderContent()}</div>
|
|
466
512
|
<Outlet />
|
|
467
|
-
|
|
468
|
-
|
|
513
|
+
|
|
514
|
+
<div className={styles.polActions}>
|
|
515
|
+
{setting.functions?.checkboxUpdate && (
|
|
469
516
|
<button
|
|
470
517
|
className={styles.btn}
|
|
471
518
|
onClick={handleCheckboxUpdate}
|
|
472
519
|
>
|
|
473
520
|
{setting.functions.checkboxUpdate.label || 'Update'}
|
|
474
521
|
</button>
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
{config?.form?.functions?.checkboxUpdate && (
|
|
478
|
-
<div className={styles.polActions}>
|
|
522
|
+
)}
|
|
523
|
+
{config?.form?.functions?.checkboxUpdate && (
|
|
479
524
|
<button
|
|
480
525
|
className={styles.btn}
|
|
481
526
|
onClick={handleCheckboxUpdate}
|
|
482
527
|
>
|
|
483
528
|
{config.form.functions.checkboxUpdate.label || 'Update'}
|
|
484
529
|
</button>
|
|
485
|
-
|
|
486
|
-
|
|
530
|
+
)}
|
|
531
|
+
|
|
532
|
+
{setting.functions?.checkboxDelete && (
|
|
533
|
+
<button
|
|
534
|
+
className={styles.btn}
|
|
535
|
+
onClick={handleCheckboxDelete}
|
|
536
|
+
>
|
|
537
|
+
{setting.functions.checkboxDelete.label || 'Delete'}
|
|
538
|
+
</button>
|
|
539
|
+
)}
|
|
540
|
+
{config?.form?.functions?.checkboxDelete && (
|
|
541
|
+
<button
|
|
542
|
+
className={styles.btn}
|
|
543
|
+
onClick={handleCheckboxDelete}
|
|
544
|
+
>
|
|
545
|
+
{config.form.functions.checkboxDelete.label || 'Delete'}
|
|
546
|
+
</button>
|
|
547
|
+
)}
|
|
487
548
|
|
|
488
|
-
|
|
489
|
-
<div className={styles.polActions}>
|
|
549
|
+
{setting.export?.label && (
|
|
490
550
|
<button className={styles.btn} onClick={handleExport}>
|
|
491
551
|
{setting.export.label}
|
|
492
552
|
</button>
|
|
493
|
-
|
|
494
|
-
|
|
553
|
+
)}
|
|
554
|
+
</div>
|
|
495
555
|
</>
|
|
496
556
|
);
|
|
497
557
|
}
|