@visns-studio/visns-components 4.10.46 → 4.10.48

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
@@ -77,7 +77,7 @@
77
77
  "react-dom": "^17.0.0 || ^18.0.0"
78
78
  },
79
79
  "name": "@visns-studio/visns-components",
80
- "version": "4.10.46",
80
+ "version": "4.10.48",
81
81
  "description": "Various packages to assist in the development of our Custom Applications.",
82
82
  "main": "src/index.js",
83
83
  "files": [
@@ -2064,6 +2064,38 @@ const DataGrid = forwardRef(
2064
2064
  }, '');
2065
2065
 
2066
2066
  if (value) {
2067
+ let columnStyle = {};
2068
+ let columnValueChecker = '';
2069
+
2070
+ if (
2071
+ column?.active?.id &&
2072
+ column?.active?.value
2073
+ ) {
2074
+ if (
2075
+ data[column.active.id]
2076
+ ?.value
2077
+ ) {
2078
+ columnValueChecker =
2079
+ data[column.active.id]
2080
+ ?.value;
2081
+ } else if (
2082
+ data[column.active.id]
2083
+ ) {
2084
+ columnValueChecker =
2085
+ data[column.active.id];
2086
+ }
2087
+
2088
+ if (
2089
+ columnValueChecker ===
2090
+ column.active.value
2091
+ ) {
2092
+ columnStyle = {
2093
+ color: column.active
2094
+ .colour,
2095
+ };
2096
+ }
2097
+ }
2098
+
2067
2099
  if (Array.isArray(value)) {
2068
2100
  if (value[0]) {
2069
2101
  value = value[0];
@@ -2096,7 +2128,7 @@ const DataGrid = forwardRef(
2096
2128
  column.placeholder !== ''
2097
2129
  ) {
2098
2130
  return (
2099
- <span>
2131
+ <span style={columnStyle}>
2100
2132
  {column.placeholder}
2101
2133
  </span>
2102
2134
  );
@@ -2117,7 +2149,13 @@ const DataGrid = forwardRef(
2117
2149
  }
2118
2150
 
2119
2151
  if (typeof value === 'string') {
2120
- return <span>{value}</span>;
2152
+ return (
2153
+ <span
2154
+ style={columnStyle}
2155
+ >
2156
+ {value}
2157
+ </span>
2158
+ );
2121
2159
  } else {
2122
2160
  return null;
2123
2161
  }
@@ -218,11 +218,14 @@ function Form({
218
218
  updateFormData({ [id]: inputValue });
219
219
 
220
220
  // Update any matching form data properties
221
- Object.keys(inputValue).forEach((key) => {
222
- if (formData.hasOwnProperty(key)) {
223
- updateFormData({ [key]: inputValue[key] });
224
- }
225
- });
221
+ Object.keys(inputValue)
222
+ .filter(
223
+ (key) =>
224
+ formData.hasOwnProperty(key) &&
225
+ key !== 'id' &&
226
+ key !== 'label'
227
+ )
228
+ .forEach((key) => updateFormData({ [key]: inputValue[key] }));
226
229
 
227
230
  formSettings.fields.forEach((field) => {
228
231
  if (field.id === id && field.trigger) {
@@ -710,87 +713,55 @@ function Form({
710
713
  });
711
714
  }
712
715
 
713
- if (Array.isArray(formData[fileKey])) {
714
- if (fileUpload && formData[fileKey]) {
715
- const uploadPromises = formData[fileKey].map(
716
- async (file) => {
717
- const toastId = toast.info(
718
- `Uploading ${file.name}`,
719
- {
720
- progress: 0,
721
- autoClose: false,
722
- }
723
- );
724
-
725
- const fileRes = await Vapor.store(file, {
726
- progress: (progress) => {
727
- setUploadProgress(progress * 100);
728
- toast.update(toastId, {
729
- progress,
730
- });
731
- },
732
- });
733
-
734
- toast.update(toastId, {
735
- render: `${file.name} uploaded successfully!`,
736
- type: 'success',
737
- autoClose: 3000,
738
- });
739
-
740
- return {
741
- uuid: fileRes.uuid,
742
- key: fileRes.key,
743
- bucket: fileRes.bucket,
744
- filename: file.name,
745
- filesize: file.size,
746
- extension: fileRes.extension,
747
- file_relationship: fileKey,
748
- fileable_field:
749
- fileFieldSetting.fileable_field,
750
- };
751
- }
752
- );
716
+ const files = Array.isArray(formData[fileKey])
717
+ ? formData[fileKey]
718
+ : [formData[fileKey]];
753
719
 
754
- formData['uploadedFiles'] = await Promise.all(
755
- uploadPromises
756
- );
757
- } else {
720
+ if (fileUpload && files.length > 0) {
721
+ const uploadPromises = files.map(async (file) => {
758
722
  const toastId = toast.info(
759
- `Uploading ${formData[fileKey].name}`,
723
+ `Uploading ${file.name}`,
760
724
  {
761
725
  progress: 0,
762
726
  autoClose: false,
763
727
  }
764
728
  );
765
729
 
766
- const fileRes = await Vapor.store(
767
- formData[fileKey],
768
- {
769
- progress: (progress) => {
770
- setUploadProgress(progress * 100);
771
- toast.update(toastId, {
772
- progress,
773
- });
774
- },
775
- }
776
- );
730
+ const fileRes = await Vapor.store(file, {
731
+ progress: (progress) => {
732
+ setUploadProgress(progress * 100);
733
+ toast.update(toastId, { progress });
734
+ },
735
+ });
777
736
 
778
737
  toast.update(toastId, {
779
- render: `${formData[fileKey].name} uploaded successfully!`,
738
+ render: `${file.name} uploaded successfully!`,
780
739
  type: 'success',
781
740
  autoClose: 3000,
782
741
  });
783
742
 
784
- formData['uuid'] = fileRes.uuid;
785
- formData['key'] = fileRes.key;
786
- formData['bucket'] = fileRes.bucket;
787
- formData['filename'] = formData[fileKey].name;
788
- formData['filesize'] = formData[fileKey].size;
789
- formData['extension'] = fileRes.extension;
790
- formData['file_relationship'] = fileKey;
791
- formData['fileable_field'] =
792
- fileFieldSetting.fileable_field;
793
- }
743
+ return {
744
+ uuid: fileRes.uuid,
745
+ key: fileRes.key,
746
+ bucket: fileRes.bucket,
747
+ filename: file.name,
748
+ filesize: file.size,
749
+ extension: fileRes.extension,
750
+ file_relationship: fileKey,
751
+ fileable_field:
752
+ fileFieldSetting.fileable_field ||
753
+ fileFieldSetting.id,
754
+ };
755
+ });
756
+
757
+ // Wait for all uploads to complete
758
+ const uploadedFiles = await Promise.all(uploadPromises);
759
+
760
+ // If there are multiple files, store them as an array, otherwise as a single object
761
+ formData['uploadedFiles'] =
762
+ uploadedFiles.length > 1
763
+ ? uploadedFiles
764
+ : uploadedFiles[0];
794
765
  }
795
766
 
796
767
  // Transform keys with dots into nested objects
@@ -805,8 +776,6 @@ function Form({
805
776
  return acc;
806
777
  }, {});
807
778
 
808
- console.info('Payload:', payload);
809
-
810
779
  const res = await CustomFetch(url, method, payload);
811
780
 
812
781
  if (res.data.error === '') {