@visns-studio/visns-components 4.6.12 → 4.7.0
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/Form.jsx
CHANGED
|
@@ -545,7 +545,6 @@ function Form({
|
|
|
545
545
|
e.preventDefault();
|
|
546
546
|
|
|
547
547
|
const { type } = e.target.dataset;
|
|
548
|
-
|
|
549
548
|
let fields = formSettings.fields;
|
|
550
549
|
let _inputClass = inputClass;
|
|
551
550
|
let validation = '';
|
|
@@ -556,86 +555,39 @@ function Form({
|
|
|
556
555
|
return;
|
|
557
556
|
}
|
|
558
557
|
|
|
559
|
-
if (item.required
|
|
560
|
-
if (
|
|
561
|
-
formData[item.id] === '' ||
|
|
562
|
-
formData[item.id] === undefined
|
|
563
|
-
) {
|
|
558
|
+
if (item.required) {
|
|
559
|
+
if (!formData[item.id]) {
|
|
564
560
|
if (
|
|
565
561
|
item.hasOwnProperty('required_check') &&
|
|
566
|
-
item.required_check
|
|
562
|
+
item.required_check &&
|
|
563
|
+
!formData[item.required_check]
|
|
567
564
|
) {
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
!validation.includes(
|
|
571
|
-
item.label +
|
|
572
|
-
' is a required field.<br/>'
|
|
573
|
-
)
|
|
574
|
-
) {
|
|
575
|
-
validation +=
|
|
576
|
-
item.label +
|
|
577
|
-
' is a required field.<br/>';
|
|
578
|
-
}
|
|
579
|
-
_inputClass[item.id] =
|
|
580
|
-
styles.inputError;
|
|
581
|
-
}
|
|
565
|
+
validation += `${item.label} is a required field.<br/>`;
|
|
566
|
+
_inputClass[item.id] = styles.inputError;
|
|
582
567
|
} else {
|
|
583
|
-
|
|
584
|
-
!validation.includes(
|
|
585
|
-
item.label +
|
|
586
|
-
' is a required field.<br/>'
|
|
587
|
-
)
|
|
588
|
-
) {
|
|
589
|
-
validation +=
|
|
590
|
-
item.label +
|
|
591
|
-
' is a required field.<br/>';
|
|
592
|
-
}
|
|
568
|
+
validation += `${item.label} is a required field.<br/>`;
|
|
593
569
|
_inputClass[item.id] = styles.inputError;
|
|
594
570
|
}
|
|
595
571
|
} else {
|
|
596
|
-
if (
|
|
597
|
-
item.hasOwnProperty('required_check') &&
|
|
598
|
-
item.required_check !== ''
|
|
599
|
-
) {
|
|
600
|
-
_inputClass[item.required_check] = '';
|
|
601
|
-
}
|
|
602
572
|
_inputClass[item.id] = '';
|
|
603
573
|
}
|
|
574
|
+
} else if (
|
|
575
|
+
item.hasOwnProperty('required_rely') &&
|
|
576
|
+
item.required_rely &&
|
|
577
|
+
formData[item.required_rely] &&
|
|
578
|
+
!formData[item.id]
|
|
579
|
+
) {
|
|
580
|
+
validation += `${item.label} is a required field.<br/>`;
|
|
581
|
+
_inputClass[item.id] = styles.inputError;
|
|
604
582
|
} else {
|
|
605
|
-
|
|
606
|
-
item.hasOwnProperty('required_rely') &&
|
|
607
|
-
item.required_rely !== ''
|
|
608
|
-
) {
|
|
609
|
-
if (formData[item.required_rely] === '') {
|
|
610
|
-
_inputClass[item.id] = '';
|
|
611
|
-
} else {
|
|
612
|
-
if (formData[item.id] === '') {
|
|
613
|
-
if (
|
|
614
|
-
!validation.includes(
|
|
615
|
-
item.label +
|
|
616
|
-
' is a required field.<br/>'
|
|
617
|
-
)
|
|
618
|
-
) {
|
|
619
|
-
validation +=
|
|
620
|
-
item.label +
|
|
621
|
-
' is a required field.<br/>';
|
|
622
|
-
}
|
|
623
|
-
_inputClass[item.id] =
|
|
624
|
-
styles.inputError;
|
|
625
|
-
} else {
|
|
626
|
-
_inputClass[item.id] = '';
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
} else {
|
|
630
|
-
_inputClass[item.id] = '';
|
|
631
|
-
}
|
|
583
|
+
_inputClass[item.id] = '';
|
|
632
584
|
}
|
|
633
585
|
});
|
|
634
586
|
|
|
635
587
|
setInputClass(_inputClass);
|
|
636
588
|
}
|
|
637
589
|
|
|
638
|
-
if (validation
|
|
590
|
+
if (validation) {
|
|
639
591
|
toast.error(<div>{parse(validation)}</div>);
|
|
640
592
|
} else {
|
|
641
593
|
let url = formSettings.url;
|
|
@@ -652,32 +604,26 @@ function Form({
|
|
|
652
604
|
} else {
|
|
653
605
|
switch (formType) {
|
|
654
606
|
case 'create':
|
|
655
|
-
if (
|
|
656
|
-
formSettings.hasOwnProperty('json') &&
|
|
657
|
-
formSettings.json === true
|
|
658
|
-
) {
|
|
607
|
+
if (formSettings.json) {
|
|
659
608
|
url += '/jsonStore';
|
|
660
609
|
}
|
|
661
610
|
break;
|
|
662
611
|
case 'update':
|
|
663
612
|
case 'delete':
|
|
664
|
-
if (
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
}`;
|
|
674
|
-
}
|
|
613
|
+
if (formSettings.json) {
|
|
614
|
+
url +=
|
|
615
|
+
formType === 'update'
|
|
616
|
+
? '/jsonUpdate'
|
|
617
|
+
: `/jsonDelete/${
|
|
618
|
+
formData[
|
|
619
|
+
formSettings.primaryKey
|
|
620
|
+
]
|
|
621
|
+
}`;
|
|
675
622
|
} else {
|
|
676
623
|
url += `/${
|
|
677
624
|
formData[formSettings.primaryKey]
|
|
678
625
|
}`;
|
|
679
626
|
}
|
|
680
|
-
|
|
681
627
|
method =
|
|
682
628
|
formType === 'update' ? 'PUT' : 'DELETE';
|
|
683
629
|
break;
|
|
@@ -686,46 +632,37 @@ function Form({
|
|
|
686
632
|
|
|
687
633
|
if (!_.isEmpty(formData)) {
|
|
688
634
|
Object.keys(formData).forEach((item) => {
|
|
689
|
-
if (
|
|
690
|
-
formData[item] !== undefined &&
|
|
691
|
-
(item === 'file' ||
|
|
692
|
-
(formData[item] instanceof File &&
|
|
693
|
-
formData[item] !== null))
|
|
694
|
-
) {
|
|
635
|
+
if (formData[item] instanceof File) {
|
|
695
636
|
fileUpload = true;
|
|
696
637
|
fileKey = item;
|
|
697
638
|
}
|
|
698
639
|
});
|
|
699
640
|
}
|
|
700
641
|
|
|
701
|
-
if (fileUpload
|
|
642
|
+
if (fileUpload && formData[fileKey]) {
|
|
702
643
|
if (Array.isArray(formData[fileKey])) {
|
|
703
|
-
const
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
const uploadedFiles = await Promise.all(
|
|
644
|
+
const uploadPromises = formData[fileKey].map(
|
|
645
|
+
async (file) => {
|
|
646
|
+
const fileRes = await Vapor.store(file, {
|
|
647
|
+
progress: (progress) => {
|
|
648
|
+
setUploadProgress(progress * 100);
|
|
649
|
+
},
|
|
650
|
+
});
|
|
651
|
+
return {
|
|
652
|
+
uuid: fileRes.uuid,
|
|
653
|
+
key: fileRes.key,
|
|
654
|
+
bucket: fileRes.bucket,
|
|
655
|
+
filename: file.name,
|
|
656
|
+
filesize: file.size,
|
|
657
|
+
extension: fileRes.extension,
|
|
658
|
+
file_relationship: fileKey,
|
|
659
|
+
};
|
|
660
|
+
}
|
|
661
|
+
);
|
|
662
|
+
formData['uploadedFiles'] = await Promise.all(
|
|
724
663
|
uploadPromises
|
|
725
664
|
);
|
|
726
|
-
|
|
727
|
-
formData['uploadedFiles'] = uploadedFiles;
|
|
728
|
-
} else if (formData[fileKey] instanceof File) {
|
|
665
|
+
} else {
|
|
729
666
|
const fileRes = await Vapor.store(
|
|
730
667
|
formData[fileKey],
|
|
731
668
|
{
|
|
@@ -734,7 +671,6 @@ function Form({
|
|
|
734
671
|
},
|
|
735
672
|
}
|
|
736
673
|
);
|
|
737
|
-
|
|
738
674
|
formData['uuid'] = fileRes.uuid;
|
|
739
675
|
formData['key'] = fileRes.key;
|
|
740
676
|
formData['bucket'] = fileRes.bucket;
|
|
@@ -745,60 +681,40 @@ function Form({
|
|
|
745
681
|
}
|
|
746
682
|
}
|
|
747
683
|
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
let payload = { ...formData };
|
|
757
|
-
Object.keys(formData).forEach((key) => {
|
|
758
|
-
const value = formData[key];
|
|
759
|
-
const field = fieldMap[key];
|
|
760
|
-
|
|
761
|
-
if (field && field.type === 'multi-dropdown-ajax') {
|
|
762
|
-
if (
|
|
763
|
-
typeof value === 'object' &&
|
|
764
|
-
value !== null &&
|
|
765
|
-
'value' in value &&
|
|
766
|
-
'label' in value
|
|
767
|
-
) {
|
|
768
|
-
payload[key] = value.value;
|
|
769
|
-
}
|
|
684
|
+
// Transform keys with dots into nested objects
|
|
685
|
+
const payload = Object.keys(formData).reduce((acc, key) => {
|
|
686
|
+
if (key.includes('.')) {
|
|
687
|
+
const [root, sub] = key.split('.');
|
|
688
|
+
if (!acc[root]) acc[root] = {};
|
|
689
|
+
acc[root][sub] = formData[key];
|
|
690
|
+
} else {
|
|
691
|
+
acc[key] = formData[key];
|
|
770
692
|
}
|
|
771
|
-
|
|
693
|
+
return acc;
|
|
694
|
+
}, {});
|
|
695
|
+
|
|
696
|
+
console.info(payload);
|
|
772
697
|
|
|
773
698
|
const res = await CustomFetch(url, method, payload);
|
|
774
699
|
|
|
775
700
|
if (res.data.error === '') {
|
|
776
|
-
if (fetchTable)
|
|
777
|
-
fetchTable();
|
|
778
|
-
}
|
|
779
|
-
|
|
701
|
+
if (fetchTable) fetchTable();
|
|
780
702
|
if (closeModal) {
|
|
781
703
|
closeModal();
|
|
782
|
-
|
|
783
704
|
if (type === 'saveAnother') {
|
|
784
705
|
fetchData();
|
|
785
706
|
modalOpen('create', 0);
|
|
786
707
|
}
|
|
787
708
|
}
|
|
788
|
-
|
|
789
709
|
toast.success(
|
|
790
|
-
formSettings?.save?.toast?.success
|
|
791
|
-
|
|
792
|
-
: 'Entry successfully saved into the system.'
|
|
710
|
+
formSettings?.save?.toast?.success ||
|
|
711
|
+
'Entry successfully saved into the system.'
|
|
793
712
|
);
|
|
794
713
|
|
|
795
|
-
if (
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
res.data.data.id
|
|
800
|
-
) {
|
|
801
|
-
navigate(formSettings.redirect + res.data.data.id);
|
|
714
|
+
if (formSettings.redirect && res.data.data?.id) {
|
|
715
|
+
navigate(
|
|
716
|
+
`${formSettings.redirect}${res.data.data.id}`
|
|
717
|
+
);
|
|
802
718
|
}
|
|
803
719
|
|
|
804
720
|
if (res.data.redirect) {
|
|
@@ -806,30 +722,26 @@ function Form({
|
|
|
806
722
|
}
|
|
807
723
|
|
|
808
724
|
if (
|
|
809
|
-
formSettings?.save?.return?.type &&
|
|
725
|
+
formSettings?.save?.return?.type === 'table' &&
|
|
810
726
|
formSettings?.save?.return?.param
|
|
811
727
|
) {
|
|
812
|
-
if (
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
columns: [],
|
|
830
|
-
dataSource: [],
|
|
831
|
-
}));
|
|
832
|
-
}
|
|
728
|
+
if (
|
|
729
|
+
res.data[formSettings.save.return.param]
|
|
730
|
+
?.length > 0
|
|
731
|
+
) {
|
|
732
|
+
const td = parseTableData(
|
|
733
|
+
res.data[formSettings.save.return.param]
|
|
734
|
+
);
|
|
735
|
+
setTableData((prevState) => ({
|
|
736
|
+
...prevState,
|
|
737
|
+
...td,
|
|
738
|
+
}));
|
|
739
|
+
} else {
|
|
740
|
+
setTableData((prevState) => ({
|
|
741
|
+
...prevState,
|
|
742
|
+
columns: [],
|
|
743
|
+
dataSource: [],
|
|
744
|
+
}));
|
|
833
745
|
}
|
|
834
746
|
}
|
|
835
747
|
}
|
|
@@ -10,7 +10,7 @@ import CustomFetch from '../Fetch';
|
|
|
10
10
|
|
|
11
11
|
import styles from './styles/Login.module.css';
|
|
12
12
|
|
|
13
|
-
const Login = ({
|
|
13
|
+
const Login = ({ logo, providers, setSystemAuth, setUserProfile }) => {
|
|
14
14
|
const location = useLocation();
|
|
15
15
|
|
|
16
16
|
const [auth, setAuth] = useState({
|
|
@@ -138,13 +138,6 @@ const Login = ({ loginBg, logo, providers, setSystemAuth, setUserProfile }) => {
|
|
|
138
138
|
return (
|
|
139
139
|
<div className={styles.lcontainer}>
|
|
140
140
|
<div className={styles.lwrap}>
|
|
141
|
-
<aside
|
|
142
|
-
className={styles.aside}
|
|
143
|
-
style={{
|
|
144
|
-
backgroundImage: `url(${loginBg})`,
|
|
145
|
-
backgroundSize: 'cover',
|
|
146
|
-
}}
|
|
147
|
-
></aside>
|
|
148
141
|
<div className={styles.logincontainer}>
|
|
149
142
|
<form onSubmit={handleSubmit}>
|
|
150
143
|
<Reveal effect="fadeInUp">
|
|
@@ -63,7 +63,6 @@
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
.logincontainer {
|
|
66
|
-
margin-left: var(--sidebar-width);
|
|
67
66
|
min-height: 100vh;
|
|
68
67
|
flex-grow: 1;
|
|
69
68
|
display: flex;
|
|
@@ -229,7 +228,6 @@ select:not(:placeholder-shown) + .fi__span {
|
|
|
229
228
|
}
|
|
230
229
|
|
|
231
230
|
.logincontainer {
|
|
232
|
-
margin-left: 0;
|
|
233
231
|
min-height: 100vh;
|
|
234
232
|
flex-grow: 1;
|
|
235
233
|
display: flex;
|
|
@@ -160,7 +160,7 @@ select:not(:placeholder-shown) + .fi__span {
|
|
|
160
160
|
):not(.inovua-react-toolkit-combo-box__input):not(
|
|
161
161
|
.inovua-react-toolkit-date-input__input
|
|
162
162
|
):not(.inovua-react-toolkit-numeric-input__input):hover {
|
|
163
|
-
border: 1px solid rgba(var(--
|
|
163
|
+
border: 1px solid rgba(var(--paragraph-color-rgb), 0.85);
|
|
164
164
|
transition: border 0.15s linear;
|
|
165
165
|
}
|
|
166
166
|
|
|
@@ -172,7 +172,7 @@ select:not(:placeholder-shown) + .fi__span {
|
|
|
172
172
|
):not(.inovua-react-toolkit-combo-box__input):not(
|
|
173
173
|
.inovua-react-toolkit-date-input__input
|
|
174
174
|
):not(.inovua-react-toolkit-numeric-input__input):focus {
|
|
175
|
-
border: 1px solid rgba(var(--
|
|
175
|
+
border: 1px solid rgba(var(--paragraph-color-rgb), 0.85);
|
|
176
176
|
}
|
|
177
177
|
|
|
178
178
|
input[type='file'] {
|
package/package.json
CHANGED