@visns-studio/visns-components 4.9.6 → 4.9.8

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
@@ -75,7 +75,7 @@
75
75
  "react-dom": "^17.0.0 || ^18.0.0"
76
76
  },
77
77
  "name": "@visns-studio/visns-components",
78
- "version": "4.9.6",
78
+ "version": "4.9.8",
79
79
  "description": "Various packages to assist in the development of our Custom Applications.",
80
80
  "main": "src/index.js",
81
81
  "files": [
@@ -566,7 +566,10 @@ function Form({
566
566
  }
567
567
 
568
568
  if (item.required) {
569
- if (!formData[item.id]) {
569
+ if (
570
+ formData[item.id] === null ||
571
+ formData[item.id] === ''
572
+ ) {
570
573
  if (
571
574
  item.hasOwnProperty('required_check') &&
572
575
  item.required_check &&
@@ -575,6 +578,7 @@ function Form({
575
578
  validation += `${item.label} is a required field.<br/>`;
576
579
  _inputClass[item.id] = styles.inputError;
577
580
  } else {
581
+ console.info('b', formData, item.id);
578
582
  validation += `${item.label} is a required field.<br/>`;
579
583
  _inputClass[item.id] = styles.inputError;
580
584
  }
@@ -585,7 +589,8 @@ function Form({
585
589
  item.hasOwnProperty('required_rely') &&
586
590
  item.required_rely &&
587
591
  formData[item.required_rely] &&
588
- !formData[item.id]
592
+ (formData[item.id] === null ||
593
+ formData[item.id] === '')
589
594
  ) {
590
595
  validation += `${item.label} is a required field.<br/>`;
591
596
  _inputClass[item.id] = styles.inputError;
@@ -604,6 +609,7 @@ function Form({
604
609
  let method = 'POST';
605
610
  let fileUpload = false;
606
611
  let fileKey = '';
612
+ let fileFieldSetting = '';
607
613
 
608
614
  if (formSettings.customUrl && formSettings.customMethod) {
609
615
  url = formSettings.customUrl;
@@ -645,6 +651,14 @@ function Form({
645
651
  if (formData[item] instanceof File) {
646
652
  fileUpload = true;
647
653
  fileKey = item;
654
+
655
+ if (formSettings.fields.length > 0) {
656
+ formSettings.fields.forEach((field) => {
657
+ if (field.id === item) {
658
+ fileFieldSetting = field;
659
+ }
660
+ });
661
+ }
648
662
  }
649
663
  });
650
664
  }
@@ -653,11 +667,29 @@ function Form({
653
667
  if (Array.isArray(formData[fileKey])) {
654
668
  const uploadPromises = formData[fileKey].map(
655
669
  async (file) => {
670
+ const toastId = toast.info(
671
+ `Uploading ${file.name}`,
672
+ {
673
+ progress: 0,
674
+ autoClose: false,
675
+ }
676
+ );
677
+
656
678
  const fileRes = await Vapor.store(file, {
657
679
  progress: (progress) => {
658
680
  setUploadProgress(progress * 100);
681
+ toast.update(toastId, {
682
+ progress,
683
+ });
659
684
  },
660
685
  });
686
+
687
+ toast.update(toastId, {
688
+ render: `${file.name} uploaded successfully!`,
689
+ type: toast.TYPE.SUCCESS,
690
+ autoClose: 3000,
691
+ });
692
+
661
693
  return {
662
694
  uuid: fileRes.uuid,
663
695
  key: fileRes.key,
@@ -666,21 +698,42 @@ function Form({
666
698
  filesize: file.size,
667
699
  extension: fileRes.extension,
668
700
  file_relationship: fileKey,
701
+ fileable_field:
702
+ fileFieldSetting.fileable_field,
669
703
  };
670
704
  }
671
705
  );
706
+
672
707
  formData['uploadedFiles'] = await Promise.all(
673
708
  uploadPromises
674
709
  );
675
710
  } else {
711
+ const toastId = toast.info(
712
+ `Uploading ${formData[fileKey].name}`,
713
+ {
714
+ progress: 0,
715
+ autoClose: false,
716
+ }
717
+ );
718
+
676
719
  const fileRes = await Vapor.store(
677
720
  formData[fileKey],
678
721
  {
679
722
  progress: (progress) => {
680
723
  setUploadProgress(progress * 100);
724
+ toast.update(toastId, {
725
+ progress,
726
+ });
681
727
  },
682
728
  }
683
729
  );
730
+
731
+ toast.update(toastId, {
732
+ render: `${formData[fileKey].name} uploaded successfully!`,
733
+ type: toast.TYPE.SUCCESS,
734
+ autoClose: 3000,
735
+ });
736
+
684
737
  formData['uuid'] = fileRes.uuid;
685
738
  formData['key'] = fileRes.key;
686
739
  formData['bucket'] = fileRes.bucket;
@@ -688,6 +741,8 @@ function Form({
688
741
  formData['filesize'] = formData[fileKey].size;
689
742
  formData['extension'] = fileRes.extension;
690
743
  formData['file_relationship'] = fileKey;
744
+ formData['fileable_field'] =
745
+ fileFieldSetting.fileable_field;
691
746
  }
692
747
  }
693
748