@visns-studio/visns-components 4.2.1 → 4.2.3
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useEffect, useRef, useState } from 'react';
|
|
1
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
2
|
import { Link, useParams } from 'react-router-dom';
|
|
3
3
|
import moment from 'moment';
|
|
4
4
|
import parse from 'html-react-parser';
|
|
@@ -23,6 +23,7 @@ import { toast } from 'react-toastify';
|
|
|
23
23
|
|
|
24
24
|
function GenericDetail({ extraUrlParam, setting, urlParam, userProfile }) {
|
|
25
25
|
const gridRef = useRef(null);
|
|
26
|
+
const currentConfigRef = useRef(null);
|
|
26
27
|
const routeParams = useParams();
|
|
27
28
|
|
|
28
29
|
const { filters, page, stages, tabs } = setting;
|
|
@@ -34,8 +35,10 @@ function GenericDetail({ extraUrlParam, setting, urlParam, userProfile }) {
|
|
|
34
35
|
/** General States */
|
|
35
36
|
const [activeStage, setActiveStage] = useState('');
|
|
36
37
|
const [config, setConfig] = useState({});
|
|
38
|
+
const [currentConfig, setCurrentConfig] = useState({});
|
|
37
39
|
const [data, setData] = useState({});
|
|
38
40
|
const [dataReload, setDataReload] = useState(0);
|
|
41
|
+
const [rowsSelected, setRowsSelected] = useState({});
|
|
39
42
|
const [subnav, setSubnav] = useState([]);
|
|
40
43
|
const [total, setTotal] = useState(0);
|
|
41
44
|
const [windowHeight, setWindowHeight] = useState(window.innerHeight);
|
|
@@ -79,6 +82,31 @@ function GenericDetail({ extraUrlParam, setting, urlParam, userProfile }) {
|
|
|
79
82
|
}
|
|
80
83
|
};
|
|
81
84
|
|
|
85
|
+
const handleCheckboxUpdate = async () => {
|
|
86
|
+
try {
|
|
87
|
+
if (currentConfigRef.current.functions.checkboxUpdate) {
|
|
88
|
+
const { data, method, message, url } =
|
|
89
|
+
currentConfigRef.current.functions.checkboxUpdate;
|
|
90
|
+
if (!Object.keys(rowsSelected).length) {
|
|
91
|
+
toast.warning(message.warning);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const res = await CustomFetch(url, method, {
|
|
95
|
+
...data,
|
|
96
|
+
rows: rowsSelected,
|
|
97
|
+
});
|
|
98
|
+
if (res.data.error === '') {
|
|
99
|
+
toast.success(message.success);
|
|
100
|
+
gridRef.current.reload();
|
|
101
|
+
} else {
|
|
102
|
+
toast.error(message.error);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
} catch (error) {
|
|
106
|
+
console.error(error);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
|
|
82
110
|
const handleReload = () => {
|
|
83
111
|
const min = 0;
|
|
84
112
|
const max = 999999999;
|
|
@@ -281,6 +309,7 @@ function GenericDetail({ extraUrlParam, setting, urlParam, userProfile }) {
|
|
|
281
309
|
|
|
282
310
|
if (activeTab) {
|
|
283
311
|
const activeTabConfig = tabs.find((t) => t.id === activeTab.id);
|
|
312
|
+
currentConfigRef.current = activeTabConfig;
|
|
284
313
|
|
|
285
314
|
if (activeTabConfig && activeTabConfig.type) {
|
|
286
315
|
switch (activeTabConfig.type) {
|
|
@@ -967,6 +996,22 @@ function GenericDetail({ extraUrlParam, setting, urlParam, userProfile }) {
|
|
|
967
996
|
/>
|
|
968
997
|
</div>
|
|
969
998
|
</div>
|
|
999
|
+
|
|
1000
|
+
{activeTabConfig.functions
|
|
1001
|
+
?.checkboxUpdate && (
|
|
1002
|
+
<div className="polActions">
|
|
1003
|
+
<button
|
|
1004
|
+
className="btn"
|
|
1005
|
+
onClick={
|
|
1006
|
+
handleCheckboxUpdate
|
|
1007
|
+
}
|
|
1008
|
+
>
|
|
1009
|
+
{activeTabConfig.functions
|
|
1010
|
+
.checkboxUpdate.label ||
|
|
1011
|
+
'Update'}
|
|
1012
|
+
</button>
|
|
1013
|
+
</div>
|
|
1014
|
+
)}
|
|
970
1015
|
</>
|
|
971
1016
|
);
|
|
972
1017
|
} else {
|
|
@@ -1085,6 +1130,16 @@ function GenericDetail({ extraUrlParam, setting, urlParam, userProfile }) {
|
|
|
1085
1130
|
form: updatedForm,
|
|
1086
1131
|
columns: activeTabConfig.columns,
|
|
1087
1132
|
settings: activeTabConfig.settings,
|
|
1133
|
+
...(activeTabConfig.tableSetting && {
|
|
1134
|
+
tableSetting:
|
|
1135
|
+
activeTabConfig.tableSetting,
|
|
1136
|
+
}),
|
|
1137
|
+
...(activeTabConfig.functions && {
|
|
1138
|
+
functions: activeTabConfig.functions,
|
|
1139
|
+
}),
|
|
1140
|
+
...(setRowsSelected && {
|
|
1141
|
+
setRowsSelected: setRowsSelected,
|
|
1142
|
+
}),
|
|
1088
1143
|
});
|
|
1089
1144
|
}
|
|
1090
1145
|
break;
|
|
@@ -442,8 +442,12 @@ const GenericDynamic = ({
|
|
|
442
442
|
}
|
|
443
443
|
}
|
|
444
444
|
} else {
|
|
445
|
-
if (
|
|
446
|
-
|
|
445
|
+
if (
|
|
446
|
+
Object.keys(activeForm).length === 0 &&
|
|
447
|
+
templateStatus &&
|
|
448
|
+
data[type][0]
|
|
449
|
+
) {
|
|
450
|
+
setActiveForm(data[type][0]);
|
|
447
451
|
setActiveFormKey(0);
|
|
448
452
|
}
|
|
449
453
|
}
|
|
@@ -455,9 +459,15 @@ const GenericDynamic = ({
|
|
|
455
459
|
useEffect(() => {
|
|
456
460
|
if (data[type] && data[type].length > 0) {
|
|
457
461
|
} else {
|
|
458
|
-
if (
|
|
459
|
-
if (
|
|
460
|
-
|
|
462
|
+
if (templateStatus) {
|
|
463
|
+
if (multiple) {
|
|
464
|
+
if (activeForm.hasOwnProperty('id') === false) {
|
|
465
|
+
handleAddNewForm(false);
|
|
466
|
+
}
|
|
467
|
+
} else {
|
|
468
|
+
if (Object.keys(activeForm).length === 0) {
|
|
469
|
+
handleAddNewForm(false);
|
|
470
|
+
}
|
|
461
471
|
}
|
|
462
472
|
}
|
|
463
473
|
}
|
|
@@ -595,8 +605,7 @@ const GenericDynamic = ({
|
|
|
595
605
|
</div>
|
|
596
606
|
<div className={styles.formcontainer}>
|
|
597
607
|
<div className={styles.modalForm}>
|
|
598
|
-
{
|
|
599
|
-
typeof activeForm === 'object' &&
|
|
608
|
+
{typeof activeForm === 'object' &&
|
|
600
609
|
!Array.isArray(activeForm)
|
|
601
610
|
? Object.entries(activeForm)
|
|
602
611
|
.filter(
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"@nivo/core": "^0.87.0",
|
|
6
6
|
"@nivo/line": "^0.87.0",
|
|
7
7
|
"@nivo/pie": "^0.87.0",
|
|
8
|
-
"@tinymce/tinymce-react": "^5.
|
|
8
|
+
"@tinymce/tinymce-react": "^5.1.1",
|
|
9
9
|
"add": "^2.0.6",
|
|
10
10
|
"akar-icons": "^1.9.31",
|
|
11
11
|
"array-move": "^4.0.0",
|
|
@@ -13,12 +13,12 @@
|
|
|
13
13
|
"axios": "^1.7.2",
|
|
14
14
|
"dayjs": "^1.11.11",
|
|
15
15
|
"file-saver": "^2.0.5",
|
|
16
|
-
"framer-motion": "^11.2.
|
|
16
|
+
"framer-motion": "^11.2.10",
|
|
17
17
|
"html-react-parser": "^5.1.10",
|
|
18
18
|
"lodash": "^4.17.21",
|
|
19
19
|
"lodash.debounce": "^4.0.8",
|
|
20
20
|
"moment": "^2.30.1",
|
|
21
|
-
"motion": "^10.
|
|
21
|
+
"motion": "^10.18.0",
|
|
22
22
|
"numeral": "^2.0.6",
|
|
23
23
|
"pluralize": "^8.0.0",
|
|
24
24
|
"quill-image-uploader": "^1.3.0",
|
|
@@ -28,19 +28,19 @@
|
|
|
28
28
|
"react-datepicker": "^6.9.0",
|
|
29
29
|
"react-dropzone": "^14.2.3",
|
|
30
30
|
"react-grid-gallery": "^1.0.1",
|
|
31
|
-
"react-number-format": "^5.
|
|
31
|
+
"react-number-format": "^5.4.0",
|
|
32
32
|
"react-password-strength-bar": "^0.4.1",
|
|
33
33
|
"react-promise-tracker": "^2.1.1",
|
|
34
34
|
"react-quill": "^2.0.0",
|
|
35
35
|
"react-reveal": "^1.2.2",
|
|
36
36
|
"react-select": "^5.8.0",
|
|
37
|
-
"react-signature-pad-wrapper": "^3.4.
|
|
37
|
+
"react-signature-pad-wrapper": "^3.4.1",
|
|
38
38
|
"react-slugify": "^3.0.3",
|
|
39
39
|
"react-sortable-hoc": "^2.0.0",
|
|
40
40
|
"react-to-print": "^2.15.1",
|
|
41
41
|
"react-toastify": "^10.0.5",
|
|
42
42
|
"react-toggle": "^4.1.3",
|
|
43
|
-
"react-tooltip": "^5.
|
|
43
|
+
"react-tooltip": "^5.27.0",
|
|
44
44
|
"react-window": "^1.8.10",
|
|
45
45
|
"reactjs-popup": "^2.0.6",
|
|
46
46
|
"truncate": "^3.0.0",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"react-dom": "^17.0.1"
|
|
58
58
|
},
|
|
59
59
|
"name": "@visns-studio/visns-components",
|
|
60
|
-
"version": "4.2.
|
|
60
|
+
"version": "4.2.3",
|
|
61
61
|
"description": "Various packages to assist in the development of our Custom Applications.",
|
|
62
62
|
"main": "index.js",
|
|
63
63
|
"scripts": {
|