@visns-studio/visns-components 4.10.14 → 4.10.16
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 +3 -2
- package/src/components/crm/Field.jsx +179 -2
- package/src/components/crm/Form.jsx +11 -5
- package/src/components/crm/generic/GenericDynamic.jsx +58 -17
- package/src/components/crm/generic/GenericFormBuilder.jsx +60 -2
- package/src/components/crm/sketch/SketchField.jsx +365 -0
- package/src/components/crm/sketch/arrow.jsx +108 -0
- package/src/components/crm/sketch/circle.jsx +75 -0
- package/src/components/crm/sketch/default-tool.jsx +16 -0
- package/src/components/crm/sketch/fabrictool.jsx +22 -0
- package/src/components/crm/sketch/history.jsx +144 -0
- package/src/components/crm/sketch/json/config.json +9 -0
- package/src/components/crm/sketch/line.jsx +64 -0
- package/src/components/crm/sketch/pan.jsx +48 -0
- package/src/components/crm/sketch/pencil.jsx +36 -0
- package/src/components/crm/sketch/rectangle-label-object.jsx +69 -0
- package/src/components/crm/sketch/rectangle-label.jsx +93 -0
- package/src/components/crm/sketch/rectangle.jsx +76 -0
- package/src/components/crm/sketch/select.jsx +16 -0
- package/src/components/crm/sketch/tools.jsx +11 -0
- package/src/components/crm/sketch/utils.jsx +67 -0
- package/src/components/crm/styles/Field.module.scss +159 -0
- package/src/components/crm/styles/Form.module.scss +78 -0
- package/src/index.js +6 -0
package/package.json
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"awesome-debounce-promise": "^2.1.0",
|
|
17
17
|
"axios": "^1.7.7",
|
|
18
18
|
"dayjs": "^1.11.13",
|
|
19
|
+
"fabric": "^6.4.3",
|
|
19
20
|
"file-saver": "^2.0.5",
|
|
20
21
|
"framer-motion": "^11.11.9",
|
|
21
22
|
"html-react-parser": "^5.1.18",
|
|
@@ -75,7 +76,7 @@
|
|
|
75
76
|
"react-dom": "^17.0.0 || ^18.0.0"
|
|
76
77
|
},
|
|
77
78
|
"name": "@visns-studio/visns-components",
|
|
78
|
-
"version": "4.10.
|
|
79
|
+
"version": "4.10.16",
|
|
79
80
|
"description": "Various packages to assist in the development of our Custom Applications.",
|
|
80
81
|
"main": "src/index.js",
|
|
81
82
|
"files": [
|
|
@@ -96,5 +97,5 @@
|
|
|
96
97
|
"url": "https://github.com/visnsstudio/visns-components/issues"
|
|
97
98
|
},
|
|
98
99
|
"homepage": "https://github.com/visnsstudio/visns-components#readme",
|
|
99
|
-
"packageManager": "yarn@4.
|
|
100
|
+
"packageManager": "yarn@4.5.1"
|
|
100
101
|
}
|
|
@@ -11,7 +11,18 @@ import { BlockPicker } from 'react-color';
|
|
|
11
11
|
import { CopyToClipboard } from 'react-copy-to-clipboard';
|
|
12
12
|
import { NumericFormat, PatternFormat } from 'react-number-format';
|
|
13
13
|
import { Editor } from '@tinymce/tinymce-react';
|
|
14
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
Edit,
|
|
16
|
+
ChevronRight,
|
|
17
|
+
Circle,
|
|
18
|
+
CircleFill,
|
|
19
|
+
CirclePlus,
|
|
20
|
+
CloudDownload,
|
|
21
|
+
Minus,
|
|
22
|
+
ArrowBack,
|
|
23
|
+
TrashCan,
|
|
24
|
+
CircleX,
|
|
25
|
+
} from 'akar-icons';
|
|
15
26
|
import { toast } from 'react-toastify';
|
|
16
27
|
import styles from './styles/Field.module.scss';
|
|
17
28
|
|
|
@@ -19,13 +30,15 @@ import CustomFetch from './Fetch';
|
|
|
19
30
|
import Form from './Form';
|
|
20
31
|
import MultiSelect from './MultiSelect';
|
|
21
32
|
import Select from './Select';
|
|
33
|
+
import SketchConfig from './sketch/json/config.json';
|
|
34
|
+
import SketchField from './sketch/SketchField';
|
|
35
|
+
import Tools from './sketch/tools';
|
|
22
36
|
import VisnsAsyncSelect from './AsyncSelect';
|
|
23
37
|
import VisnsAutocomplete from './Autocomplete';
|
|
24
38
|
import VisnsDropZone from '../cms/DropZone';
|
|
25
39
|
|
|
26
40
|
import 'react-toggle/style.css';
|
|
27
41
|
import 'react-datepicker/dist/react-datepicker.css';
|
|
28
|
-
import Item from '../cms/sorting/Item';
|
|
29
42
|
|
|
30
43
|
function Field({
|
|
31
44
|
api,
|
|
@@ -38,6 +51,7 @@ function Field({
|
|
|
38
51
|
inputClass,
|
|
39
52
|
mapbox,
|
|
40
53
|
onChange,
|
|
54
|
+
onChangeCanvas,
|
|
41
55
|
onChangeCheckbox,
|
|
42
56
|
onChangeCheckboxManual,
|
|
43
57
|
onChangeColour,
|
|
@@ -65,6 +79,30 @@ function Field({
|
|
|
65
79
|
const [formItemClass, setFormItemClass] = useState('');
|
|
66
80
|
const [options, setOptions] = useState([]);
|
|
67
81
|
|
|
82
|
+
/** Canvas States */
|
|
83
|
+
const [canvasPopupOpen, setCanvasPopupOpen] = useState(false);
|
|
84
|
+
const [canvasUrl, setCanvasUrl] = useState('');
|
|
85
|
+
const [sketchTool, setSketchTool] = useState(Tools.Pencil);
|
|
86
|
+
const [toolClass, setToolClass] = useState('pencil');
|
|
87
|
+
const [lineWidth, setLineWidth] = useState(2);
|
|
88
|
+
const [lineColor, setLineColor] = useState('rgba(0, 0, 0, 1)');
|
|
89
|
+
const sketchRef = useRef(null);
|
|
90
|
+
|
|
91
|
+
/** Canvas Functions */
|
|
92
|
+
const handleCanvasSave = async () => {
|
|
93
|
+
// Save the current canvas state
|
|
94
|
+
const canvasState = sketchRef.current.saveCanvasState();
|
|
95
|
+
|
|
96
|
+
// Export the canvas image data as a Base64 string
|
|
97
|
+
const imageData = await sketchRef.current.exportCanvasImage(); // Use await here
|
|
98
|
+
|
|
99
|
+
// Call the onChangeCanvas function with both values
|
|
100
|
+
onChangeCanvas(settings, canvasState, imageData);
|
|
101
|
+
|
|
102
|
+
// Close the canvas popup
|
|
103
|
+
setCanvasPopupOpen(false);
|
|
104
|
+
};
|
|
105
|
+
|
|
68
106
|
const cover = {
|
|
69
107
|
position: 'fixed',
|
|
70
108
|
top: '0px',
|
|
@@ -154,6 +192,13 @@ function Field({
|
|
|
154
192
|
setFormItemClass(`${styles.formItem}`);
|
|
155
193
|
break;
|
|
156
194
|
}
|
|
195
|
+
|
|
196
|
+
if (settings.type === 'canvas') {
|
|
197
|
+
const canvasType = SketchConfig.canvasTypes.find(
|
|
198
|
+
(a) => a.id === settings.canvasType
|
|
199
|
+
);
|
|
200
|
+
setCanvasUrl(canvasType.url);
|
|
201
|
+
}
|
|
157
202
|
}, [settings, counter]);
|
|
158
203
|
|
|
159
204
|
const fetchChildDropdownData = (s, v) => {
|
|
@@ -258,6 +303,7 @@ function Field({
|
|
|
258
303
|
'address',
|
|
259
304
|
'async-dropdown-ajax',
|
|
260
305
|
'checkbox',
|
|
306
|
+
'canvas',
|
|
261
307
|
'colour',
|
|
262
308
|
'copytoclipboard',
|
|
263
309
|
'date',
|
|
@@ -386,6 +432,16 @@ function Field({
|
|
|
386
432
|
dataOptions={dataOptions}
|
|
387
433
|
/>
|
|
388
434
|
);
|
|
435
|
+
case 'canvas':
|
|
436
|
+
return canvasUrl ? (
|
|
437
|
+
<div
|
|
438
|
+
onClick={() => setCanvasPopupOpen(true)}
|
|
439
|
+
style={{ cursor: 'pointer' }}
|
|
440
|
+
>
|
|
441
|
+
<img src={canvasUrl} width="200" alt="Canvas Preview" />
|
|
442
|
+
</div>
|
|
443
|
+
) : null;
|
|
444
|
+
|
|
389
445
|
case 'checkbox':
|
|
390
446
|
return (
|
|
391
447
|
<div
|
|
@@ -1700,6 +1756,7 @@ function Field({
|
|
|
1700
1756
|
'address',
|
|
1701
1757
|
'async-dropdown-ajax',
|
|
1702
1758
|
'checkbox',
|
|
1759
|
+
'canvas',
|
|
1703
1760
|
'colour',
|
|
1704
1761
|
'copytoclipboard',
|
|
1705
1762
|
'date',
|
|
@@ -1897,6 +1954,126 @@ function Field({
|
|
|
1897
1954
|
updateForm={setChildForm}
|
|
1898
1955
|
/>
|
|
1899
1956
|
</Popup>
|
|
1957
|
+
<Popup
|
|
1958
|
+
open={canvasPopupOpen}
|
|
1959
|
+
onClose={() => setCanvasPopupOpen(false)}
|
|
1960
|
+
closeOnDocumentClick={false}
|
|
1961
|
+
>
|
|
1962
|
+
<div className={`${styles.modalwrap} ${styles['top--modal']}`}>
|
|
1963
|
+
<div className={styles.modal}>
|
|
1964
|
+
<div className={styles.modal__header}>
|
|
1965
|
+
<h1>Edit Canvas</h1>
|
|
1966
|
+
<button
|
|
1967
|
+
className={styles.modal__close}
|
|
1968
|
+
onClick={() => setCanvasPopupOpen(false)}
|
|
1969
|
+
>
|
|
1970
|
+
<CircleX size={24} color="#FFF" />
|
|
1971
|
+
</button>
|
|
1972
|
+
</div>
|
|
1973
|
+
<div
|
|
1974
|
+
className={`${styles.modal__content} ${styles.drawDiv}`}
|
|
1975
|
+
>
|
|
1976
|
+
{/* Sketch Tools */}
|
|
1977
|
+
<ul className={styles.drawactions}>
|
|
1978
|
+
<li>
|
|
1979
|
+
<button
|
|
1980
|
+
onClick={() => {
|
|
1981
|
+
handleCanvasSave();
|
|
1982
|
+
}}
|
|
1983
|
+
className={styles['drawactions--save']}
|
|
1984
|
+
>
|
|
1985
|
+
<CloudDownload size={16} /> Save
|
|
1986
|
+
</button>
|
|
1987
|
+
</li>
|
|
1988
|
+
<li>
|
|
1989
|
+
<button
|
|
1990
|
+
onClick={() => {
|
|
1991
|
+
setSketchTool(Tools.Pencil);
|
|
1992
|
+
setToolClass('pencil');
|
|
1993
|
+
}}
|
|
1994
|
+
className={`${
|
|
1995
|
+
styles['drawaction-pencil']
|
|
1996
|
+
} ${
|
|
1997
|
+
toolClass === 'pencil'
|
|
1998
|
+
? styles['drawactive']
|
|
1999
|
+
: ''
|
|
2000
|
+
}`}
|
|
2001
|
+
>
|
|
2002
|
+
<Edit size={16} /> Pencil
|
|
2003
|
+
</button>
|
|
2004
|
+
</li>
|
|
2005
|
+
<li>
|
|
2006
|
+
<button
|
|
2007
|
+
onClick={() => {
|
|
2008
|
+
setSketchTool(Tools.Line);
|
|
2009
|
+
|
|
2010
|
+
setToolClass('line');
|
|
2011
|
+
}}
|
|
2012
|
+
className={`${
|
|
2013
|
+
styles['drawaction-line']
|
|
2014
|
+
} ${
|
|
2015
|
+
toolClass === 'line'
|
|
2016
|
+
? styles['drawactive']
|
|
2017
|
+
: ''
|
|
2018
|
+
}`}
|
|
2019
|
+
>
|
|
2020
|
+
<Minus size={16} /> Line
|
|
2021
|
+
</button>
|
|
2022
|
+
</li>
|
|
2023
|
+
<li>
|
|
2024
|
+
<button
|
|
2025
|
+
onClick={() => {
|
|
2026
|
+
setSketchTool(Tools.Circle);
|
|
2027
|
+
|
|
2028
|
+
setToolClass('circle');
|
|
2029
|
+
}}
|
|
2030
|
+
className={`${
|
|
2031
|
+
styles['drawaction-circle']
|
|
2032
|
+
} ${
|
|
2033
|
+
toolClass === 'circle'
|
|
2034
|
+
? styles['drawactive']
|
|
2035
|
+
: ''
|
|
2036
|
+
}`}
|
|
2037
|
+
>
|
|
2038
|
+
<Circle size={16} /> Circle
|
|
2039
|
+
</button>
|
|
2040
|
+
</li>
|
|
2041
|
+
<li>
|
|
2042
|
+
<button
|
|
2043
|
+
onClick={() => sketchRef.current.undo()}
|
|
2044
|
+
className={styles['drawaction-undo']}
|
|
2045
|
+
>
|
|
2046
|
+
<ArrowBack size={16} /> Undo
|
|
2047
|
+
</button>
|
|
2048
|
+
</li>
|
|
2049
|
+
<li>
|
|
2050
|
+
<button
|
|
2051
|
+
onClick={() =>
|
|
2052
|
+
sketchRef.current.clearCanvas()
|
|
2053
|
+
}
|
|
2054
|
+
className={styles['drawactions--clear']}
|
|
2055
|
+
>
|
|
2056
|
+
<TrashCan size={16} /> Clear
|
|
2057
|
+
</button>
|
|
2058
|
+
</li>
|
|
2059
|
+
</ul>
|
|
2060
|
+
{(canvasUrl || inputValue.state) && (
|
|
2061
|
+
<SketchField
|
|
2062
|
+
ref={sketchRef}
|
|
2063
|
+
width={740}
|
|
2064
|
+
height={800}
|
|
2065
|
+
tool={sketchTool}
|
|
2066
|
+
lineColor={lineColor}
|
|
2067
|
+
lineWidth={lineWidth}
|
|
2068
|
+
className={styles.drawcontainer}
|
|
2069
|
+
backgroundImage={canvasUrl}
|
|
2070
|
+
defaultValue={inputValue.state || null}
|
|
2071
|
+
/>
|
|
2072
|
+
)}
|
|
2073
|
+
</div>
|
|
2074
|
+
</div>
|
|
2075
|
+
</div>
|
|
2076
|
+
</Popup>
|
|
1900
2077
|
</div>
|
|
1901
2078
|
);
|
|
1902
2079
|
}
|
|
@@ -151,6 +151,8 @@ function Form({
|
|
|
151
151
|
}
|
|
152
152
|
};
|
|
153
153
|
|
|
154
|
+
const handleChangeCanvas = (id, value) => {};
|
|
155
|
+
|
|
154
156
|
const handleChangeCheckbox = (e) => {
|
|
155
157
|
const { checked, name, value } = e.target;
|
|
156
158
|
|
|
@@ -1367,15 +1369,18 @@ function Form({
|
|
|
1367
1369
|
);
|
|
1368
1370
|
} else {
|
|
1369
1371
|
return (
|
|
1370
|
-
<div className=
|
|
1371
|
-
<div className=
|
|
1372
|
-
<div className=
|
|
1372
|
+
<div className={`${styles.modalwrap} ${styles['top--modal']}`}>
|
|
1373
|
+
<div className={styles.modal}>
|
|
1374
|
+
<div className={styles.modal__header}>
|
|
1373
1375
|
<h1>{formSettings[formType]?.title}</h1>
|
|
1374
|
-
<button
|
|
1376
|
+
<button
|
|
1377
|
+
className={styles.modal__close}
|
|
1378
|
+
onClick={closeModal}
|
|
1379
|
+
>
|
|
1375
1380
|
<CircleX strokeWidth={1} size={24} />
|
|
1376
1381
|
</button>
|
|
1377
1382
|
</div>
|
|
1378
|
-
<div className=
|
|
1383
|
+
<div className={styles.modal__content}>
|
|
1379
1384
|
<div className={styles.formcontainer}>
|
|
1380
1385
|
<form className={styles.modalForm}>
|
|
1381
1386
|
{formSettings?.fields?.map((item, index) => {
|
|
@@ -1426,6 +1431,7 @@ function Form({
|
|
|
1426
1431
|
}
|
|
1427
1432
|
mapbox={mapbox}
|
|
1428
1433
|
onChange={handleChange}
|
|
1434
|
+
onChangeCanvas={handleChangeCanvas}
|
|
1429
1435
|
onChangeCheckbox={
|
|
1430
1436
|
handleChangeCheckbox
|
|
1431
1437
|
}
|
|
@@ -31,6 +31,8 @@ const updateField = (fields, name, value) => {
|
|
|
31
31
|
|
|
32
32
|
const renderValue = (field, data) => {
|
|
33
33
|
switch (field.type) {
|
|
34
|
+
case 'canvas':
|
|
35
|
+
return field.value || '';
|
|
34
36
|
case 'datetime':
|
|
35
37
|
case 'date':
|
|
36
38
|
return field.value && moment(field.value).isValid()
|
|
@@ -103,6 +105,7 @@ const GenericDynamic = ({
|
|
|
103
105
|
}) => {
|
|
104
106
|
const [activeForm, setActiveForm] = useState({});
|
|
105
107
|
const [activeFormKey, setActiveFormKey] = useState(0);
|
|
108
|
+
const [canvasSaveCounter, setCanvasSaveCounter] = useState(0);
|
|
106
109
|
|
|
107
110
|
const handleChange = (e) => {
|
|
108
111
|
const {
|
|
@@ -174,6 +177,36 @@ const GenericDynamic = ({
|
|
|
174
177
|
}
|
|
175
178
|
};
|
|
176
179
|
|
|
180
|
+
const handleChangeCanvas = (fieldSetting, value, imageData) => {
|
|
181
|
+
// Check if activeForm has keys
|
|
182
|
+
if (activeForm && typeof activeForm === 'object') {
|
|
183
|
+
// Iterate over the keys in activeForm to find the matching id
|
|
184
|
+
for (const key in activeForm) {
|
|
185
|
+
if (activeForm[key].id === fieldSetting.id) {
|
|
186
|
+
// If a matching id is found, update the corresponding field
|
|
187
|
+
setActiveForm((prevState) => ({
|
|
188
|
+
...prevState,
|
|
189
|
+
[key]: {
|
|
190
|
+
...prevState[key],
|
|
191
|
+
value, // Update the value for the matching id
|
|
192
|
+
imageData,
|
|
193
|
+
},
|
|
194
|
+
}));
|
|
195
|
+
|
|
196
|
+
setCanvasSaveCounter((prevState) => prevState + 1);
|
|
197
|
+
return; // Exit after updating to prevent further iterations
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
useEffect(() => {
|
|
204
|
+
if (canvasSaveCounter > 0) {
|
|
205
|
+
console.info(activeForm);
|
|
206
|
+
handleSaveForm(false);
|
|
207
|
+
}
|
|
208
|
+
}, [canvasSaveCounter]);
|
|
209
|
+
|
|
177
210
|
const handleChangeCheckbox = (e) => {
|
|
178
211
|
const { checked, name, value } = e.target;
|
|
179
212
|
|
|
@@ -550,27 +583,29 @@ const GenericDynamic = ({
|
|
|
550
583
|
});
|
|
551
584
|
};
|
|
552
585
|
|
|
553
|
-
const handleSaveForm = async () => {
|
|
586
|
+
const handleSaveForm = async (validate = true) => {
|
|
554
587
|
try {
|
|
555
588
|
let error = '';
|
|
556
589
|
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
590
|
+
if (validate) {
|
|
591
|
+
const excludedTypes = [
|
|
592
|
+
'dynamicdata',
|
|
593
|
+
'plaintext',
|
|
594
|
+
'plaintextheading',
|
|
595
|
+
'section',
|
|
596
|
+
'table_radio',
|
|
597
|
+
];
|
|
564
598
|
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
599
|
+
Object.entries(activeForm).forEach(([key, field]) => {
|
|
600
|
+
if (
|
|
601
|
+
field.required === true &&
|
|
602
|
+
!excludedTypes.includes(field.type) &&
|
|
603
|
+
(field.value === null || field.value === '')
|
|
604
|
+
) {
|
|
605
|
+
error += `<p>${field.label} is required</p>`;
|
|
606
|
+
}
|
|
607
|
+
});
|
|
608
|
+
}
|
|
574
609
|
|
|
575
610
|
if (error === '') {
|
|
576
611
|
const res = await CustomFetch(setting.save, 'POST', {
|
|
@@ -836,6 +871,9 @@ const GenericDynamic = ({
|
|
|
836
871
|
onChange={
|
|
837
872
|
handleChange
|
|
838
873
|
}
|
|
874
|
+
onChangeCanvas={
|
|
875
|
+
handleChangeCanvas
|
|
876
|
+
}
|
|
839
877
|
onChangeCheckbox={
|
|
840
878
|
handleChangeCheckbox
|
|
841
879
|
}
|
|
@@ -884,6 +922,9 @@ const GenericDynamic = ({
|
|
|
884
922
|
originalData
|
|
885
923
|
)}
|
|
886
924
|
onChange={handleChange}
|
|
925
|
+
onChangeCanvas={
|
|
926
|
+
handleChangeCanvas
|
|
927
|
+
}
|
|
887
928
|
onChangeCheckbox={
|
|
888
929
|
handleChangeCheckbox
|
|
889
930
|
}
|
|
@@ -8,7 +8,7 @@ import Toggle from 'react-toggle';
|
|
|
8
8
|
import { toast } from 'react-toastify';
|
|
9
9
|
import { v4 as uuidv4 } from 'uuid';
|
|
10
10
|
import { Editor } from '@tinymce/tinymce-react';
|
|
11
|
-
import {
|
|
11
|
+
import { CirclePlus, CircleX, TrashCan } from 'akar-icons';
|
|
12
12
|
|
|
13
13
|
import 'react-toggle/style.css';
|
|
14
14
|
import 'react-datepicker/dist/react-datepicker.css';
|
|
@@ -17,6 +17,7 @@ import 'react-confirm-alert/src/react-confirm-alert.css';
|
|
|
17
17
|
import Breadcrumb from '../Breadcrumb';
|
|
18
18
|
import CustomFetch from '../Fetch';
|
|
19
19
|
import SortableList from '../../../components/cms/sorting/List';
|
|
20
|
+
import SketchConfig from '../sketch/json/config.json';
|
|
20
21
|
|
|
21
22
|
import styles from './styles/GenericFormBuilder.module.scss'; // Import the CSS module
|
|
22
23
|
|
|
@@ -44,7 +45,8 @@ function GenericFormBuilder({ setting, urlParam, userProfile }) {
|
|
|
44
45
|
label: '',
|
|
45
46
|
type: '',
|
|
46
47
|
});
|
|
47
|
-
const [fieldTypes
|
|
48
|
+
const [fieldTypes] = useState([
|
|
49
|
+
{ value: 'canvas', label: 'Canvas' },
|
|
48
50
|
{ value: 'checkbox', label: 'Checkbox' },
|
|
49
51
|
{ value: 'html5_date', label: 'Date' },
|
|
50
52
|
{ value: 'html5_datetime', label: 'Date & Time' },
|
|
@@ -78,6 +80,7 @@ function GenericFormBuilder({ setting, urlParam, userProfile }) {
|
|
|
78
80
|
});
|
|
79
81
|
const [modalFormShow, setModalFormShow] = useState(false);
|
|
80
82
|
const [roles, setRoles] = useState([]);
|
|
83
|
+
const canvasTypes = SketchConfig.canvasTypes;
|
|
81
84
|
|
|
82
85
|
/** Data Option Functionalities */
|
|
83
86
|
const handleDataOption = (e) => {
|
|
@@ -428,6 +431,21 @@ function GenericFormBuilder({ setting, urlParam, userProfile }) {
|
|
|
428
431
|
|
|
429
432
|
const renderField = (field) => {
|
|
430
433
|
switch (field.type) {
|
|
434
|
+
case 'canvas':
|
|
435
|
+
const canvasType = canvasTypes.find(
|
|
436
|
+
(item) => item.id === field.canvasType
|
|
437
|
+
);
|
|
438
|
+
return (
|
|
439
|
+
<label className={`${styles.fi__label}`}>
|
|
440
|
+
<span
|
|
441
|
+
className={`${styles.fi__span} ${styles.prefocus}`}
|
|
442
|
+
>
|
|
443
|
+
{field.label}{' '}
|
|
444
|
+
{field.required === 'yes' ? '*' : null}
|
|
445
|
+
</span>
|
|
446
|
+
<img src={canvasType.url} width="200" />
|
|
447
|
+
</label>
|
|
448
|
+
);
|
|
431
449
|
case 'checkbox':
|
|
432
450
|
return (
|
|
433
451
|
<label className={styles.fi__label}>
|
|
@@ -1679,6 +1697,46 @@ function GenericFormBuilder({ setting, urlParam, userProfile }) {
|
|
|
1679
1697
|
</div>
|
|
1680
1698
|
) : null}
|
|
1681
1699
|
|
|
1700
|
+
{['canvas'].includes(dataField.type) ? (
|
|
1701
|
+
<div className={styles.formItem}>
|
|
1702
|
+
<label className={styles.fi__label}>
|
|
1703
|
+
<select
|
|
1704
|
+
name="canvasType"
|
|
1705
|
+
value={dataField.canvasType}
|
|
1706
|
+
onChange={handleChangeForm}
|
|
1707
|
+
>
|
|
1708
|
+
<option>
|
|
1709
|
+
Please select a type
|
|
1710
|
+
</option>
|
|
1711
|
+
{canvasTypes.map(
|
|
1712
|
+
(
|
|
1713
|
+
canvasType,
|
|
1714
|
+
canvasTypeKey
|
|
1715
|
+
) => (
|
|
1716
|
+
<option
|
|
1717
|
+
value={
|
|
1718
|
+
canvasType.id
|
|
1719
|
+
}
|
|
1720
|
+
key={
|
|
1721
|
+
canvasTypeKey
|
|
1722
|
+
}
|
|
1723
|
+
>
|
|
1724
|
+
{
|
|
1725
|
+
canvasType.label
|
|
1726
|
+
}
|
|
1727
|
+
</option>
|
|
1728
|
+
)
|
|
1729
|
+
)}
|
|
1730
|
+
</select>
|
|
1731
|
+
<span
|
|
1732
|
+
className={styles.fi__span}
|
|
1733
|
+
>
|
|
1734
|
+
Canvas Type
|
|
1735
|
+
</span>
|
|
1736
|
+
</label>
|
|
1737
|
+
</div>
|
|
1738
|
+
) : null}
|
|
1739
|
+
|
|
1682
1740
|
{['signature'].includes(dataField.type) ? (
|
|
1683
1741
|
<div className={styles.formItem}>
|
|
1684
1742
|
<label className={styles.fi__label}>
|