@visns-studio/visns-components 5.6.11 → 5.6.12

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
@@ -84,7 +84,7 @@
84
84
  "react-dom": "^17.0.0 || ^18.0.0"
85
85
  },
86
86
  "name": "@visns-studio/visns-components",
87
- "version": "5.6.11",
87
+ "version": "5.6.12",
88
88
  "description": "Various packages to assist in the development of our Custom Applications.",
89
89
  "main": "src/index.js",
90
90
  "files": [
@@ -935,6 +935,12 @@ const DataGrid = forwardRef(
935
935
  const cellElement = event.target.closest(
936
936
  '.InovuaReactDataGrid__cell'
937
937
  );
938
+
939
+ // Add null check to prevent errors when cellElement is null
940
+ if (!cellElement) {
941
+ return; // Exit early if no cell element was found
942
+ }
943
+
938
944
  const columnIndex = Array.from(
939
945
  cellElement.parentNode.children
940
946
  ).indexOf(cellElement);
@@ -1042,6 +1048,12 @@ const DataGrid = forwardRef(
1042
1048
  const cellElement = event.target.closest(
1043
1049
  '.InovuaReactDataGrid__cell'
1044
1050
  );
1051
+
1052
+ // Add null check to prevent errors when cellElement is null
1053
+ if (!cellElement) {
1054
+ return; // Exit early if no cell element was found
1055
+ }
1056
+
1045
1057
  const columnIndex = Array.from(
1046
1058
  cellElement.parentNode.children
1047
1059
  ).indexOf(cellElement);
@@ -2773,13 +2785,68 @@ const DataGrid = forwardRef(
2773
2785
  e.preventDefault();
2774
2786
 
2775
2787
  // Check if every required field in column.validate exists and is truthy in data
2776
- const isValid =
2777
- column.validate?.every(
2778
- (v) =>
2779
- data[v]
2780
- ) ?? true;
2788
+ if (
2789
+ column.validate &&
2790
+ column.validate
2791
+ .length > 0
2792
+ ) {
2793
+ const missingFields =
2794
+ column.validate.filter(
2795
+ (v) =>
2796
+ !data[
2797
+ v
2798
+ ]
2799
+ );
2781
2800
 
2782
- if (isValid) {
2801
+ if (
2802
+ missingFields.length ===
2803
+ 0
2804
+ ) {
2805
+ handleTimer(
2806
+ data[
2807
+ form
2808
+ .primaryKey
2809
+ ],
2810
+ column.id
2811
+ );
2812
+ } else {
2813
+ // Format field names to be more readable
2814
+ const formattedFields =
2815
+ missingFields.map(
2816
+ (
2817
+ field
2818
+ ) => {
2819
+ // Try to find the column with this field ID to get its label
2820
+ const fieldColumn =
2821
+ columns.find(
2822
+ (
2823
+ col
2824
+ ) =>
2825
+ col.id ===
2826
+ field
2827
+ );
2828
+ // Use the label if found, otherwise use the field ID
2829
+ return (
2830
+ fieldColumn?.label ||
2831
+ field
2832
+ );
2833
+ }
2834
+ );
2835
+
2836
+ const fieldList =
2837
+ formattedFields.join(
2838
+ ', '
2839
+ );
2840
+ toast.error(
2841
+ `Please complete the following required field${
2842
+ missingFields.length >
2843
+ 1
2844
+ ? 's'
2845
+ : ''
2846
+ } before starting the timer: ${fieldList}`
2847
+ );
2848
+ }
2849
+ } else {
2783
2850
  handleTimer(
2784
2851
  data[
2785
2852
  form
@@ -2787,10 +2854,6 @@ const DataGrid = forwardRef(
2787
2854
  ],
2788
2855
  column.id
2789
2856
  );
2790
- } else {
2791
- toast.error(
2792
- 'Please complete the required fields before starting the timer.'
2793
- );
2794
2857
  }
2795
2858
  }}
2796
2859
  >