@visns-studio/visns-components 4.3.8 → 4.3.10

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.
@@ -543,8 +543,9 @@ function GenericDetail({ extraUrlParam, setting, urlParam, userProfile }) {
543
543
  <GenericDynamic
544
544
  data={data}
545
545
  fetchData={handleReload}
546
- label={activeTabConfig.setting.label}
546
+ label={data.task_template.label}
547
547
  multiple={false}
548
+ originalData={data}
548
549
  primaryKey={activeTabConfig.setting.key}
549
550
  setData={setData}
550
551
  setting={activeTabConfig.setting.url}
@@ -41,10 +41,14 @@ const renderValue = (field, data) => {
41
41
  if (field.dynamicfield && typeof field.dynamicfield === 'string') {
42
42
  const [table, key] = field.dynamicfield.split('::');
43
43
 
44
+ console.info(data, table, key);
45
+
44
46
  if (table && key) {
45
47
  switch (table) {
46
48
  case 'opportunities':
47
49
  return data[table][key];
50
+ case 'clients':
51
+ return data['client'][key];
48
52
  default:
49
53
  if (key === 'surname' && !data[key]) {
50
54
  return data['lastname'] || '';
@@ -550,12 +554,17 @@ const GenericDynamic = ({
550
554
  }
551
555
  }
552
556
  } else {
553
- if (
554
- Object.keys(activeForm).length === 0 &&
555
- templateStatus &&
556
- data[type][0]
557
- ) {
558
- setActiveForm(data[type][0]);
557
+ if (data[type].hasOwnProperty('id')) {
558
+ if (
559
+ Object.keys(activeForm).length === 0 &&
560
+ templateStatus &&
561
+ data[type][0]
562
+ ) {
563
+ setActiveForm(data[type][0]);
564
+ setActiveFormKey(0);
565
+ }
566
+ } else {
567
+ setActiveForm(data[type]);
559
568
  setActiveFormKey(0);
560
569
  }
561
570
  }
@@ -707,7 +716,7 @@ const GenericDynamic = ({
707
716
  <>
708
717
  <div className={styles.gridtxt__header}>
709
718
  <span>
710
- {label}{' '}
719
+ {label}
711
720
  {multiple && ` - Form #${activeForm?.id ?? ''}`}
712
721
  </span>
713
722
  </div>
@@ -830,7 +839,7 @@ const GenericDynamic = ({
830
839
  </button>
831
840
  )}
832
841
 
833
- {activeForm.id && (
842
+ {activeForm.id ? (
834
843
  <>
835
844
  {multiple && activeForm.form_status === 0 ? (
836
845
  <button className="btn" onClick={handleSaveForm}>
@@ -842,6 +851,10 @@ const GenericDynamic = ({
842
851
  </button>
843
852
  )}
844
853
  </>
854
+ ) : (
855
+ <button className="btn" onClick={handleSaveForm}>
856
+ Save
857
+ </button>
845
858
  )}
846
859
  </div>
847
860
  </>
@@ -124,15 +124,27 @@ function GenericFormBuilder({ setting, urlParam, userProfile }) {
124
124
  const handleAddRowOption = (e) => {
125
125
  e.preventDefault();
126
126
 
127
+ console.info(dataField);
128
+
129
+ // Initialize rows if it doesn't exist
130
+ if (!dataField.rows) {
131
+ setDataField((items) => ({
132
+ ...items,
133
+ rows: [],
134
+ }));
135
+ }
136
+
127
137
  if (rowOption.label !== '') {
128
- const isLabelUnique = !dataField.rows.some(
129
- (option) => option.label === rowOption.label
130
- );
138
+ const isLabelUnique = dataField.rows
139
+ ? !dataField.rows.some(
140
+ (option) => option.label === rowOption.label
141
+ )
142
+ : true;
131
143
 
132
144
  if (isLabelUnique) {
133
145
  setDataField((items) => ({
134
146
  ...items,
135
- rows: [...items.rows, rowOption],
147
+ rows: [...(items.rows || []), rowOption],
136
148
  }));
137
149
 
138
150
  setRowOption(() => ({
@@ -179,6 +191,7 @@ function GenericFormBuilder({ setting, urlParam, userProfile }) {
179
191
  label: '',
180
192
  type: '',
181
193
  options: [],
194
+ // rows: [],
182
195
  size: 'half',
183
196
  required: 'no',
184
197
  }));
package/package.json CHANGED
@@ -57,7 +57,7 @@
57
57
  "react-dom": "^17.0.1"
58
58
  },
59
59
  "name": "@visns-studio/visns-components",
60
- "version": "4.3.8",
60
+ "version": "4.3.10",
61
61
  "description": "Various packages to assist in the development of our Custom Applications.",
62
62
  "main": "index.js",
63
63
  "scripts": {