@visns-studio/visns-components 3.5.10 → 3.6.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.
@@ -506,6 +506,25 @@ function Field({
506
506
  </div>
507
507
  );
508
508
  case 'dynamicdata':
509
+ return (
510
+ <div
511
+ className="fi__div"
512
+ style={
513
+ settings.height
514
+ ? {
515
+ height: settings.height,
516
+ paddingTop: '10px',
517
+ marginLeft: '13px',
518
+ }
519
+ : {
520
+ paddingTop: '10px',
521
+ marginLeft: '13px',
522
+ }
523
+ }
524
+ >
525
+ {inputValue && inputValue !== 'null' ? inputValue : ''}
526
+ </div>
527
+ );
509
528
  case 'plaintext':
510
529
  return (
511
530
  <div
@@ -25,10 +25,32 @@ const updateField = (fields, name, value) => {
25
25
  }, {});
26
26
  };
27
27
 
28
- const renderValue = (field) => {
28
+ const renderValue = (field, data) => {
29
29
  switch (field.type) {
30
30
  case 'datetime':
31
31
  case 'date':
32
+ case 'dynamicdata':
33
+ if (field.dynamicfield && typeof field.dynamicfield === 'string') {
34
+ // Split the dynamicfield string into table and key parts using the "::" delimiter
35
+ const [table, key] = field.dynamicfield.split('::');
36
+
37
+ if (table && key) {
38
+ switch (table) {
39
+ case 'opportunities':
40
+ return data[table][key];
41
+ default:
42
+ return data[key];
43
+ }
44
+ } else {
45
+ console.warn(
46
+ `Dynamic field not found or invalid: ${field.dynamicfield}`
47
+ );
48
+ }
49
+ } else {
50
+ console.warn('Dynamic field is missing or not a string');
51
+ }
52
+ break;
53
+
32
54
  case 'time':
33
55
  return field.value && moment(field.value).isValid()
34
56
  ? moment(field.value).toDate()
@@ -373,7 +395,7 @@ const GenericDynamic = ({ data, fetchData, label, setData, setting, type }) => {
373
395
  }
374
396
  } else {
375
397
  setActiveForm([]);
376
- handleAddNewForm();
398
+ // handleAddNewForm();
377
399
  }
378
400
  }, [data, type]);
379
401
 
@@ -531,7 +553,8 @@ const GenericDynamic = ({ data, fetchData, label, setData, setting, type }) => {
531
553
  formData={activeForm}
532
554
  inputClass={''}
533
555
  inputValue={renderValue(
534
- field
556
+ field,
557
+ data
535
558
  )}
536
559
  onChange={handleChange}
537
560
  onChangeCheckbox={
@@ -14,6 +14,7 @@ import 'react-toggle/style.css';
14
14
  import 'react-datepicker/dist/react-datepicker.css';
15
15
  import 'react-confirm-alert/src/react-confirm-alert.css';
16
16
 
17
+ import Breadcrumb from '../Breadcrumb';
17
18
  import CustomFetch from '../Fetch';
18
19
  import SortableList from '../../../components/cms/sorting/List';
19
20
 
@@ -21,7 +22,7 @@ function GenericFormBuilder({ setting, urlParam, userProfile }) {
21
22
  const editorRef = useRef(null);
22
23
  const routeParams = useParams();
23
24
 
24
- const { fetchUrl, fields } = setting;
25
+ const { fetchUrl, fields, parentUrl, formTitle } = setting;
25
26
 
26
27
  const { dataId } = useParams();
27
28
  const [data, setData] = useState({});
@@ -31,7 +32,7 @@ function GenericFormBuilder({ setting, urlParam, userProfile }) {
31
32
  description: '',
32
33
  type: '',
33
34
  options: [],
34
- size: 'half',
35
+ size: 'quarter',
35
36
  required: 'no',
36
37
  });
37
38
  const [dataOption, setDataOption] = useState({
@@ -511,7 +512,7 @@ function GenericFormBuilder({ setting, urlParam, userProfile }) {
511
512
 
512
513
  if (_error === '') {
513
514
  const res = await CustomFetch(
514
- `/ajax/forms/${dataId}`,
515
+ `${fetchUrl}/${dataId}`,
515
516
  'PUT',
516
517
  {
517
518
  ...data,
@@ -553,7 +554,7 @@ function GenericFormBuilder({ setting, urlParam, userProfile }) {
553
554
  const saveOnSort = async () => {
554
555
  try {
555
556
  const res = await CustomFetch(
556
- `/ajax/forms/sort/${dataId}`,
557
+ `${fetchUrl}/sort/${dataId}`,
557
558
  'POST',
558
559
  {
559
560
  detail: data.detail,
@@ -584,9 +585,14 @@ function GenericFormBuilder({ setting, urlParam, userProfile }) {
584
585
  <div className="grid__row">
585
586
  <div className="grid__full crmtitle">
586
587
  <h1>
587
- <Link to="/forms">Form</Link>{' '}
588
- <CircleChevronRight strokeWidth={2} size={18} />{' '}
589
- {data.label}
588
+ <Breadcrumb
589
+ data={data}
590
+ page={{
591
+ previousUrl: parentUrl,
592
+ title: 'Forms',
593
+ titleKey: 'label',
594
+ }}
595
+ />
590
596
  </h1>
591
597
  </div>
592
598
  </div>
@@ -611,7 +617,7 @@ function GenericFormBuilder({ setting, urlParam, userProfile }) {
611
617
  <div className="grid__subcontent">
612
618
  <div className="formSplit">
613
619
  <div className="gridtxt__header">
614
- <span>Form Preview</span>
620
+ <span>{formTitle ? formTitle : null}</span>
615
621
  </div>
616
622
  {data.detail && data.detail.length > 0 ? (
617
623
  <div className="modal__content">
package/package.json CHANGED
@@ -50,7 +50,7 @@
50
50
  "react-dom": "^17.0.1"
51
51
  },
52
52
  "name": "@visns-studio/visns-components",
53
- "version": "3.5.10",
53
+ "version": "3.6.0",
54
54
  "description": "Various packages to assist in the development of our Custom Applications.",
55
55
  "main": "index.js",
56
56
  "scripts": {