@visns-studio/visns-components 4.5.11 → 4.5.13
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/DataGrid.jsx +1 -0
- package/components/crm/Field.jsx +127 -36
- package/components/crm/Form.jsx +2 -2
- package/components/crm/MultiSelect.jsx +6 -1
- package/components/crm/generic/GenericDynamic.jsx +0 -4
- package/components/crm/generic/GenericIndex.jsx +0 -1
- package/components/crm/styles/Field.module.css +48 -0
- package/package.json +1 -1
package/components/crm/Field.jsx
CHANGED
|
@@ -6,6 +6,7 @@ import _ from 'lodash';
|
|
|
6
6
|
import Toggle from 'react-toggle';
|
|
7
7
|
import moment from 'moment';
|
|
8
8
|
import parse from 'html-react-parser';
|
|
9
|
+
import Popup from 'reactjs-popup';
|
|
9
10
|
import { BlockPicker } from 'react-color';
|
|
10
11
|
import { CopyToClipboard } from 'react-copy-to-clipboard';
|
|
11
12
|
import { NumericFormat, PatternFormat } from 'react-number-format';
|
|
@@ -15,6 +16,7 @@ import { toast } from 'react-toastify';
|
|
|
15
16
|
import styles from './styles/Field.module.css';
|
|
16
17
|
|
|
17
18
|
import CustomFetch from './Fetch';
|
|
19
|
+
import Form from './Form';
|
|
18
20
|
import MultiSelect from './MultiSelect';
|
|
19
21
|
import Select from './Select';
|
|
20
22
|
import VisnsAsyncSelect from './AsyncSelect';
|
|
@@ -54,6 +56,7 @@ function Field({
|
|
|
54
56
|
const editorRef = useRef(null);
|
|
55
57
|
const fileImageInputRef = useRef(null);
|
|
56
58
|
const [colorPickerShow, setColorPickerShow] = useState(false);
|
|
59
|
+
const [counter, setCounter] = useState(0);
|
|
57
60
|
const [dataOptions, setDataOptions] = useState([]);
|
|
58
61
|
const [formItemStyle, setFormItemStyle] = useState({});
|
|
59
62
|
const [formItemClass, setFormItemClass] = useState('formItem');
|
|
@@ -142,7 +145,7 @@ function Field({
|
|
|
142
145
|
} else if (settings.size === 'quarter') {
|
|
143
146
|
setFormItemClass('formItem qtrItem');
|
|
144
147
|
}
|
|
145
|
-
}, [settings]);
|
|
148
|
+
}, [settings, counter]);
|
|
146
149
|
|
|
147
150
|
useEffect(() => {
|
|
148
151
|
const fetchChildDropdownData = () => {
|
|
@@ -220,7 +223,7 @@ function Field({
|
|
|
220
223
|
};
|
|
221
224
|
|
|
222
225
|
fetchChildDropdownData();
|
|
223
|
-
}, [inputValue, settings]);
|
|
226
|
+
}, [inputValue, settings, counter]);
|
|
224
227
|
|
|
225
228
|
useEffect(() => {
|
|
226
229
|
const processOptions = () => {
|
|
@@ -532,18 +535,35 @@ function Field({
|
|
|
532
535
|
case 'dropdown':
|
|
533
536
|
case 'dropdown-ajax':
|
|
534
537
|
return (
|
|
535
|
-
<
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
538
|
+
<div className={styles.dropdownContainer}>
|
|
539
|
+
<Select
|
|
540
|
+
settings={settings}
|
|
541
|
+
className={
|
|
542
|
+
settings.create ? styles.selectFullWidth : ''
|
|
543
|
+
}
|
|
544
|
+
onChange={onChange}
|
|
545
|
+
inputValue={inputValue === null ? '' : inputValue}
|
|
546
|
+
options={
|
|
547
|
+
settings.type === 'dropdown'
|
|
548
|
+
? settings.options
|
|
549
|
+
: options
|
|
550
|
+
}
|
|
551
|
+
dataOptions={dataOptions}
|
|
552
|
+
/>
|
|
553
|
+
|
|
554
|
+
{settings.create && (
|
|
555
|
+
<button
|
|
556
|
+
className={styles.buttonRight}
|
|
557
|
+
onClick={(e) => {
|
|
558
|
+
e.preventDefault();
|
|
559
|
+
|
|
560
|
+
handleAddEntry(settings.create);
|
|
561
|
+
}}
|
|
562
|
+
>
|
|
563
|
+
<CirclePlus strokeWidth={2} size={16} />
|
|
564
|
+
</button>
|
|
565
|
+
)}
|
|
566
|
+
</div>
|
|
547
567
|
);
|
|
548
568
|
case 'dynamicdata':
|
|
549
569
|
return (
|
|
@@ -849,28 +869,44 @@ function Field({
|
|
|
849
869
|
case 'multi-dropdown':
|
|
850
870
|
case 'multi-dropdown-ajax':
|
|
851
871
|
return (
|
|
852
|
-
<
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
872
|
+
<div className={styles.dropdownContainer}>
|
|
873
|
+
<MultiSelect
|
|
874
|
+
settings={settings}
|
|
875
|
+
className={
|
|
876
|
+
settings.create ? styles.selectFullWidth : ''
|
|
877
|
+
}
|
|
878
|
+
multi={
|
|
879
|
+
settings.hasOwnProperty('multi')
|
|
880
|
+
? settings.multi
|
|
881
|
+
: false
|
|
882
|
+
}
|
|
883
|
+
onChange={onChangeSelect}
|
|
884
|
+
inputValue={
|
|
885
|
+
inputValue === null || inputValue === undefined
|
|
886
|
+
? ''
|
|
887
|
+
: inputValue
|
|
888
|
+
}
|
|
889
|
+
options={
|
|
890
|
+
settings.type === 'multi-dropdown'
|
|
891
|
+
? settings.options
|
|
892
|
+
: options
|
|
893
|
+
}
|
|
894
|
+
dataOptions={dataOptions}
|
|
895
|
+
style={style}
|
|
896
|
+
/>
|
|
897
|
+
{settings.create && (
|
|
898
|
+
<button
|
|
899
|
+
className={styles.buttonRight}
|
|
900
|
+
onClick={(e) => {
|
|
901
|
+
e.preventDefault();
|
|
902
|
+
|
|
903
|
+
handleAddEntry(settings.create);
|
|
904
|
+
}}
|
|
905
|
+
>
|
|
906
|
+
<CirclePlus strokeWidth={2} size={16} />
|
|
907
|
+
</button>
|
|
908
|
+
)}
|
|
909
|
+
</div>
|
|
874
910
|
);
|
|
875
911
|
case 'percentage':
|
|
876
912
|
return (
|
|
@@ -1441,6 +1477,40 @@ function Field({
|
|
|
1441
1477
|
}
|
|
1442
1478
|
};
|
|
1443
1479
|
|
|
1480
|
+
/** Child Form */
|
|
1481
|
+
const [childForm, setChildForm] = useState({});
|
|
1482
|
+
const [childFormShow, setChildFormShow] = useState(false);
|
|
1483
|
+
|
|
1484
|
+
const childFormClose = () => {
|
|
1485
|
+
setChildFormShow(false);
|
|
1486
|
+
setChildForm({});
|
|
1487
|
+
};
|
|
1488
|
+
|
|
1489
|
+
const childFormOpen = () => {
|
|
1490
|
+
setChildFormShow(true);
|
|
1491
|
+
};
|
|
1492
|
+
|
|
1493
|
+
const handleAddEntry = (form) => {
|
|
1494
|
+
if (form) {
|
|
1495
|
+
let f = form;
|
|
1496
|
+
|
|
1497
|
+
form.fields.forEach((item, itemKey) => {
|
|
1498
|
+
if (item.hasOwnProperty('dataId') && formData[item.dataId]) {
|
|
1499
|
+
f.fields[itemKey].value = formData[item.dataId].value
|
|
1500
|
+
? formData[item.dataId].value
|
|
1501
|
+
: formData[item.dataId];
|
|
1502
|
+
}
|
|
1503
|
+
});
|
|
1504
|
+
|
|
1505
|
+
setChildForm(f);
|
|
1506
|
+
childFormOpen();
|
|
1507
|
+
}
|
|
1508
|
+
};
|
|
1509
|
+
|
|
1510
|
+
const handleReload = () => {
|
|
1511
|
+
setCounter(counter + 1);
|
|
1512
|
+
};
|
|
1513
|
+
|
|
1444
1514
|
return (
|
|
1445
1515
|
<div className={formItemClass} style={formItemStyle}>
|
|
1446
1516
|
<label className={styles.fi__label}>
|
|
@@ -1449,6 +1519,27 @@ function Field({
|
|
|
1449
1519
|
{renderFieldLabel()}
|
|
1450
1520
|
</label>
|
|
1451
1521
|
{renderAdditionalContainer()}
|
|
1522
|
+
<Popup
|
|
1523
|
+
open={childFormShow}
|
|
1524
|
+
onClose={childFormClose}
|
|
1525
|
+
closeOnDocumentClick={false}
|
|
1526
|
+
>
|
|
1527
|
+
<Form
|
|
1528
|
+
ajaxSetting={childForm.ajaxSetting}
|
|
1529
|
+
api={api}
|
|
1530
|
+
closeModal={childFormClose}
|
|
1531
|
+
columnId={0}
|
|
1532
|
+
fetchTable={handleReload}
|
|
1533
|
+
formSettings={childForm}
|
|
1534
|
+
formType={'create'}
|
|
1535
|
+
gridRef={null}
|
|
1536
|
+
mapbox={null}
|
|
1537
|
+
modalOpen={childFormOpen}
|
|
1538
|
+
paramValue={null}
|
|
1539
|
+
style={style}
|
|
1540
|
+
updateForm={setChildForm}
|
|
1541
|
+
/>
|
|
1542
|
+
</Popup>
|
|
1452
1543
|
</div>
|
|
1453
1544
|
);
|
|
1454
1545
|
}
|
package/components/crm/Form.jsx
CHANGED
|
@@ -1348,7 +1348,7 @@ function Form({
|
|
|
1348
1348
|
<div className="modalwrap top--modal">
|
|
1349
1349
|
<div className="modal">
|
|
1350
1350
|
<div className="modal__header">
|
|
1351
|
-
<h1>{formSettings[formType]
|
|
1351
|
+
<h1>{formSettings[formType]?.title}</h1>
|
|
1352
1352
|
<button className="modal__close" onClick={closeModal}>
|
|
1353
1353
|
<CircleX strokeWidth={1} size={24} />
|
|
1354
1354
|
</button>
|
|
@@ -1356,7 +1356,7 @@ function Form({
|
|
|
1356
1356
|
<div className="modal__content">
|
|
1357
1357
|
<div className={styles.formcontainer}>
|
|
1358
1358
|
<form className={styles.modalForm}>
|
|
1359
|
-
{formSettings
|
|
1359
|
+
{formSettings?.fields?.map((item, index) => {
|
|
1360
1360
|
if (
|
|
1361
1361
|
item.hasOwnProperty('hide') &&
|
|
1362
1362
|
item.hide === true
|
|
@@ -4,6 +4,7 @@ import Select, { createFilter } from 'react-select';
|
|
|
4
4
|
import styles from './styles/AsyncSelect.module.css';
|
|
5
5
|
|
|
6
6
|
function MultiSelect({
|
|
7
|
+
className,
|
|
7
8
|
inputValue,
|
|
8
9
|
multi,
|
|
9
10
|
onChange,
|
|
@@ -52,7 +53,11 @@ function MultiSelect({
|
|
|
52
53
|
onChange={(inputValue, action) => {
|
|
53
54
|
onChange(inputValue, action, settings.id);
|
|
54
55
|
}}
|
|
55
|
-
className={
|
|
56
|
+
className={
|
|
57
|
+
className
|
|
58
|
+
? `${styles.visns__ms} ${className}`
|
|
59
|
+
: styles.visns__ms
|
|
60
|
+
}
|
|
56
61
|
classNamePrefix="visns-select"
|
|
57
62
|
styles={{
|
|
58
63
|
menu: (provided) => ({ ...provided, zIndex: 9999 }),
|
|
@@ -268,8 +268,6 @@ const GenericDynamic = ({
|
|
|
268
268
|
return prevActiveForm;
|
|
269
269
|
}
|
|
270
270
|
|
|
271
|
-
console.info(prevActiveForm);
|
|
272
|
-
|
|
273
271
|
// Create a new row with placeholders based on the options length
|
|
274
272
|
const numOptions = prevActiveForm[formKey].options.length;
|
|
275
273
|
const newRow = Array(numOptions).fill(''); // Create an array of empty strings
|
|
@@ -590,8 +588,6 @@ const GenericDynamic = ({
|
|
|
590
588
|
}, [activeForm]);
|
|
591
589
|
|
|
592
590
|
const shouldDisplayFormList = (data, type) => {
|
|
593
|
-
console.info(data[type]);
|
|
594
|
-
|
|
595
591
|
if (!data[type] || !Array.isArray(data[type])) {
|
|
596
592
|
return false;
|
|
597
593
|
}
|
|
@@ -7,6 +7,35 @@
|
|
|
7
7
|
box-sizing: border-box;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
.dropdownContainer {
|
|
11
|
+
position: relative;
|
|
12
|
+
width: 100%;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.selectFullWidth {
|
|
16
|
+
width: 90%;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.buttonRight {
|
|
20
|
+
position: absolute;
|
|
21
|
+
right: 0;
|
|
22
|
+
top: 50%;
|
|
23
|
+
transform: translateY(-50%);
|
|
24
|
+
z-index: 1;
|
|
25
|
+
background: var(--primary-color);
|
|
26
|
+
color: var(--secondary-color);
|
|
27
|
+
padding: 1rem 0.5rem;
|
|
28
|
+
border: none;
|
|
29
|
+
border-radius: var(--br);
|
|
30
|
+
cursor: pointer;
|
|
31
|
+
transition: background 0.3s;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.buttonRight:hover {
|
|
35
|
+
background: var(--secondary-color);
|
|
36
|
+
color: var(--primary-color);
|
|
37
|
+
}
|
|
38
|
+
|
|
10
39
|
.formItem .fi__label {
|
|
11
40
|
position: relative;
|
|
12
41
|
display: block;
|
|
@@ -51,6 +80,25 @@ select:not(:placeholder-shown) + .fi__span {
|
|
|
51
80
|
top: 0;
|
|
52
81
|
}
|
|
53
82
|
|
|
83
|
+
.fi__button--right {
|
|
84
|
+
position: absolute;
|
|
85
|
+
right: 50px;
|
|
86
|
+
top: 20px;
|
|
87
|
+
z-index: 500;
|
|
88
|
+
background: var(--primary-color);
|
|
89
|
+
color: var(--item-color);
|
|
90
|
+
padding: 0.2rem 0.4rem;
|
|
91
|
+
border: none;
|
|
92
|
+
border-radius: var(--br);
|
|
93
|
+
cursor: pointer;
|
|
94
|
+
transition: background 0.3s;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.fi__button--right:hover {
|
|
98
|
+
background: var(--secondary-color);
|
|
99
|
+
color: var(--primary-color);
|
|
100
|
+
}
|
|
101
|
+
|
|
54
102
|
.formItem textarea,
|
|
55
103
|
.formItem select,
|
|
56
104
|
.formItem
|
package/package.json
CHANGED