@visns-studio/visns-components 3.5.9 → 3.5.11

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()
@@ -229,18 +251,6 @@ const GenericDynamic = ({ data, fetchData, label, setData, setting, type }) => {
229
251
  }
230
252
  };
231
253
 
232
- // Utility function to slugify a string
233
- const slugify = (text) => {
234
- return text
235
- .toString()
236
- .toLowerCase()
237
- .replace(/\s+/g, '-') // Replace spaces with -
238
- .replace(/[^\w\-]+/g, '') // Remove all non-word chars
239
- .replace(/\-\-+/g, '-') // Replace multiple - with single -
240
- .replace(/^-+/, '') // Trim - from start of text
241
- .replace(/-+$/, ''); // Trim - from end of text
242
- };
243
-
244
254
  const handleDownloadForm = async (item, key) => {
245
255
  // Show loading toast and keep its ID
246
256
  const toastId = toast.loading('Downloading form...');
@@ -384,7 +394,8 @@ const GenericDynamic = ({ data, fetchData, label, setData, setting, type }) => {
384
394
  setActiveFormKey(data[type].length - 1);
385
395
  }
386
396
  } else {
387
- handleAddNewForm();
397
+ setActiveForm([]);
398
+ // handleAddNewForm();
388
399
  }
389
400
  }, [data, type]);
390
401
 
@@ -542,7 +553,8 @@ const GenericDynamic = ({ data, fetchData, label, setData, setting, type }) => {
542
553
  formData={activeForm}
543
554
  inputClass={''}
544
555
  inputValue={renderValue(
545
- field
556
+ field,
557
+ data
546
558
  )}
547
559
  onChange={handleChange}
548
560
  onChangeCheckbox={
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.9",
53
+ "version": "3.5.11",
54
54
  "description": "Various packages to assist in the development of our Custom Applications.",
55
55
  "main": "index.js",
56
56
  "scripts": {