@visns-studio/visns-components 1.2.10 → 1.3.2
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/components/crm/visns-data-grid.jsx +147 -30
- package/package.json +1 -1
|
@@ -25,8 +25,13 @@ import {
|
|
|
25
25
|
CloudDownload,
|
|
26
26
|
Copy,
|
|
27
27
|
Edit,
|
|
28
|
+
Folder,
|
|
29
|
+
Inbox,
|
|
30
|
+
Network,
|
|
28
31
|
Ribbon,
|
|
29
32
|
Search,
|
|
33
|
+
ShippingBoxV1,
|
|
34
|
+
TriangleAlert,
|
|
30
35
|
} from "akar-icons";
|
|
31
36
|
|
|
32
37
|
import "@inovua/reactdatagrid-community/index.css";
|
|
@@ -95,6 +100,7 @@ const DataGrid = forwardRef(
|
|
|
95
100
|
form,
|
|
96
101
|
columns,
|
|
97
102
|
settings,
|
|
103
|
+
setFilterData,
|
|
98
104
|
style,
|
|
99
105
|
tableFilters,
|
|
100
106
|
historySearch,
|
|
@@ -336,7 +342,15 @@ const DataGrid = forwardRef(
|
|
|
336
342
|
<button
|
|
337
343
|
className="btn"
|
|
338
344
|
onClick={() => {
|
|
339
|
-
|
|
345
|
+
if (form.url) {
|
|
346
|
+
window.open(
|
|
347
|
+
form.url,
|
|
348
|
+
"",
|
|
349
|
+
"width=1440,height=1024,menubar=1,resizable=1,status=1,titlebar=1,toolbar=1"
|
|
350
|
+
);
|
|
351
|
+
} else {
|
|
352
|
+
modalOpen("create", 0);
|
|
353
|
+
}
|
|
340
354
|
}}
|
|
341
355
|
>
|
|
342
356
|
<div className="icon-plus"></div> Create
|
|
@@ -372,36 +386,72 @@ const DataGrid = forwardRef(
|
|
|
372
386
|
? import.meta.env.REACT_APP_ASSET_PATH
|
|
373
387
|
: "";
|
|
374
388
|
|
|
375
|
-
const addIcon = (src, alt, tooltipContent, key) => {
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
389
|
+
const addIcon = (src, icon, alt, tooltipContent, key) => {
|
|
390
|
+
if (src && src !== "") {
|
|
391
|
+
icons.push(
|
|
392
|
+
<img
|
|
393
|
+
src={`${assetPath}${src}`}
|
|
394
|
+
alt={alt}
|
|
395
|
+
data-tooltip-id="system-tooltip"
|
|
396
|
+
data-tooltip-content={tooltipContent}
|
|
397
|
+
key={key}
|
|
398
|
+
/>
|
|
399
|
+
);
|
|
400
|
+
} else {
|
|
401
|
+
let IconComponent = null;
|
|
402
|
+
|
|
403
|
+
if (icon === "archive") {
|
|
404
|
+
IconComponent = ShippingBoxV1;
|
|
405
|
+
} else if (icon === "folder") {
|
|
406
|
+
IconComponent = Folder;
|
|
407
|
+
} else if (icon === "inbox") {
|
|
408
|
+
IconComponent = Inbox;
|
|
409
|
+
} else if (icon === "network") {
|
|
410
|
+
IconComponent = Network;
|
|
411
|
+
} else if (icon === "urgent") {
|
|
412
|
+
IconComponent = TriangleAlert;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
if (IconComponent) {
|
|
416
|
+
icons.push(
|
|
417
|
+
<IconComponent
|
|
418
|
+
data-tooltip-id="system-tooltip"
|
|
419
|
+
data-tooltip-content={tooltipContent}
|
|
420
|
+
strokeWidth={2}
|
|
421
|
+
size={18}
|
|
422
|
+
className="tdaction"
|
|
423
|
+
key={key}
|
|
424
|
+
/>
|
|
425
|
+
);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
385
428
|
};
|
|
386
429
|
|
|
387
430
|
c.config.forEach((config) => {
|
|
388
|
-
const
|
|
389
|
-
|
|
431
|
+
const fieldValue = config.id.reduce((acc, id) => {
|
|
432
|
+
if (acc === "") {
|
|
433
|
+
return data[id];
|
|
434
|
+
} else {
|
|
435
|
+
return acc[id];
|
|
436
|
+
}
|
|
437
|
+
}, "");
|
|
390
438
|
|
|
391
439
|
const iconData = config.icons.find(
|
|
392
440
|
(icon) => icon.value === fieldValue
|
|
393
441
|
);
|
|
442
|
+
|
|
394
443
|
if (
|
|
395
444
|
iconData &&
|
|
396
|
-
iconData.src &&
|
|
445
|
+
(iconData.src || iconData.icon) &&
|
|
397
446
|
iconData.alt &&
|
|
398
447
|
iconData.tooltipContent
|
|
399
448
|
) {
|
|
400
449
|
addIcon(
|
|
401
|
-
iconData.src,
|
|
450
|
+
iconData.src ? iconData.src : null,
|
|
451
|
+
iconData.icon ? iconData.icon : null,
|
|
402
452
|
iconData.alt,
|
|
403
453
|
iconData.tooltipContent,
|
|
404
|
-
`coding-${
|
|
454
|
+
`coding-${config.id[0]}`
|
|
405
455
|
);
|
|
406
456
|
}
|
|
407
457
|
});
|
|
@@ -468,12 +518,16 @@ const DataGrid = forwardRef(
|
|
|
468
518
|
);
|
|
469
519
|
|
|
470
520
|
switch (s.id) {
|
|
521
|
+
case "archive":
|
|
522
|
+
return getIconComponent(ShippingBoxV1);
|
|
471
523
|
case "complete":
|
|
472
524
|
return getIconComponent(Check);
|
|
473
525
|
case "copy":
|
|
474
526
|
return getIconComponent(Copy);
|
|
475
527
|
case "delete":
|
|
476
528
|
return getIconComponent(Backspace);
|
|
529
|
+
case "family":
|
|
530
|
+
return getIconComponent(Network);
|
|
477
531
|
case "primary":
|
|
478
532
|
return getIconComponent(Ribbon);
|
|
479
533
|
case "ssa":
|
|
@@ -511,6 +565,7 @@ const DataGrid = forwardRef(
|
|
|
511
565
|
let icons = [];
|
|
512
566
|
let relationName;
|
|
513
567
|
let stage;
|
|
568
|
+
let style;
|
|
514
569
|
let value;
|
|
515
570
|
|
|
516
571
|
const commonProps = {
|
|
@@ -636,13 +691,29 @@ const DataGrid = forwardRef(
|
|
|
636
691
|
filterEditorProps: filterEditorProps,
|
|
637
692
|
render: ({ data }) => {
|
|
638
693
|
if (data && data[column.id]) {
|
|
639
|
-
|
|
640
|
-
column.
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
);
|
|
694
|
+
const value = moment(
|
|
695
|
+
data[column.id]
|
|
696
|
+
).format(column.format || "DD-MM-YYYY");
|
|
697
|
+
style = {};
|
|
644
698
|
|
|
645
|
-
|
|
699
|
+
if (
|
|
700
|
+
column.active &&
|
|
701
|
+
column.active.id &&
|
|
702
|
+
column.active.value === "expired"
|
|
703
|
+
) {
|
|
704
|
+
if (
|
|
705
|
+
data[column.active.id] &&
|
|
706
|
+
moment(
|
|
707
|
+
data[column.active.id]
|
|
708
|
+
).isBefore(moment())
|
|
709
|
+
) {
|
|
710
|
+
style = {
|
|
711
|
+
color: column.active.colour,
|
|
712
|
+
};
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
return <span style={style}>{value}</span>;
|
|
646
717
|
} else {
|
|
647
718
|
return null;
|
|
648
719
|
}
|
|
@@ -970,11 +1041,46 @@ const DataGrid = forwardRef(
|
|
|
970
1041
|
.filter((value) => value !== "");
|
|
971
1042
|
|
|
972
1043
|
if (values.length > 0) {
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
1044
|
+
let result = "";
|
|
1045
|
+
|
|
1046
|
+
if (
|
|
1047
|
+
column.relation?.id &&
|
|
1048
|
+
column.relation?.key
|
|
1049
|
+
) {
|
|
1050
|
+
const relationValue =
|
|
1051
|
+
column.relation.key.reduce(
|
|
1052
|
+
(acc, id) =>
|
|
1053
|
+
acc === ""
|
|
1054
|
+
? data[id]
|
|
1055
|
+
: acc && acc[id]
|
|
1056
|
+
? acc[id]
|
|
1057
|
+
: "",
|
|
1058
|
+
""
|
|
1059
|
+
);
|
|
1060
|
+
|
|
1061
|
+
result = `${
|
|
1062
|
+
relationValue[
|
|
1063
|
+
column.relation.id
|
|
1064
|
+
]
|
|
1065
|
+
}<br />`;
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
if (
|
|
1069
|
+
column.where &&
|
|
1070
|
+
column.where.id &&
|
|
1071
|
+
column.where.value
|
|
1072
|
+
) {
|
|
1073
|
+
if (
|
|
1074
|
+
data[column.where.id] ===
|
|
1075
|
+
column.where.value
|
|
1076
|
+
) {
|
|
1077
|
+
result += values.join("<br />");
|
|
1078
|
+
}
|
|
1079
|
+
} else {
|
|
1080
|
+
result += values.join("<br />");
|
|
1081
|
+
}
|
|
1082
|
+
|
|
1083
|
+
return <span>{parse(result)}</span>;
|
|
978
1084
|
}
|
|
979
1085
|
}
|
|
980
1086
|
|
|
@@ -987,9 +1093,13 @@ const DataGrid = forwardRef(
|
|
|
987
1093
|
name: column.id,
|
|
988
1094
|
render: ({ data }) => {
|
|
989
1095
|
if (data && data[column.id]) {
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
)
|
|
1096
|
+
value = data[column.id].split("<br />");
|
|
1097
|
+
|
|
1098
|
+
if (value[0]) {
|
|
1099
|
+
return <span>{parse(value[0])}</span>;
|
|
1100
|
+
} else {
|
|
1101
|
+
return null;
|
|
1102
|
+
}
|
|
993
1103
|
} else {
|
|
994
1104
|
return null;
|
|
995
1105
|
}
|
|
@@ -1144,6 +1254,12 @@ const DataGrid = forwardRef(
|
|
|
1144
1254
|
setFilterValue(newFilterValue);
|
|
1145
1255
|
}, [columns, filterDataSource]);
|
|
1146
1256
|
|
|
1257
|
+
useEffect(() => {
|
|
1258
|
+
if (setFilterData) {
|
|
1259
|
+
setFilterData(filterValue);
|
|
1260
|
+
}
|
|
1261
|
+
}, [filterValue]);
|
|
1262
|
+
|
|
1147
1263
|
useEffect(() => {
|
|
1148
1264
|
columns.forEach((column) => {
|
|
1149
1265
|
if (column.filter && column.filter.url) {
|
|
@@ -1242,6 +1358,7 @@ const DataGrid = forwardRef(
|
|
|
1242
1358
|
defaultSortInfo={sortInfo}
|
|
1243
1359
|
enableColumnAutosize={false}
|
|
1244
1360
|
enableColumnFilterContextMenu={false}
|
|
1361
|
+
enableSelection={false}
|
|
1245
1362
|
headerProps={headerProps}
|
|
1246
1363
|
idProperty={`visns-datagrid-${ajaxSetting.url.replace(
|
|
1247
1364
|
/\//g,
|
package/package.json
CHANGED
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"react-dom": "^17.0.1"
|
|
35
35
|
},
|
|
36
36
|
"name": "@visns-studio/visns-components",
|
|
37
|
-
"version": "1.2
|
|
37
|
+
"version": "1.3.2",
|
|
38
38
|
"description": "Various packages to assist in the development of our Custom Applications.",
|
|
39
39
|
"main": "index.js",
|
|
40
40
|
"devDependencies": {},
|